On 3/17/2025 7:15 PM, Victor Skvortsov wrote: > VFs cannot read the NAK_COUNTER register. This information is only > available through PMFW metrics. > > Signed-off-by: Victor Skvortsov <victor.skvortsov@xxxxxxx> Reviewed-by: Lijo Lazar <lijo.lazar@xxxxxxx> Thanks, Lijo > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 27 ++++++++++++++++------ > 1 file changed, 20 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > index 7ca2ebdd3c95..86236cfad38c 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > @@ -227,6 +227,24 @@ static ssize_t amdgpu_device_get_pcie_replay_count(struct device *dev, > static DEVICE_ATTR(pcie_replay_count, 0444, > amdgpu_device_get_pcie_replay_count, NULL); > > +static int amdgpu_device_attr_sysfs_init(struct amdgpu_device *adev) > +{ > + int ret = 0; > + > + if (!amdgpu_sriov_vf(adev)) > + ret = sysfs_create_file(&adev->dev->kobj, > + &dev_attr_pcie_replay_count.attr); > + > + return ret; > +} > + > +static void amdgpu_device_attr_sysfs_fini(struct amdgpu_device *adev) > +{ > + if (!amdgpu_sriov_vf(adev)) > + sysfs_remove_file(&adev->dev->kobj, > + &dev_attr_pcie_replay_count.attr); > +} > + > static ssize_t amdgpu_sysfs_reg_state_get(struct file *f, struct kobject *kobj, > struct bin_attribute *attr, char *buf, > loff_t ppos, size_t count) > @@ -4166,11 +4184,6 @@ static bool amdgpu_device_check_iommu_remap(struct amdgpu_device *adev) > } > #endif > > -static const struct attribute *amdgpu_dev_attributes[] = { > - &dev_attr_pcie_replay_count.attr, > - NULL > -}; > - > static void amdgpu_device_set_mcbp(struct amdgpu_device *adev) > { > if (amdgpu_mcbp == 1) > @@ -4609,7 +4622,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, > } else > adev->ucode_sysfs_en = true; > > - r = sysfs_create_files(&adev->dev->kobj, amdgpu_dev_attributes); > + r = amdgpu_device_attr_sysfs_init(adev); > if (r) > dev_err(adev->dev, "Could not create amdgpu device attr\n"); > > @@ -4746,7 +4759,7 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev) > amdgpu_pm_sysfs_fini(adev); > if (adev->ucode_sysfs_en) > amdgpu_ucode_sysfs_fini(adev); > - sysfs_remove_files(&adev->dev->kobj, amdgpu_dev_attributes); > + amdgpu_device_attr_sysfs_fini(adev); > amdgpu_fru_sysfs_fini(adev); > > amdgpu_reg_state_sysfs_fini(adev);