From patchwork Tue Jun 1 18:49:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai X-Patchwork-Id: 103591 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o51IpDKg028894 for ; Tue, 1 Jun 2010 18:51:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753128Ab0FASvN (ORCPT ); Tue, 1 Jun 2010 14:51:13 -0400 Received: from rcsinet10.oracle.com ([148.87.113.121]:45997 "EHLO rcsinet10.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753044Ab0FASvM (ORCPT ); Tue, 1 Jun 2010 14:51:12 -0400 Received: from rcsinet15.oracle.com (rcsinet15.oracle.com [148.87.113.117]) by rcsinet10.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o51Ip803007529 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 1 Jun 2010 18:51:09 GMT Received: from acsmt355.oracle.com (acsmt355.oracle.com [141.146.40.155]) by rcsinet15.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o51IOWTA012014; Tue, 1 Jun 2010 18:51:07 GMT Received: from abhmt014.oracle.com by acsmt355.oracle.com with ESMTP id 314042601275418258; Tue, 01 Jun 2010 11:50:58 -0700 Received: from [129.146.53.87] (/129.146.53.87) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 01 Jun 2010 11:50:58 -0700 Message-ID: <4C055651.4030504@oracle.com> Date: Tue, 01 Jun 2010 11:49:53 -0700 From: Yinghai Lu User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100317 SUSE/3.0.4-1.1.1 Thunderbird/3.0.4 MIME-Version: 1.0 To: Jesse Barnes , Kenji Kaneshige CC: "linux-pci@vger.kernel.org" Subject: [RFC PATCH] pciehp: only wait command complete for real command X-Auth-Type: Internal IP X-Source-IP: rcsinet15.oracle.com [148.87.113.117] X-CT-RefId: str=0001.0A090206.4C05569D.015D:SCFMA4539811,ss=1,fgs=0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 01 Jun 2010 18:51:13 +0000 (UTC) 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 @@ -176,6 +176,7 @@ static int pcie_write_cmd(struct control int retval = 0; u16 slot_status; u16 slot_ctrl; + u16 wait_mask; mutex_lock(&ctrl->ctrl_lock); @@ -215,9 +216,14 @@ static int pcie_write_cmd(struct control goto out; } + wait_mask = mask & (PCI_EXP_SLTCTL_AIC | PCI_EXP_SLTCTL_PIC | PCI_EXP_SLTCTL_PCC); + if (wait_mask && ((slot_ctrl & wait_mask) == (cmd & wait_mask))) + wait_mask = 0; + if (wait_mask) + ctrl->cmd_busy = 1; + slot_ctrl &= ~mask; slot_ctrl |= (cmd & mask); - ctrl->cmd_busy = 1; smp_mb(); retval = pciehp_writew(ctrl, PCI_EXP_SLTCTL, slot_ctrl); if (retval) @@ -226,7 +232,7 @@ static int pcie_write_cmd(struct control /* * Wait for command completion. */ - if (!retval && !ctrl->no_cmd_complete) { + if (!retval && !ctrl->no_cmd_complete && wait_mask) { int poll = 0; /* * if hotplug interrupt is not enabled or command