drm/amdgpu: Add supported NPS modes node
Subsystems (2)
PATCH 1/1 drm/amdgpu: Add supported NPS modes node
Add sysfs node to show supported NPS mode
Signed-off-by Asad Kamal <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +34 -0
@@ -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 , };
Signature · 1 line
2.46.0
Quoted 2 lines · Asad Kamal
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"
Quoted 1 line
Signed-off-by Asad Kamal <[email protected]>
Reviewed-by Lijo Lazar <[email protected]>
Thanks,
Lijo
Quoted 66 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +34
-0@@ -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 , };