From patchwork Mon Feb 24 23:59:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 3712291 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 77BA9BF13A for ; Mon, 24 Feb 2014 23:58:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9FAF02015A for ; Mon, 24 Feb 2014 23:58:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B39D520127 for ; Mon, 24 Feb 2014 23:58:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752936AbaBXX6E (ORCPT ); Mon, 24 Feb 2014 18:58:04 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:23547 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752900AbaBXX6E (ORCPT ); Mon, 24 Feb 2014 18:58:04 -0500 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s1ONw08r020765 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 24 Feb 2014 23:58:01 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s1ONvxHj026229 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 24 Feb 2014 23:57:59 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id s1ONvwW2000624; Mon, 24 Feb 2014 23:57:58 GMT Received: from linux-siqj.site (/10.132.126.191) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 24 Feb 2014 15:57:58 -0800 From: Yinghai Lu To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Yinghai Lu Subject: [PATCH] pciehp: only wait command complete for really hotplug control Date: Mon, 24 Feb 2014 15:59:27 -0800 Message-Id: <1393286367-16482-1-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.4.5 X-Source-IP: acsinet21.oracle.com [141.146.126.237] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 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. So change to only wait when following bits get changed. PCI_EXP_SLTCTL_EIC PCI_EXP_SLTCTL_PCC PCI_EXP_SLTCTL_PIC PCI_EXP_SLTCTL_AIC With that we could set 16 seconds during booting, later with 32 sockets system with 64 pcie hotplug slots we could save 64 seconds. Signed-off-by: Yinghai Lu --- drivers/pci/hotplug/pciehp_hpc.c | 11 ++++++----- include/uapi/linux/pci_regs.h | 5 +++++ 2 files changed, 11 insertions(+), 5 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 @@ -152,8 +152,8 @@ static void pcie_wait_cmd(struct control static void pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask) { struct pci_dev *pdev = ctrl_dev(ctrl); + u16 slot_ctrl, old_slot_ctrl; u16 slot_status; - u16 slot_ctrl; mutex_lock(&ctrl->ctrl_lock); @@ -181,9 +181,8 @@ static void pcie_write_cmd(struct contro } } - pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &slot_ctrl); - slot_ctrl &= ~mask; - slot_ctrl |= (cmd & mask); + pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &old_slot_ctrl); + slot_ctrl = (old_slot_ctrl & ~mask) | (cmd & mask); ctrl->cmd_busy = 1; smp_mb(); pcie_capability_write_word(pdev, PCI_EXP_SLTCTL, slot_ctrl); @@ -191,7 +190,9 @@ static void pcie_write_cmd(struct contro /* * Wait for command completion. */ - if (!ctrl->no_cmd_complete) { + if (!ctrl->no_cmd_complete && + ((PCI_EXP_SLTCTL_WAIT_MASK & old_slot_ctrl) != + (PCI_EXP_SLTCTL_WAIT_MASK & slot_ctrl))) { int poll = 0; /* * if hotplug interrupt is not enabled or command Index: linux-2.6/include/uapi/linux/pci_regs.h =================================================================== --- linux-2.6.orig/include/uapi/linux/pci_regs.h +++ linux-2.6/include/uapi/linux/pci_regs.h @@ -535,6 +535,11 @@ #define PCI_EXP_SLTCTL_PWR_OFF 0x0400 /* Power Off */ #define PCI_EXP_SLTCTL_EIC 0x0800 /* Electromechanical Interlock Control */ #define PCI_EXP_SLTCTL_DLLSCE 0x1000 /* Data Link Layer State Changed Enable */ +/* only need to wait command complete for hpc related */ +#define PCI_EXP_SLTCTL_WAIT_MASK (PCI_EXP_SLTCTL_EIC | \ + PCI_EXP_SLTCTL_PCC | \ + PCI_EXP_SLTCTL_PIC | \ + PCI_EXP_SLTCTL_AIC) #define PCI_EXP_SLTSTA 26 /* Slot Status */ #define PCI_EXP_SLTSTA_ABP 0x0001 /* Attention Button Pressed */ #define PCI_EXP_SLTSTA_PFD 0x0002 /* Power Fault Detected */