Skip to content

Commit 2bd50dd

Browse files
rjwysockijbarnes993
authored andcommitted
PCI: PCIe: Disable PCIe port services during port initialization
In principle PCIe port services may be enabled by the BIOS, so it's better to disable them during port initialization to avoid spurious events from being generated. Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Hidetoshi Seto <[email protected]> Signed-off-by: Jesse Barnes <[email protected]>
1 parent 28eb5f2 commit 2bd50dd

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

drivers/pci/pcie/portdrv_core.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,20 +259,43 @@ static int get_port_device_capability(struct pci_dev *dev)
259259
/* Hot-Plug Capable */
260260
if ((cap_mask & PCIE_PORT_SERVICE_HP) && (reg16 & PCI_EXP_FLAGS_SLOT)) {
261261
pci_read_config_dword(dev, pos + PCI_EXP_SLTCAP, &reg32);
262-
if (reg32 & PCI_EXP_SLTCAP_HPC)
262+
if (reg32 & PCI_EXP_SLTCAP_HPC) {
263263
services |= PCIE_PORT_SERVICE_HP;
264+
/*
265+
* Disable hot-plug interrupts in case they have been
266+
* enabled by the BIOS and the hot-plug service driver
267+
* is not loaded.
268+
*/
269+
pos += PCI_EXP_SLTCTL;
270+
pci_read_config_word(dev, pos, &reg16);
271+
reg16 &= ~(PCI_EXP_SLTCTL_CCIE | PCI_EXP_SLTCTL_HPIE);
272+
pci_write_config_word(dev, pos, reg16);
273+
}
264274
}
265275
/* AER capable */
266276
if ((cap_mask & PCIE_PORT_SERVICE_AER)
267-
&& pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR))
277+
&& pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR)) {
268278
services |= PCIE_PORT_SERVICE_AER;
279+
/*
280+
* Disable AER on this port in case it's been enabled by the
281+
* BIOS (the AER service driver will enable it when necessary).
282+
*/
283+
pci_disable_pcie_error_reporting(dev);
284+
}
269285
/* VC support */
270286
if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_VC))
271287
services |= PCIE_PORT_SERVICE_VC;
272288
/* Root ports are capable of generating PME too */
273289
if ((cap_mask & PCIE_PORT_SERVICE_PME)
274-
&& dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT)
290+
&& dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) {
275291
services |= PCIE_PORT_SERVICE_PME;
292+
/*
293+
* Disable PME interrupt on this port in case it's been enabled
294+
* by the BIOS (the PME service driver will enable it when
295+
* necessary).
296+
*/
297+
pcie_pme_interrupt_enable(dev, false);
298+
}
276299

277300
return services;
278301
}

0 commit comments

Comments
 (0)