[PATCH 7/8] drm/xe: msix support preparations - enable memirq
Dani Liberman
dliberman at habana.ai
Wed Jun 26 10:33:44 UTC 2024
From: Ilia Levi <illevi at habana.ai>
In order to configure the HW engines to use MSIX, we first need to
enable memory based bnterrupts (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 <illevi at habana.ai>
---
drivers/gpu/drm/xe/xe_device.c | 6 +++-
drivers/gpu/drm/xe/xe_device.h | 12 ++++++++
drivers/gpu/drm/xe/xe_irq.c | 56 +++++++++++++++++++++-------------
drivers/gpu/drm/xe/xe_irq.h | 1 +
4 files changed, 53 insertions(+), 22 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index 432ec038b63c..854bceff7775 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -591,6 +591,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);
@@ -604,7 +608,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);
if (err)
return err;
diff --git a/drivers/gpu/drm/xe/xe_device.h b/drivers/gpu/drm/xe/xe_device.h
index bb07f5669dbb..7b4f651652e9 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)
{
@@ -154,6 +155,17 @@ static inline bool xe_device_has_memirq(struct xe_device *xe)
return GRAPHICS_VERx100(xe) >= 1250;
}
+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 2ccc7475645d..efa584e90cbf 100644
--- a/drivers/gpu/drm/xe/xe_irq.c
+++ b/drivers/gpu/drm/xe/xe_irq.c
@@ -559,19 +559,15 @@ static void vf_irq_reset(struct xe_device *xe)
struct xe_tile *tile;
unsigned int id;
- 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)
@@ -579,6 +575,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);
@@ -606,13 +607,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
@@ -621,6 +615,17 @@ 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->info.gt_count)
+ return;
+
+ 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);
@@ -732,7 +737,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;
@@ -751,14 +756,23 @@ 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;
}
+ xe->irq.num_of_interrupts = nvec;
+
+ return 0;
+}
+
+int xe_irq_install(struct xe_device *xe)
+{
+ int err;
+
+ xe_irq_reset(xe);
+
if (xe->irq.msix_enabled)
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 4278d8be5010..8a362ba14166 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_shutdown(struct xe_device *xe);
void xe_irq_suspend(struct xe_device *xe);
--
2.34.1
More information about the Intel-xe
mailing list