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

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

Also adjust the module param documentation.

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

index ef23acaf5a2c00e1440ad5db9f1d7b062dee83aa..d0bd1a5a3c012c3ed75f0248998c5b05bb987e7e 100644 (file)
@@ -618,39 +618,37 @@ module_param_named(timeout_period, amdgpu_watchdog_timer.period, uint, 0644);
 
 /**
  * DOC: si_support (int)
- * Set SI support driver. This parameter works after set config CONFIG_DRM_AMDGPU_SI. For SI asic, when radeon driver is enabled,
- * set value 0 to use radeon driver, while set value 1 to use amdgpu driver. The default is using radeon driver when it available,
- * otherwise using amdgpu driver.
- */
+ * 1 = enabled, 0 = disabled, -1 = default
+ *
+ * SI (Southern Islands) are first generation GCN GPUs, supported by both
+ * drivers: radeon (old) and amdgpu (new). This parameter controls whether
+ * amdgpu should support SI.
+ * By default, SI chips are supported by radeon (except when radeon is not built).
+ * Only relevant when CONFIG_DRM_AMDGPU_SI is enabled to build SI support in amdgpu.
+ * See also radeon.si_support which should be disabled when amdgpu.si_support is
+ * enabled, and vice versa.
+ */
+int amdgpu_si_support = -1;
 #ifdef CONFIG_DRM_AMDGPU_SI
-
-#if IS_ENABLED(CONFIG_DRM_RADEON) || IS_ENABLED(CONFIG_DRM_RADEON_MODULE)
-int amdgpu_si_support;
-MODULE_PARM_DESC(si_support, "SI support (1 = enabled, 0 = disabled (default))");
-#else
-int amdgpu_si_support = 1;
-MODULE_PARM_DESC(si_support, "SI support (1 = enabled (default), 0 = disabled)");
-#endif
-
+MODULE_PARM_DESC(si_support, "SI support (1 = enabled, 0 = disabled, -1 = default)");
 module_param_named(si_support, amdgpu_si_support, int, 0444);
 #endif
 
 /**
  * DOC: cik_support (int)
- * Set CIK support driver. This parameter works after set config CONFIG_DRM_AMDGPU_CIK. For CIK asic, when radeon driver is enabled,
- * set value 0 to use radeon driver, while set value 1 to use amdgpu driver. The default is using radeon driver when it available,
- * otherwise using amdgpu driver.
- */
+ * 1 = enabled, 0 = disabled, -1 = default
+ *
+ * CIK (Sea Islands) are second generation GCN GPUs, supported by both
+ * drivers: radeon (old) and amdgpu (new). This parameter controls whether
+ * amdgpu should support CIK.
+ * By default, CIK chips are supported by radeon (except when radeon is not built).
+ * Only relevant when CONFIG_DRM_AMDGPU_CIK is enabled to build CIK support in amdgpu.
+ * See also radeon.cik_support which should be disabled when amdgpu.cik_support is
+ * enabled, and vice versa.
+ */
+int amdgpu_cik_support = -1;
 #ifdef CONFIG_DRM_AMDGPU_CIK
-
-#if IS_ENABLED(CONFIG_DRM_RADEON) || IS_ENABLED(CONFIG_DRM_RADEON_MODULE)
-int amdgpu_cik_support;
-MODULE_PARM_DESC(cik_support, "CIK support (1 = enabled, 0 = disabled (default))");
-#else
-int amdgpu_cik_support = 1;
-MODULE_PARM_DESC(cik_support, "CIK support (1 = enabled (default), 0 = disabled)");
-#endif
-
+MODULE_PARM_DESC(cik_support, "CIK support  (1 = enabled, 0 = disabled, -1 = default)");
 module_param_named(cik_support, amdgpu_cik_support, int, 0444);
 #endif
 
@@ -2306,6 +2304,69 @@ static unsigned long amdgpu_fix_asic_type(struct pci_dev *pdev, unsigned long fl
        return flags;
 }
 
+static bool amdgpu_support_enabled(struct device *dev,
+                                  const enum amd_asic_type family)
+{
+       const char *gen;
+       const char *param;
+       int module_param = -1;
+       bool radeon_support_built = IS_ENABLED(CONFIG_DRM_RADEON);
+       bool amdgpu_support_built = false;
+       bool support_by_default = false;
+
+       switch (family) {
+       case CHIP_TAHITI:
+       case CHIP_PITCAIRN:
+       case CHIP_VERDE:
+       case CHIP_OLAND:
+       case CHIP_HAINAN:
+               gen = "SI";
+               param = "si_support";
+               module_param = amdgpu_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";
+               param = "cik_support";
+               module_param = amdgpu_cik_support;
+               amdgpu_support_built = IS_ENABLED(CONFIG_DRM_AMDGPU_CIK);
+               break;
+
+       default:
+               /* All other chips are supported by amdgpu only */
+               return true;
+       }
+
+       if (!amdgpu_support_built) {
+               dev_info(dev, "amdgpu built without %s support\n", gen);
+               return false;
+       }
+
+       if ((module_param == -1 && (support_by_default || !radeon_support_built)) ||
+           module_param == 1) {
+               if (radeon_support_built)
+                       dev_info(dev, "%s support provided by amdgpu.\n"
+                                "Use radeon.%s=1 amdgpu.%s=0 to override.\n",
+                                gen, param, param);
+
+               return true;
+       }
+
+       if (radeon_support_built)
+               dev_info(dev, "%s support provided by radeon.\n"
+                        "Use radeon.%s=0 amdgpu.%s=1 to override.\n",
+                        gen, param, param);
+       else if (module_param == 0)
+               dev_info(dev, "%s support disabled by module param\n", gen);
+
+       return false;
+}
+
 static int amdgpu_pci_probe(struct pci_dev *pdev,
                            const struct pci_device_id *ent)
 {
@@ -2353,48 +2414,8 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
                return -ENOTSUPP;
        }
 
-       switch (flags & AMD_ASIC_MASK) {
-       case CHIP_TAHITI:
-       case CHIP_PITCAIRN:
-       case CHIP_VERDE:
-       case CHIP_OLAND:
-       case CHIP_HAINAN:
-#ifdef CONFIG_DRM_AMDGPU_SI
-               if (!amdgpu_si_support) {
-                       dev_info(&pdev->dev,
-                                "SI support provided by radeon.\n");
-                       dev_info(&pdev->dev,
-                                "Use radeon.si_support=0 amdgpu.si_support=1 to override.\n"
-                               );
-                       return -ENODEV;
-               }
-               break;
-#else
-               dev_info(&pdev->dev, "amdgpu is built without SI support.\n");
+       if (!amdgpu_support_enabled(&pdev->dev, flags & AMD_ASIC_MASK))
                return -ENODEV;
-#endif
-       case CHIP_KAVERI:
-       case CHIP_BONAIRE:
-       case CHIP_HAWAII:
-       case CHIP_KABINI:
-       case CHIP_MULLINS:
-#ifdef CONFIG_DRM_AMDGPU_CIK
-               if (!amdgpu_cik_support) {
-                       dev_info(&pdev->dev,
-                                "CIK support provided by radeon.\n");
-                       dev_info(&pdev->dev,
-                                "Use radeon.cik_support=0 amdgpu.cik_support=1 to override.\n"
-                               );
-                       return -ENODEV;
-               }
-               break;
-#else
-               dev_info(&pdev->dev, "amdgpu is built without CIK support.\n");
-               return -ENODEV;
-#endif
-       default:
-               break;
-       }
 
        adev = devm_drm_dev_alloc(&pdev->dev, &amdgpu_kms_driver, typeof(*adev), ddev);
        if (IS_ERR(adev))