Skip to content

Commit b95dc06

Browse files
committed
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 55285e2 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: 55285e2 ("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 <[email protected]>
1 parent 9a45ac2 commit b95dc06

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,7 @@ struct amdgpu_device {
10771077
bool runpm;
10781078
bool in_runpm;
10791079
bool has_pr3;
1080+
bool is_fw_fb;
10801081

10811082
bool pm_sysfs_en;
10821083
bool ucode_sysfs_en;

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <linux/mmu_notifier.h>
4040
#include <linux/suspend.h>
4141
#include <linux/cc_platform.h>
42+
#include <linux/fb.h>
4243

4344
#include "amdgpu.h"
4445
#include "amdgpu_irq.h"
@@ -1890,6 +1891,26 @@ MODULE_DEVICE_TABLE(pci, pciidlist);
18901891

18911892
static const struct drm_driver amdgpu_kms_driver;
18921893

1894+
static bool amdgpu_is_fw_framebuffer(resource_size_t base,
1895+
resource_size_t size)
1896+
{
1897+
bool found = false;
1898+
#if IS_REACHABLE(CONFIG_FB)
1899+
struct apertures_struct *a;
1900+
1901+
a = alloc_apertures(1);
1902+
if (!a)
1903+
return false;
1904+
1905+
a->ranges[0].base = base;
1906+
a->ranges[0].size = size;
1907+
1908+
found = is_firmware_framebuffer(a);
1909+
kfree(a);
1910+
#endif
1911+
return found;
1912+
}
1913+
18931914
static int amdgpu_pci_probe(struct pci_dev *pdev,
18941915
const struct pci_device_id *ent)
18951916
{
@@ -1898,6 +1919,8 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
18981919
unsigned long flags = ent->driver_data;
18991920
int ret, retry = 0, i;
19001921
bool supports_atomic = false;
1922+
bool is_fw_fb;
1923+
resource_size_t base, size;
19011924

19021925
/* skip devices which are owned by radeon */
19031926
for (i = 0; i < ARRAY_SIZE(amdgpu_unsupported_pciidlist); i++) {
@@ -1966,6 +1989,10 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
19661989
}
19671990
#endif
19681991

1992+
base = pci_resource_start(pdev, 0);
1993+
size = pci_resource_len(pdev, 0);
1994+
is_fw_fb = amdgpu_is_fw_framebuffer(base, size);
1995+
19691996
/* Get rid of things like offb */
19701997
ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &amdgpu_kms_driver);
19711998
if (ret)
@@ -1978,6 +2005,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
19782005
adev->dev = &pdev->dev;
19792006
adev->pdev = pdev;
19802007
ddev = adev_to_drm(adev);
2008+
adev->is_fw_fb = is_fw_fb;
19812009

19822010
if (!supports_atomic)
19832011
ddev->driver_features &= ~DRIVER_ATOMIC;

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags)
206206
adev->runpm = true;
207207
break;
208208
}
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;
209215
if (adev->runpm)
210216
dev_info(adev->dev, "Using BACO for runtime pm\n");
211217
}

0 commit comments

Comments
 (0)