From: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
To: Riana Tauro <riana.tauro@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <anshuman.gupta@intel.com>,
<rodrigo.vivi@intel.com>, <vinay.belgaumkar@intel.com>,
<aravind.iddamsetty@intel.com>, <john.c.harrison@intel.com>,
<ashutosh.dixit@intel.com>, <soham.purkait@intel.com>
Subject: Re: [PATCH v2 4/8] drm/xe: add function to convert xe hw engine class to user class
Date: Tue, 10 Dec 2024 15:48:28 -0800 [thread overview]
Message-ID: <Z1jTTEkbCJYNJy1L@orsosgc001> (raw)
In-Reply-To: <20241121063904.3033754-5-riana.tauro@intel.com>
On Thu, Nov 21, 2024 at 12:09:00PM +0530, Riana Tauro wrote:
>Avoid duplication of code in PMU by moving hw engine to user class
>to a separate function. Refactor existing code to use
>this new function.
>
>v2: replace with array (Umesh)
> fix commit message (Rodrigo)
>
>Signed-off-by: Riana Tauro <riana.tauro@intel.com>
>---
> drivers/gpu/drm/xe/xe_hw_engine.c | 21 +++++++++++++++++++++
> drivers/gpu/drm/xe/xe_hw_engine.h | 1 +
> drivers/gpu/drm/xe/xe_query.c | 12 ++----------
> 3 files changed, 24 insertions(+), 10 deletions(-)
>
>diff --git a/drivers/gpu/drm/xe/xe_hw_engine.c b/drivers/gpu/drm/xe/xe_hw_engine.c
>index c4b0dc3be39c..c41b4038dbb3 100644
>--- a/drivers/gpu/drm/xe/xe_hw_engine.c
>+++ b/drivers/gpu/drm/xe/xe_hw_engine.c
>@@ -979,6 +979,27 @@ const char *xe_hw_engine_class_to_str(enum xe_engine_class class)
> return NULL;
> }
>
>+/**
>+ * xe_hw_engine_to_user_class - converts xe hw engine to user engine class
>+ * @engine_class: hw engine class
>+ *
>+ * Returns: user engine class on success, -1 on error
1) Depends on what you want to return on error since you return u16. If
the WARN_ON fires below, you may just want to return a default like:
DRM_XE_ENGINE_CLASS_RENDER or 0 and change the comment above
accordingly.
2) Returning -1 means use an int return type and make sure all callers
check for the return and act accordingly.
I would recommend 1.
>+ */
>+u16 xe_hw_engine_to_user_class(enum xe_engine_class engine_class)
since now this is a xe_hw_engine api, pass the hwe to this function
instead of the engine_class.
>+{
>+ const u16 xe_to_user_engine_class[] = {
>+ [XE_ENGINE_CLASS_RENDER] = DRM_XE_ENGINE_CLASS_RENDER,
>+ [XE_ENGINE_CLASS_COPY] = DRM_XE_ENGINE_CLASS_COPY,
>+ [XE_ENGINE_CLASS_VIDEO_DECODE] = DRM_XE_ENGINE_CLASS_VIDEO_DECODE,
>+ [XE_ENGINE_CLASS_VIDEO_ENHANCE] = DRM_XE_ENGINE_CLASS_VIDEO_ENHANCE,
>+ [XE_ENGINE_CLASS_COMPUTE] = DRM_XE_ENGINE_CLASS_COMPUTE,
>+ };
>+
>+ WARN_ON(engine_class >= ARRAY_SIZE(xe_to_user_engine_class));
Revisiting this, it should not index into the array if the engine_class
is invalid.
if(WARN_ON(engine_class >= ARRAY_SIZE(xe_to_user_engine_class)))
return <something>;
Thanks,
Umesh
>+
>+ return xe_to_user_engine_class[engine_class];
>+}
>+
> u64 xe_hw_engine_read_timestamp(struct xe_hw_engine *hwe)
> {
> return xe_mmio_read64_2x32(&hwe->gt->mmio, RING_TIMESTAMP(hwe->mmio_base));
>diff --git a/drivers/gpu/drm/xe/xe_hw_engine.h b/drivers/gpu/drm/xe/xe_hw_engine.h
>index 6b5f9fa2a594..06b39cb1a434 100644
>--- a/drivers/gpu/drm/xe/xe_hw_engine.h
>+++ b/drivers/gpu/drm/xe/xe_hw_engine.h
>@@ -74,6 +74,7 @@ static inline bool xe_hw_engine_is_valid(struct xe_hw_engine *hwe)
>
> const char *xe_hw_engine_class_to_str(enum xe_engine_class class);
> u64 xe_hw_engine_read_timestamp(struct xe_hw_engine *hwe);
>+u16 xe_hw_engine_to_user_class(enum xe_engine_class engine_class);
> enum xe_force_wake_domains xe_hw_engine_to_fw_domain(struct xe_hw_engine *hwe);
>
> void xe_hw_engine_mmio_write32(struct xe_hw_engine *hwe, struct xe_reg reg, u32 val);
>diff --git a/drivers/gpu/drm/xe/xe_query.c b/drivers/gpu/drm/xe/xe_query.c
>index 3eda616f1502..a260c43f13f4 100644
>--- a/drivers/gpu/drm/xe/xe_query.c
>+++ b/drivers/gpu/drm/xe/xe_query.c
>@@ -27,14 +27,6 @@
> #include "xe_ttm_vram_mgr.h"
> #include "xe_wa.h"
>
>-static const u16 xe_to_user_engine_class[] = {
>- [XE_ENGINE_CLASS_RENDER] = DRM_XE_ENGINE_CLASS_RENDER,
>- [XE_ENGINE_CLASS_COPY] = DRM_XE_ENGINE_CLASS_COPY,
>- [XE_ENGINE_CLASS_VIDEO_DECODE] = DRM_XE_ENGINE_CLASS_VIDEO_DECODE,
>- [XE_ENGINE_CLASS_VIDEO_ENHANCE] = DRM_XE_ENGINE_CLASS_VIDEO_ENHANCE,
>- [XE_ENGINE_CLASS_COMPUTE] = DRM_XE_ENGINE_CLASS_COMPUTE,
>-};
>-
> static const enum xe_engine_class user_to_xe_engine_class[] = {
> [DRM_XE_ENGINE_CLASS_RENDER] = XE_ENGINE_CLASS_RENDER,
> [DRM_XE_ENGINE_CLASS_COPY] = XE_ENGINE_CLASS_COPY,
>@@ -207,7 +199,7 @@ static int query_engines(struct xe_device *xe,
> continue;
>
> engines->engines[i].instance.engine_class =
>- xe_to_user_engine_class[hwe->class];
>+ xe_hw_engine_to_user_class(hwe->class);
> engines->engines[i].instance.engine_instance =
> hwe->logical_instance;
> engines->engines[i].instance.gt_id = gt->info.id;
>@@ -678,7 +670,7 @@ static int query_oa_units(struct xe_device *xe,
> if (!xe_hw_engine_is_reserved(hwe) &&
> xe_oa_unit_id(hwe) == u->oa_unit_id) {
> du->eci[j].engine_class =
>- xe_to_user_engine_class[hwe->class];
>+ xe_hw_engine_to_user_class(hwe->class);
> du->eci[j].engine_instance = hwe->logical_instance;
> du->eci[j].gt_id = gt->info.id;
> j++;
>--
>2.40.0
>
next prev parent reply other threads:[~2024-12-10 23:49 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-21 6:38 [PATCH v2 0/8] Add PMU support for single engine busyness Riana Tauro
2024-11-21 6:33 ` ✓ CI.Patch_applied: success for Add PMU support for single engine busyness (rev2) Patchwork
2024-11-21 6:34 ` ✗ CI.checkpatch: warning " Patchwork
2024-11-21 6:35 ` ✓ CI.KUnit: success " Patchwork
2024-11-21 6:38 ` [PATCH v2 1/8] [DO NOT REVIEW] drm/xe/pmu: Enable PMU interface Riana Tauro
2024-11-21 6:38 ` [PATCH v2 2/8] [DO NOT REVIEW] drm/xe/pmu: Add GT C6 events Riana Tauro
2024-11-21 6:38 ` [PATCH v2 3/8] [DO NOT REVIEW] drm/xe/pmu: Add GT frequency events Riana Tauro
2024-11-21 6:39 ` [PATCH v2 4/8] drm/xe: add function to convert xe hw engine class to user class Riana Tauro
2024-12-10 23:48 ` Umesh Nerlige Ramappa [this message]
2024-12-18 7:33 ` Riana Tauro
2024-12-19 0:13 ` Umesh Nerlige Ramappa
2024-11-21 6:39 ` [PATCH v2 5/8] drm/xe: Add single engine busyness support Riana Tauro
2024-12-12 23:56 ` Umesh Nerlige Ramappa
2024-12-13 0:52 ` Lucas De Marchi
2024-12-13 7:06 ` Riana Tauro
2024-12-13 14:15 ` Lucas De Marchi
2024-12-13 6:22 ` Riana Tauro
2024-11-21 6:39 ` [PATCH v2 6/8] drm/xe/trace: Add trace for xe_engine_activity Riana Tauro
2024-11-21 6:39 ` [PATCH v2 7/8] drm/xe/guc: Expose engine busyness only for supported GuC version Riana Tauro
2024-12-13 5:44 ` Lucas De Marchi
2024-12-13 6:00 ` Riana Tauro
2024-12-13 6:04 ` Lucas De Marchi
2024-12-13 6:10 ` Riana Tauro
2024-12-13 17:26 ` Lucas De Marchi
2024-12-19 0:19 ` John Harrison
2024-11-21 6:39 ` [PATCH v2 8/8] drm/xe/pmu: Add PMU support for engine busyness Riana Tauro
2024-12-13 5:58 ` Lucas De Marchi
2024-12-18 5:12 ` Riana Tauro
2024-12-18 14:13 ` Lucas De Marchi
2024-12-18 14:51 ` Riana Tauro
2024-12-19 5:47 ` Riana Tauro
2024-12-19 18:46 ` Umesh Nerlige Ramappa
2025-01-06 14:06 ` Riana Tauro
2024-11-21 6:53 ` ✓ CI.Build: success for Add PMU support for single engine busyness (rev2) Patchwork
2024-11-21 6:55 ` ✗ CI.Hooks: failure " Patchwork
2024-11-21 6:57 ` ✓ CI.checksparse: success " Patchwork
2024-11-21 7:17 ` ✗ Xe.CI.BAT: failure " Patchwork
2024-11-21 13:52 ` ✗ Xe.CI.Full: " Patchwork
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=Z1jTTEkbCJYNJy1L@orsosgc001 \
--to=umesh.nerlige.ramappa@intel.com \
--cc=anshuman.gupta@intel.com \
--cc=aravind.iddamsetty@intel.com \
--cc=ashutosh.dixit@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=john.c.harrison@intel.com \
--cc=riana.tauro@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=soham.purkait@intel.com \
--cc=vinay.belgaumkar@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