[AMD Official Use Only - General] Reviewed-by: Le Ma <le.ma@xxxxxxx> > -----Original Message----- > From: amd-gfx <amd-gfx-bounces@xxxxxxxxxxxxxxxxxxxxx> On Behalf Of Lijo > Lazar > Sent: Thursday, June 15, 2023 4:56 PM > To: amd-gfx@xxxxxxxxxxxxxxxxxxxxx > Cc: Deucher, Alexander <Alexander.Deucher@xxxxxxx>; Ma, Le > <Le.Ma@xxxxxxx>; Kamal, Asad <Asad.Kamal@xxxxxxx>; Zhang, Hawking > <Hawking.Zhang@xxxxxxx> > Subject: [PATCH] drm/amdgpu: Add vbios attribute only if supported > > Not all devices carry VBIOS version information. Add the device attribute only if > supported. > > Signed-off-by: Lijo Lazar <lijo.lazar@xxxxxxx> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 9 +++++++++ > drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h | 1 + > drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 +++++ > drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 -- > 4 files changed, 15 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c > index 9ba4817a9148..f4e3c133a16c 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c > @@ -1791,6 +1791,15 @@ const struct attribute_group > amdgpu_vbios_version_attr_group = { > .attrs = amdgpu_vbios_version_attrs > }; > > +int amdgpu_atombios_sysfs_init(struct amdgpu_device *adev) { > + if (adev->mode_info.atom_context) > + return devm_device_add_group(adev->dev, > + > &amdgpu_vbios_version_attr_group); > + > + return 0; > +} > + > /** > * amdgpu_atombios_fini - free the driver info and callbacks for atombios > * > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h > b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h > index 4153d520e2a3..b639a80ee3fc 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h > @@ -217,5 +217,6 @@ int amdgpu_atombios_get_data_table(struct > amdgpu_device *adev, > > void amdgpu_atombios_fini(struct amdgpu_device *adev); int > amdgpu_atombios_init(struct amdgpu_device *adev); > +int amdgpu_atombios_sysfs_init(struct amdgpu_device *adev); > > #endif > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > index e25f085ee886..eda0a598722e 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > @@ -4018,6 +4018,11 @@ int amdgpu_device_init(struct amdgpu_device *adev, > /* Get a log2 for easy divisions. */ > adev->mm_stats.log2_max_MBps = ilog2(max(1u, max_MBps)); > > + r = amdgpu_atombios_sysfs_init(adev); > + if (r) > + drm_err(&adev->ddev, > + "registering atombios sysfs failed (%d).\n", r); > + > r = amdgpu_pm_sysfs_init(adev); > if (r) > DRM_ERROR("registering pm sysfs failed (%d).\n", r); diff --git > a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c > index 999d008b6b48..70455b00c36e 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c > @@ -2896,12 +2896,10 @@ static struct pci_error_handlers > amdgpu_pci_err_handler = { > > extern const struct attribute_group amdgpu_vram_mgr_attr_group; extern > const struct attribute_group amdgpu_gtt_mgr_attr_group; -extern const struct > attribute_group amdgpu_vbios_version_attr_group; > > static const struct attribute_group *amdgpu_sysfs_groups[] = { > &amdgpu_vram_mgr_attr_group, > &amdgpu_gtt_mgr_attr_group, > - &amdgpu_vbios_version_attr_group, > NULL, > }; > > -- > 2.25.1