| From 8587d48d694da5aca580f92461658ec14470592b Mon Sep 17 00:00:00 2001 |
| From: Yang Wang <kevinyang.wang@amd.com> |
| Date: Wed, 12 Aug 2026 11:08:40 +0800 |
| Subject: drm/amdgpu: check thunderbolt before switcheroo registration |
| |
| From: Yang Wang <kevinyang.wang@amd.com> |
| |
| commit 8587d48d694da5aca580f92461658ec14470592b upstream. |
| |
| Introduce a helper to consolidate the vga_switcheroo registration condition |
| used by the init and fini paths. |
| |
| Keep the explicit pci_is_thunderbolt_attached() check, as dev_is_removable() |
| does not provide equivalent coverage for Thunderbolt-attached GPUs. |
| This ensures such devices remain excluded from switcheroo registration while |
| preserving the existing PX and Apple gmux handling. |
| |
| Cc: stable@vger.kernel.org |
| Signed-off-by: Yang Wang <kevinyang.wang@amd.com> |
| Reviewed-by: Kenneth Feng <kenneth.feng@amd.com> |
| Signed-off-by: Alex Deucher <alexander.deucher@amd.com> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| --- |
| drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 ++++++++++---- |
| 1 file changed, 10 insertions(+), 4 deletions(-) |
| |
| --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |
| +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |
| @@ -3586,6 +3586,14 @@ static void amdgpu_device_set_mcbp(struc |
| DRM_INFO("MCBP is enabled\n"); |
| } |
| |
| +static bool |
| +amdgpu_device_should_register_switcheroo(struct amdgpu_device *adev, bool px) |
| +{ |
| + return !pci_is_thunderbolt_attached(adev->pdev) && |
| + (px || (!dev_is_removable(&adev->pdev->dev) && |
| + apple_gmux_detect(NULL, NULL))); |
| +} |
| + |
| /** |
| * amdgpu_device_init - initialize the driver |
| * |
| @@ -4002,8 +4010,7 @@ fence_driver_init: |
| |
| px = amdgpu_device_supports_px(ddev); |
| |
| - if (px || (!dev_is_removable(&adev->pdev->dev) && |
| - apple_gmux_detect(NULL, NULL))) |
| + if (amdgpu_device_should_register_switcheroo(adev, px)) |
| vga_switcheroo_register_client(adev->pdev, |
| &amdgpu_switcheroo_ops, px); |
| |
| @@ -4162,8 +4169,7 @@ void amdgpu_device_fini_sw(struct amdgpu |
| |
| px = amdgpu_device_supports_px(adev_to_drm(adev)); |
| |
| - if (px || (!dev_is_removable(&adev->pdev->dev) && |
| - apple_gmux_detect(NULL, NULL))) |
| + if (amdgpu_device_should_register_switcheroo(adev, px)) |
| vga_switcheroo_unregister_client(adev->pdev); |
| |
| if (px) |