]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/radeon: Refactor how SI and CIK support is determined
authorTimur Kristóf <timur.kristof@gmail.com>
Sun, 9 Nov 2025 15:41:04 +0000 (16:41 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 14 Nov 2025 16:27:04 +0000 (11:27 -0500)
Move the determination into a separate function.
Change radeon.si_support and radeon.cik_support so that their
default value is -1 (default).

This prepares the code for changing the default driver based
on the chip.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon_drv.c

index 26ad9adc5d8c18e4be9b88809b25341a3625d451..1dfe5482d48e24e9993c124de9dc0b46c03d7bad 100644 (file)
@@ -241,12 +241,12 @@ module_param_named(uvd, radeon_uvd, int, 0444);
 MODULE_PARM_DESC(vce, "vce enable/disable vce support (1 = enable, 0 = disable)");
 module_param_named(vce, radeon_vce, int, 0444);
 
-int radeon_si_support = 1;
-MODULE_PARM_DESC(si_support, "SI support (1 = enabled (default), 0 = disabled)");
+int radeon_si_support = -1;
+MODULE_PARM_DESC(si_support, "SI support (1 = enabled, 0 = disabled, -1 = default)");
 module_param_named(si_support, radeon_si_support, int, 0444);
 
-int radeon_cik_support = 1;
-MODULE_PARM_DESC(cik_support, "CIK support (1 = enabled (default), 0 = disabled)");
+int radeon_cik_support = -1;
+MODULE_PARM_DESC(cik_support, "CIK support (1 = enabled, 0 = disabled, -1 = default)");
 module_param_named(cik_support, radeon_cik_support, int, 0444);
 
 static const struct pci_device_id pciidlist[] = {
@@ -256,6 +256,50 @@ MODULE_DEVICE_TABLE(pci, pciidlist);
 
 static const struct drm_driver kms_driver;
 
+static bool radeon_support_enabled(struct device *dev,
+                                  const enum radeon_family family)
+{
+       const char *gen;
+       int module_param = -1;
+       bool amdgpu_support_built = IS_ENABLED(CONFIG_DRM_AMDGPU);
+       bool support_by_default = true;
+
+       switch (family) {
+       case CHIP_TAHITI:
+       case CHIP_PITCAIRN:
+       case CHIP_VERDE:
+       case CHIP_OLAND:
+       case CHIP_HAINAN:
+               gen = "SI";
+               module_param = radeon_si_support;
+               amdgpu_support_built &= IS_ENABLED(CONFIG_DRM_AMDGPU_SI);
+               break;
+
+       case CHIP_BONAIRE:
+       case CHIP_HAWAII:
+       case CHIP_KAVERI:
+       case CHIP_KABINI:
+       case CHIP_MULLINS:
+               gen = "CIK";
+               module_param = radeon_cik_support;
+               amdgpu_support_built &= IS_ENABLED(CONFIG_DRM_AMDGPU_CIK);
+               break;
+
+       default:
+               /* All other chips are supported by radeon only */
+               return true;
+       }
+
+       if ((module_param == -1 && (support_by_default || !amdgpu_support_built)) ||
+           module_param == 1)
+               return true;
+
+       if (!module_param)
+               dev_info(dev, "%s support disabled by module param\n", gen);
+
+       return false;
+}
+
 static int radeon_pci_probe(struct pci_dev *pdev,
                            const struct pci_device_id *ent)
 {
@@ -271,30 +315,8 @@ static int radeon_pci_probe(struct pci_dev *pdev,
 
        flags = ent->driver_data;
 
-       if (!radeon_si_support) {
-               switch (flags & RADEON_FAMILY_MASK) {
-               case CHIP_TAHITI:
-               case CHIP_PITCAIRN:
-               case CHIP_VERDE:
-               case CHIP_OLAND:
-               case CHIP_HAINAN:
-                       dev_info(dev,
-                                "SI support disabled by module param\n");
-                       return -ENODEV;
-               }
-       }
-       if (!radeon_cik_support) {
-               switch (flags & RADEON_FAMILY_MASK) {
-               case CHIP_KAVERI:
-               case CHIP_BONAIRE:
-               case CHIP_HAWAII:
-               case CHIP_KABINI:
-               case CHIP_MULLINS:
-                       dev_info(dev,
-                                "CIK support disabled by module param\n");
-                       return -ENODEV;
-               }
-       }
+       if (!radeon_support_enabled(dev, flags & RADEON_FAMILY_MASK))
+               return -ENODEV;
 
        if (vga_switcheroo_client_probe_defer(pdev))
                return -EPROBE_DEFER;