Skip to contentSkip to conversation

drm/amdgpu: Adjust logic in amdgpu_device_partner_bandwidth()

PATCH In review Alex Deucher 3 participants 3 messages May 16, 2024 – May 24, 2024

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 drm/amdgpu: Adjust logic in amdgpu_device_partner_bandwidth()

Use current speed/width on devices which don't support dynamic PCIe switching.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +12 -7
index e72e774d17e6a..f0011dac589d2 100644
@@ -5946,13 +5946,18 @@ static void amdgpu_device_partner_bandwidth(struct amdgpu_device *adev,
 	*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;
+	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;
+			*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 */
+		pcie_bandwidth_available(adev->pdev, NULL, speed, width);
 	}
 }
 
Signature · 1 line
2.45.0
#1 lore raw

Ping?

Quoted 43 lines · Alex Deucher

Use current speed/width on devices which don't support dynamic PCIe switching.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +12 -8
index e72e774d17e6a..f0011dac589d2 100644
@@ -5946,13 +5946,18 @@ static void amdgpu_device_partner_bandwidth(struct amdgpu_device *adev,
        *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;
+       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;
+                       *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 */
+               pcie_bandwidth_available(adev->pdev, NULL, speed, width);
        }
 }
 
--

2.45.0

Acked-by on v1 1/1
#2 lore raw
In reply to Alex Deucher

Am 16.05.24 um 17:05 schrieb Alex Deucher:

Quoted 5 lines

Use current speed/width on devices which don't support dynamic PCIe switching.

Quoted 34 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 19 ++++++++++++-------
  1 file changed, 12 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +12 -7
index e72e774d17e6a..f0011dac589d2 100644
@@ -5946,13 +5946,18 @@ static void amdgpu_device_partner_bandwidth(struct amdgpu_device *adev,
  	*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;
+	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;
+			*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 */
+		pcie_bandwidth_available(adev->pdev, NULL, speed, width);
  	}
  }