Skip to content

Commit 00f89ae

Browse files
Philipp Stannerbjorn-helgaas
authored andcommitted
PCI: Fix devres regression in pci_intx()
pci_intx() becomes managed if pcim_enable_device() has been called in advance. Commit 25216af ("PCI: Add managed pcim_intx()") changed this behavior so that pci_intx() always leads to creation of a separate device resource for itself, whereas earlier, a shared resource was used for all PCI devres operations. Unfortunately, pci_intx() seems to be used in some drivers' remove() paths; in the managed case this causes a device resource to be created on driver detach, which causes .probe() to fail if the driver is reloaded: pci 0000:00:1f.2: Resources present before probing Fix the regression by only redirecting pci_intx() to its managed twin pcim_intx() if the pci_command changes. Link: https://lore.kernel.org/r/[email protected] Fixes: 25216af ("PCI: Add managed pcim_intx()") Reported-by: Damien Le Moal <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Philipp Stanner <[email protected]> [bhelgaas: add error message to commit log] Signed-off-by: Bjorn Helgaas <[email protected]> Tested-by: Damien Le Moal <[email protected]>
1 parent 8400291 commit 00f89ae

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

drivers/pci/pci.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4477,21 +4477,22 @@ void pci_intx(struct pci_dev *pdev, int enable)
44774477
{
44784478
u16 pci_command, new;
44794479

4480-
/* Preserve the "hybrid" behavior for backwards compatibility */
4481-
if (pci_is_managed(pdev)) {
4482-
WARN_ON_ONCE(pcim_intx(pdev, enable) != 0);
4483-
return;
4484-
}
4485-
44864480
pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
44874481

44884482
if (enable)
44894483
new = pci_command & ~PCI_COMMAND_INTX_DISABLE;
44904484
else
44914485
new = pci_command | PCI_COMMAND_INTX_DISABLE;
44924486

4493-
if (new != pci_command)
4487+
if (new != pci_command) {
4488+
/* Preserve the "hybrid" behavior for backwards compatibility */
4489+
if (pci_is_managed(pdev)) {
4490+
WARN_ON_ONCE(pcim_intx(pdev, enable) != 0);
4491+
return;
4492+
}
4493+
44944494
pci_write_config_word(pdev, PCI_COMMAND, new);
4495+
}
44954496
}
44964497
EXPORT_SYMBOL_GPL(pci_intx);
44974498

0 commit comments

Comments
 (0)