drm/radeon: Bail earlier when radeon.cik_/si_support=0 is passed
authorHans de Goede <hdegoede@redhat.com>
Sat, 7 Sep 2019 20:32:38 +0000 (22:32 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 16 Sep 2019 15:42:56 +0000 (10:42 -0500)
Bail from the pci_driver probe function instead of from the drm_driver
load function.

This avoid /dev/dri/card0 temporarily getting registered and then
unregistered again, sending unwanted add / remove udev events to
userspace.

Specifically this avoids triggering the (userspace) bug fixed by this
plymouth merge-request:
https://gitlab.freedesktop.org/plymouth/plymouth/merge_requests/59

Note that despite that being an userspace bug, not sending unnecessary
udev events is a good idea in general.

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1490490
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon_drv.c
drivers/gpu/drm/radeon/radeon_kms.c

index 5838162f687fe33a8fdeb2611398e55800ec8f3d..4267cb55bc331e0f4ebd37a2d3eed6b7319c1fbb 100644 (file)
@@ -323,8 +323,39 @@ bool radeon_device_is_virtual(void);
 static int radeon_pci_probe(struct pci_dev *pdev,
                            const struct pci_device_id *ent)
 {
+       unsigned long flags = 0;
        int ret;
 
+       if (!ent)
+               return -ENODEV; /* Avoid NULL-ptr deref in drm_get_pci_dev */
+
+       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(&pdev->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(&pdev->dev,
+                                "CIK support disabled by module param\n");
+                       return -ENODEV;
+               }
+       }
+
        if (vga_switcheroo_client_probe_defer(pdev))
                return -EPROBE_DEFER;
 
index 07f7ace42c4baaa3bc0940a6296c38d8e9d5ba7a..e85c554eeaa9457c82fe9ab76d2721689b975d1c 100644 (file)
@@ -100,31 +100,6 @@ int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags)
        struct radeon_device *rdev;
        int r, acpi_status;
 
-       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->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->dev,
-                                "CIK support disabled by module param\n");
-                       return -ENODEV;
-               }
-       }
-
        rdev = kzalloc(sizeof(struct radeon_device), GFP_KERNEL);
        if (rdev == NULL) {
                return -ENOMEM;