[PATCH i-g-t 1/2] lib/xe/xe_query: xe_find_engine_by_class helper
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Tue Oct 22 13:55:56 UTC 2024
On Mon, Oct 21, 2024 at 02:59:08PM +0200, Kamil Konieczny wrote:
> Hi Pravalika,
> On 2024-10-16 at 15:49:32 +0530, Pravalika Gurram wrote:
> > Added "xe_find_engine_by_class" helper function to query with the required
> > engine class and get the engine info.
> >
> > Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> > Signed-off-by: Pravalika Gurram <pravalika.gurram at intel.com>
> > ---
> > lib/xe/xe_query.c | 20 ++++++++++++++++++++
> > lib/xe/xe_query.h | 1 +
> > 2 files changed, 21 insertions(+)
> >
> > diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
> > index 8694fa3f9..0c9cff066 100644
> > --- a/lib/xe/xe_query.c
> > +++ b/lib/xe/xe_query.c
> > @@ -731,6 +731,26 @@ bool xe_has_engine_class(int fd, uint16_t engine_class)
> > return false;
> > }
> >
> > +/**
> > + * xe_find_engine_by_class
> > + * @fd: xe device fd
> > + * @engine_class: engine class
> > + *
> > + * Returns engine info of xe device @fd and @engine_class otherwise NULL.
> > + */
> > +struct drm_xe_engine *xe_find_engine_by_class(int fd, uint16_t engine_class)
> > +{
> > + struct xe_device *xe_dev;
> > +
> > + xe_dev = find_in_cache(fd);
> > + igt_assert(xe_dev);
>
> imho here just 'if (!xe_dev) return NULL;'
>
> Regards,
> Kamil
Assert is fine here. Sth really wrong will happen if previously there
will be no fd xe_dev data in the cache.
--
Zbigniew
>
> > +
> > + for (int i = 0; i < xe_dev->engines->num_engines; i++)
> > + if (xe_dev->engines->engines[i].instance.engine_class == engine_class)
> > + return &xe_dev->engines->engines[i];
> > +
> > + return NULL;
> > +}
> > /**
> > * xe_has_media_gt:
> > * @fd: xe device fd
> > diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
> > index fd1155f7f..cabb8078c 100644
> > --- a/lib/xe/xe_query.h
> > +++ b/lib/xe/xe_query.h
> > @@ -108,6 +108,7 @@ uint16_t xe_dev_id(int fd);
> > int xe_supports_faults(int fd);
> > const char *xe_engine_class_string(uint32_t engine_class);
> > bool xe_has_engine_class(int fd, uint16_t engine_class);
> > +struct drm_xe_engine *xe_find_engine_by_class(int fd, uint16_t engine_class);
> > bool xe_has_media_gt(int fd);
> > bool xe_is_media_gt(int fd, int gt);
> > uint16_t xe_gt_get_tile_id(int fd, int gt);
> > --
> > 2.34.1
> >
More information about the igt-dev
mailing list