drm/amdgpu: Check pcie replays reporting support
Subsystems (2)
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
@@ -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
@@ -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
@@ -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
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.
--- 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
@@ -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 0x1A000static 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
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 reportingDirect pcie replay count reporting is not available on nbio v7.9. Reporting is done through firmware.
Signed-off-by Lijo Lazar <[email protected]>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@@ -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 0x1A000static void
nbio_v7_9_set_reg_remap(struct amdgpu_device *adev)@@ -524,7 +505,6 @@ const structamdgpu_nbio_funcsnbio_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
[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 supportCheck if pcie replay count reporting is supported before creating sysfs attribute.
Signed-off-by Lijo Lazar <[email protected]>---
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@@ -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@@ -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, structras_common_if*ras_block) { int r;drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h +0
-0@@ -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);
u64amdgpu_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
[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
@@ -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
@@ -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
@@ -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