Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: register a vga_switcheroo client for MacBooks with apple-gmux

Commit 3840c5bcc245 ("drm/amdgpu: disentangle runtime pm and
vga_switcheroo") made amdgpu only register a vga_switcheroo client for
GPU's with PX, however AMD GPUs in dual gpu Apple Macbooks do need to
register, but don't have PX. Instead of AMD's PX, they use apple-gmux.

Use apple_gmux_detect() to identify these gpus, and
pci_is_thunderbolt_attached() to ensure eGPUs connected to Dual GPU
Macbooks don't register with vga_switcheroo.

Fixes: 3840c5bcc245 ("drm/amdgpu: disentangle runtime pm and vga_switcheroo")
Link: https://lore.kernel.org/amd-gfx/20230210044826.9834-10-orlandoch.dev@gmail.com/
Signed-off-by: Orlando Chamberlain <orlandoch.dev@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Orlando Chamberlain and committed by
Alex Deucher
d37a3929 1fd0da91

+16 -5
+16 -5
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 35 35 #include <linux/devcoredump.h> 36 36 #include <generated/utsrelease.h> 37 37 #include <linux/pci-p2pdma.h> 38 + #include <linux/apple-gmux.h> 38 39 39 40 #include <drm/drm_aperture.h> 40 41 #include <drm/drm_atomic_helper.h> ··· 3931 3930 if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) 3932 3931 vga_client_register(adev->pdev, amdgpu_device_vga_set_decode); 3933 3932 3934 - if (amdgpu_device_supports_px(ddev)) { 3935 - px = true; 3933 + px = amdgpu_device_supports_px(ddev); 3934 + 3935 + if (px || (!pci_is_thunderbolt_attached(adev->pdev) && 3936 + apple_gmux_detect(NULL, NULL))) 3936 3937 vga_switcheroo_register_client(adev->pdev, 3937 3938 &amdgpu_switcheroo_ops, px); 3939 + 3940 + if (px) 3938 3941 vga_switcheroo_init_domain_pm_ops(adev->dev, &adev->vga_pm_domain); 3939 - } 3940 3942 3941 3943 if (adev->gmc.xgmi.pending_reset) 3942 3944 queue_delayed_work(system_wq, &mgpu_info.delayed_reset_work, ··· 4043 4039 void amdgpu_device_fini_sw(struct amdgpu_device *adev) 4044 4040 { 4045 4041 int idx; 4042 + bool px; 4046 4043 4047 4044 amdgpu_fence_driver_sw_fini(adev); 4048 4045 amdgpu_device_ip_fini(adev); ··· 4062 4057 4063 4058 kfree(adev->bios); 4064 4059 adev->bios = NULL; 4065 - if (amdgpu_device_supports_px(adev_to_drm(adev))) { 4060 + 4061 + px = amdgpu_device_supports_px(adev_to_drm(adev)); 4062 + 4063 + if (px || (!pci_is_thunderbolt_attached(adev->pdev) && 4064 + apple_gmux_detect(NULL, NULL))) 4066 4065 vga_switcheroo_unregister_client(adev->pdev); 4066 + 4067 + if (px) 4067 4068 vga_switcheroo_fini_domain_pm_ops(adev->dev); 4068 - } 4069 + 4069 4070 if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) 4070 4071 vga_client_unregister(adev->pdev); 4071 4072