Skip to content

Commit ad955d9

Browse files
Yinghai LuJerry Snitselaar
authored andcommitted
pciehp: only wait command complete for really hotplug control
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. Orabug: 18479141 Signed-off-by: Yinghai Lu <[email protected]> Signed-off-by: Brian Maly <[email protected]> Reviewed-by: Jerry Snitselaar <[email protected]>
1 parent dac771f commit ad955d9

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

drivers/pci/hotplug/pciehp_hpc.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ static void pcie_wait_cmd(struct controller *ctrl, int poll)
175175
static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
176176
{
177177
int retval = 0;
178+
u16 slot_ctrl, old_slot_ctrl;
178179
u16 slot_status;
179-
u16 slot_ctrl;
180180

181181
mutex_lock(&ctrl->ctrl_lock);
182182

@@ -210,14 +210,13 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
210210
}
211211
}
212212

213-
retval = pciehp_readw(ctrl, PCI_EXP_SLTCTL, &slot_ctrl);
213+
retval = pciehp_readw(ctrl, PCI_EXP_SLTCTL, &old_slot_ctrl);
214214
if (retval) {
215215
ctrl_err(ctrl, "%s: Cannot read SLOTCTRL register\n", __func__);
216216
goto out;
217217
}
218218

219-
slot_ctrl &= ~mask;
220-
slot_ctrl |= (cmd & mask);
219+
slot_ctrl = (old_slot_ctrl & ~mask) | (cmd & mask);
221220
ctrl->cmd_busy = 1;
222221
smp_mb();
223222
retval = pciehp_writew(ctrl, PCI_EXP_SLTCTL, slot_ctrl);
@@ -227,7 +226,9 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
227226
/*
228227
* Wait for command completion.
229228
*/
230-
if (!retval && !ctrl->no_cmd_complete) {
229+
if (!retval && !ctrl->no_cmd_complete &&
230+
((PCI_EXP_SLTCTL_WAIT_MASK & old_slot_ctrl) !=
231+
(PCI_EXP_SLTCTL_WAIT_MASK & slot_ctrl))) {
231232
int poll = 0;
232233
/*
233234
* if hotplug interrupt is not enabled or command

include/linux/pci_regs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,11 @@
486486
#define PCI_EXP_SLTCTL_PCC 0x0400 /* Power Controller Control */
487487
#define PCI_EXP_SLTCTL_EIC 0x0800 /* Electromechanical Interlock Control */
488488
#define PCI_EXP_SLTCTL_DLLSCE 0x1000 /* Data Link Layer State Changed Enable */
489+
/* only need to wait command complete for hpc related */
490+
#define PCI_EXP_SLTCTL_WAIT_MASK (PCI_EXP_SLTCTL_EIC | \
491+
PCI_EXP_SLTCTL_PCC | \
492+
PCI_EXP_SLTCTL_PIC | \
493+
PCI_EXP_SLTCTL_AIC)
489494
#define PCI_EXP_SLTSTA 26 /* Slot Status */
490495
#define PCI_EXP_SLTSTA_ABP 0x0001 /* Attention Button Pressed */
491496
#define PCI_EXP_SLTSTA_PFD 0x0002 /* Power Fault Detected */

0 commit comments

Comments
 (0)