From: Ilia Levi <ilia.levi@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: ilia.levi@intel.com, michal.wajdeczko@intel.com,
jonathan.cavitt@intel.com, niranjana.vishwanathapura@intel.com,
matthew.brost@intel.com, koby.elbaz@intel.com,
yaron.avizrat@intel.com
Subject: [PATCH v3 4/4] drm/xe: memirq handler changes
Date: Mon, 2 Sep 2024 17:08:26 +0300 [thread overview]
Message-ID: <20240902140826.2526259-5-ilia.levi@intel.com> (raw)
In-Reply-To: <20240902140826.2526259-1-ilia.levi@intel.com>
This patch exposes an interrupt processing handler for a single hw engine.
This handler also caters for the MSI-X mode, where the hardware engines
report interrupt source and status to the offset of engine instance zero.
Refactored code to use this handler from the VF use-case as well.
Signed-off-by: Ilia Levi <ilia.levi@intel.com>
Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
---
drivers/gpu/drm/xe/xe_hw_engine.c | 19 ++++++++++++++++++-
drivers/gpu/drm/xe/xe_memirq.c | 31 ++++++++++++++++++++++++-------
drivers/gpu/drm/xe/xe_memirq.h | 1 +
3 files changed, 43 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_hw_engine.c b/drivers/gpu/drm/xe/xe_hw_engine.c
index c9c3beb3ce8d..1b8c8a24916c 100644
--- a/drivers/gpu/drm/xe/xe_hw_engine.c
+++ b/drivers/gpu/drm/xe/xe_hw_engine.c
@@ -460,6 +460,20 @@ hw_engine_setup_default_state(struct xe_hw_engine *hwe)
xe_rtp_process_to_sr(&ctx, engine_entries, &hwe->reg_sr);
}
+static const struct engine_info *find_engine_info(enum xe_engine_class class, int instance)
+{
+ const struct engine_info *info;
+ enum xe_hw_engine_id id;
+
+ for (id = 0; id < XE_NUM_HW_ENGINES; ++id) {
+ info = &engine_infos[id];
+ if (info->class == class && info->instance == instance)
+ return info;
+ }
+
+ return NULL;
+}
+
static void hw_engine_init_early(struct xe_gt *gt, struct xe_hw_engine *hwe,
enum xe_hw_engine_id id)
{
@@ -479,7 +493,10 @@ static void hw_engine_init_early(struct xe_gt *gt, struct xe_hw_engine *hwe,
hwe->class = info->class;
hwe->instance = info->instance;
hwe->mmio_base = info->mmio_base;
- hwe->irq_offset = info->irq_offset;
+ /* For MSI-X, hw engines report to offset of engine instance zero */
+ hwe->irq_offset = xe_device_has_msix(gt_to_xe(gt)) ?
+ find_engine_info(info->class, 0)->irq_offset :
+ info->irq_offset;
hwe->domain = info->domain;
hwe->name = info->name;
hwe->fence_irq = >->fence_irq[info->class];
diff --git a/drivers/gpu/drm/xe/xe_memirq.c b/drivers/gpu/drm/xe/xe_memirq.c
index 5cbc366b2eea..b743d4eedd3d 100644
--- a/drivers/gpu/drm/xe/xe_memirq.c
+++ b/drivers/gpu/drm/xe/xe_memirq.c
@@ -398,6 +398,28 @@ static void memirq_dispatch_guc(struct xe_memirq *memirq, struct iosys_map *stat
xe_guc_irq_handler(guc, GUC_INTR_GUC2HOST);
}
+/**
+ * xe_memirq_hwe_handler - Check and process interrupts for a specific HW engine.
+ * @memirq: the &xe_memirq
+ * @hwe: the hw engine to process
+ *
+ * This function reads and dispatches `Memory Based Interrupts` for the provided HW engine.
+ */
+void xe_memirq_hwe_handler(struct xe_memirq *memirq, struct xe_hw_engine *hwe)
+{
+ u16 offset = hwe->irq_offset;
+ u16 instance = hw_reports_to_instance_zero(memirq) ? hwe->instance : 0;
+ struct iosys_map src_offset = IOSYS_MAP_INIT_OFFSET(&memirq->bo->vmap,
+ XE_MEMIRQ_SOURCE_OFFSET(instance));
+
+ if (memirq_received(memirq, &src_offset, offset, "SRC")) {
+ struct iosys_map status_offset =
+ IOSYS_MAP_INIT_OFFSET(&memirq->bo->vmap,
+ XE_MEMIRQ_STATUS_OFFSET(instance) + offset * SZ_16);
+ memirq_dispatch_engine(memirq, &status_offset, hwe);
+ }
+}
+
/**
* xe_memirq_handler - The `Memory Based Interrupts`_ Handler.
* @memirq: the &xe_memirq
@@ -425,13 +447,8 @@ void xe_memirq_handler(struct xe_memirq *memirq)
if (gt->tile != tile)
continue;
- for_each_hw_engine(hwe, gt, id) {
- if (memirq_received(memirq, &memirq->source, hwe->irq_offset, "SRC")) {
- map = IOSYS_MAP_INIT_OFFSET(&memirq->status,
- hwe->irq_offset * SZ_16);
- memirq_dispatch_engine(memirq, &map, hwe);
- }
- }
+ for_each_hw_engine(hwe, gt, id)
+ xe_memirq_hwe_handler(memirq, hwe);
}
/* GuC and media GuC (if present) must be checked separately */
diff --git a/drivers/gpu/drm/xe/xe_memirq.h b/drivers/gpu/drm/xe/xe_memirq.h
index 2934f03cfbb5..26fc116ad555 100644
--- a/drivers/gpu/drm/xe/xe_memirq.h
+++ b/drivers/gpu/drm/xe/xe_memirq.h
@@ -20,6 +20,7 @@ u32 xe_memirq_enable_ptr(struct xe_memirq *memirq);
void xe_memirq_reset(struct xe_memirq *memirq);
void xe_memirq_postinstall(struct xe_memirq *memirq);
+void xe_memirq_hwe_handler(struct xe_memirq *memirq, struct xe_hw_engine *hwe);
void xe_memirq_handler(struct xe_memirq *memirq);
int xe_memirq_init_guc(struct xe_memirq *memirq, struct xe_guc *guc);
--
2.43.2
next prev parent reply other threads:[~2024-09-02 14:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-02 14:08 [PATCH v3 0/4] memirq infra changes Ilia Levi
2024-09-02 14:08 ` [PATCH v3 1/4] drm/xe: MSI-X support placeholder Ilia Levi
2024-09-02 14:08 ` [PATCH v3 2/4] drm/xe: move memirq out of VF Ilia Levi
2024-09-05 16:53 ` Michal Wajdeczko
2024-09-05 21:03 ` Cavitt, Jonathan
2024-09-02 14:08 ` [PATCH v3 3/4] drm/xe: memirq infra changes for MSI-X Ilia Levi
2024-09-05 16:35 ` Michal Wajdeczko
2024-09-05 20:51 ` Cavitt, Jonathan
2024-09-02 14:08 ` Ilia Levi [this message]
2024-09-02 14:16 ` ✓ CI.Patch_applied: success for memirq infra changes (rev4) Patchwork
2024-09-02 14:17 ` ✓ CI.checkpatch: " Patchwork
2024-09-02 14:18 ` ✓ CI.KUnit: " Patchwork
2024-09-02 14:29 ` ✓ CI.Build: " Patchwork
2024-09-02 14:32 ` ✓ CI.Hooks: " Patchwork
2024-09-02 14:33 ` ✓ CI.checksparse: " Patchwork
2024-09-02 14:53 ` ✓ CI.BAT: " Patchwork
2024-09-02 16:51 ` ✓ 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=20240902140826.2526259-5-ilia.levi@intel.com \
--to=ilia.levi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=jonathan.cavitt@intel.com \
--cc=koby.elbaz@intel.com \
--cc=matthew.brost@intel.com \
--cc=michal.wajdeczko@intel.com \
--cc=niranjana.vishwanathapura@intel.com \
--cc=yaron.avizrat@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