Skip to contentSkip to conversation

drm/amdgpu: drop drm_firmware_drivers_only()

PATCH In review Alex Deucher 2 participants 5 messages Mar 14, 2025

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/3 drm/amdgpu: drop drm_firmware_drivers_only()

There are a number of systems and cloud providers out there that have nomodeset hardcoded in their kernel parameters to block nouveau for the nvidia driver. This prevents the amdgpu driver from loading. Unfortunately the end user cannot easily change this. The preferred way to block modules from loading is to use modprobe.blacklist=<driver>. That is what providers should be using to block specific drivers.

Drop the check to allow the driver to load even when nomodeset is specified on the kernel command line.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -3
index 3b34fdd105937..dd86661153582 100644
@@ -3022,9 +3022,6 @@ static int __init amdgpu_init(void)
 {
 	int r;
 
-	if (drm_firmware_drivers_only())
-		return -EINVAL;
-
 	r = amdgpu_sync_init();
 	if (r)
 		goto error_sync;
Signature · 1 line
2.48.1
author maintainer
#1 lore raw

PATCH 2/3 drm/amdgpu: adjust drm_firmware_drivers_only() handling

Move to probe so we can check the PCI device type and only apply the drm_firmware_drivers_only() check for PCI DISPLAY classes. Also add a module parameter to override the nomodeset kernel parameter as a workaround for platforms that have this hardcoded on their kernel command lines.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +14 -0
index dd86661153582..4e1a6a249bba5 100644
@@ -178,6 +178,7 @@ uint amdgpu_sdma_phase_quantum = 32;
 char *amdgpu_disable_cu;
 char *amdgpu_virtual_display;
 bool enforce_isolation;
+int amdgpu_modeset = -1;
 
 /* Specifies the default granularity for SVM, used in buffer
  * migration and restoration of backing memory when handling
@@ -1040,6 +1041,13 @@ module_param_named(user_partt_mode, amdgpu_user_partt_mode, uint, 0444);
 module_param(enforce_isolation, bool, 0444);
 MODULE_PARM_DESC(enforce_isolation, "enforce process isolation between graphics and compute . enforce_isolation = on");
 
+/**
+ * DOC: modeset (int)
+ * Override nomodeset (1 = override, -1 = auto). The default is -1 (auto).
+ */
+MODULE_PARM_DESC(modeset, "Override nomodeset (1 = enable, -1 = auto)");
+module_param_named(modeset, amdgpu_modeset, int, 0444);
+
 /**
  * DOC: seamless (int)
  * Seamless boot will keep the image on the screen during the boot process.
@@ -2270,6 +2278,12 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
 	int ret, retry = 0, i;
 	bool supports_atomic = false;
 
+	if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA ||
+	    (pdev->class >> 8) == PCI_CLASS_DISPLAY_OTHER) {
+		if (drm_firmware_drivers_only() && amdgpu_modeset == -1)
+			return -EINVAL;
+	}
+
 	/* skip devices which are owned by radeon */
 	for (i = 0; i < ARRAY_SIZE(amdgpu_unsupported_pciidlist); i++) {
 		if (amdgpu_unsupported_pciidlist[i] == pdev->device)
Signature · 1 line
2.48.1
Reviewed-by on v1 2/3
#2 lore raw

RE: [PATCH 2/3] drm/amdgpu: adjust drm_firmware_drivers_only() handling

[AMD Official Use Only - AMD Internal Distribution Only]

Quoted 64 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, March 13, 2025 9:02 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu: adjust drm_firmware_drivers_only() handling

Move to probe so we can check the PCI device type and only apply the drm_firmware_drivers_only() check for PCI DISPLAY classes. Also add a module parameter to override the nomodeset kernel parameter as a workaround for platforms that have this hardcoded on their kernel command lines.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +8 -0
index dd86661153582..4e1a6a249bba5 100644
@@ -178,6 +178,7 @@ uint amdgpu_sdma_phase_quantum = 32;
 char *amdgpu_disable_cu;
 char *amdgpu_virtual_display;
 bool enforce_isolation;
+int amdgpu_modeset = -1;
 
 /* Specifies the default granularity for SVM, used in buffer
  * migration and restoration of backing memory when handling
@@ -1040,6 +1041,13 @@ module_param_named(user_partt_mode,
 amdgpu_user_partt_mode, uint, 0444);
 module_param(enforce_isolation, bool, 0444);
 MODULE_PARM_DESC(enforce_isolation, "enforce process isolation between
 graphics and compute . enforce_isolation = on");
 
+/**
+ * DOC: modeset (int)
+ * Override nomodeset (1 = override, -1 = auto). The default is -1 (auto).
+ */
+MODULE_PARM_DESC(modeset, "Override nomodeset (1 = enable, -1 = auto)");
+module_param_named(modeset, amdgpu_modeset, int, 0444);
+
 /**

* DOC: seamless (int)
* Seamless boot will keep the image on the screen during the boot process.

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +6 -1
@@ -2270,6 +2278,12 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
      int ret, retry = 0, i;
      bool supports_atomic = false;
 
+     if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA ||
+         (pdev->class >> 8) == PCI_CLASS_DISPLAY_OTHER) {
+             if (drm_firmware_drivers_only() && amdgpu_modeset == -1)
+                     return -EINVAL;
+     }
+
      /* skip devices which are owned by radeon */
      for (i = 0; i < ARRAY_SIZE(amdgpu_unsupported_pciidlist); i++) {
              if (amdgpu_unsupported_pciidlist[i] == pdev->device)
--

2.48.1

author maintainer
#3 lore raw

PATCH 3/3 drm/amdgpu: don't free conflicting apertures for non-display devices

In reply to Alex Deucher

PCI_CLASS_ACCELERATOR_PROCESSING devices won't ever be the sysfb, so there is no need to free conflicting apertures.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +11 -4
index 1eff6252f66b4..689f1833d02b7 100644
@@ -4401,10 +4401,17 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	if (r)
 		return r;
 
-	/* Get rid of things like offb */
-	r = aperture_remove_conflicting_pci_devices(adev->pdev, amdgpu_kms_driver.name);
-	if (r)
-		return r;
+	/*
+	 * No need to remove conflicting FBs for non-display class devices.
+	 * This prevents the sysfb from being freed accidently.
+	 */
+	if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA ||
+	    (pdev->class >> 8) == PCI_CLASS_DISPLAY_OTHER) {
+		/* Get rid of things like offb */
+		r = aperture_remove_conflicting_pci_devices(adev->pdev, amdgpu_kms_driver.name);
+		if (r)
+			return r;
+	}
 
 	/* Enable TMZ based on IP_VERSION */
 	amdgpu_gmc_tmz_set(adev);
Signature · 1 line
2.48.1
Reviewed-by on v1 3/3
#4 lore raw

RE: [PATCH 3/3] drm/amdgpu: don't free conflicting apertures for non-display devices

[AMD Official Use Only - AMD Internal Distribution Only]

Quoted 49 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, March 13, 2025 9:02 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 3/3] drm/amdgpu: don't free conflicting apertures for non-display devices

PCI_CLASS_ACCELERATOR_PROCESSING devices won't ever be the sysfb, so there is no need to free conflicting apertures.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +11 -4
index 1eff6252f66b4..689f1833d02b7 100644
@@ -4401,10 +4401,17 @@ int amdgpu_device_init(struct amdgpu_device *adev,
      if (r)
              return r;
 
-     /* Get rid of things like offb */
-     r = aperture_remove_conflicting_pci_devices(adev->pdev,
 amdgpu_kms_driver.name);
-     if (r)
-             return r;
+     /*
+      * No need to remove conflicting FBs for non-display class devices.
+      * This prevents the sysfb from being freed accidently.
+      */
+     if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA ||
+         (pdev->class >> 8) == PCI_CLASS_DISPLAY_OTHER) {
+             /* Get rid of things like offb */
+             r = aperture_remove_conflicting_pci_devices(adev->pdev,
 amdgpu_kms_driver.name);
+             if (r)
+                     return r;
+     }
 
      /* Enable TMZ based on IP_VERSION */
      amdgpu_gmc_tmz_set(adev);

--
2.48.1