drm/xe/hw_engine: define sysfs_ops on all directories
[ Upstream commit a5c71fd5b69b9da77e5e0b268e69e256932ba49c ]
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: 3f0e14651a ("drm/xe: Runtime PM wake on every sysfs call")
Reviewed-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250327122647.886637-1-tejas.upadhyay@intel.com
Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
(cherry picked from commit 40780b9760b561e093508d07b8b9b06c94ab201e)
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
857e9432da
commit
9e0bdc1557
@@ -32,14 +32,61 @@ bool xe_hw_engine_timeout_in_range(u64 timeout, u64 min, u64 max)
|
|||||||
return timeout >= min && timeout <= 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);
|
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 = {
|
static const struct kobj_type kobj_xe_hw_engine_type = {
|
||||||
.release = kobj_xe_hw_engine_release,
|
.release = xe_hw_engine_sysfs_kobj_release,
|
||||||
.sysfs_ops = &kobj_sysfs_ops
|
.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,
|
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)
|
if (!kobj)
|
||||||
return -ENOMEM;
|
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");
|
err = kobject_add(kobj, parent, "%s", ".defaults");
|
||||||
if (err)
|
if (err)
|
||||||
goto err_object;
|
goto err_object;
|
||||||
@@ -559,57 +606,6 @@ err_object:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
static void hw_engine_class_sysfs_fini(void *arg)
|
||||||
{
|
{
|
||||||
@@ -640,7 +636,7 @@ int xe_hw_engine_class_sysfs_init(struct xe_gt *gt)
|
|||||||
if (!kobj)
|
if (!kobj)
|
||||||
return -ENOMEM;
|
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");
|
err = kobject_add(kobj, gt->sysfs, "engines");
|
||||||
if (err)
|
if (err)
|
||||||
|
|||||||
Reference in New Issue
Block a user