Skip to contentSkip to conversation

drm/amdgpu: Check pcie replays reporting support

PATCH In review Lijo Lazar 3 participants 5 messages May 29, 2025

Subsystems (2)
lore
Share & tools
lore

Lijo Lazar

author
#0 lore raw

PATCH 1/2 drm/amdgpu: Check pcie replays reporting support

Check if pcie replay count reporting is supported before creating sysfs attribute.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.c   | 9 +++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h   | 2 ++
 3 files changed, 13 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -2
index 72e41781afb0..9eaee8dacea7 100644
@@ -232,7 +232,7 @@ static int amdgpu_device_attr_sysfs_init(struct amdgpu_device *adev)
 {
 	int ret = 0;
 
-	if (!amdgpu_sriov_vf(adev))
+	if (amdgpu_nbio_is_replay_cnt_supported(adev))
 		ret = sysfs_create_file(&adev->dev->kobj,
 					&dev_attr_pcie_replay_count.attr);
 
@@ -241,7 +241,7 @@ static int amdgpu_device_attr_sysfs_init(struct amdgpu_device *adev)
 
 static void amdgpu_device_attr_sysfs_fini(struct amdgpu_device *adev)
 {
-	if (!amdgpu_sriov_vf(adev))
+	if (amdgpu_nbio_is_replay_cnt_supported(adev))
 		sysfs_remove_file(&adev->dev->kobj,
 				  &dev_attr_pcie_replay_count.attr);
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.c +9 -0
index d085687a47ea..e56ba93a8df6 100644
@@ -53,6 +53,15 @@ u64 amdgpu_nbio_get_pcie_replay_count(struct amdgpu_device *adev)
 	return 0;
 }
 
+bool amdgpu_nbio_is_replay_cnt_supported(struct amdgpu_device *adev)
+{
+	if (amdgpu_sriov_vf(adev) || !adev->asic_funcs->get_pcie_replay_count ||
+	    (!adev->nbio.funcs || !adev->nbio.funcs->get_pcie_replay_count))
+		return false;
+
+	return true;
+}
+
 int amdgpu_nbio_ras_late_init(struct amdgpu_device *adev, struct ras_common_if *ras_block)
 {
 	int r;
drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h +2 -0
index 79c2f807b9fe..b528de6a01f6 100644
@@ -119,4 +119,6 @@ int amdgpu_nbio_ras_sw_init(struct amdgpu_device *adev);
 int amdgpu_nbio_ras_late_init(struct amdgpu_device *adev, struct ras_common_if *ras_block);
 u64 amdgpu_nbio_get_pcie_replay_count(struct amdgpu_device *adev);
 
+bool amdgpu_nbio_is_replay_cnt_supported(struct amdgpu_device *adev);
+
 #endif
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 2/2 drm/amdgpu: Remove nbiov7.9 replay count reporting

Direct pcie replay count reporting is not available on nbio v7.9. Reporting is done through firmware.

Fixes 50709d18f4a6 ("drm/amdgpu: Add pci replay count to nbio v7.9")
---
 drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c | 20 --------------------
 1 file changed, 20 deletions(-)
drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c +0 -20
index a376f072700d..1c22bc11c1f8 100644
@@ -31,9 +31,6 @@
 
 #define NPS_MODE_MASK 0x000000FFL
 
-/* Core 0 Port 0 counter */
-#define smnPCIEP_NAK_COUNTER 0x1A340218
-
 static void nbio_v7_9_remap_hdp_registers(struct amdgpu_device *adev)
 {
 	WREG32_SOC15(NBIO, 0, regBIF_BX0_REMAP_HDP_MEM_FLUSH_CNTL,
@@ -467,22 +464,6 @@ static void nbio_v7_9_init_registers(struct amdgpu_device *adev)
 	}
 }
 
-static u64 nbio_v7_9_get_pcie_replay_count(struct amdgpu_device *adev)
-{
-	u32 val, nak_r, nak_g;
-
-	if (adev->flags & AMD_IS_APU)
-		return 0;
-
-	/* Get the number of NAKs received and generated */
-	val = RREG32_PCIE(smnPCIEP_NAK_COUNTER);
-	nak_r = val & 0xFFFF;
-	nak_g = val >> 16;
-
-	/* Add the total number of NAKs, i.e the number of replays */
-	return (nak_r + nak_g);
-}
-
 #define MMIO_REG_HOLE_OFFSET 0x1A000
 
 static void nbio_v7_9_set_reg_remap(struct amdgpu_device *adev)
@@ -524,7 +505,6 @@ const struct amdgpu_nbio_funcs nbio_v7_9_funcs = {
 	.get_memory_partition_mode = nbio_v7_9_get_memory_partition_mode,
 	.is_nps_switch_requested = nbio_v7_9_is_nps_switch_requested,
 	.init_registers = nbio_v7_9_init_registers,
-	.get_pcie_replay_count = nbio_v7_9_get_pcie_replay_count,
 	.set_reg_remap = nbio_v7_9_set_reg_remap,
 };
 
Signature · 1 line
2.25.1
Acked-by on v1 2/2
#2 lore raw

RE: [PATCH 2/2] drm/amdgpu: Remove nbiov7.9 replay count reporting

[AMD Official Use Only - AMD Internal Distribution Only]

Quoted 66 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, May 29, 2025 2:00 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Kamal, Asad <[email protected]>; Gadre, Mangesh <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: Remove nbiov7.9 replay count reporting

Direct pcie replay count reporting is not available on nbio v7.9. Reporting is done through firmware.

Fixes 50709d18f4a6 ("drm/amdgpu: Add pci replay count to nbio v7.9")

---
drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c | 20 --------------------

1 file changed, 20 deletions(-)
drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c +0 -18
index a376f072700d..1c22bc11c1f8 100644
@@ -31,9 +31,6 @@
 
 #define NPS_MODE_MASK 0x000000FFL
 
-/* Core 0 Port 0 counter */
-#define smnPCIEP_NAK_COUNTER 0x1A340218
-
 static void nbio_v7_9_remap_hdp_registers(struct amdgpu_device *adev)  {
      WREG32_SOC15(NBIO, 0,
 regBIF_BX0_REMAP_HDP_MEM_FLUSH_CNTL,
@@ -467,22 +464,6 @@ static void nbio_v7_9_init_registers(struct amdgpu_device
 *adev)
      }
 }
 
-static u64 nbio_v7_9_get_pcie_replay_count(struct amdgpu_device *adev) -{
-      u32 val, nak_r, nak_g;
-
-      if (adev->flags & AMD_IS_APU)
-              return 0;
-
-      /* Get the number of NAKs received and generated */
-      val = RREG32_PCIE(smnPCIEP_NAK_COUNTER);
-      nak_r = val & 0xFFFF;
-      nak_g = val >> 16;
-
-      /* Add the total number of NAKs, i.e the number of replays */
-      return (nak_r + nak_g);
-}
-
 #define MMIO_REG_HOLE_OFFSET 0x1A000
 

static void nbio_v7_9_set_reg_remap(struct amdgpu_device *adev) @@ -524,7 +505,6 @@ const struct amdgpu_nbio_funcs nbio_v7_9_funcs = {
.get_memory_partition_mode = nbio_v7_9_get_memory_partition_mode, .is_nps_switch_requested = nbio_v7_9_is_nps_switch_requested, .init_registers = nbio_v7_9_init_registers,
- .get_pcie_replay_count = nbio_v7_9_get_pcie_replay_count,

      .set_reg_remap = nbio_v7_9_set_reg_remap,  };

--
2.25.1

Acked-by on v1 1/2
#3 lore raw
In reply to Lijo Lazar

[AMD Official Use Only - AMD Internal Distribution Only]

Quoted 77 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, May 29, 2025 2:00 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Kamal, Asad <[email protected]>; Gadre, Mangesh <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Check pcie replays reporting support

Check if pcie replay count reporting is supported before creating sysfs attribute.

---

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++--
drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.c   | 9 +++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h   | 2 ++
3 files changed, 13 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -2
index 72e41781afb0..9eaee8dacea7 100644
@@ -232,7 +232,7 @@ static int amdgpu_device_attr_sysfs_init(struct
 amdgpu_device *adev)  {
      int ret = 0;
 
-      if (!amdgpu_sriov_vf(adev))
+      if (amdgpu_nbio_is_replay_cnt_supported(adev))
              ret = sysfs_create_file(&adev->dev->kobj,
                                      &dev_attr_pcie_replay_count.attr);
 
@@ -241,7 +241,7 @@ static int amdgpu_device_attr_sysfs_init(struct
 amdgpu_device *adev)
 
 static void amdgpu_device_attr_sysfs_fini(struct amdgpu_device *adev)  {
-      if (!amdgpu_sriov_vf(adev))
+      if (amdgpu_nbio_is_replay_cnt_supported(adev))
              sysfs_remove_file(&adev->dev->kobj,
                                &dev_attr_pcie_replay_count.attr);
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.c +8 -0
index d085687a47ea..e56ba93a8df6 100644
@@ -53,6 +53,15 @@ u64 amdgpu_nbio_get_pcie_replay_count(struct
 amdgpu_device *adev)
      return 0;
 }
 
+bool amdgpu_nbio_is_replay_cnt_supported(struct amdgpu_device *adev) {
+      if (amdgpu_sriov_vf(adev) || !adev->asic_funcs->get_pcie_replay_count ||
+          (!adev->nbio.funcs || !adev->nbio.funcs->get_pcie_replay_count))
+              return false;
+
+      return true;
+}
+

int amdgpu_nbio_ras_late_init(struct amdgpu_device *adev, struct ras_common_if

*ras_block)  {
      int r;
drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h +0 -0
index 79c2f807b9fe..b528de6a01f6 100644
@@ -119,4 +119,6 @@ int amdgpu_nbio_ras_sw_init(struct amdgpu_device *adev);

int amdgpu_nbio_ras_late_init(struct amdgpu_device *adev, struct ras_common_if *ras_block);
u64 amdgpu_nbio_get_pcie_replay_count(struct amdgpu_device *adev);

drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h +2 -0
+bool amdgpu_nbio_is_replay_cnt_supported(struct amdgpu_device *adev);
+

#endif
--
2.25.1

#4 lore raw
In reply to Lijo Lazar

[AMD Official Use Only - AMD Internal Distribution Only]

Series is Reviewed-by: Asad Kamal <[email protected]>

Thanks & Regards
Asad

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, May 29, 2025 2:00 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Kamal, Asad <[email protected]>; Gadre, Mangesh <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Check pcie replays reporting support

Check if pcie replay count reporting is supported before creating sysfs attribute.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.c   | 9 +++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h   | 2 ++
 3 files changed, 13 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -2
index 72e41781afb0..9eaee8dacea7 100644
@@ -232,7 +232,7 @@ static int amdgpu_device_attr_sysfs_init(struct amdgpu_device *adev)  {
        int ret = 0;
 
-       if (!amdgpu_sriov_vf(adev))
+       if (amdgpu_nbio_is_replay_cnt_supported(adev))
                ret = sysfs_create_file(&adev->dev->kobj,
                                        &dev_attr_pcie_replay_count.attr);
 
@@ -241,7 +241,7 @@ static int amdgpu_device_attr_sysfs_init(struct amdgpu_device *adev)
 
 static void amdgpu_device_attr_sysfs_fini(struct amdgpu_device *adev)  {
-       if (!amdgpu_sriov_vf(adev))
+       if (amdgpu_nbio_is_replay_cnt_supported(adev))
                sysfs_remove_file(&adev->dev->kobj,
                                  &dev_attr_pcie_replay_count.attr);
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.c +8 -0
index d085687a47ea..e56ba93a8df6 100644
@@ -53,6 +53,15 @@ u64 amdgpu_nbio_get_pcie_replay_count(struct amdgpu_device *adev)
        return 0;
 }
 
+bool amdgpu_nbio_is_replay_cnt_supported(struct amdgpu_device *adev) {
+       if (amdgpu_sriov_vf(adev) || !adev->asic_funcs->get_pcie_replay_count ||
+           (!adev->nbio.funcs || !adev->nbio.funcs->get_pcie_replay_count))
+               return false;
+
+       return true;
+}
+
 int amdgpu_nbio_ras_late_init(struct amdgpu_device *adev, struct ras_common_if *ras_block)  {
        int r;
drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h +2 -1
index 79c2f807b9fe..b528de6a01f6 100644
@@ -119,4 +119,6 @@ int amdgpu_nbio_ras_sw_init(struct amdgpu_device *adev);  int amdgpu_nbio_ras_late_init(struct amdgpu_device *adev, struct ras_common_if *ras_block);
 u64 amdgpu_nbio_get_pcie_replay_count(struct amdgpu_device *adev);
 
+bool amdgpu_nbio_is_replay_cnt_supported(struct amdgpu_device *adev);
+
 #endif
--

2.25.1