If compiled without SI or CIK support but amdgpu tries to load it
will run into failures with uninitialized callbacks.

Show a nicer message in this case and fail probe instead.

Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4050
Signed-off-by: Mario Limonciello <mario.limoncie...@amd.com>
Reviewed-by: Alex Deucher <alexander.deuc...@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 43 +++++++++++++------------
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 81d9877c87357..4164889fb63a4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1793,7 +1793,6 @@ static const u16 amdgpu_unsupported_pciidlist[] = {
 };
 
 static const struct pci_device_id pciidlist[] = {
-#ifdef CONFIG_DRM_AMDGPU_SI
        {0x1002, 0x6780, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
        {0x1002, 0x6784, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
        {0x1002, 0x6788, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
@@ -1866,8 +1865,6 @@ static const struct pci_device_id pciidlist[] = {
        {0x1002, 0x6665, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_HAINAN|AMD_IS_MOBILITY},
        {0x1002, 0x6667, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_HAINAN|AMD_IS_MOBILITY},
        {0x1002, 0x666F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_HAINAN|AMD_IS_MOBILITY},
-#endif
-#ifdef CONFIG_DRM_AMDGPU_CIK
        /* Kaveri */
        {0x1002, 0x1304, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
        {0x1002, 0x1305, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
@@ -1950,7 +1947,6 @@ static const struct pci_device_id pciidlist[] = {
        {0x1002, 0x985D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
        {0x1002, 0x985E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
        {0x1002, 0x985F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
-#endif
        /* topaz */
        {0x1002, 0x6900, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TOPAZ},
        {0x1002, 0x6901, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TOPAZ},
@@ -2282,14 +2278,14 @@ 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) {
-               switch (flags & AMD_ASIC_MASK) {
-               case CHIP_TAHITI:
-               case CHIP_PITCAIRN:
-               case CHIP_VERDE:
-               case CHIP_OLAND:
-               case CHIP_HAINAN:
+               if (!amdgpu_si_support) {
                        dev_info(&pdev->dev,
                                 "SI support provided by radeon.\n");
                        dev_info(&pdev->dev,
@@ -2297,16 +2293,18 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
                                );
                        return -ENODEV;
                }
-       }
+               break;
+#else
+               dev_info(&pdev->dev, "amdgpu is built without SI support.\n");
+               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) {
-               switch (flags & AMD_ASIC_MASK) {
-               case CHIP_KAVERI:
-               case CHIP_BONAIRE:
-               case CHIP_HAWAII:
-               case CHIP_KABINI:
-               case CHIP_MULLINS:
+               if (!amdgpu_cik_support) {
                        dev_info(&pdev->dev,
                                 "CIK support provided by radeon.\n");
                        dev_info(&pdev->dev,
@@ -2314,8 +2312,13 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
                                );
                        return -ENODEV;
                }
-       }
+#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))
-- 
2.43.0

Reply via email to