Skip to content

Commit f284dff

Browse files
committed
x86/pci: Comment pci_mmconfig_insert() obscure MCFG dependency
In pci_mmconfig_insert(), there's no reference to "addr" between locking pci_mmcfg_lock and testing "addr", so it *looks* like we should move the test before the lock. But 07f9b61 ("x86/PCI: MMCONFIG: Check earlier for MMCONFIG region at address zero") did that, which broke things by returning -EINVAL when "addr" is zero instead of -EEXIST. So 07f9b61 was reverted by 67d470e ("Revert "x86/PCI: MMCONFIG: Check earlier for MMCONFIG region at address zero""). Add a comment about this issue to prevent it from happening again. Link: https://lore.kernel.org/r/[email protected] Tested-by: Tomasz Pala <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent d26e7fc commit f284dff

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/x86/pci/mmconfig-shared.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,10 @@ int pci_mmconfig_insert(struct device *dev, u16 seg, u8 start, u8 end,
786786
return -EEXIST;
787787
}
788788

789+
/*
790+
* Don't move earlier; we must return -EEXIST, not -EINVAL, if
791+
* pci_mmconfig_lookup() finds something
792+
*/
789793
if (!addr) {
790794
mutex_unlock(&pci_mmcfg_lock);
791795
return -EINVAL;

0 commit comments

Comments
 (0)