]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdgpu: Check pcie replays reporting support
authorLijo Lazar <lijo.lazar@amd.com>
Thu, 29 May 2025 07:19:30 +0000 (12:49 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 18 Jun 2025 16:19:02 +0000 (12:19 -0400)
Check if pcie replay count reporting is supported before creating sysfs
attribute.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Acked-by: Mangesh Gadre <Mangesh.Gadre@amd.com>
Reviewed-by: Asad Kamal <asad.kamal@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.c
drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h

index 6715d76ad03a7f153e24481b5ccce750ba5419cf..13708dc7706a541baf87e0e216afd2b709c97dc9 100644 (file)
@@ -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);
 }
index d085687a47ea16dfb1eb138b69f1a13e1786bc1e..e56ba93a8df6433b12d6f5a48dde66b87591aa77 100644 (file)
@@ -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;
index 79c2f807b9fe87eb479fd94c0a3511dbaf23d305..b528de6a01f6d3d57b5151afbbeba1014afb9991 100644 (file)
@@ -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