On 11/4/2024 7:19 PM, Asad Kamal wrote: > Add sysfs node to show supported NPS mode > Better to add more description here to say "supported NPS modes for the partition configuration selected using xcp_cfg" > Signed-off-by: Asad Kamal <asad.kamal@xxxxxxx> Reviewed-by: Lijo Lazar <lijo.lazar@xxxxxxx> Thanks, Lijo > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 34 +++++++++++++++++++++++++ > 1 file changed, 34 insertions(+) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c > index 83a16918ea76..5e1673b1a30c 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c > @@ -471,6 +471,16 @@ static const char *xcp_desc[] = { > [AMDGPU_CPX_PARTITION_MODE] = "CPX", > }; > > +static const char *nps_desc[] = { > + [UNKNOWN_MEMORY_PARTITION_MODE] = "UNKNOWN", > + [AMDGPU_NPS1_PARTITION_MODE] = "NPS1", > + [AMDGPU_NPS2_PARTITION_MODE] = "NPS2", > + [AMDGPU_NPS3_PARTITION_MODE] = "NPS3", > + [AMDGPU_NPS4_PARTITION_MODE] = "NPS4", > + [AMDGPU_NPS6_PARTITION_MODE] = "NPS6", > + [AMDGPU_NPS8_PARTITION_MODE] = "NPS8", > +}; > + > ATTRIBUTE_GROUPS(xcp_cfg_res_sysfs); > > #define to_xcp_attr(x) \ > @@ -540,6 +550,26 @@ static ssize_t supported_xcp_configs_show(struct kobject *kobj, > return size; > } > > +static ssize_t supported_nps_configs_show(struct kobject *kobj, > + struct kobj_attribute *attr, char *buf) > +{ > + struct amdgpu_xcp_cfg *xcp_cfg = to_xcp_cfg(kobj); > + int size = 0, mode; > + char *sep = ""; > + > + if (!xcp_cfg || !xcp_cfg->compatible_nps_modes) > + return sysfs_emit(buf, "Not supported\n"); > + > + for_each_inst(mode, xcp_cfg->compatible_nps_modes) { > + size += sysfs_emit_at(buf, size, "%s%s", sep, nps_desc[mode]); > + sep = ", "; > + } > + > + size += sysfs_emit_at(buf, size, "\n"); > + > + return size; > +} > + > static ssize_t xcp_config_show(struct kobject *kobj, > struct kobj_attribute *attr, char *buf) > { > @@ -596,9 +626,13 @@ static const struct kobj_type xcp_cfg_sysfs_ktype = { > static struct kobj_attribute supp_part_sysfs_mode = > __ATTR_RO(supported_xcp_configs); > > +static struct kobj_attribute supp_nps_sysfs_mode = > + __ATTR_RO(supported_nps_configs); > + > static const struct attribute *xcp_attrs[] = { > &supp_part_sysfs_mode.attr, > &xcp_cfg_sysfs_mode.attr, > + &supp_nps_sysfs_mode.attr, > NULL, > }; >