From: "Ghimiray, Himal Prasad" <himal.prasad.ghimiray@intel.com>
To: Tejas Upadhyay <tejas.upadhyay@intel.com>,
<intel-xe@lists.freedesktop.org>
Cc: <rodrigo.vivi@intel.com>
Subject: Re: [PATCH V2] drm/xe/hw_engine: define sysfs_ops on all directories
Date: Fri, 28 Mar 2025 10:56:44 +0530 [thread overview]
Message-ID: <f57a62cc-dee0-4935-87c6-aebbdbc2d3d8@intel.com> (raw)
In-Reply-To: <20250327122647.886637-1-tejas.upadhyay@intel.com>
On 27-03-2025 17:56, Tejas Upadhyay wrote:
> Sysfs_ops needs to be defined on all directories which
> can have attr files with set/get method. Add sysfs_ops
> to even those directories which is currently empty but
> would have attr files with set/get method in future.
> Leave .default with default sysfs_ops as it will never
> have setter method.
>
> V2(Himal/Rodrigo):
> - use single sysfs_ops for all dir and attr with set/get
> - add default ops as ./default does not need runtime pm at all
>
> Fixes: 3f0e14651ab0 ("drm/xe: Runtime PM wake on every sysfs call")
> Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
LGTM
Reviewed-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> ---
> drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c | 108 +++++++++---------
> 1 file changed, 52 insertions(+), 56 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c b/drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c
> index e238c0e9fdd0..640950172088 100644
> --- a/drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c
> +++ b/drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c
> @@ -32,14 +32,61 @@ bool xe_hw_engine_timeout_in_range(u64 timeout, u64 min, u64 max)
> return timeout >= min && timeout <= max;
> }
>
> -static void kobj_xe_hw_engine_release(struct kobject *kobj)
> +static void xe_hw_engine_sysfs_kobj_release(struct kobject *kobj)
> {
> kfree(kobj);
> }
>
> +static ssize_t xe_hw_engine_class_sysfs_attr_show(struct kobject *kobj,
> + struct attribute *attr,
> + char *buf)
> +{
> + struct xe_device *xe = kobj_to_xe(kobj);
> + struct kobj_attribute *kattr;
> + ssize_t ret = -EIO;
> +
> + kattr = container_of(attr, struct kobj_attribute, attr);
> + if (kattr->show) {
> + xe_pm_runtime_get(xe);
> + ret = kattr->show(kobj, kattr, buf);
> + xe_pm_runtime_put(xe);
> + }
> +
> + return ret;
> +}
> +
> +static ssize_t xe_hw_engine_class_sysfs_attr_store(struct kobject *kobj,
> + struct attribute *attr,
> + const char *buf,
> + size_t count)
> +{
> + struct xe_device *xe = kobj_to_xe(kobj);
> + struct kobj_attribute *kattr;
> + ssize_t ret = -EIO;
> +
> + kattr = container_of(attr, struct kobj_attribute, attr);
> + if (kattr->store) {
> + xe_pm_runtime_get(xe);
> + ret = kattr->store(kobj, kattr, buf, count);
> + xe_pm_runtime_put(xe);
> + }
> +
> + return ret;
> +}
> +
> +static const struct sysfs_ops xe_hw_engine_class_sysfs_ops = {
> + .show = xe_hw_engine_class_sysfs_attr_show,
> + .store = xe_hw_engine_class_sysfs_attr_store,
> +};
> +
> static const struct kobj_type kobj_xe_hw_engine_type = {
> - .release = kobj_xe_hw_engine_release,
> - .sysfs_ops = &kobj_sysfs_ops
> + .release = xe_hw_engine_sysfs_kobj_release,
> + .sysfs_ops = &xe_hw_engine_class_sysfs_ops,
> +};
> +
> +static const struct kobj_type kobj_xe_hw_engine_type_def = {
> + .release = xe_hw_engine_sysfs_kobj_release,
> + .sysfs_ops = &kobj_sysfs_ops,
> };
>
> static ssize_t job_timeout_max_store(struct kobject *kobj,
> @@ -543,7 +590,7 @@ static int xe_add_hw_engine_class_defaults(struct xe_device *xe,
> if (!kobj)
> return -ENOMEM;
>
> - kobject_init(kobj, &kobj_xe_hw_engine_type);
> + kobject_init(kobj, &kobj_xe_hw_engine_type_def);
> err = kobject_add(kobj, parent, "%s", ".defaults");
> if (err)
> goto err_object;
> @@ -560,57 +607,6 @@ static int xe_add_hw_engine_class_defaults(struct xe_device *xe,
> }
> ALLOW_ERROR_INJECTION(xe_add_hw_engine_class_defaults, ERRNO); /* See xe_pci_probe() */
>
> -static void xe_hw_engine_sysfs_kobj_release(struct kobject *kobj)
> -{
> - kfree(kobj);
> -}
> -
> -static ssize_t xe_hw_engine_class_sysfs_attr_show(struct kobject *kobj,
> - struct attribute *attr,
> - char *buf)
> -{
> - struct xe_device *xe = kobj_to_xe(kobj);
> - struct kobj_attribute *kattr;
> - ssize_t ret = -EIO;
> -
> - kattr = container_of(attr, struct kobj_attribute, attr);
> - if (kattr->show) {
> - xe_pm_runtime_get(xe);
> - ret = kattr->show(kobj, kattr, buf);
> - xe_pm_runtime_put(xe);
> - }
> -
> - return ret;
> -}
> -
> -static ssize_t xe_hw_engine_class_sysfs_attr_store(struct kobject *kobj,
> - struct attribute *attr,
> - const char *buf,
> - size_t count)
> -{
> - struct xe_device *xe = kobj_to_xe(kobj);
> - struct kobj_attribute *kattr;
> - ssize_t ret = -EIO;
> -
> - kattr = container_of(attr, struct kobj_attribute, attr);
> - if (kattr->store) {
> - xe_pm_runtime_get(xe);
> - ret = kattr->store(kobj, kattr, buf, count);
> - xe_pm_runtime_put(xe);
> - }
> -
> - return ret;
> -}
> -
> -static const struct sysfs_ops xe_hw_engine_class_sysfs_ops = {
> - .show = xe_hw_engine_class_sysfs_attr_show,
> - .store = xe_hw_engine_class_sysfs_attr_store,
> -};
> -
> -static const struct kobj_type xe_hw_engine_sysfs_kobj_type = {
> - .release = xe_hw_engine_sysfs_kobj_release,
> - .sysfs_ops = &xe_hw_engine_class_sysfs_ops,
> -};
>
> static void hw_engine_class_sysfs_fini(void *arg)
> {
> @@ -641,7 +637,7 @@ int xe_hw_engine_class_sysfs_init(struct xe_gt *gt)
> if (!kobj)
> return -ENOMEM;
>
> - kobject_init(kobj, &xe_hw_engine_sysfs_kobj_type);
> + kobject_init(kobj, &kobj_xe_hw_engine_type);
>
> err = kobject_add(kobj, gt->sysfs, "engines");
> if (err)
prev parent reply other threads:[~2025-03-28 5:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-27 12:26 [PATCH V2] drm/xe/hw_engine: define sysfs_ops on all directories Tejas Upadhyay
2025-03-27 12:29 ` ✓ CI.Patch_applied: success for " Patchwork
2025-03-27 12:29 ` ✓ CI.checkpatch: " Patchwork
2025-03-27 12:31 ` ✓ CI.KUnit: " Patchwork
2025-03-27 12:47 ` ✓ CI.Build: " Patchwork
2025-03-27 12:49 ` ✓ CI.Hooks: " Patchwork
2025-03-27 12:51 ` ✓ CI.checksparse: " Patchwork
2025-03-27 13:13 ` ✓ Xe.CI.BAT: " Patchwork
2025-03-27 20:38 ` ✗ Xe.CI.Full: failure " Patchwork
2025-03-28 5:26 ` Ghimiray, Himal Prasad [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=f57a62cc-dee0-4935-87c6-aebbdbc2d3d8@intel.com \
--to=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=rodrigo.vivi@intel.com \
--cc=tejas.upadhyay@intel.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