drm/amdgpu: disable runpm if we are the primary adapter

If we are the primary adapter (i.e., the one used by the firwmare
framebuffer), disable runtime pm. This fixes a regression caused
by commit 55285e21f045 which results in the displays waking up
shortly after they go to sleep due to the device coming out of
runtime suspend and sending a hotplug uevent.

v2: squash in reworked fix from Evan

Fixes: 55285e21f045 ("fbdev/efifb: Release PCI device's runtime PM ref during FB destroy")
Bug: https://bugzilla.kernel.org/show_bug.cgi?id=215203
Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1840
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

+35
+1
drivers/gpu/drm/amd/amdgpu/amdgpu.h
··· 1077 1077 bool runpm; 1078 1078 bool in_runpm; 1079 1079 bool has_pr3; 1080 + bool is_fw_fb; 1080 1081 1081 1082 bool pm_sysfs_en; 1082 1083 bool ucode_sysfs_en;
+28
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
··· 39 39 #include <linux/mmu_notifier.h> 40 40 #include <linux/suspend.h> 41 41 #include <linux/cc_platform.h> 42 + #include <linux/fb.h> 42 43 43 44 #include "amdgpu.h" 44 45 #include "amdgpu_irq.h" ··· 1891 1890 1892 1891 static const struct drm_driver amdgpu_kms_driver; 1893 1892 1893 + static bool amdgpu_is_fw_framebuffer(resource_size_t base, 1894 + resource_size_t size) 1895 + { 1896 + bool found = false; 1897 + #if IS_REACHABLE(CONFIG_FB) 1898 + struct apertures_struct *a; 1899 + 1900 + a = alloc_apertures(1); 1901 + if (!a) 1902 + return false; 1903 + 1904 + a->ranges[0].base = base; 1905 + a->ranges[0].size = size; 1906 + 1907 + found = is_firmware_framebuffer(a); 1908 + kfree(a); 1909 + #endif 1910 + return found; 1911 + } 1912 + 1894 1913 static int amdgpu_pci_probe(struct pci_dev *pdev, 1895 1914 const struct pci_device_id *ent) 1896 1915 { ··· 1919 1898 unsigned long flags = ent->driver_data; 1920 1899 int ret, retry = 0, i; 1921 1900 bool supports_atomic = false; 1901 + bool is_fw_fb; 1902 + resource_size_t base, size; 1922 1903 1923 1904 /* skip devices which are owned by radeon */ 1924 1905 for (i = 0; i < ARRAY_SIZE(amdgpu_unsupported_pciidlist); i++) { ··· 1989 1966 } 1990 1967 #endif 1991 1968 1969 + base = pci_resource_start(pdev, 0); 1970 + size = pci_resource_len(pdev, 0); 1971 + is_fw_fb = amdgpu_is_fw_framebuffer(base, size); 1972 + 1992 1973 /* Get rid of things like offb */ 1993 1974 ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &amdgpu_kms_driver); 1994 1975 if (ret) ··· 2005 1978 adev->dev = &pdev->dev; 2006 1979 adev->pdev = pdev; 2007 1980 ddev = adev_to_drm(adev); 1981 + adev->is_fw_fb = is_fw_fb; 2008 1982 2009 1983 if (!supports_atomic) 2010 1984 ddev->driver_features &= ~DRIVER_ATOMIC;
+6
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
··· 206 206 adev->runpm = true; 207 207 break; 208 208 } 209 + /* XXX: disable runtime pm if we are the primary adapter 210 + * to avoid displays being re-enabled after DPMS. 211 + * This needs to be sorted out and fixed properly. 212 + */ 213 + if (adev->is_fw_fb) 214 + adev->runpm = false; 209 215 if (adev->runpm) 210 216 dev_info(adev->dev, "Using BACO for runtime pm\n"); 211 217 }