diff mbox series

[v4,7/8] drm/xe: Add helper to return any available hw engine

Message ID 20240515214258.59209-8-lucas.demarchi@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/xe: Per client usage | expand

Commit Message

Lucas De Marchi May 15, 2024, 9:42 p.m. UTC
Get the first available engine from a gt, which helps in the case any
engine serves as a context, like when reading RING_TIMESTAMP.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_gt.c | 11 +++++++++++
 drivers/gpu/drm/xe/xe_gt.h |  7 +++++++
 2 files changed, 18 insertions(+)

Comments

Umesh Nerlige Ramappa May 16, 2024, 6:55 p.m. UTC | #1
On Wed, May 15, 2024 at 02:42:57PM -0700, Lucas De Marchi wrote:
>Get the first available engine from a gt, which helps in the case any
>engine serves as a context, like when reading RING_TIMESTAMP.
>
>Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>

Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>

>---
> drivers/gpu/drm/xe/xe_gt.c | 11 +++++++++++
> drivers/gpu/drm/xe/xe_gt.h |  7 +++++++
> 2 files changed, 18 insertions(+)
>
>diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
>index 5194a3d38e76..3432fef56486 100644
>--- a/drivers/gpu/drm/xe/xe_gt.c
>+++ b/drivers/gpu/drm/xe/xe_gt.c
>@@ -833,3 +833,14 @@ struct xe_hw_engine *xe_gt_any_hw_engine_by_reset_domain(struct xe_gt *gt,
>
> 	return NULL;
> }
>+
>+struct xe_hw_engine *xe_gt_any_hw_engine(struct xe_gt *gt)
>+{
>+	struct xe_hw_engine *hwe;
>+	enum xe_hw_engine_id id;
>+
>+	for_each_hw_engine(hwe, gt, id)
>+		return hwe;
>+
>+	return NULL;
>+}
>diff --git a/drivers/gpu/drm/xe/xe_gt.h b/drivers/gpu/drm/xe/xe_gt.h
>index ad3fd31e0a41..a53f01362d94 100644
>--- a/drivers/gpu/drm/xe/xe_gt.h
>+++ b/drivers/gpu/drm/xe/xe_gt.h
>@@ -67,6 +67,13 @@ void xe_gt_remove(struct xe_gt *gt);
> struct xe_hw_engine *
> xe_gt_any_hw_engine_by_reset_domain(struct xe_gt *gt, enum xe_engine_class class);
>
>+/**
>+ * xe_gt_any_hw_engine - scan the list of engines and return the
>+ * first available
>+ * @gt: GT structure
>+ */
>+struct xe_hw_engine *xe_gt_any_hw_engine(struct xe_gt *gt);
>+
> struct xe_hw_engine *xe_gt_hw_engine(struct xe_gt *gt,
> 				     enum xe_engine_class class,
> 				     u16 instance,
>-- 
>2.43.0
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
index 5194a3d38e76..3432fef56486 100644
--- a/drivers/gpu/drm/xe/xe_gt.c
+++ b/drivers/gpu/drm/xe/xe_gt.c
@@ -833,3 +833,14 @@  struct xe_hw_engine *xe_gt_any_hw_engine_by_reset_domain(struct xe_gt *gt,
 
 	return NULL;
 }
+
+struct xe_hw_engine *xe_gt_any_hw_engine(struct xe_gt *gt)
+{
+	struct xe_hw_engine *hwe;
+	enum xe_hw_engine_id id;
+
+	for_each_hw_engine(hwe, gt, id)
+		return hwe;
+
+	return NULL;
+}
diff --git a/drivers/gpu/drm/xe/xe_gt.h b/drivers/gpu/drm/xe/xe_gt.h
index ad3fd31e0a41..a53f01362d94 100644
--- a/drivers/gpu/drm/xe/xe_gt.h
+++ b/drivers/gpu/drm/xe/xe_gt.h
@@ -67,6 +67,13 @@  void xe_gt_remove(struct xe_gt *gt);
 struct xe_hw_engine *
 xe_gt_any_hw_engine_by_reset_domain(struct xe_gt *gt, enum xe_engine_class class);
 
+/**
+ * xe_gt_any_hw_engine - scan the list of engines and return the
+ * first available
+ * @gt: GT structure
+ */
+struct xe_hw_engine *xe_gt_any_hw_engine(struct xe_gt *gt);
+
 struct xe_hw_engine *xe_gt_hw_engine(struct xe_gt *gt,
 				     enum xe_engine_class class,
 				     u16 instance,