drm/amd: Use the first non-dGPU PCI device for BW limits
Subsystems (2)
PATCH v2 1/2 drm/amd: Use the first non-dGPU PCI device for BW limits
When bandwidth limits are looked up using pcie_bandwidth_available() virtual links such as USB4 are analyzed which might not represent the real speed. Furthermore devices may change speeds autonomously which may introduce conditional variation to the results reported in the status registers.
Instead look at the capabilities of first PCI device outside of dGPU to decide upper limits that the dGPU will work at.
For eGPU this effectively means that it will use the speed of the link partner. As the new semenatics of this are unique to AMD dGPUs, create a new local symbol instead of changing pcie_bandwidth_available().
USB4 V2 with Errata and ECN through June 2023 Section 11.2.1
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 37 ++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +35 -2
@@ -5721,6 +5721,39 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,return r; } +/** +* amdgpu_device_partner_bandwidth - find the bandwidth of appropriate partner +* +* @adev: amdgpu_device pointer +* @speed: pointer to the speed of the link +* @width: pointer to the width of the link +* +* Evaluate the hierarchy to find the speed and bandwidth capabilities of the +* first physical partner to an AMD dGPU. +* This will exclude any virtual switches and links. +*/ +static void amdgpu_device_partner_bandwidth (struct amdgpu_device *adev, +enum pci_bus_speed *speed, +enum pcie_link_width *width) +{ +struct pci_dev *parent = adev->pdev; + +if (!speed || !width) +return ; + + *speed =PCI_SPEED_UNKNOWN ; + *width =PCIE_LNK_WIDTH_UNKNOWN ; + +while ((parent =pci_upstream_bridge (parent))) { +/* skip upstream/downstream switches internal to dGPU*/ +if (parent->vendor ==PCI_VENDOR_ID_ATI ) +continue ; + *speed =pcie_get_speed_cap (parent); + *width =pcie_get_width_cap (parent); +break ; + } +} +/** * amdgpu_device_get_pcie_info - fence pcie info about the PCIE slot *
@@ -5754,8 +5787,8 @@ static void amdgpu_device_get_pcie_info(struct amdgpu_device *adev)if (adev->pm.pcie_gen_mask && adev->pm.pcie_mlw_mask)return ; -pcie_bandwidth_available (adev->pdev,NULL , - &platform_speed_cap, &platform_link_width); +amdgpu_device_partner_bandwidth (adev, &platform_speed_cap, + &platform_link_width);if (adev->pm.pcie_gen_mask ==0 ) {/* asic caps */
Signature · 1 line
2.34.1
PATCH v2 2/2 drm/amd: Exclude dGPUs in eGPU enclosures from DPM quirks
The PCIe speed capabilities advertised by a USB4 or TBT3 link are limited to PCIe gen 1 per the USB4 spec. In reality the speed will change dynamically based on fabric conditions and other traffic.
DPM is disabled when dGPUs are connected directly to Intel hosts since the PCIe root port isn't able to handle dynamic speed switching.
As this limitation is specifically for PCIe root ports in the SoC, don't apply it when connected to an eGPU enclosure connected to an Intel host.
---v1->v2:
* Adjust commit message
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -2
@@ -1551,11 +1551,15 @@ bool amdgpu_device_seamless_boot_supported(struct amdgpu_device *adev)* https://edc.intel.com/content/www/us/en/design/products/platforms/details/raptor-lake-s/13th-generation-core-processors-datasheet-volume-1-of-2/005/pci-express-support/ * https://gitlab.freedesktop.org/drm/amd/-/issues/2663 */ -static bool amdgpu_device_pcie_dynamic_switching_supported (void ) +static bool amdgpu_device_pcie_dynamic_switching_supported (struct amdgpu_device *adev) {#if IS_ENABLED (CONFIG_X86 )struct cpuinfo_x86 *c = &cpu_data (0 ); +/* eGPU change speeds based on USB4 fabric conditions */ +if (dev_is_removable (adev->dev)) +return true; +if (c->x86_vendor ==X86_VENDOR_INTEL )return false;#endif
@@ -2395,7 +2399,7 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev) adev->pm.pp_feature &= ~PP_GFXOFF_MASK ;if (amdgpu_sriov_vf (adev) && adev->asic_type ==CHIP_SIENNA_CICHLID ) adev->pm.pp_feature &= ~PP_OVERDRIVE_MASK ; -if (!amdgpu_device_pcie_dynamic_switching_supported ()) +if (!amdgpu_device_pcie_dynamic_switching_supported (adev)) adev->pm.pp_feature &= ~PP_PCIE_DPM_MASK ; total = true;
Signature · 1 line
2.34.1
Quoted 6 lines · Mario Limonciello
When bandwidth limits are looked up using
pcie_bandwidth_available()virtual links such as USB4 are analyzed which might not represent the real speed. Furthermore devices may change speeds autonomously which may introduce conditional variation to the results reported in the status registers.
Quoted 6 lines
Instead look at the capabilities of first PCI device outside of dGPU to decide upper limits that the dGPU will work at.
For eGPU this effectively means that it will use the speed of the link partner. As the new semenatics of this are unique to AMD dGPUs, create a new local symbol instead of changing
pcie_bandwidth_available().
The last line may be removed. As discussed in the thread with Mike, looking at link partner's capabilities is the right thing to do regardless of the issue. pcie_bandwidth_available() api doesn't need to be blamed :)
Series is -
Thanks,
Lijo
Quoted 65 lines
USB4 V2 with Errata and ECN through June 2023 Section 11.2.1
Signed-off-by Mario Limonciello <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 37 ++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +35
-2@@ -5721,6 +5721,39 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,return r; } +/** +* amdgpu_device_partner_bandwidth - find the bandwidth of appropriate partner +* +* @adev: amdgpu_device pointer +* @speed: pointer to the speed of the link +* @width: pointer to the width of the link +* +* Evaluate the hierarchy to find the speed and bandwidth capabilities of the +* first physical partner to an AMD dGPU. +* This will exclude any virtual switches and links. +*/ +static void amdgpu_device_partner_bandwidth (struct amdgpu_device *adev, +enum pci_bus_speed *speed, +enum pcie_link_width *width) +{ +struct pci_dev *parent = adev->pdev; + +if (!speed || !width) +return ; + + *speed =PCI_SPEED_UNKNOWN ; + *width =PCIE_LNK_WIDTH_UNKNOWN ; + +while ((parent =pci_upstream_bridge (parent))) { +/* skip upstream/downstream switches internal to dGPU*/ +if (parent->vendor ==PCI_VENDOR_ID_ATI ) +continue ; + *speed =pcie_get_speed_cap (parent); + *width =pcie_get_width_cap (parent); +break ; + } +} +/** * amdgpu_device_get_pcie_info - fence pcie info about the PCIE slot * @@ -5754,8 +5787,8 @@ static void amdgpu_device_get_pcie_info(struct amdgpu_device *adev)if (adev->pm.pcie_gen_mask && adev->pm.pcie_mlw_mask)return ; -pcie_bandwidth_available (adev->pdev,NULL , - &platform_speed_cap, &platform_link_width); +amdgpu_device_partner_bandwidth (adev, &platform_speed_cap, + &platform_link_width);if (adev->pm.pcie_gen_mask ==0 ) {/* asic caps */