Module Name:    src
Committed By:   tnn
Date:           Mon Nov  6 14:33:51 UTC 2023

Modified Files:
        src/sys/external/bsd/drm2/dist/drm/radeon: radeon_bios.c

Log Message:
radeon: fix and enable ACPI methods for getting ROM BIOS

The hacky way of getting the BIOS mapped only works on x86. ACPI
should be preferred if available. Makes BIOS reading though VFCT
work on aarch64 with EDK2. (But only if EDK2 has POSTed the GPU.)

XXX amdgpu should get the same treatment.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 \
    src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c
diff -u src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c:1.12 src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c:1.13
--- src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c:1.12	Sat May 28 01:07:47 2022
+++ src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c	Mon Nov  6 14:33:51 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeon_bios.c,v 1.12 2022/05/28 01:07:47 manu Exp $	*/
+/*	$NetBSD: radeon_bios.c,v 1.13 2023/11/06 14:33:51 tnn Exp $	*/
 
 /*
  * Copyright 2008 Advanced Micro Devices, Inc.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: radeon_bios.c,v 1.12 2022/05/28 01:07:47 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeon_bios.c,v 1.13 2023/11/06 14:33:51 tnn Exp $");
 
 #include <linux/acpi.h>
 #include <linux/pci.h>
@@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: radeon_bios.
 #include "radeon_reg.h"
 
 #if defined(__NetBSD__) && NACPICA > 0
+#define CONFIG_ACPI
 #include <dev/acpi/acpireg.h>
 #define	_COMPONENT	ACPI_DISPLAY_COMPONENT
 ACPI_MODULE_NAME("radeon_acpi")
@@ -252,10 +253,15 @@ static bool radeon_atrm_get_bios(struct 
 	if (rdev->flags & RADEON_IS_IGP)
 		return false;
 
-	while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
 #ifdef __NetBSD__
+	pdev = rdev->pdev;
+	while (pdev != NULL) {
 		dhandle = (pdev->pd_ad ? pdev->pd_ad->ad_handle : NULL);
+		pdev = NULL;
+		if (rdev->pdev->class != PCI_CLASS_DISPLAY_VGA)
+			continue;
 #else
+	while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
 		dhandle = ACPI_HANDLE(&pdev->dev);
 #endif
 		if (!dhandle)
@@ -269,11 +275,16 @@ static bool radeon_atrm_get_bios(struct 
 	}
 
 	if (!found) {
-		while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
 #ifdef __NetBSD__
+		pdev = rdev->pdev;
+		while (pdev != NULL) {
 			dhandle = (pdev->pd_ad ? pdev->pd_ad->ad_handle
 			    : NULL);
+			pdev = NULL;
+			if (rdev->pdev->class != PCI_CLASS_DISPLAY_OTHER)
+				continue;
 #else
+		while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
 			dhandle = ACPI_HANDLE(&pdev->dev);
 #endif
 			if (!dhandle)

Reply via email to