All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mario Limonciello <superm1@kernel.org>
To: Alex Deucher <alexander.deucher@amd.com>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/amdgpu: add helper for determining removable devices (USB4, TB)
Date: Thu, 19 Nov 2026 08:46:55 -0600	[thread overview]
Message-ID: <2a2d29ce-269e-42df-9ebc-950984dd4589@kernel.org> (raw)
In-Reply-To: <20261119144309.3013871-1-alexander.deucher@amd.com>

On 11/19/26 08:43, Alex Deucher wrote:
> 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.
> 
> Cc: superm1@kernel.org
> Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/6163
> Fixes: d9b3a066dfcd ("drm/amd: Exclude dGPUs in eGPU enclosures from DPM quirks")
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>

> ---
>   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(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 7e1b9a70fd150..5dfb57e7c0b32 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -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);
>   
>   /*
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
> index 6bbca70a4e2eb..4918e891f9781 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
> @@ -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))) {
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index ea960085bfc8c..7179011d1b0a2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -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));
>   }
>   
>   /**
> diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c b/drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c
> index 04041b398781b..3da92fb09495d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c
> +++ b/drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c
> @@ -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;


      reply	other threads:[~2026-11-19 14:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 14:43 [PATCH] drm/amdgpu: add helper for determining removable devices (USB4, TB) Alex Deucher
2026-11-19 14:46 ` Mario Limonciello [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a2d29ce-269e-42df-9ebc-950984dd4589@kernel.org \
    --to=superm1@kernel.org \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.