drm/amdgpu: add helper for determining removable devices (USB4, TB)
Subsystems (2)
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: add helper for determining removable devices (USB4, TB)
Apparently some Intel TB ports don't set dev_is_removable() on attached devices and thus the current check fails. Add a helper to check both dev_is_removable() and TB attached.
Fixes d9b3a066dfcd ("drm/amd: Exclude dGPUs in eGPU enclosures from DPM quirks")
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 24 ++++++++++++++-------- drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c | 4 ++-- 4 files changed, 21 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -1053,6 +1053,8 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,int amdgpu_device_reinit_after_reset (struct amdgpu_reset_context *reset_context); +bool amdgpu_device_is_removable (struct amdgpu_device *adev); +int emu_soc_asic_init (struct amdgpu_device *adev);/*
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +1 -1
@@ -369,7 +369,7 @@ static bool amdgpu_atrm_get_bios(struct amdgpu_device *adev)bool found = false;/* ATRM is for on-platform devices only */ -if (dev_is_removable (&adev->pdev->dev)) +if (amdgpu_device_is_removable (adev))return false;while ((pdev =pci_get_base_class (PCI_BASE_CLASS_DISPLAY , pdev))) {
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +16 -8
@@ -617,8 +617,7 @@ void amdgpu_device_detect_runtime_pm_mode(struct amdgpu_device *adev)int bamaco_support; adev->pm.rpm_mode =AMDGPU_RUNPM_NONE ; -if (pci_is_thunderbolt_attached (adev->pdev) || -dev_is_removable (&adev->pdev->dev)) { +if (amdgpu_device_is_removable (adev)) {dev_info (adev->dev,"Runtime PM disabled for externally attached device\n" );return ;
@@ -1286,6 +1285,16 @@ bool amdgpu_device_seamless_boot_supported(struct amdgpu_device *adev)return amdgpu_ip_version (adev,DCE_HWIP ,0 ) >=IP_VERSION (3 ,0 ,0 ); } +bool amdgpu_device_is_removable (struct amdgpu_device *adev) +{ +/* older TB systems don't set dev_is_removable so check both here */ +if (dev_is_removable (adev->dev) || +pci_is_thunderbolt_attached (adev->pdev)) +return true; + +return false; +} +#if IS_ENABLED (CONFIG_X86 )static const struct x86_cpu_id amdgpu_pcie_dynamic_switching_quirks[] = {/*
@@ -1308,8 +1317,8 @@ static const struct x86_cpu_id amdgpu_pcie_dynamic_switching_quirks[] = {static bool amdgpu_device_pcie_dynamic_switching_supported (struct amdgpu_device *adev) { -/* eGPU change speeds based on USB4 fabric conditions */ -if (dev_is_removable (adev->dev)) +/* eGPU change speeds based on USB4/TB fabric conditions */ +if (amdgpu_device_is_removable (adev))return true;/* Hosts have problems with dynamic speed switching */
@@ -2077,7 +2086,7 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev) (amdgpu_is_atpx_hybrid () ||amdgpu_has_atpx_dgpu_power_cntl ()) && ((adev->flags &AMD_IS_APU ) ==0 ) && - !dev_is_removable(&adev->pdev->dev)) + !amdgpu_device_is_removable(adev)) adev->flags |= AMD_IS_PX;if (!(adev->flags &AMD_IS_APU )) {
@@ -3820,9 +3829,8 @@ static void amdgpu_device_sys_interface_fini(struct amdgpu_device *adev)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 ))); +return !amdgpu_device_is_removable (adev) && + (px ||apple_gmux_detect (NULL ,NULL )); }/**
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +2 -2
@@ -357,7 +357,7 @@ static void nbio_v2_3_enable_aspm(struct amdgpu_device *adev, data |=NAVI10_PCIE__LC_L0S_INACTIVITY_DEFAULT <<PCIE_LC_CNTL__LC_L0S_INACTIVITY__SHIFT ; -if (dev_is_removable (&adev->pdev->dev)) +if (amdgpu_device_is_removable (adev)) data |=NAVI10_PCIE__LC_L1_INACTIVITY_TBT_DEFAULT <<PCIE_LC_CNTL__LC_L1_INACTIVITY__SHIFT ;else data |=NAVI10_PCIE__LC_L1_INACTIVITY_DEFAULT <<PCIE_LC_CNTL__LC_L1_INACTIVITY__SHIFT ;
@@ -476,7 +476,7 @@ static void nbio_v2_3_program_aspm(struct amdgpu_device *adev) def = data =RREG32_PCIE (smnPCIE_LC_CNTL); data |=NAVI10_PCIE__LC_L0S_INACTIVITY_DEFAULT <<PCIE_LC_CNTL__LC_L0S_INACTIVITY__SHIFT ; -if (dev_is_removable (&adev->pdev->dev)) +if (amdgpu_device_is_removable (adev)) data |=NAVI10_PCIE__LC_L1_INACTIVITY_TBT_DEFAULT <<PCIE_LC_CNTL__LC_L1_INACTIVITY__SHIFT ;else data |=NAVI10_PCIE__LC_L1_INACTIVITY_DEFAULT <<PCIE_LC_CNTL__LC_L1_INACTIVITY__SHIFT ;
Signature · 1 line
2.56.1
Quoted 8 lines · Alex Deucher
Apparently some Intel TB ports don't set
dev_is_removable()on attached devices and thus the current check fails. Add a helper to check bothdev_is_removable()and TB attached.Fixes d9b3a066dfcd ("drm/amd: Exclude dGPUs in eGPU enclosures from DPM quirks")Signed-off-by Alex Deucher <[email protected]>
Reviewed-by Mario Limonciello (AMD) <[email protected]>
Quoted 118 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 24 ++++++++++++++-------- drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c | 4 ++-- 4 files changed, 21 insertions(+), 11 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +2
-0@@ -1053,6 +1053,8 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,int amdgpu_device_reinit_after_reset (struct amdgpu_reset_context *reset_context); +bool amdgpu_device_is_removable (struct amdgpu_device *adev); +int emu_soc_asic_init (struct amdgpu_device *adev);/* drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +1
-1@@ -369,7 +369,7 @@ static bool amdgpu_atrm_get_bios(struct amdgpu_device *adev)bool found = false;/* ATRM is for on-platform devices only */ -if (dev_is_removable (&adev->pdev->dev)) +if (amdgpu_device_is_removable (adev))return false;while ((pdev =pci_get_base_class (PCI_BASE_CLASS_DISPLAY , pdev))) {drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +16
-8@@ -617,8 +617,7 @@ void amdgpu_device_detect_runtime_pm_mode(struct amdgpu_device *adev)int bamaco_support; adev->pm.rpm_mode =AMDGPU_RUNPM_NONE ; -if (pci_is_thunderbolt_attached (adev->pdev) || -dev_is_removable (&adev->pdev->dev)) { +if (amdgpu_device_is_removable (adev)) {dev_info (adev->dev,"Runtime PM disabled for externally attached device\n" );return ;@@ -1286,6 +1285,16 @@ bool amdgpu_device_seamless_boot_supported(struct amdgpu_device *adev)return amdgpu_ip_version (adev,DCE_HWIP ,0 ) >=IP_VERSION (3 ,0 ,0 ); } +bool amdgpu_device_is_removable (struct amdgpu_device *adev) +{ +/* older TB systems don't set dev_is_removable so check both here */ +if (dev_is_removable (adev->dev) || +pci_is_thunderbolt_attached (adev->pdev)) +return true; + +return false; +} +#if IS_ENABLED (CONFIG_X86 )static const struct x86_cpu_id amdgpu_pcie_dynamic_switching_quirks[] = {/* @@ -1308,8 +1317,8 @@ static const struct x86_cpu_id amdgpu_pcie_dynamic_switching_quirks[] = {static bool amdgpu_device_pcie_dynamic_switching_supported (struct amdgpu_device *adev) { -/* eGPU change speeds based on USB4 fabric conditions */ -if (dev_is_removable (adev->dev)) +/* eGPU change speeds based on USB4/TB fabric conditions */ +if (amdgpu_device_is_removable (adev))return true;/* Hosts have problems with dynamic speed switching */ @@ -2077,7 +2086,7 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev) (amdgpu_is_atpx_hybrid () ||amdgpu_has_atpx_dgpu_power_cntl ()) && ((adev->flags &AMD_IS_APU ) ==0 ) && - !dev_is_removable(&adev->pdev->dev)) + !amdgpu_device_is_removable(adev)) adev->flags |= AMD_IS_PX;if (!(adev->flags &AMD_IS_APU )) {@@ -3820,9 +3829,8 @@ static void amdgpu_device_sys_interface_fini(struct amdgpu_device *adev)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 ))); +return !amdgpu_device_is_removable (adev) && + (px ||apple_gmux_detect (NULL ,NULL )); }/** drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +2
-2@@ -357,7 +357,7 @@ static void nbio_v2_3_enable_aspm(struct amdgpu_device *adev, data |=NAVI10_PCIE__LC_L0S_INACTIVITY_DEFAULT <<PCIE_LC_CNTL__LC_L0S_INACTIVITY__SHIFT ; -if (dev_is_removable (&adev->pdev->dev)) +if (amdgpu_device_is_removable (adev)) data |=NAVI10_PCIE__LC_L1_INACTIVITY_TBT_DEFAULT <<PCIE_LC_CNTL__LC_L1_INACTIVITY__SHIFT ;else data |=NAVI10_PCIE__LC_L1_INACTIVITY_DEFAULT <<PCIE_LC_CNTL__LC_L1_INACTIVITY__SHIFT ;@@ -476,7 +476,7 @@ static void nbio_v2_3_program_aspm(struct amdgpu_device *adev) def = data =RREG32_PCIE (smnPCIE_LC_CNTL); data |=NAVI10_PCIE__LC_L0S_INACTIVITY_DEFAULT <<PCIE_LC_CNTL__LC_L0S_INACTIVITY__SHIFT ; -if (dev_is_removable (&adev->pdev->dev)) +if (amdgpu_device_is_removable (adev)) data |=NAVI10_PCIE__LC_L1_INACTIVITY_TBT_DEFAULT <<PCIE_LC_CNTL__LC_L1_INACTIVITY__SHIFT ;else data |=NAVI10_PCIE__LC_L1_INACTIVITY_DEFAULT <<PCIE_LC_CNTL__LC_L1_INACTIVITY__SHIFT ;