diff mbox

[RFC] pciehp: only wait command complete for real command

Message ID 4C055651.4030504@oracle.com (mailing list archive)
State Rejected, archived
Headers show

Commit Message

Yinghai June 1, 2010, 6:49 p.m. UTC
None
diff mbox

Patch

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