From: "Lazar, Lijo" <lijo.lazar@amd.com>
To: Asad Kamal <asad.kamal@amd.com>, amd-gfx@lists.freedesktop.org
Cc: le.ma@amd.com, hawking.zhang@amd.com, shiwu.zhang@amd.com,
charis.poag@amd.com, donald.cheung@amd.com,
sepehr.khatir@amd.com, daniel.oliveira@amd.com
Subject: Re: [PATCH v2 4/4] drm/amdgpu: Add supported partition mode node
Date: Tue, 24 Sep 2024 20:51:02 +0530 [thread overview]
Message-ID: <e08026e6-efe5-4cef-a5bb-fefe9b92acaa@amd.com> (raw)
In-Reply-To: <20240924141549.244754-4-asad.kamal@amd.com>
On 9/24/2024 7:45 PM, Asad Kamal wrote:
> Add sysfs node to show supoorted partition modes across all NPS modes
>
> Signed-off-by: Asad Kamal <asad.kamal@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 48 +++++++++++++++++++++++--
> 1 file changed, 45 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
> index fc4ab1d8c7c9..10daa6a15e5e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
> @@ -463,6 +463,14 @@ static struct attribute *xcp_cfg_res_sysfs_attrs[] = {
> &XCP_CFG_SYSFS_RES_ATTR_PTR(num_shared), NULL
> };
>
> +static const char *xcp_desc[] = {
> + [AMDGPU_SPX_PARTITION_MODE] = "SPX",
> + [AMDGPU_DPX_PARTITION_MODE] = "DPX",
> + [AMDGPU_TPX_PARTITION_MODE] = "TPX",
> + [AMDGPU_QPX_PARTITION_MODE] = "QPX",
> + [AMDGPU_CPX_PARTITION_MODE] = "CPX",
> +};
> +
> ATTRIBUTE_GROUPS(xcp_cfg_res_sysfs);
>
> #define to_xcp_attr(x) \
> @@ -511,6 +519,27 @@ static int amdgpu_xcp_get_res_info(struct amdgpu_xcp_mgr *xcp_mgr,
> }
>
> #define to_xcp_cfg(x) container_of(x, struct amdgpu_xcp_cfg, kobj)
> +static ssize_t supported_xcp_configs_show(struct kobject *kobj,
> + struct kobj_attribute *attr, char *buf)
> +{
> + struct amdgpu_xcp_cfg *xcp_cfg = to_xcp_cfg(kobj);
> + struct amdgpu_xcp_mgr *xcp_mgr = xcp_cfg->xcp_mgr;
> + int size = 0, mode;
> + char *sep = "";
> +
> + if (!xcp_mgr || !xcp_mgr->supp_xcp_modes)
> + return sysfs_emit(buf, "Not supported\n");
> +
> + for_each_inst(mode, xcp_mgr->supp_xcp_modes) {
> + size += sysfs_emit_at(buf, size, "%s%s", sep, xcp_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)
> {
> @@ -564,6 +593,19 @@ static const struct kobj_type xcp_cfg_sysfs_ktype = {
> .sysfs_ops = &kobj_sysfs_ops,
> };
>
> +static struct kobj_attribute supp_part_sysfs_mode =
> + __ATTR_RO(supported_xcp_configs);
> +
> +static const struct kobj_type supp_part_sysfs_ktype = {
> + .sysfs_ops = &kobj_sysfs_ops,
> +};
> +
I think this is not required. Other than that, this looks good.
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Thanks,
Lijo
> +static const struct attribute *xcp_attrs[] = {
> + &supp_part_sysfs_mode.attr,
> + &xcp_cfg_sysfs_mode.attr,
> + NULL,
> +};
> +
> void amdgpu_xcp_cfg_sysfs_init(struct amdgpu_device *adev)
> {
> struct amdgpu_xcp_res_details *xcp_res;
> @@ -583,7 +625,7 @@ void amdgpu_xcp_cfg_sysfs_init(struct amdgpu_device *adev)
> if (r)
> goto err1;
>
> - r = sysfs_create_file(&xcp_cfg->kobj, &xcp_cfg_sysfs_mode.attr);
> + r = sysfs_create_files(&xcp_cfg->kobj, xcp_attrs);
> if (r)
> goto err1;
>
> @@ -611,7 +653,7 @@ void amdgpu_xcp_cfg_sysfs_init(struct amdgpu_device *adev)
> kobject_put(&xcp_res->kobj);
> }
>
> - sysfs_remove_file(&xcp_cfg->kobj, &xcp_cfg_sysfs_mode.attr);
> + sysfs_remove_files(&xcp_cfg->kobj, xcp_attrs);
> err1:
> kobject_put(&xcp_cfg->kobj);
> }
> @@ -631,6 +673,6 @@ void amdgpu_xcp_cfg_sysfs_fini(struct amdgpu_device *adev)
> kobject_put(&xcp_res->kobj);
> }
>
> - sysfs_remove_file(&xcp_cfg->kobj, &xcp_cfg_sysfs_mode.attr);
> + sysfs_remove_files(&xcp_cfg->kobj, xcp_attrs);
> kobject_put(&xcp_cfg->kobj);
> }
prev parent reply other threads:[~2024-09-24 15:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-24 14:15 [PATCH v2 1/4] drm/amd: Add helper to get partition config modes Asad Kamal
2024-09-24 14:15 ` [PATCH v2 2/4] drm/amdgpu: Add callback get xcp resource info Asad Kamal
2024-09-24 14:15 ` [PATCH v2 3/4] drm/amdgpu: Add sysfs nodes to get xcp details Asad Kamal
2024-09-24 14:15 ` [PATCH v2 4/4] drm/amdgpu: Add supported partition mode node Asad Kamal
2024-09-24 15:15 ` Zhang, Hawking
2024-09-24 15:21 ` Lazar, Lijo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e08026e6-efe5-4cef-a5bb-fefe9b92acaa@amd.com \
--to=lijo.lazar@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=asad.kamal@amd.com \
--cc=charis.poag@amd.com \
--cc=daniel.oliveira@amd.com \
--cc=donald.cheung@amd.com \
--cc=hawking.zhang@amd.com \
--cc=le.ma@amd.com \
--cc=sepehr.khatir@amd.com \
--cc=shiwu.zhang@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox