agp/amd64: Only try host-bridges when agp_try_unsupported is set
PATCH 1/1 agp/amd64: Only try host-bridges when agp_try_unsupported is set
On modern AMD Ryzen systems the IOMMU code initializes early on adding resources to the "00:00.2 IOMMU" PCI-device without binding a driver to it (because it needs to run early).
Subsequently trying to bind a driver to it will then fail with -EBUSY because of this check in drivers/base/dd.c: really_probe():
dev_dbg(dev, "bus: '%s': %s: probing driver %s with device\n",
drv->bus->name, __func__, drv->name);
if (!list_empty(&dev->devres_head)) {
dev_crit(dev, "Resources present before probing\n");
ret = -EBUSY;
goto done;
}Notice the dev_crit() logging here, this is a problem because anything logged at critical or higher level will actually get logged to the console even when quiet is present breaking flicker free boot and this is happening on most AMD Ryzen systems, e.g. :
[ 1.141358] pci 0000:00:00.0: bus: 'pci': really_probe: probing driver agpgart-amd64 with device [ 1.141441] pci 0000:00:00.2: bus: 'pci': really_probe: probing driver agpgart-amd64 with device [ 1.141444] pci 0000:00:00.2: Resources present before probing [ 1.141450] pci 0000:00:01.0: bus: 'pci': really_probe: probing driver agpgart-amd64 with device [ 1.141496] pci 0000:00:02.0: bus: 'pci': really_probe: probing driver agpgart-amd64 with device
The real issue here is that the agpgart-amd64 driver is probing all PCI-devices because the match in agp_amd64_pci_promisc_table[] matches all PCI-devices.
As can be seen from the class matches in agp_amd64_pci_table[], AGP support is always part of the host-bridge. Change the match in agp_amd64_pci_promisc_table[] to only match on host-bridges, so that the IOMMU will no longer get probed with the agpgart-amd64 driver.
This not only fixes the troublesome dev_crit() logging it should also speed up things in general.
---
Given how old AGP is I would expect the agp_amd64_pci_table[] to be complete and I wonder if maybe we should not change the default of the AMD specific agp_try_unsupported to 0? Note the global non AMD specific agp_try_unsupported_boot flag already defaults to 0.
--- drivers/char/agp/amd64-agp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/agp/amd64-agp.c +1 -1
@@ -721,7 +721,7 @@ static const struct pci_device_id agp_amd64_pci_table[] = {MODULE_DEVICE_TABLE (pci, agp_amd64_pci_table);static const struct pci_device_id agp_amd64_pci_promisc_table[] = { - {PCI_DEVICE_CLASS (0 ,0 ) }, + {PCI_DEVICE_CLASS ((PCI_CLASS_BRIDGE_HOST <<8 ), ~0 ) }, { } };
Signature · 1 line
2.49.0
+ Suravee and Vasant
Quoted 39 lines · Hans de Goede
On modern AMD Ryzen systems the IOMMU code initializes early on adding resources to the "00:00.2 IOMMU" PCI-device without binding a driver to it (because it needs to run early).
Subsequently trying to bind a driver to it will then fail with
-EBUSYbecause of this check indrivers/base/dd.c:really_probe():dev_dbg(dev, "bus: '%s': %s: probing driver %s with device\n", drv->bus->name, __func__, drv->name); if (!list_empty(&dev->devres_head)) { dev_crit(dev, "Resources present before probing\n"); ret = -EBUSY; goto done; }Notice the
dev_crit()logging here, this is a problem because anything logged at critical or higher level will actually get logged to the console even when quiet is present breaking flicker free boot and this is happening on most AMD Ryzen systems, e.g. :[ 1.141358] pci 0000:00:00.0: bus: 'pci': really_probe: probing driver agpgart-amd64 with device [ 1.141441] pci 0000:00:00.2: bus: 'pci': really_probe: probing driver agpgart-amd64 with device [ 1.141444] pci 0000:00:00.2: Resources present before probing [ 1.141450] pci 0000:00:01.0: bus: 'pci': really_probe: probing driver agpgart-amd64 with device [ 1.141496] pci 0000:00:02.0: bus: 'pci': really_probe: probing driver agpgart-amd64 with deviceThe real issue here is that the agpgart-amd64 driver is probing all PCI-devices because the match in agp_amd64_pci_promisc_table[] matches all PCI-devices.
As can be seen from the class matches in agp_amd64_pci_table[], AGP support is always part of the host-bridge. Change the match in agp_amd64_pci_promisc_table[] to only match on host-bridges, so that the IOMMU will no longer get probed with the agpgart-amd64 driver.
This not only fixes the troublesome
dev_crit()logging it should also speed up things in general.
Quoted 6 lines
Signed-off-by Hans de Goede <[email protected]>---
Given how old AGP is I would expect the agp_amd64_pci_table[] to be complete and I wonder if maybe we should not change the default of the AMD specificagp_try_unsupportedto 0? Note the global non AMD specificagp_try_unsupported_bootflag already defaults to 0.
No objections from me.
Alex
Quoted 20 lines
--- drivers/char/agp/amd64-agp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/agp/amd64-agp.c +1
-2@@ -721,7 +721,7 @@ static const struct pci_device_id agp_amd64_pci_table[] = {MODULE_DEVICE_TABLE (pci, agp_amd64_pci_table);static const struct pci_device_id agp_amd64_pci_promisc_table[] = { - {PCI_DEVICE_CLASS (0 ,0 ) }, + {PCI_DEVICE_CLASS ((PCI_CLASS_BRIDGE_HOST <<8 ), ~0 ) }, { } }; --2.49.0
Hi Alex,
Quoted 42 lines · Alex Deucher
+ Suravee and Vasant
Quoted 39 lines · Hans de Goede
On modern AMD Ryzen systems the IOMMU code initializes early on adding resources to the "00:00.2 IOMMU" PCI-device without binding a driver to it (because it needs to run early).
Subsequently trying to bind a driver to it will then fail with
-EBUSYbecause of this check indrivers/base/dd.c:really_probe():dev_dbg(dev, "bus: '%s': %s: probing driver %s with device\n", drv->bus->name, __func__, drv->name); if (!list_empty(&dev->devres_head)) { dev_crit(dev, "Resources present before probing\n"); ret = -EBUSY; goto done; }Notice the
dev_crit()logging here, this is a problem because anything logged at critical or higher level will actually get logged to the console even when quiet is present breaking flicker free boot and this is happening on most AMD Ryzen systems, e.g. :[ 1.141358] pci 0000:00:00.0: bus: 'pci': really_probe: probing driver agpgart-amd64 with device [ 1.141441] pci 0000:00:00.2: bus: 'pci': really_probe: probing driver agpgart-amd64 with device [ 1.141444] pci 0000:00:00.2: Resources present before probing [ 1.141450] pci 0000:00:01.0: bus: 'pci': really_probe: probing driver agpgart-amd64 with device [ 1.141496] pci 0000:00:02.0: bus: 'pci': really_probe: probing driver agpgart-amd64 with deviceThe real issue here is that the agpgart-amd64 driver is probing all PCI-devices because the match in agp_amd64_pci_promisc_table[] matches all PCI-devices.
As can be seen from the class matches in agp_amd64_pci_table[], AGP support is always part of the host-bridge. Change the match in agp_amd64_pci_promisc_table[] to only match on host-bridges, so that the IOMMU will no longer get probed with the agpgart-amd64 driver.
This not only fixes the troublesome
dev_crit()logging it should also speed up things in general.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Hans de Goede <[email protected]>---
Given how old AGP is I would expect the agp_amd64_pci_table[] to be complete and I wonder if maybe we should not change the default of the AMD specificagp_try_unsupportedto 0? Note the global non AMD specificagp_try_unsupported_bootflag already defaults to 0.No objections from me.
Thank you. To be clear with "No objections from me", I guess you mean no objections from you to changing the default of agp_try_unsupported to 0, right ?
Note regardless of changing the default (which would be another patch) I still think it would be good to also have this change.
Regards,
Hans
Quoted 20 lines
Quoted 20 lines
--- drivers/char/agp/amd64-agp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/agp/amd64-agp.c +1
-2@@ -721,7 +721,7 @@ static const struct pci_device_id agp_amd64_pci_table[] = {MODULE_DEVICE_TABLE (pci, agp_amd64_pci_table);static const struct pci_device_id agp_amd64_pci_promisc_table[] = { - {PCI_DEVICE_CLASS (0 ,0 ) }, + {PCI_DEVICE_CLASS ((PCI_CLASS_BRIDGE_HOST <<8 ), ~0 ) }, { } }; --2.49.0
Quoted 3 lines · Hans de Goede
On modern AMD Ryzen systems the IOMMU code initializes early on adding resources to the "00:00.2 IOMMU" PCI-device without binding a driver to it (because it needs to run early).
There's already a patch pending and a discussion ongoing for this issue:
https://lore.kernel.org/r/f8ff40f35a9a5836d1371f60e85c09c5735e3c5e.1750497201.git.lukas@wunner.de/
Thanks,
Lukas
Hi,
Quoted 8 lines · Lukas Wunner
Quoted 3 lines · Hans de Goede
On modern AMD Ryzen systems the IOMMU code initializes early on adding resources to the "00:00.2 IOMMU" PCI-device without binding a driver to it (because it needs to run early).
There's already a patch pending and a discussion ongoing for this issue:
https://lore.kernel.org/r/f8ff40f35a9a5836d1371f60e85c09c5735e3c5e.1750497201.git.lukas@wunner.de/
Thank you for pointing that out. I've replied in that thread.
Regards,
Hans