dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] agp/amd64: Bind to unsupported devices only if AGP is present
@ 2025-06-21  9:40 Lukas Wunner
  2025-06-21 12:07 ` Ben Hutchings
  0 siblings, 1 reply; 15+ messages in thread
From: Lukas Wunner @ 2025-06-21  9:40 UTC (permalink / raw)
  To: David Airlie, Bjorn Helgaas
  Cc: Ben Hutchings, Joerg Roedel, Suravee Suthikulpanit, Andi Kleen,
	Ahmed Salem, Borislav Petkov, dri-devel, iommu, linux-pci

Since commit 172efbb40333 ("AGP: Try unsupported AGP chipsets on x86-64 by
default"), the AGP driver for AMD Opteron/Athlon64 CPUs attempts to bind
to any PCI device.

On modern CPUs exposing an AMD IOMMU, this results in a message with
KERN_CRIT severity:

  pci 0000:00:00.2: Resources present before probing

The driver used to bind only to devices exposing the AGP Capability, but
that restriction was removed by commit 6fd024893911 ("amd64-agp: Probe
unknown AGP devices the right way").

Reinstate checking for AGP presence to avoid the message.

Fixes: 3be5fa236649 (Revert "iommu/amd: Prevent binding other PCI drivers to IOMMU PCI devices")
Reported-by: Fedor Pchelkin <pchelkin@ispras.ru>
Closes: https://lore.kernel.org/r/wpoivftgshz5b5aovxbkxl6ivvquinukqfvb5z6yi4mv7d25ew@edtzr2p74ckg/
Signed-off-by: Lukas Wunner <lukas@wunner.de>
---
Compile tested only, I do not have a machine with AMD IOMMU at my disposal.

Reporter is not cc'ed because ispras.ru is an OFAC sanctioned entity,
which prohibits me from two-way engagement with the reporter:
https://sanctionssearch.ofac.treas.gov/Details.aspx?id=50890
https://www.linuxfoundation.org/blog/navigating-global-regulations-and-open-source-us-ofac-sanctions

 drivers/char/agp/amd64-agp.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index bf49096..4bf508b 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -735,6 +735,18 @@ static int agp_amd64_resume(struct device *dev)
 	.driver.pm  = &agp_amd64_pm_ops,
 };
 
+static bool __init agp_dev_present(void)
+{
+	struct pci_dev *pdev = NULL;
+
+	for_each_pci_dev(pdev)
+		if (pci_find_capability(pdev, PCI_CAP_ID_AGP)) {
+			pci_dev_put(pdev);
+			return true;
+		}
+
+	return false;
+}
 
 /* Not static due to IOMMU code calling it early. */
 int __init agp_amd64_init(void)
@@ -761,7 +773,7 @@ int __init agp_amd64_init(void)
 		}
 
 		/* First check that we have at least one AMD64 NB */
-		if (!amd_nb_num()) {
+		if (!amd_nb_num() || !agp_dev_present()) {
 			pci_unregister_driver(&agp_amd64_pci_driver);
 			return -ENODEV;
 		}
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2025-07-02 15:24 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-21  9:40 [PATCH] agp/amd64: Bind to unsupported devices only if AGP is present Lukas Wunner
2025-06-21 12:07 ` Ben Hutchings
2025-06-21 12:29   ` Lukas Wunner
2025-06-21 13:51     ` Ben Hutchings
2025-06-21 14:05       ` Lukas Wunner
2025-06-24 21:54         ` Ben Hutchings
2025-06-25 14:08           ` Hans de Goede
2025-06-25 14:33             ` Lukas Wunner
2025-06-25 18:43               ` Hans de Goede
2025-06-30 11:10                 ` Hans de Goede
2025-07-02 10:47                   ` Lukas Wunner
2025-07-02 13:29                     ` Lukas Wunner
2025-07-01 18:28                 ` Lukas Wunner
2025-07-02 15:24                 ` Lukas Wunner
2025-07-01 18:18           ` Lukas Wunner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).