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

Gadre, Mangesh Mangesh.Gadre at amd.com
Thu May 29 09:04:54 UTC 2025


[AMD Official Use Only - AMD Internal Distribution Only]

Acked-by:  Mangesh Gadre <Mangesh.Gadre at amd.com>

>-----Original Message-----
>From: Lazar, Lijo <Lijo.Lazar at amd.com>
>Sent: Thursday, May 29, 2025 2:00 PM
>To: amd-gfx at lists.freedesktop.org
>Cc: Zhang, Hawking <Hawking.Zhang at amd.com>; Deucher, Alexander
><Alexander.Deucher at amd.com>; Kamal, Asad <Asad.Kamal at amd.com>; Gadre,
>Mangesh <Mangesh.Gadre at amd.com>
>Subject: [PATCH 1/2] drm/amdgpu: Check pcie replays reporting support
>
>Check if pcie replay count reporting is supported before creating sysfs attribute.
>
>Signed-off-by: Lijo Lazar <lijo.lazar at amd.com>
>---
> 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(-)
>
>diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>index 72e41781afb0..9eaee8dacea7 100644
>--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>@@ -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);
> }
>diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.c
>b/drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.c
>index d085687a47ea..e56ba93a8df6 100644
>--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.c
>+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.c
>@@ -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;
>diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h
>b/drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h
>index 79c2f807b9fe..b528de6a01f6 100644
>--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h
>+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h
>@@ -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



More information about the amd-gfx mailing list