[2/3] drm/amdgpu: don't use pci_is_thunderbolt_attached()

Mario Limonciello mario.limonciello at amd.com
Tue Oct 31 19:14:37 UTC 2023


On 10/27/2023 10:42, Alex Deucher wrote:
> It's only valid on Intel systems with the Intel VSEC.
> Use dev_is_removable() instead.  This should do the right
> thing regardless of the platform.
> 
> Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2925
> Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
> ---

Reviewed-by: Mario Limonciello <mario.limonciello at amd.com>

>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----
>   drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c     | 5 +++--
>   2 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 2381de831271..5c90080e93ba 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -41,6 +41,7 @@
>   #include <drm/drm_fb_helper.h>
>   #include <drm/drm_probe_helper.h>
>   #include <drm/amdgpu_drm.h>
> +#include <linux/device.h>
>   #include <linux/vgaarb.h>
>   #include <linux/vga_switcheroo.h>
>   #include <linux/efi.h>
> @@ -2223,7 +2224,6 @@ static int amdgpu_device_parse_gpu_info_fw(struct amdgpu_device *adev)
>    */
>   static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)
>   {
> -	struct drm_device *dev = adev_to_drm(adev);
>   	struct pci_dev *parent;
>   	int i, r;
>   	bool total;
> @@ -2294,7 +2294,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) &&
> -	    !pci_is_thunderbolt_attached(to_pci_dev(dev->dev)))
> +	    !dev_is_removable(&adev->pdev->dev))
>   		adev->flags |= AMD_IS_PX;
>   
>   	if (!(adev->flags & AMD_IS_APU)) {
> @@ -4138,7 +4138,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
>   
>   	px = amdgpu_device_supports_px(ddev);
>   
> -	if (px || (!pci_is_thunderbolt_attached(adev->pdev) &&
> +	if (px || (!dev_is_removable(&adev->pdev->dev) &&
>   				apple_gmux_detect(NULL, NULL)))
>   		vga_switcheroo_register_client(adev->pdev,
>   					       &amdgpu_switcheroo_ops, px);
> @@ -4288,7 +4288,7 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)
>   
>   	px = amdgpu_device_supports_px(adev_to_drm(adev));
>   
> -	if (px || (!pci_is_thunderbolt_attached(adev->pdev) &&
> +	if (px || (!dev_is_removable(&adev->pdev->dev) &&
>   				apple_gmux_detect(NULL, NULL)))
>   		vga_switcheroo_unregister_client(adev->pdev);
>   
> diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c b/drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c
> index e523627cfe25..df218d5ca775 100644
> --- a/drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c
> +++ b/drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c
> @@ -28,6 +28,7 @@
>   #include "nbio/nbio_2_3_offset.h"
>   #include "nbio/nbio_2_3_sh_mask.h"
>   #include <uapi/linux/kfd_ioctl.h>
> +#include <linux/device.h>
>   #include <linux/pci.h>
>   
>   #define smnPCIE_CONFIG_CNTL	0x11180044
> @@ -361,7 +362,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 (pci_is_thunderbolt_attached(adev->pdev))
> +		if (dev_is_removable(&adev->pdev->dev))
>   			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;
> @@ -480,7 +481,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 (pci_is_thunderbolt_attached(adev->pdev))
> +	if (dev_is_removable(&adev->pdev->dev))
>   		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;



More information about the amd-gfx mailing list