summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/amd/amdgpu
diff options
context:
space:
mode:
authorMario Limonciello <mario.limonciello@amd.com>2026-05-20 10:46:17 -0500
committerAlex Deucher <alexander.deucher@amd.com>2026-05-27 10:48:36 -0400
commiteb53125a7ad99c7fc2f249bffdc561afa002a46c (patch)
tree25d17620fa2610b7eae95c274127d1c78fd8bffd /drivers/gpu/drm/amd/amdgpu
parentdeb02080ca5d3f015cf71e56067a39ef2f141998 (diff)
downloadlwn-eb53125a7ad99c7fc2f249bffdc561afa002a46c.tar.gz
lwn-eb53125a7ad99c7fc2f249bffdc561afa002a46c.zip
drm/amd: Add dedicated helper for amdgpu_device_find_parent()
There are a few cases that code walks up the topology to find the link partner of the integrated switch in a dGPU. Split this out to a helper and call in all places. This does have a functional change that amdgpu_device_gpu_bandwidth() doesn't cache the internal link but only the parent. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_device.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 21a3fb574d53..480eeb8510f8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1913,6 +1913,19 @@ static void amdgpu_uid_fini(struct amdgpu_device *adev)
adev->uid_info = NULL;
}
+static struct pci_dev *amdgpu_device_find_parent(struct amdgpu_device *adev)
+{
+ struct pci_dev *parent = adev->pdev;
+
+ /* skip upstream/downstream switches internal to dGPU */
+ while ((parent = pci_upstream_bridge(parent))) {
+ if (parent->vendor == PCI_VENDOR_ID_ATI)
+ continue;
+ }
+
+ return parent;
+}
+
/**
* amdgpu_device_ip_early_init - run early init for hardware IPs
*
@@ -5921,8 +5934,6 @@ 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;
@@ -5930,13 +5941,11 @@ static void amdgpu_device_partner_bandwidth(struct amdgpu_device *adev,
*width = PCIE_LNK_WIDTH_UNKNOWN;
if (amdgpu_device_pcie_dynamic_switching_supported(adev)) {
- while ((parent = pci_upstream_bridge(parent))) {
- /* skip upstream/downstream switches internal to dGPU*/
- if (parent->vendor == PCI_VENDOR_ID_ATI)
- continue;
+ struct pci_dev *parent = amdgpu_device_find_parent(adev);
+
+ if (parent) {
*speed = pcie_get_speed_cap(parent);
*width = pcie_get_width_cap(parent);
- break;
}
} else {
/* use the current speeds rather than max if switching is not supported */
@@ -5963,22 +5972,15 @@ static void amdgpu_device_gpu_bandwidth(struct amdgpu_device *adev,
if (!speed || !width)
return;
- parent = pci_upstream_bridge(parent);
- if (parent && parent->vendor == PCI_VENDOR_ID_ATI) {
- /* use the upstream/downstream switches internal to dGPU */
+ /* use the device itself */
+ *speed = pcie_get_speed_cap(adev->pdev);
+ *width = pcie_get_width_cap(adev->pdev);
+
+ /* use the link outside the device */
+ parent = amdgpu_device_find_parent(adev);
+ if (parent) {
*speed = pcie_get_speed_cap(parent);
*width = pcie_get_width_cap(parent);
- while ((parent = pci_upstream_bridge(parent))) {
- if (parent->vendor == PCI_VENDOR_ID_ATI) {
- /* use the upstream/downstream switches internal to dGPU */
- *speed = pcie_get_speed_cap(parent);
- *width = pcie_get_width_cap(parent);
- }
- }
- } else {
- /* use the device itself */
- *speed = pcie_get_speed_cap(adev->pdev);
- *width = pcie_get_width_cap(adev->pdev);
}
}