[Intel-xe] [PATCH V2 1/6] drm/xe: Add sysfs entries for engines under its GT

Upadhyay, Tejas tejas.upadhyay at intel.com
Wed Jun 28 11:16:25 UTC 2023



> -----Original Message-----
> From: Ghimiray, Himal Prasad <himal.prasad.ghimiray at intel.com>
> Sent: Wednesday, June 28, 2023 12:28 PM
> To: Upadhyay, Tejas <tejas.upadhyay at intel.com>; intel-
> xe at lists.freedesktop.org
> Subject: RE: [Intel-xe] [PATCH V2 1/6] drm/xe: Add sysfs entries for engines
> under its GT
> 
> 
> 
> > -----Original Message-----
> > From: Intel-xe <intel-xe-bounces at lists.freedesktop.org> On Behalf Of
> > Tejas Upadhyay
> > Sent: 26 June 2023 15:47
> > To: intel-xe at lists.freedesktop.org
> > Subject: [Intel-xe] [PATCH V2 1/6] drm/xe: Add sysfs entries for
> > engines under its GT
> >
> > Add engines sysfs directory under its GT and create sub directory for
> > all engine class (note its not per instance) present on GT.
> >
> > For example,
> > DUT# cat /sys/class/drm/cardX/device/gtN/engines/
> There is series https://patchwork.freedesktop.org/series/118927/ which
> brings in gt* under tile*.
> Please address the sysfs path accordingly.
> 
> And better to have directory name as engine_classes  instead of engines/
> wherever applicable.

Till series is merged need to address based on gt dir only. As we don't know which patch will get merge first. 

Thanks,
Tejas
> 
> > bcs/ ccs/
> >
> > Signed-off-by: Tejas Upadhyay <tejas.upadhyay at intel.com>
> > ---
> >  drivers/gpu/drm/xe/xe_gt.c       |  6 +++
> >  drivers/gpu/drm/xe/xe_gt_sysfs.c | 92
> > ++++++++++++++++++++++++++++++++  drivers/gpu/drm/xe/xe_gt_sysfs.h
> |
> > 3 ++
> >  3 files changed, 101 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
> > index 2458397ce8af..19c7964a064f 100644
> > --- a/drivers/gpu/drm/xe/xe_gt.c
> > +++ b/drivers/gpu/drm/xe/xe_gt.c
> > @@ -319,6 +319,12 @@ static int gt_fw_domain_init(struct xe_gt *gt)
> >  	if (err)
> >  		goto err_force_wake;
> >
> > +	err = xe_gt_sysfs_engines(gt);
> > +	if (err)
> > +		drm_warn(&gt_to_xe(gt)->drm,
> > +			 "failed to register engines sysfs directory, err: %d\n",
> > +			 err);
> > +
> >  	err = xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
> >  	XE_WARN_ON(err);
> >  	xe_device_mem_access_put(gt_to_xe(gt));
> > diff --git a/drivers/gpu/drm/xe/xe_gt_sysfs.c
> > b/drivers/gpu/drm/xe/xe_gt_sysfs.c
> > index c01cc689058c..7528cc723699 100644
> > --- a/drivers/gpu/drm/xe/xe_gt_sysfs.c
> > +++ b/drivers/gpu/drm/xe/xe_gt_sysfs.c
> > @@ -22,6 +22,98 @@ static struct kobj_type xe_gt_sysfs_kobj_type = {
> >  	.sysfs_ops = &kobj_sysfs_ops,
> >  };
> >
> > +static void kobj_xe_engine_release(struct kobject *kobj) {
> > +	kfree(kobj);
> > +}
> > +
> > +static struct kobj_type kobj_xe_engine_type = {
> > +	.release = kobj_xe_engine_release,
> > +	.sysfs_ops = &kobj_sysfs_ops
> > +};
> Make kobj_type struct const.
> > +
> > +static struct kobject *
> > +kobj_xe_engine(struct kobject *parent, char *name) {
> Instead of engine/engine_class seems appropriate.
> > +	struct kobject *kobj;
> > +
> > +	kobj = kzalloc(sizeof(*kobj), GFP_KERNEL);
> > +	if (!kobj)
> > +		return NULL;
> > +
> > +	kobject_init(kobj, &kobj_xe_engine_type);
> > +	if (kobject_add(kobj, parent, "%s", name)) {
> > +		kobject_put(kobj);
> > +		return NULL;
> > +	}
> > +
> > +	return kobj;
> > +}
> > +
> > +int xe_gt_sysfs_engines(struct xe_gt *gt) {
> > +	struct xe_hw_engine *hwe;
> > +	enum xe_hw_engine_id id;
> > +	struct kobject *kobj;
> > +	u16 class_mask = 0;
> > +	int err = 0;
> > +
> > +	kobj = kzalloc(sizeof(*kobj), GFP_KERNEL);
> > +	if (!kobj)
> > +		return -ENOMEM;
> > +
> > +	kobject_init(kobj, &xe_gt_sysfs_kobj_type);
> > +
> > +	err = kobject_add(kobj, gt->sysfs, "engines");
> > +	if (err) {
> > +		kobject_put(kobj);
> > +		return err;
> > +	}
> > +
> > +	for_each_hw_engine(hwe, gt, id) {
> > +		char name[MAX_ENGINE_NAME_LEN];
> > +		struct kobject *khwe;
> > +
> > +		if ((hwe->class == XE_ENGINE_CLASS_OTHER) ||
> > +		    (hwe->class == XE_ENGINE_CLASS_MAX))
> > +			continue;
> > +
> > +		if ((class_mask & hwe->class) == hwe->class)
> > +			continue;
> > +
> > +		class_mask |= hwe->class;
> Seems error prone. Once   XE_ENGINE_CLASS_COPY is handled class_mask
> will be 3
> and for  XE_ENGINE_CLASS_VIDEO_DECODE  and
> XE_ENGINE_CLASS_VIDEO_ENHANCE if ((class_mask & hwe->class) == hwe-
> >class)
> 		continue;
> will skip sysfs creation.
> > +
> > +		switch (hwe->class) {
> > +		case XE_ENGINE_CLASS_RENDER:
> > +			strcpy(name, "rcs");
> > +			break;
> > +		case XE_ENGINE_CLASS_VIDEO_DECODE:
> > +			strcpy(name, "vcs");
> > +			break;
> > +		case XE_ENGINE_CLASS_VIDEO_ENHANCE:
> > +			strcpy(name, "vecs");
> > +			break;
> > +		case XE_ENGINE_CLASS_COPY:
> > +			strcpy(name, "bcs");
> > +			break;
> > +		case XE_ENGINE_CLASS_COMPUTE:
> > +			strcpy(name, "ccs");
> > +			break;
> > +		default:
> > +			kobject_put(kobj);
> > +			return -EINVAL;
> > +		}
> > +
> > +		khwe = kobj_xe_engine(kobj, name);
> > +		if (!khwe) {
> > +			kobject_put(kobj);
> > +			return -EINVAL;
> > +		}
> > +	}
> > +
> > +	return err;
> > +}
> > +
> >  static void gt_sysfs_fini(struct drm_device *drm, void *arg)  {
> >  	struct xe_gt *gt = arg;
> > diff --git a/drivers/gpu/drm/xe/xe_gt_sysfs.h
> > b/drivers/gpu/drm/xe/xe_gt_sysfs.h
> > index ecbfcc5c7d42..a531aebd10d6 100644
> > --- a/drivers/gpu/drm/xe/xe_gt_sysfs.h
> > +++ b/drivers/gpu/drm/xe/xe_gt_sysfs.h
> > @@ -8,7 +8,10 @@
> >
> >  #include "xe_gt_sysfs_types.h"
> >
> > +#define MAX_ENGINE_NAME_LEN	16
> > +
> >  int xe_gt_sysfs_init(struct xe_gt *gt);
> > +int xe_gt_sysfs_engines(struct xe_gt *gt);
> >
> >  static inline struct xe_gt *
> >  kobj_to_gt(struct kobject *kobj)
> > --
> > 2.25.1



More information about the Intel-xe mailing list