On MacBookPros with switchable graphics, the firmware puts VRAM at MC
address 0 when the iGPU is enabled.  A later post (S3 resume, GPU
reset) moves VRAM back to the VBIOS default.  gmc_v8_0 reads
MC_VM_FB_LOCATION once at init and reprograms it only on SR-IOV.  On
bare metal, the driver then keeps using the old layout.

vi_reset_quirks[] handles this for the MacBookPro14,3 by PCI ID:

  commit a22e5e4f2ebb ("drm/amdgpu: reset VI ASIC on MacBookPro14,3")

Add the test that SI and CIK use: an Apple subsystem vendor and VRAM at
0.  Other Polaris MacBookPros then get the same reset at load, for
example the MacBookPro13,3 if its firmware leaves VRAM at 0.  These
boards are not tested.

Keep vi_reset_quirks[].  Its MacBookPro15,1 entries fix a different
failure, a module reload after S3:

  commit a5be7ad8f5f0 ("drm/amdgpu: reset VI ASIC on MacBookPro15,1")

VRAM is not at 0 at that point, so the new test may not cover it.

After the reset, FB_BASE is not 0, so the new test does not fire again
on a module reload.

Only compile-tested.

Suggested-by: Alex Deucher <[email protected]>
Cc: [email protected]
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Maciej Kucharek <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/vi.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c
index a0435fd55..cad6bbfce 100644
--- a/drivers/gpu/drm/amd/amdgpu/vi.c
+++ b/drivers/gpu/drm/amd/amdgpu/vi.c
@@ -1405,6 +1405,16 @@ static bool vi_need_reset_on_init(struct amdgpu_device 
*adev)
        unsigned int i;
        u32 clock_cntl, pc;
 
+       /*
+        * MacBookPros with switchable graphics put VRAM at 0 when the iGPU
+        * is enabled.  Any later post (S3 resume, GPU reset) moves it back to
+        * the vbios default, so reset and post on load to start with the
+        * vbios layout.
+        */
+       if (adev->pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE &&
+           !(RREG32(mmMC_VM_FB_LOCATION) & MC_VM_FB_LOCATION__FB_BASE_MASK))
+               return true;
+
        for (i = 0; i < ARRAY_SIZE(vi_reset_quirks); i++)
                if (adev->pdev->device == vi_reset_quirks[i].device &&
                    adev->pdev->subsystem_vendor == 
vi_reset_quirks[i].subsystem_vendor &&
-- 
2.55.0

Reply via email to