===================================================================
@@ -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