From patchwork Mon Mar 24 22:13:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 3884541 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B27479F2E8 for ; Mon, 24 Mar 2014 22:12:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E5CA72020E for ; Mon, 24 Mar 2014 22:12:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0EE29201C0 for ; Mon, 24 Mar 2014 22:12:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751445AbaCXWMN (ORCPT ); Mon, 24 Mar 2014 18:12:13 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:35938 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750875AbaCXWMN (ORCPT ); Mon, 24 Mar 2014 18:12:13 -0400 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s2OMC8uj008744 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 24 Mar 2014 22:12:09 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s2OMC7aE002839 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 24 Mar 2014 22:12:08 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s2OMC71q027528; Mon, 24 Mar 2014 22:12:07 GMT Received: from linux-siqj.site (/10.132.126.191) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 24 Mar 2014 15:12:07 -0700 From: Yinghai Lu To: Bjorn Helgaas Cc: Rajat Jain , linux-pci@vger.kernel.org, Yinghai Lu Subject: [PATCH v2] pciehp: only wait command complete for real hotplug control Date: Mon, 24 Mar 2014 15:13:52 -0700 Message-Id: <1395699232-28727-1-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: X-Source-IP: acsinet22.oracle.com [141.146.126.238] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On system with 16 PCI express hotplug slots, customer complain every slot will report "Command not completed in 1000 msec" during initialization. Intel says that we should only wait command complete only for Electromechanical Interlock Control Power Controller Control Power Indicator Control Attention Indicator Control System with AMD/Nvidia chipset have same problem. Two ways to address the problem: 1. change to only wait when (EIC, PCC, PIC, AIC) bits get changed. 2. or check CMD_COMPLETE and wait before write command. Only wait when CC is set and cmd_busy is true. For chipset from intel will only have CC set for real hotplug control, so we could skip the wait for others. This patch is using second way. With that we could save 16 seconds during booting, later with 32 sockets system with 64 pcie hotplug slots we could save 64 seconds. -v2: use second way that is suggested by Bjorn. It also solve the problem on Rajat's sytem that have wrong inital CC Signed-off-by: Yinghai Lu Tested-by: Rajat Jain --- drivers/pci/hotplug/pciehp_hpc.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6/drivers/pci/hotplug/pciehp_hpc.c =================================================================== --- linux-2.6.orig/drivers/pci/hotplug/pciehp_hpc.c +++ linux-2.6/drivers/pci/hotplug/pciehp_hpc.c @@ -158,15 +158,8 @@ static void pcie_write_cmd(struct contro mutex_lock(&ctrl->ctrl_lock); pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status); - if (slot_status & PCI_EXP_SLTSTA_CC) { - if (!ctrl->no_cmd_complete) { - /* - * After 1 sec and CMD_COMPLETED still not set, just - * proceed forward to issue the next command according - * to spec. Just print out the error message. - */ - ctrl_dbg(ctrl, "CMD_COMPLETED not clear after 1 sec\n"); - } else if (!NO_CMD_CMPL(ctrl)) { + if (ctrl->no_cmd_complete && slot_status & PCI_EXP_SLTSTA_CC) { + if (!NO_CMD_CMPL(ctrl)) { /* * This controller seems to notify of command completed * event even though it supports none of power @@ -182,16 +175,11 @@ static void pcie_write_cmd(struct contro } pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &slot_ctrl); - slot_ctrl &= ~mask; - slot_ctrl |= (cmd & mask); - ctrl->cmd_busy = 1; - smp_mb(); - pcie_capability_write_word(pdev, PCI_EXP_SLTCTL, slot_ctrl); - /* * Wait for command completion. */ - if (!ctrl->no_cmd_complete) { + if (!ctrl->no_cmd_complete && (slot_status & PCI_EXP_SLTSTA_CC) && + ctrl->cmd_busy) { int poll = 0; /* * if hotplug interrupt is not enabled or command @@ -203,6 +191,12 @@ static void pcie_write_cmd(struct contro poll = 1; pcie_wait_cmd(ctrl, poll); } + + slot_ctrl &= ~mask; + slot_ctrl |= (cmd & mask); + ctrl->cmd_busy = 1; + smp_mb(); + pcie_capability_write_word(pdev, PCI_EXP_SLTCTL, slot_ctrl); mutex_unlock(&ctrl->ctrl_lock); }