Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ilia Levi <ilia.levi@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: ilia.levi@intel.com, dliberman@habana.ai,
	niranjana.vishwanathapura@intel.com, michal.wajdeczko@intel.com
Subject: [PATCH v4 08/11] drm/xe: msix support preparations - enable memirq
Date: Thu, 25 Jul 2024 13:22:10 +0300	[thread overview]
Message-ID: <20240725102213.2182896-9-ilia.levi@intel.com> (raw)
In-Reply-To: <20240725102213.2182896-1-ilia.levi@intel.com>

In order to configure the HW engines to use MSIX, we first need to
enable memory based interrupts (memirq). Up until now only VF used
memirq.

Thus before enabling memirq, we need to test whether MSIX is enabled.
For this purpose we move IRQ vectors allocation to an earlier entry
point.

Signed-off-by: Ilia Levi <ilia.levi@intel.com>
---
 drivers/gpu/drm/xe/xe_device.c |  6 ++++-
 drivers/gpu/drm/xe/xe_device.h |  7 +++++
 drivers/gpu/drm/xe/xe_irq.c    | 49 +++++++++++++++++++++-------------
 drivers/gpu/drm/xe/xe_irq.h    |  1 +
 4 files changed, 43 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index 8865751acf80..153b0862844b 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -644,6 +644,10 @@ int xe_device_probe(struct xe_device *xe)
 			return err;
 	}
 
+	err = xe_irq_init(xe);
+	if (err)
+		return err;
+
 	for_each_tile(tile, xe, id) {
 		if (IS_SRIOV_VF(xe)) {
 			xe_guc_comm_init_early(&tile->primary_gt->uc.guc);
@@ -657,7 +661,7 @@ int xe_device_probe(struct xe_device *xe)
 		err = xe_ggtt_init_early(tile->mem.ggtt);
 		if (err)
 			return err;
-		if (IS_SRIOV_VF(xe)) {
+		if (xe_device_needs_memirq(xe)) {
 			err = xe_memirq_init(&tile->memirq, false);
 			if (err)
 				return err;
diff --git a/drivers/gpu/drm/xe/xe_device.h b/drivers/gpu/drm/xe/xe_device.h
index d4c6ca1da8e8..720841ff241b 100644
--- a/drivers/gpu/drm/xe/xe_device.h
+++ b/drivers/gpu/drm/xe/xe_device.h
@@ -9,6 +9,7 @@
 #include <drm/drm_util.h>
 
 #include "xe_device_types.h"
+#include "xe_sriov.h"
 
 static inline struct xe_device *to_xe_device(const struct drm_device *dev)
 {
@@ -164,6 +165,12 @@ static inline bool xe_device_has_msix(struct xe_device *xe)
 	return xe->irq.msix.enabled;
 }
 
+static inline bool xe_device_needs_memirq(struct xe_device *xe)
+{
+	return (IS_SRIOV_VF(xe) || xe_device_has_msix(xe)) &&
+		xe_device_has_memirq(xe);
+}
+
 u32 xe_device_ccs_bytes(struct xe_device *xe, u64 size);
 
 void xe_device_snapshot_print(struct xe_device *xe, struct drm_printer *p);
diff --git a/drivers/gpu/drm/xe/xe_irq.c b/drivers/gpu/drm/xe/xe_irq.c
index 821efd464021..208d961919ea 100644
--- a/drivers/gpu/drm/xe/xe_irq.c
+++ b/drivers/gpu/drm/xe/xe_irq.c
@@ -563,17 +563,15 @@ static void vf_irq_reset(struct xe_device *xe)
 
 	xe_assert(xe, IS_SRIOV_VF(xe));
 
-	if (GRAPHICS_VERx100(xe) < 1210)
-		xelp_intr_disable(xe);
-	else
+	if (GRAPHICS_VERx100(xe) >= 1210) {
 		xe_assert(xe, xe_device_has_memirq(xe));
-
-	for_each_tile(tile, xe, id) {
-		if (xe_device_has_memirq(xe))
-			xe_memirq_reset(&tile->memirq);
-		else
-			gt_irq_reset(tile);
+		return;
 	}
+
+	xelp_intr_disable(xe);
+
+	for_each_tile(tile, xe, id)
+		gt_irq_reset(tile);
 }
 
 static void xe_irq_reset(struct xe_device *xe)
@@ -581,6 +579,11 @@ static void xe_irq_reset(struct xe_device *xe)
 	struct xe_tile *tile;
 	u8 id;
 
+	if (xe_device_needs_memirq(xe)) {
+		for_each_tile(tile, xe, id)
+			xe_memirq_reset(&tile->memirq);
+	}
+
 	if (IS_SRIOV_VF(xe))
 		return vf_irq_reset(xe);
 
@@ -608,13 +611,6 @@ static void xe_irq_reset(struct xe_device *xe)
 
 static void vf_irq_postinstall(struct xe_device *xe)
 {
-	struct xe_tile *tile;
-	unsigned int id;
-
-	for_each_tile(tile, xe, id)
-		if (xe_device_has_memirq(xe))
-			xe_memirq_postinstall(&tile->memirq);
-
 	if (GRAPHICS_VERx100(xe) < 1210)
 		xelp_intr_enable(xe, true);
 	else
@@ -623,6 +619,14 @@ static void vf_irq_postinstall(struct xe_device *xe)
 
 static void xe_irq_postinstall(struct xe_device *xe)
 {
+	struct xe_tile *tile;
+	unsigned int id;
+
+	if (xe_device_needs_memirq(xe)) {
+		for_each_tile(tile, xe, id)
+			xe_memirq_postinstall(&tile->memirq);
+	}
+
 	if (IS_SRIOV_VF(xe))
 		return vf_irq_postinstall(xe);
 
@@ -740,7 +744,7 @@ static int xe_irq_msix_request(struct xe_device *xe)
 	return 0;
 }
 
-int xe_irq_install(struct xe_device *xe)
+int xe_irq_init(struct xe_device *xe)
 {
 	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
 	unsigned int irq_flags = PCI_IRQ_MSIX;
@@ -761,14 +765,21 @@ int xe_irq_install(struct xe_device *xe)
 		return nvec;
 	}
 
-	xe_irq_reset(xe);
-
 	err = pci_alloc_irq_vectors(pdev, nvec, nvec, irq_flags);
 	if (err < 0) {
 		drm_err(&xe->drm, "MSI/MSIX: Failed to enable support %d\n", err);
 		return err;
 	}
 
+	return 0;
+}
+
+int xe_irq_install(struct xe_device *xe)
+{
+	int err;
+
+	xe_irq_reset(xe);
+
 	if (xe_device_has_msix(xe))
 		err = xe_irq_msix_request(xe);
 	else
diff --git a/drivers/gpu/drm/xe/xe_irq.h b/drivers/gpu/drm/xe/xe_irq.h
index 94b32a780c68..b1a124a551ee 100644
--- a/drivers/gpu/drm/xe/xe_irq.h
+++ b/drivers/gpu/drm/xe/xe_irq.h
@@ -12,6 +12,7 @@ struct xe_device;
 struct xe_tile;
 struct xe_gt;
 
+int xe_irq_init(struct xe_device *xe);
 int xe_irq_install(struct xe_device *xe);
 void xe_irq_suspend(struct xe_device *xe);
 void xe_irq_resume(struct xe_device *xe);
-- 
2.43.2


  parent reply	other threads:[~2024-07-25 10:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-25 10:22 [PATCH v4 00/11] Add MSIX functionality to XE Ilia Levi
2024-07-25 10:22 ` [PATCH v4 01/11] drm/xe/irq: refactor irq flows to support also msix Ilia Levi
2024-07-25 10:22 ` [PATCH v4 02/11] drm/xe/irq: add msix allocator Ilia Levi
2024-07-25 10:22 ` [PATCH v4 03/11] drm/xe: add irq offset of engine instance 0 to hw engine properties Ilia Levi
2024-07-25 10:22 ` [PATCH v4 04/11] drm/xe: move memirq out of vf Ilia Levi
2024-07-25 10:22 ` [PATCH v4 05/11] drm/xe: memirq infra changes for msix Ilia Levi
2024-07-25 10:22 ` [PATCH v4 06/11] drm/xe/irq: add hw engine irq handler Ilia Levi
2024-07-25 10:22 ` [PATCH v4 07/11] drm/xe: move the kernel lrc from hwe to execlist port Ilia Levi
2024-07-25 10:22 ` Ilia Levi [this message]
2024-07-25 10:22 ` [PATCH v4 09/11] drm/xe/exec: adding msix infra to exec queue Ilia Levi
2024-07-25 10:22 ` [PATCH v4 10/11] drm/xe/irq: add default msix Ilia Levi
2024-07-25 10:22 ` [PATCH v4 11/11] drm/xe: msix support for hw engines Ilia Levi
2024-07-25 10:29 ` ✓ CI.Patch_applied: success for Add MSIX functionality to XE (rev6) Patchwork
2024-07-25 10:29 ` ✓ CI.checkpatch: " Patchwork
2024-07-25 10:30 ` ✓ CI.KUnit: " Patchwork
2024-07-25 10:50 ` ✓ CI.Build: " Patchwork
2024-07-25 10:52 ` ✓ CI.Hooks: " Patchwork
2024-07-25 10:53 ` ✓ CI.checksparse: " Patchwork
2024-07-25 11:39 ` ✗ CI.BAT: failure " Patchwork
2024-07-25 13:35 ` ✗ 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=20240725102213.2182896-9-ilia.levi@intel.com \
    --to=ilia.levi@intel.com \
    --cc=dliberman@habana.ai \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=michal.wajdeczko@intel.com \
    --cc=niranjana.vishwanathapura@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