* [PATCH v8 0/9] Update AUX invalidation sequence
@ 2023-07-21 16:15 Andi Shyti
2023-07-21 16:15 ` [PATCH v8 1/9] drm/i915/gt: Cleanup aux invalidation registers Andi Shyti
` (8 more replies)
0 siblings, 9 replies; 25+ messages in thread
From: Andi Shyti @ 2023-07-21 16:15 UTC (permalink / raw)
To: Jonathan Cavitt, Matt Roper, Chris Wilson, Mika Kuoppala,
Nirmoy Das, Andrzej Hajda
Cc: intel-gfx, linux-stable, dri-evel, Andi Shyti
Hi,
as there are new hardware directives, we need a little adaptation
for the AUX invalidation sequence.
In this version we support all the engines affected by this
change.
The stable backport has some challenges because the original
patch that this series fixes has had more changes in between.
This patch is slowly exploding with code refactorings and
features added and fixed.
Thanks a lot Nirmoy, Andrzej and Matt for your review and for the
fruitful discussions!
Thanks,
Andi
Changelog:
=========
v7 -> v8
- Removed the aux invalidation from the device info and added a
helper function, instead (patch 2).
- Use "MTL and beyond" instead of "MTL+" in comments.
- Use the "gen12_" prefix instead of "intel_".
- In patch 6 return an int error instead of an error embedded in
the pointer in the intel_emit_pipe_control_cs() function and
propagate the error to the upper layers.
v6 -> v7
- Fix correct sequence applied to the correct engine. A little
confusion promptly cought by Nirmoy when applying to the VD
engine the sequence belonging to the compute engines. Thanks a
lot, Nirmoy!
v5 -> v6
- Fixed ccs flush in the engines VE and BCS. They are sent as a
separate command instead of added in the pipe control.
- Separated the CCS flusing in the pipe control patch with the
quiescing of the memory. They were meant to be on separate
patch already in the previous verision, but apparently I
squashed them by mistake.
v4 -> v5
- The AUX CCS is added as a device property instead of checking
against FLAT CCS. This adds the new HAS_AUX_CCS check
(Patch 2, new).
- little and trivial refactoring here and there.
- extended the flags{0,1}/bit_group_{0,1} renaming to other
functions.
- Created an intel_emit_pipe_control_cs() wrapper for submitting
the pipe control.
- Quiesce memory for all the engines, not just RCS (Patch 6,
new).
- The PIPE_CONTROL_CCS_FLUSH is added to all the engines.
- Remove redundant EMIT_FLUSH_CCS mode flag.
- Remove unnecessary NOOPs from the command streamer for
invalidating the CCS table.
- Use INVALID_MMIO_REG and gen12_get_aux_inv_reg() instad of
__MMIO(0) and reg.reg.
- Remove useless wrapper and just use gen12_get_aux_inv_reg().
v3 -> v4
- A trivial patch 3 is added to rename the flags with
bit_group_{0,1} to align with the datasheet naming.
- Patch 4 fixes a confusion I made where the CCS flag was
applied to the wrong bit group.
v2 -> v3
- added r-b from Nirmoy in patch 1 and 4.
- added patch 3 which enables the ccs_flush in the control pipe
for mtl+ compute and render engines.
- added redundant checks in patch 2 for enabling the EMIT_FLUSH
flag.
v1 -> v2
- add a clean up preliminary patch for the existing registers
- add support for more engines
- add the Fixes tag
Andi Shyti (7):
drm/i915/gt: Cleanup aux invalidation registers
drm/i915: Add the gen12_needs_ccs_aux_inv helper
drm/i915/gt: Rename flags with bit_group_X according to the datasheet
drm/i915/gt: Enable the CCS_FLUSH bit in the pipe control
drm/i915/gt: Refactor intel_emit_pipe_control_cs() in a single
function
drm/i915/gt: Ensure memory quiesced before invalidation for all
engines
drm/i915/gt: Support aux invalidation on all engines
Jonathan Cavitt (2):
drm/i915/gt: Ensure memory quiesced before invalidation
drm/i915/gt: Poll aux invalidation register bit on invalidation
drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 198 ++++++++++++-------
drivers/gpu/drm/i915/gt/gen8_engine_cs.h | 21 +-
drivers/gpu/drm/i915/gt/intel_gpu_commands.h | 2 +
drivers/gpu/drm/i915/gt/intel_gt_regs.h | 16 +-
drivers/gpu/drm/i915/gt/intel_lrc.c | 17 +-
5 files changed, 155 insertions(+), 99 deletions(-)
--
2.40.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v8 1/9] drm/i915/gt: Cleanup aux invalidation registers
2023-07-21 16:15 [PATCH v8 0/9] Update AUX invalidation sequence Andi Shyti
@ 2023-07-21 16:15 ` Andi Shyti
2023-07-21 16:15 ` [PATCH v8 2/9] drm/i915: Add the gen12_needs_ccs_aux_inv helper Andi Shyti
` (7 subsequent siblings)
8 siblings, 0 replies; 25+ messages in thread
From: Andi Shyti @ 2023-07-21 16:15 UTC (permalink / raw)
To: Jonathan Cavitt, Matt Roper, Chris Wilson, Mika Kuoppala,
Nirmoy Das, Andrzej Hajda
Cc: intel-gfx, linux-stable, dri-evel, Andi Shyti
Fix the 'NV' definition postfix that is supposed to be INV.
Take the chance to also order properly the registers based on
their address and call the GEN12_GFX_CCS_AUX_INV address as
GEN12_CCS_AUX_INV like all the other similar registers.
Remove also VD1, VD3 and VE1 registers that don't exist and add
BCS0 and CCS0.
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Cc: <stable@vger.kernel.org> # v5.8+
Reviewed-by: Nirmoy Das <nirmoy.das@intel.com>
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
---
drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 8 ++++----
drivers/gpu/drm/i915/gt/intel_gt_regs.h | 16 ++++++++--------
drivers/gpu/drm/i915/gt/intel_lrc.c | 6 +++---
3 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
index 23857cc08eca1..563efee055602 100644
--- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
@@ -287,8 +287,8 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
if (!HAS_FLAT_CCS(rq->engine->i915)) {
/* hsdes: 1809175790 */
- cs = gen12_emit_aux_table_inv(rq->engine->gt,
- cs, GEN12_GFX_CCS_AUX_NV);
+ cs = gen12_emit_aux_table_inv(rq->engine->gt, cs,
+ GEN12_CCS_AUX_INV);
}
*cs++ = preparser_disable(false);
@@ -348,10 +348,10 @@ int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode)
if (aux_inv) { /* hsdes: 1809175790 */
if (rq->engine->class == VIDEO_DECODE_CLASS)
cs = gen12_emit_aux_table_inv(rq->engine->gt,
- cs, GEN12_VD0_AUX_NV);
+ cs, GEN12_VD0_AUX_INV);
else
cs = gen12_emit_aux_table_inv(rq->engine->gt,
- cs, GEN12_VE0_AUX_NV);
+ cs, GEN12_VE0_AUX_INV);
}
if (mode & EMIT_INVALIDATE)
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_regs.h b/drivers/gpu/drm/i915/gt/intel_gt_regs.h
index 718cb2c80f79e..2cdfb2f713d02 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_regs.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt_regs.h
@@ -332,9 +332,11 @@
#define GEN8_PRIVATE_PAT_HI _MMIO(0x40e0 + 4)
#define GEN10_PAT_INDEX(index) _MMIO(0x40e0 + (index) * 4)
#define BSD_HWS_PGA_GEN7 _MMIO(0x4180)
-#define GEN12_GFX_CCS_AUX_NV _MMIO(0x4208)
-#define GEN12_VD0_AUX_NV _MMIO(0x4218)
-#define GEN12_VD1_AUX_NV _MMIO(0x4228)
+
+#define GEN12_CCS_AUX_INV _MMIO(0x4208)
+#define GEN12_VD0_AUX_INV _MMIO(0x4218)
+#define GEN12_VE0_AUX_INV _MMIO(0x4238)
+#define GEN12_BCS0_AUX_INV _MMIO(0x4248)
#define GEN8_RTCR _MMIO(0x4260)
#define GEN8_M1TCR _MMIO(0x4264)
@@ -342,14 +344,12 @@
#define GEN8_BTCR _MMIO(0x426c)
#define GEN8_VTCR _MMIO(0x4270)
-#define GEN12_VD2_AUX_NV _MMIO(0x4298)
-#define GEN12_VD3_AUX_NV _MMIO(0x42a8)
-#define GEN12_VE0_AUX_NV _MMIO(0x4238)
-
#define BLT_HWS_PGA_GEN7 _MMIO(0x4280)
-#define GEN12_VE1_AUX_NV _MMIO(0x42b8)
+#define GEN12_VD2_AUX_INV _MMIO(0x4298)
+#define GEN12_CCS0_AUX_INV _MMIO(0x42c8)
#define AUX_INV REG_BIT(0)
+
#define VEBOX_HWS_PGA_GEN7 _MMIO(0x4380)
#define GEN12_AUX_ERR_DBG _MMIO(0x43f4)
diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
index 1b710102390bf..235f3fab60a98 100644
--- a/drivers/gpu/drm/i915/gt/intel_lrc.c
+++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
@@ -1374,7 +1374,7 @@ gen12_emit_indirect_ctx_rcs(const struct intel_context *ce, u32 *cs)
/* hsdes: 1809175790 */
if (!HAS_FLAT_CCS(ce->engine->i915))
cs = gen12_emit_aux_table_inv(ce->engine->gt,
- cs, GEN12_GFX_CCS_AUX_NV);
+ cs, GEN12_CCS_AUX_INV);
/* Wa_16014892111 */
if (IS_MTL_GRAPHICS_STEP(ce->engine->i915, M, STEP_A0, STEP_B0) ||
@@ -1403,10 +1403,10 @@ gen12_emit_indirect_ctx_xcs(const struct intel_context *ce, u32 *cs)
if (!HAS_FLAT_CCS(ce->engine->i915)) {
if (ce->engine->class == VIDEO_DECODE_CLASS)
cs = gen12_emit_aux_table_inv(ce->engine->gt,
- cs, GEN12_VD0_AUX_NV);
+ cs, GEN12_VD0_AUX_INV);
else if (ce->engine->class == VIDEO_ENHANCEMENT_CLASS)
cs = gen12_emit_aux_table_inv(ce->engine->gt,
- cs, GEN12_VE0_AUX_NV);
+ cs, GEN12_VE0_AUX_INV);
}
return cs;
--
2.40.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v8 2/9] drm/i915: Add the gen12_needs_ccs_aux_inv helper
2023-07-21 16:15 [PATCH v8 0/9] Update AUX invalidation sequence Andi Shyti
2023-07-21 16:15 ` [PATCH v8 1/9] drm/i915/gt: Cleanup aux invalidation registers Andi Shyti
@ 2023-07-21 16:15 ` Andi Shyti
2023-07-21 19:12 ` Matt Roper
` (2 more replies)
2023-07-21 16:15 ` [PATCH v8 3/9] drm/i915/gt: Ensure memory quiesced before invalidation Andi Shyti
` (6 subsequent siblings)
8 siblings, 3 replies; 25+ messages in thread
From: Andi Shyti @ 2023-07-21 16:15 UTC (permalink / raw)
To: Jonathan Cavitt, Matt Roper, Chris Wilson, Mika Kuoppala,
Nirmoy Das, Andrzej Hajda
Cc: intel-gfx, linux-stable, dri-evel, Andi Shyti
We always assumed that a device might either have AUX or FLAT
CCS, but this is an approximation that is not always true, e.g.
PVC represents an exception.
Set the basis for future finer selection by implementing a
boolean gen12_needs_ccs_aux_inv() function that tells whether aux
invalidation is needed or not.
Currently PVC is the only exception to the above mentioned rule.
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Jonathan Cavitt <jonathan.cavitt@intel.com>
Cc: <stable@vger.kernel.org> # v5.8+
---
drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
index 563efee055602..460c9225a50fc 100644
--- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
@@ -165,6 +165,18 @@ static u32 preparser_disable(bool state)
return MI_ARB_CHECK | 1 << 8 | state;
}
+static bool gen12_needs_ccs_aux_inv(struct intel_engine_cs *engine)
+{
+ if (IS_PONTEVECCHIO(engine->i915))
+ return false;
+
+ /*
+ * so far platforms supported by i915 having
+ * flat ccs do not require AUX invalidation
+ */
+ return !HAS_FLAT_CCS(engine->i915);
+}
+
u32 *gen12_emit_aux_table_inv(struct intel_gt *gt, u32 *cs, const i915_reg_t inv_reg)
{
u32 gsi_offset = gt->uncore->gsi_offset;
@@ -267,7 +279,7 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
else if (engine->class == COMPUTE_CLASS)
flags &= ~PIPE_CONTROL_3D_ENGINE_FLAGS;
- if (!HAS_FLAT_CCS(rq->engine->i915))
+ if (gen12_needs_ccs_aux_inv(rq->engine))
count = 8 + 4;
else
count = 8;
@@ -285,7 +297,7 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
cs = gen8_emit_pipe_control(cs, flags, LRC_PPHWSP_SCRATCH_ADDR);
- if (!HAS_FLAT_CCS(rq->engine->i915)) {
+ if (gen12_needs_ccs_aux_inv(rq->engine)) {
/* hsdes: 1809175790 */
cs = gen12_emit_aux_table_inv(rq->engine->gt, cs,
GEN12_CCS_AUX_INV);
@@ -307,7 +319,7 @@ int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode)
if (mode & EMIT_INVALIDATE) {
cmd += 2;
- if (!HAS_FLAT_CCS(rq->engine->i915) &&
+ if (gen12_needs_ccs_aux_inv(rq->engine) &&
(rq->engine->class == VIDEO_DECODE_CLASS ||
rq->engine->class == VIDEO_ENHANCEMENT_CLASS)) {
aux_inv = rq->engine->mask &
--
2.40.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v8 3/9] drm/i915/gt: Ensure memory quiesced before invalidation
2023-07-21 16:15 [PATCH v8 0/9] Update AUX invalidation sequence Andi Shyti
2023-07-21 16:15 ` [PATCH v8 1/9] drm/i915/gt: Cleanup aux invalidation registers Andi Shyti
2023-07-21 16:15 ` [PATCH v8 2/9] drm/i915: Add the gen12_needs_ccs_aux_inv helper Andi Shyti
@ 2023-07-21 16:15 ` Andi Shyti
2023-07-21 16:15 ` [PATCH v8 4/9] drm/i915/gt: Rename flags with bit_group_X according to the datasheet Andi Shyti
` (5 subsequent siblings)
8 siblings, 0 replies; 25+ messages in thread
From: Andi Shyti @ 2023-07-21 16:15 UTC (permalink / raw)
To: Jonathan Cavitt, Matt Roper, Chris Wilson, Mika Kuoppala,
Nirmoy Das, Andrzej Hajda
Cc: intel-gfx, linux-stable, dri-evel, Andi Shyti
From: Jonathan Cavitt <jonathan.cavitt@intel.com>
All memory traffic must be quiesced before requesting
an aux invalidation on platforms that use Aux CCS.
Fixes: 972282c4cf24 ("drm/i915/gen12: Add aux table invalidate for all engines")
Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Cc: <stable@vger.kernel.org> # v5.8+
Reviewed-by: Nirmoy Das <nirmoy.das@intel.com>
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
---
drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
index 460c9225a50fc..6210b38a2d382 100644
--- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
@@ -214,7 +214,11 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
{
struct intel_engine_cs *engine = rq->engine;
- if (mode & EMIT_FLUSH) {
+ /*
+ * On Aux CCS platforms the invalidation of the Aux
+ * table requires quiescing memory traffic beforehand
+ */
+ if (mode & EMIT_FLUSH || gen12_needs_ccs_aux_inv(engine)) {
u32 flags = 0;
int err;
u32 *cs;
--
2.40.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v8 4/9] drm/i915/gt: Rename flags with bit_group_X according to the datasheet
2023-07-21 16:15 [PATCH v8 0/9] Update AUX invalidation sequence Andi Shyti
` (2 preceding siblings ...)
2023-07-21 16:15 ` [PATCH v8 3/9] drm/i915/gt: Ensure memory quiesced before invalidation Andi Shyti
@ 2023-07-21 16:15 ` Andi Shyti
2023-07-21 16:15 ` [PATCH v8 5/9] drm/i915/gt: Enable the CCS_FLUSH bit in the pipe control Andi Shyti
` (4 subsequent siblings)
8 siblings, 0 replies; 25+ messages in thread
From: Andi Shyti @ 2023-07-21 16:15 UTC (permalink / raw)
To: Jonathan Cavitt, Matt Roper, Chris Wilson, Mika Kuoppala,
Nirmoy Das, Andrzej Hajda
Cc: intel-gfx, linux-stable, dri-evel, Andi Shyti
In preparation of the next patch align with the datasheet (BSPEC
47112) with the naming of the pipe control set of flag values.
The variable "flags" in gen12_emit_flush_rcs() is applied as a
set of flags called Bit Group 1.
Define also the Bit Group 0 as bit_group_0 where currently only
PIPE_CONTROL0_HDC_PIPELINE_FLUSH bit is set.
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Cc: <stable@vger.kernel.org> # v5.8+
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Reviewed-by: Nirmoy Das <nirmoy.das@intel.com>
---
drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 34 +++++++++++++-----------
drivers/gpu/drm/i915/gt/gen8_engine_cs.h | 18 ++++++++-----
2 files changed, 29 insertions(+), 23 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
index 6210b38a2d382..5d2175e918dd2 100644
--- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
@@ -219,7 +219,8 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
* table requires quiescing memory traffic beforehand
*/
if (mode & EMIT_FLUSH || gen12_needs_ccs_aux_inv(engine)) {
- u32 flags = 0;
+ u32 bit_group_0 = 0;
+ u32 bit_group_1 = 0;
int err;
u32 *cs;
@@ -227,32 +228,33 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
if (err)
return err;
- flags |= PIPE_CONTROL_TILE_CACHE_FLUSH;
- flags |= PIPE_CONTROL_FLUSH_L3;
- flags |= PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH;
- flags |= PIPE_CONTROL_DEPTH_CACHE_FLUSH;
+ bit_group_0 |= PIPE_CONTROL0_HDC_PIPELINE_FLUSH;
+
+ bit_group_1 |= PIPE_CONTROL_TILE_CACHE_FLUSH;
+ bit_group_1 |= PIPE_CONTROL_FLUSH_L3;
+ bit_group_1 |= PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH;
+ bit_group_1 |= PIPE_CONTROL_DEPTH_CACHE_FLUSH;
/* Wa_1409600907:tgl,adl-p */
- flags |= PIPE_CONTROL_DEPTH_STALL;
- flags |= PIPE_CONTROL_DC_FLUSH_ENABLE;
- flags |= PIPE_CONTROL_FLUSH_ENABLE;
+ bit_group_1 |= PIPE_CONTROL_DEPTH_STALL;
+ bit_group_1 |= PIPE_CONTROL_DC_FLUSH_ENABLE;
+ bit_group_1 |= PIPE_CONTROL_FLUSH_ENABLE;
- flags |= PIPE_CONTROL_STORE_DATA_INDEX;
- flags |= PIPE_CONTROL_QW_WRITE;
+ bit_group_1 |= PIPE_CONTROL_STORE_DATA_INDEX;
+ bit_group_1 |= PIPE_CONTROL_QW_WRITE;
- flags |= PIPE_CONTROL_CS_STALL;
+ bit_group_1 |= PIPE_CONTROL_CS_STALL;
if (!HAS_3D_PIPELINE(engine->i915))
- flags &= ~PIPE_CONTROL_3D_ARCH_FLAGS;
+ bit_group_1 &= ~PIPE_CONTROL_3D_ARCH_FLAGS;
else if (engine->class == COMPUTE_CLASS)
- flags &= ~PIPE_CONTROL_3D_ENGINE_FLAGS;
+ bit_group_1 &= ~PIPE_CONTROL_3D_ENGINE_FLAGS;
cs = intel_ring_begin(rq, 6);
if (IS_ERR(cs))
return PTR_ERR(cs);
- cs = gen12_emit_pipe_control(cs,
- PIPE_CONTROL0_HDC_PIPELINE_FLUSH,
- flags, LRC_PPHWSP_SCRATCH_ADDR);
+ cs = gen12_emit_pipe_control(cs, bit_group_0, bit_group_1,
+ LRC_PPHWSP_SCRATCH_ADDR);
intel_ring_advance(rq, cs);
}
diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.h b/drivers/gpu/drm/i915/gt/gen8_engine_cs.h
index 655e5c00ddc27..a44eda096557c 100644
--- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.h
+++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.h
@@ -49,25 +49,29 @@ u32 *gen12_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs);
u32 *gen12_emit_aux_table_inv(struct intel_gt *gt, u32 *cs, const i915_reg_t inv_reg);
static inline u32 *
-__gen8_emit_pipe_control(u32 *batch, u32 flags0, u32 flags1, u32 offset)
+__gen8_emit_pipe_control(u32 *batch, u32 bit_group_0,
+ u32 bit_group_1, u32 offset)
{
memset(batch, 0, 6 * sizeof(u32));
- batch[0] = GFX_OP_PIPE_CONTROL(6) | flags0;
- batch[1] = flags1;
+ batch[0] = GFX_OP_PIPE_CONTROL(6) | bit_group_0;
+ batch[1] = bit_group_1;
batch[2] = offset;
return batch + 6;
}
-static inline u32 *gen8_emit_pipe_control(u32 *batch, u32 flags, u32 offset)
+static inline u32 *gen8_emit_pipe_control(u32 *batch,
+ u32 bit_group_1, u32 offset)
{
- return __gen8_emit_pipe_control(batch, 0, flags, offset);
+ return __gen8_emit_pipe_control(batch, 0, bit_group_1, offset);
}
-static inline u32 *gen12_emit_pipe_control(u32 *batch, u32 flags0, u32 flags1, u32 offset)
+static inline u32 *gen12_emit_pipe_control(u32 *batch, u32 bit_group_0,
+ u32 bit_group_1, u32 offset)
{
- return __gen8_emit_pipe_control(batch, flags0, flags1, offset);
+ return __gen8_emit_pipe_control(batch, bit_group_0,
+ bit_group_1, offset);
}
static inline u32 *
--
2.40.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v8 5/9] drm/i915/gt: Enable the CCS_FLUSH bit in the pipe control
2023-07-21 16:15 [PATCH v8 0/9] Update AUX invalidation sequence Andi Shyti
` (3 preceding siblings ...)
2023-07-21 16:15 ` [PATCH v8 4/9] drm/i915/gt: Rename flags with bit_group_X according to the datasheet Andi Shyti
@ 2023-07-21 16:15 ` Andi Shyti
2023-07-21 19:16 ` Matt Roper
` (2 more replies)
2023-07-21 16:15 ` [PATCH v8 6/9] drm/i915/gt: Refactor intel_emit_pipe_control_cs() in a single function Andi Shyti
` (3 subsequent siblings)
8 siblings, 3 replies; 25+ messages in thread
From: Andi Shyti @ 2023-07-21 16:15 UTC (permalink / raw)
To: Jonathan Cavitt, Matt Roper, Chris Wilson, Mika Kuoppala,
Nirmoy Das, Andrzej Hajda
Cc: intel-gfx, linux-stable, dri-evel, Andi Shyti
Enable the CCS_FLUSH bit 13 in the control pipe for render and
compute engines in platforms starting from Meteor Lake (BSPEC
43904 and 47112).
Fixes: 972282c4cf24 ("drm/i915/gen12: Add aux table invalidate for all engines")
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Cc: Jonathan Cavitt <jonathan.cavitt@intel.com>
Cc: Nirmoy Das <nirmoy.das@intel.com>
Cc: <stable@vger.kernel.org> # v5.8+
---
drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 7 +++++++
drivers/gpu/drm/i915/gt/intel_gpu_commands.h | 1 +
2 files changed, 8 insertions(+)
diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
index 5d2175e918dd2..139a7e69f5c4d 100644
--- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
@@ -230,6 +230,13 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
bit_group_0 |= PIPE_CONTROL0_HDC_PIPELINE_FLUSH;
+ /*
+ * When required, in MTL and beyond platforms we
+ * need to set the CCS_FLUSH bit in the pipe control
+ */
+ if (GRAPHICS_VER_FULL(rq->i915) >= IP_VER(12, 70))
+ bit_group_0 |= PIPE_CONTROL_CCS_FLUSH;
+
bit_group_1 |= PIPE_CONTROL_TILE_CACHE_FLUSH;
bit_group_1 |= PIPE_CONTROL_FLUSH_L3;
bit_group_1 |= PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH;
diff --git a/drivers/gpu/drm/i915/gt/intel_gpu_commands.h b/drivers/gpu/drm/i915/gt/intel_gpu_commands.h
index 5d143e2a8db03..5df7cce23197c 100644
--- a/drivers/gpu/drm/i915/gt/intel_gpu_commands.h
+++ b/drivers/gpu/drm/i915/gt/intel_gpu_commands.h
@@ -299,6 +299,7 @@
#define PIPE_CONTROL_QW_WRITE (1<<14)
#define PIPE_CONTROL_POST_SYNC_OP_MASK (3<<14)
#define PIPE_CONTROL_DEPTH_STALL (1<<13)
+#define PIPE_CONTROL_CCS_FLUSH (1<<13) /* MTL+ */
#define PIPE_CONTROL_WRITE_FLUSH (1<<12)
#define PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH (1<<12) /* gen6+ */
#define PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE (1<<11) /* MBZ on ILK */
--
2.40.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v8 6/9] drm/i915/gt: Refactor intel_emit_pipe_control_cs() in a single function
2023-07-21 16:15 [PATCH v8 0/9] Update AUX invalidation sequence Andi Shyti
` (4 preceding siblings ...)
2023-07-21 16:15 ` [PATCH v8 5/9] drm/i915/gt: Enable the CCS_FLUSH bit in the pipe control Andi Shyti
@ 2023-07-21 16:15 ` Andi Shyti
2023-07-24 7:54 ` Andrzej Hajda
2023-07-24 9:07 ` Nirmoy Das
2023-07-21 16:15 ` [PATCH v8 7/9] drm/i915/gt: Ensure memory quiesced before invalidation for all engines Andi Shyti
` (2 subsequent siblings)
8 siblings, 2 replies; 25+ messages in thread
From: Andi Shyti @ 2023-07-21 16:15 UTC (permalink / raw)
To: Jonathan Cavitt, Matt Roper, Chris Wilson, Mika Kuoppala,
Nirmoy Das, Andrzej Hajda
Cc: intel-gfx, linux-stable, dri-evel, Andi Shyti
Just a trivial refactoring for reducing the number of code
duplicate. This will come at handy in the next commits.
Meantime, propagate the error to the above layers if we fail to
emit the pipe control.
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Cc: <stable@vger.kernel.org> # v5.8+
---
drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 47 +++++++++++++-----------
1 file changed, 26 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
index 139a7e69f5c4d..5e19b45a5cabe 100644
--- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
@@ -7,6 +7,7 @@
#include "i915_drv.h"
#include "intel_engine_regs.h"
#include "intel_gpu_commands.h"
+#include "intel_gt_print.h"
#include "intel_lrc.h"
#include "intel_ring.h"
@@ -189,23 +190,30 @@ u32 *gen12_emit_aux_table_inv(struct intel_gt *gt, u32 *cs, const i915_reg_t inv
return cs;
}
+static int gen12_emit_pipe_control_cs(struct i915_request *rq, u32 bit_group_0,
+ u32 bit_group_1, u32 offset)
+{
+ u32 *cs;
+
+ cs = intel_ring_begin(rq, 6);
+ if (IS_ERR(cs))
+ return PTR_ERR(cs);
+
+ cs = gen12_emit_pipe_control(cs, bit_group_0, bit_group_1,
+ LRC_PPHWSP_SCRATCH_ADDR);
+ intel_ring_advance(rq, cs);
+
+ return 0;
+}
+
static int mtl_dummy_pipe_control(struct i915_request *rq)
{
/* Wa_14016712196 */
if (IS_MTL_GRAPHICS_STEP(rq->engine->i915, M, STEP_A0, STEP_B0) ||
- IS_MTL_GRAPHICS_STEP(rq->engine->i915, P, STEP_A0, STEP_B0)) {
- u32 *cs;
-
- /* dummy PIPE_CONTROL + depth flush */
- cs = intel_ring_begin(rq, 6);
- if (IS_ERR(cs))
- return PTR_ERR(cs);
- cs = gen12_emit_pipe_control(cs,
- 0,
- PIPE_CONTROL_DEPTH_CACHE_FLUSH,
- LRC_PPHWSP_SCRATCH_ADDR);
- intel_ring_advance(rq, cs);
- }
+ IS_MTL_GRAPHICS_STEP(rq->engine->i915, P, STEP_A0, STEP_B0))
+ return gen12_emit_pipe_control_cs(rq, 0,
+ PIPE_CONTROL_DEPTH_CACHE_FLUSH,
+ LRC_PPHWSP_SCRATCH_ADDR);
return 0;
}
@@ -222,7 +230,6 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
u32 bit_group_0 = 0;
u32 bit_group_1 = 0;
int err;
- u32 *cs;
err = mtl_dummy_pipe_control(rq);
if (err)
@@ -256,13 +263,11 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
else if (engine->class == COMPUTE_CLASS)
bit_group_1 &= ~PIPE_CONTROL_3D_ENGINE_FLAGS;
- cs = intel_ring_begin(rq, 6);
- if (IS_ERR(cs))
- return PTR_ERR(cs);
-
- cs = gen12_emit_pipe_control(cs, bit_group_0, bit_group_1,
- LRC_PPHWSP_SCRATCH_ADDR);
- intel_ring_advance(rq, cs);
+ err = gen12_emit_pipe_control_cs(rq, bit_group_0, bit_group_1,
+ LRC_PPHWSP_SCRATCH_ADDR);
+ if (err)
+ gt_warn(engine->gt,
+ "Failed to emit flush pipe control\n");
}
if (mode & EMIT_INVALIDATE) {
--
2.40.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v8 7/9] drm/i915/gt: Ensure memory quiesced before invalidation for all engines
2023-07-21 16:15 [PATCH v8 0/9] Update AUX invalidation sequence Andi Shyti
` (5 preceding siblings ...)
2023-07-21 16:15 ` [PATCH v8 6/9] drm/i915/gt: Refactor intel_emit_pipe_control_cs() in a single function Andi Shyti
@ 2023-07-21 16:15 ` Andi Shyti
2023-07-24 8:19 ` Andrzej Hajda
2023-07-21 16:15 ` [PATCH v8 8/9] drm/i915/gt: Poll aux invalidation register bit on invalidation Andi Shyti
2023-07-21 16:15 ` [PATCH v8 9/9] drm/i915/gt: Support aux invalidation on all engines Andi Shyti
8 siblings, 1 reply; 25+ messages in thread
From: Andi Shyti @ 2023-07-21 16:15 UTC (permalink / raw)
To: Jonathan Cavitt, Matt Roper, Chris Wilson, Mika Kuoppala,
Nirmoy Das, Andrzej Hajda
Cc: intel-gfx, linux-stable, dri-evel, Andi Shyti
Commit af9e423a8aae ("drm/i915/gt: Ensure memory quiesced before
invalidation") has made sure that the memory is quiesced before
invalidating the AUX CCS table. Do it for all the other engines
and not just RCS.
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Cc: Jonathan Cavitt <jonathan.cavitt@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: <stable@vger.kernel.org> # v5.8+
---
drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 36 ++++++++++++++++--------
1 file changed, 25 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
index 5e19b45a5cabe..646151e1b5deb 100644
--- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
@@ -331,26 +331,40 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode)
{
intel_engine_mask_t aux_inv = 0;
- u32 cmd, *cs;
+ u32 cmd_flush = 0;
+ u32 cmd = 4;
+ u32 *cs;
- cmd = 4;
- if (mode & EMIT_INVALIDATE) {
+ if (mode & EMIT_INVALIDATE)
cmd += 2;
- if (gen12_needs_ccs_aux_inv(rq->engine) &&
- (rq->engine->class == VIDEO_DECODE_CLASS ||
- rq->engine->class == VIDEO_ENHANCEMENT_CLASS)) {
- aux_inv = rq->engine->mask &
- ~GENMASK(_BCS(I915_MAX_BCS - 1), BCS0);
- if (aux_inv)
- cmd += 4;
- }
+ if (gen12_needs_ccs_aux_inv(rq->engine))
+ aux_inv = rq->engine->mask &
+ ~GENMASK(_BCS(I915_MAX_BCS - 1), BCS0);
+
+ /*
+ * On Aux CCS platforms the invalidation of the Aux
+ * table requires quiescing memory traffic beforehand
+ */
+ if (aux_inv) {
+ cmd += 4; /* for the AUX invalidation */
+ cmd += 2; /* for the engine quiescing */
+
+ cmd_flush = MI_FLUSH_DW;
+
+ if (rq->engine->class == COPY_ENGINE_CLASS)
+ cmd_flush |= MI_FLUSH_DW_CCS;
}
cs = intel_ring_begin(rq, cmd);
if (IS_ERR(cs))
return PTR_ERR(cs);
+ if (cmd_flush) {
+ *cs++ = cmd_flush;
+ *cs++ = 0;
+ }
+
if (mode & EMIT_INVALIDATE)
*cs++ = preparser_disable(true);
--
2.40.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v8 8/9] drm/i915/gt: Poll aux invalidation register bit on invalidation
2023-07-21 16:15 [PATCH v8 0/9] Update AUX invalidation sequence Andi Shyti
` (6 preceding siblings ...)
2023-07-21 16:15 ` [PATCH v8 7/9] drm/i915/gt: Ensure memory quiesced before invalidation for all engines Andi Shyti
@ 2023-07-21 16:15 ` Andi Shyti
2023-07-21 16:15 ` [PATCH v8 9/9] drm/i915/gt: Support aux invalidation on all engines Andi Shyti
8 siblings, 0 replies; 25+ messages in thread
From: Andi Shyti @ 2023-07-21 16:15 UTC (permalink / raw)
To: Jonathan Cavitt, Matt Roper, Chris Wilson, Mika Kuoppala,
Nirmoy Das, Andrzej Hajda
Cc: intel-gfx, linux-stable, dri-evel, Andi Shyti
From: Jonathan Cavitt <jonathan.cavitt@intel.com>
For platforms that use Aux CCS, wait for aux invalidation to
complete by checking the aux invalidation register bit is
cleared.
Fixes: 972282c4cf24 ("drm/i915/gen12: Add aux table invalidate for all engines")
Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Cc: <stable@vger.kernel.org> # v5.8+
Reviewed-by: Nirmoy Das <nirmoy.das@intel.com>
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
---
drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 17 ++++++++++++-----
drivers/gpu/drm/i915/gt/intel_gpu_commands.h | 1 +
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
index 646151e1b5deb..6daf7d99700e0 100644
--- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
@@ -185,7 +185,15 @@ u32 *gen12_emit_aux_table_inv(struct intel_gt *gt, u32 *cs, const i915_reg_t inv
*cs++ = MI_LOAD_REGISTER_IMM(1) | MI_LRI_MMIO_REMAP_EN;
*cs++ = i915_mmio_reg_offset(inv_reg) + gsi_offset;
*cs++ = AUX_INV;
- *cs++ = MI_NOOP;
+
+ *cs++ = MI_SEMAPHORE_WAIT_TOKEN |
+ MI_SEMAPHORE_REGISTER_POLL |
+ MI_SEMAPHORE_POLL |
+ MI_SEMAPHORE_SAD_EQ_SDD;
+ *cs++ = 0;
+ *cs++ = i915_mmio_reg_offset(inv_reg) + gsi_offset;
+ *cs++ = 0;
+ *cs++ = 0;
return cs;
}
@@ -297,10 +305,9 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
else if (engine->class == COMPUTE_CLASS)
flags &= ~PIPE_CONTROL_3D_ENGINE_FLAGS;
+ count = 8;
if (gen12_needs_ccs_aux_inv(rq->engine))
- count = 8 + 4;
- else
- count = 8;
+ count += 8;
cs = intel_ring_begin(rq, count);
if (IS_ERR(cs))
@@ -347,7 +354,7 @@ int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode)
* table requires quiescing memory traffic beforehand
*/
if (aux_inv) {
- cmd += 4; /* for the AUX invalidation */
+ cmd += 8; /* for the AUX invalidation */
cmd += 2; /* for the engine quiescing */
cmd_flush = MI_FLUSH_DW;
diff --git a/drivers/gpu/drm/i915/gt/intel_gpu_commands.h b/drivers/gpu/drm/i915/gt/intel_gpu_commands.h
index 5df7cce23197c..2bd8d98d21102 100644
--- a/drivers/gpu/drm/i915/gt/intel_gpu_commands.h
+++ b/drivers/gpu/drm/i915/gt/intel_gpu_commands.h
@@ -121,6 +121,7 @@
#define MI_SEMAPHORE_TARGET(engine) ((engine)<<15)
#define MI_SEMAPHORE_WAIT MI_INSTR(0x1c, 2) /* GEN8+ */
#define MI_SEMAPHORE_WAIT_TOKEN MI_INSTR(0x1c, 3) /* GEN12+ */
+#define MI_SEMAPHORE_REGISTER_POLL (1 << 16)
#define MI_SEMAPHORE_POLL (1 << 15)
#define MI_SEMAPHORE_SAD_GT_SDD (0 << 12)
#define MI_SEMAPHORE_SAD_GTE_SDD (1 << 12)
--
2.40.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v8 9/9] drm/i915/gt: Support aux invalidation on all engines
2023-07-21 16:15 [PATCH v8 0/9] Update AUX invalidation sequence Andi Shyti
` (7 preceding siblings ...)
2023-07-21 16:15 ` [PATCH v8 8/9] drm/i915/gt: Poll aux invalidation register bit on invalidation Andi Shyti
@ 2023-07-21 16:15 ` Andi Shyti
2023-07-24 9:42 ` [Intel-gfx] " Andrzej Hajda
8 siblings, 1 reply; 25+ messages in thread
From: Andi Shyti @ 2023-07-21 16:15 UTC (permalink / raw)
To: Jonathan Cavitt, Matt Roper, Chris Wilson, Mika Kuoppala,
Nirmoy Das, Andrzej Hajda
Cc: intel-gfx, linux-stable, dri-evel, Andi Shyti
Perform some refactoring with the purpose of keeping in one
single place all the operations around the aux table
invalidation.
With this refactoring add more engines where the invalidation
should be performed.
Fixes: 972282c4cf24 ("drm/i915/gen12: Add aux table invalidate for all engines")
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Cc: Jonathan Cavitt <jonathan.cavitt@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: <stable@vger.kernel.org> # v5.8+
---
drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 53 ++++++++++++++----------
drivers/gpu/drm/i915/gt/gen8_engine_cs.h | 3 +-
drivers/gpu/drm/i915/gt/intel_lrc.c | 17 +-------
3 files changed, 36 insertions(+), 37 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
index 6daf7d99700e0..d33462387d1c6 100644
--- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
@@ -178,9 +178,36 @@ static bool gen12_needs_ccs_aux_inv(struct intel_engine_cs *engine)
return !HAS_FLAT_CCS(engine->i915);
}
-u32 *gen12_emit_aux_table_inv(struct intel_gt *gt, u32 *cs, const i915_reg_t inv_reg)
+static i915_reg_t gen12_get_aux_inv_reg(struct intel_engine_cs *engine)
+{
+ if (!gen12_needs_ccs_aux_inv(engine))
+ return INVALID_MMIO_REG;
+
+ switch (engine->id) {
+ case RCS0:
+ return GEN12_CCS_AUX_INV;
+ case BCS0:
+ return GEN12_BCS0_AUX_INV;
+ case VCS0:
+ return GEN12_VD0_AUX_INV;
+ case VCS2:
+ return GEN12_VD2_AUX_INV;
+ case VECS0:
+ return GEN12_VE0_AUX_INV;
+ case CCS0:
+ return GEN12_CCS0_AUX_INV;
+ default:
+ return INVALID_MMIO_REG;
+ }
+}
+
+u32 *gen12_emit_aux_table_inv(struct intel_engine_cs *engine, u32 *cs)
{
- u32 gsi_offset = gt->uncore->gsi_offset;
+ i915_reg_t inv_reg = gen12_get_aux_inv_reg(engine);
+ u32 gsi_offset = engine->gt->uncore->gsi_offset;
+
+ if (i915_mmio_reg_valid(inv_reg))
+ return cs;
*cs++ = MI_LOAD_REGISTER_IMM(1) | MI_LRI_MMIO_REMAP_EN;
*cs++ = i915_mmio_reg_offset(inv_reg) + gsi_offset;
@@ -322,11 +349,7 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
cs = gen8_emit_pipe_control(cs, flags, LRC_PPHWSP_SCRATCH_ADDR);
- if (gen12_needs_ccs_aux_inv(rq->engine)) {
- /* hsdes: 1809175790 */
- cs = gen12_emit_aux_table_inv(rq->engine->gt, cs,
- GEN12_CCS_AUX_INV);
- }
+ cs = gen12_emit_aux_table_inv(engine, cs);
*cs++ = preparser_disable(false);
intel_ring_advance(rq, cs);
@@ -337,7 +360,6 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode)
{
- intel_engine_mask_t aux_inv = 0;
u32 cmd_flush = 0;
u32 cmd = 4;
u32 *cs;
@@ -345,15 +367,11 @@ int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode)
if (mode & EMIT_INVALIDATE)
cmd += 2;
- if (gen12_needs_ccs_aux_inv(rq->engine))
- aux_inv = rq->engine->mask &
- ~GENMASK(_BCS(I915_MAX_BCS - 1), BCS0);
-
/*
* On Aux CCS platforms the invalidation of the Aux
* table requires quiescing memory traffic beforehand
*/
- if (aux_inv) {
+ if (gen12_needs_ccs_aux_inv(rq->engine)) {
cmd += 8; /* for the AUX invalidation */
cmd += 2; /* for the engine quiescing */
@@ -396,14 +414,7 @@ int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode)
*cs++ = 0; /* upper addr */
*cs++ = 0; /* value */
- if (aux_inv) { /* hsdes: 1809175790 */
- if (rq->engine->class == VIDEO_DECODE_CLASS)
- cs = gen12_emit_aux_table_inv(rq->engine->gt,
- cs, GEN12_VD0_AUX_INV);
- else
- cs = gen12_emit_aux_table_inv(rq->engine->gt,
- cs, GEN12_VE0_AUX_INV);
- }
+ cs = gen12_emit_aux_table_inv(rq->engine, cs);
if (mode & EMIT_INVALIDATE)
*cs++ = preparser_disable(false);
diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.h b/drivers/gpu/drm/i915/gt/gen8_engine_cs.h
index a44eda096557c..867ba697aceb8 100644
--- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.h
+++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.h
@@ -13,6 +13,7 @@
#include "intel_gt_regs.h"
#include "intel_gpu_commands.h"
+struct intel_engine_cs;
struct intel_gt;
struct i915_request;
@@ -46,7 +47,7 @@ u32 *gen8_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs);
u32 *gen11_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs);
u32 *gen12_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs);
-u32 *gen12_emit_aux_table_inv(struct intel_gt *gt, u32 *cs, const i915_reg_t inv_reg);
+u32 *gen12_emit_aux_table_inv(struct intel_engine_cs *engine, u32 *cs);
static inline u32 *
__gen8_emit_pipe_control(u32 *batch, u32 bit_group_0,
diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
index 235f3fab60a98..119deb9f938c7 100644
--- a/drivers/gpu/drm/i915/gt/intel_lrc.c
+++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
@@ -1371,10 +1371,7 @@ gen12_emit_indirect_ctx_rcs(const struct intel_context *ce, u32 *cs)
IS_DG2_G11(ce->engine->i915))
cs = gen8_emit_pipe_control(cs, PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE, 0);
- /* hsdes: 1809175790 */
- if (!HAS_FLAT_CCS(ce->engine->i915))
- cs = gen12_emit_aux_table_inv(ce->engine->gt,
- cs, GEN12_CCS_AUX_INV);
+ cs = gen12_emit_aux_table_inv(ce->engine, cs);
/* Wa_16014892111 */
if (IS_MTL_GRAPHICS_STEP(ce->engine->i915, M, STEP_A0, STEP_B0) ||
@@ -1399,17 +1396,7 @@ gen12_emit_indirect_ctx_xcs(const struct intel_context *ce, u32 *cs)
PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE,
0);
- /* hsdes: 1809175790 */
- if (!HAS_FLAT_CCS(ce->engine->i915)) {
- if (ce->engine->class == VIDEO_DECODE_CLASS)
- cs = gen12_emit_aux_table_inv(ce->engine->gt,
- cs, GEN12_VD0_AUX_INV);
- else if (ce->engine->class == VIDEO_ENHANCEMENT_CLASS)
- cs = gen12_emit_aux_table_inv(ce->engine->gt,
- cs, GEN12_VE0_AUX_INV);
- }
-
- return cs;
+ return gen12_emit_aux_table_inv(ce->engine, cs);
}
static void
--
2.40.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH v8 2/9] drm/i915: Add the gen12_needs_ccs_aux_inv helper
2023-07-21 16:15 ` [PATCH v8 2/9] drm/i915: Add the gen12_needs_ccs_aux_inv helper Andi Shyti
@ 2023-07-21 19:12 ` Matt Roper
2023-07-24 7:52 ` Andrzej Hajda
2023-07-24 8:38 ` [Intel-gfx] " Nirmoy Das
2 siblings, 0 replies; 25+ messages in thread
From: Matt Roper @ 2023-07-21 19:12 UTC (permalink / raw)
To: Andi Shyti
Cc: Mika Kuoppala, intel-gfx, Jonathan Cavitt, dri-evel, linux-stable,
Andrzej Hajda, Nirmoy Das
On Fri, Jul 21, 2023 at 06:15:07PM +0200, Andi Shyti wrote:
> We always assumed that a device might either have AUX or FLAT
> CCS, but this is an approximation that is not always true, e.g.
> PVC represents an exception.
>
> Set the basis for future finer selection by implementing a
> boolean gen12_needs_ccs_aux_inv() function that tells whether aux
> invalidation is needed or not.
>
> Currently PVC is the only exception to the above mentioned rule.
>
> Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
> Cc: Matt Roper <matthew.d.roper@intel.com>
> Cc: Jonathan Cavitt <jonathan.cavitt@intel.com>
> Cc: <stable@vger.kernel.org> # v5.8+
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
> ---
> drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> index 563efee055602..460c9225a50fc 100644
> --- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> +++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> @@ -165,6 +165,18 @@ static u32 preparser_disable(bool state)
> return MI_ARB_CHECK | 1 << 8 | state;
> }
>
> +static bool gen12_needs_ccs_aux_inv(struct intel_engine_cs *engine)
> +{
> + if (IS_PONTEVECCHIO(engine->i915))
> + return false;
> +
> + /*
> + * so far platforms supported by i915 having
> + * flat ccs do not require AUX invalidation
> + */
> + return !HAS_FLAT_CCS(engine->i915);
> +}
> +
> u32 *gen12_emit_aux_table_inv(struct intel_gt *gt, u32 *cs, const i915_reg_t inv_reg)
> {
> u32 gsi_offset = gt->uncore->gsi_offset;
> @@ -267,7 +279,7 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
> else if (engine->class == COMPUTE_CLASS)
> flags &= ~PIPE_CONTROL_3D_ENGINE_FLAGS;
>
> - if (!HAS_FLAT_CCS(rq->engine->i915))
> + if (gen12_needs_ccs_aux_inv(rq->engine))
> count = 8 + 4;
> else
> count = 8;
> @@ -285,7 +297,7 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
>
> cs = gen8_emit_pipe_control(cs, flags, LRC_PPHWSP_SCRATCH_ADDR);
>
> - if (!HAS_FLAT_CCS(rq->engine->i915)) {
> + if (gen12_needs_ccs_aux_inv(rq->engine)) {
> /* hsdes: 1809175790 */
> cs = gen12_emit_aux_table_inv(rq->engine->gt, cs,
> GEN12_CCS_AUX_INV);
> @@ -307,7 +319,7 @@ int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode)
> if (mode & EMIT_INVALIDATE) {
> cmd += 2;
>
> - if (!HAS_FLAT_CCS(rq->engine->i915) &&
> + if (gen12_needs_ccs_aux_inv(rq->engine) &&
> (rq->engine->class == VIDEO_DECODE_CLASS ||
> rq->engine->class == VIDEO_ENHANCEMENT_CLASS)) {
> aux_inv = rq->engine->mask &
> --
> 2.40.1
>
--
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v8 5/9] drm/i915/gt: Enable the CCS_FLUSH bit in the pipe control
2023-07-21 16:15 ` [PATCH v8 5/9] drm/i915/gt: Enable the CCS_FLUSH bit in the pipe control Andi Shyti
@ 2023-07-21 19:16 ` Matt Roper
2023-07-24 7:53 ` Andrzej Hajda
2023-07-24 8:47 ` [Intel-gfx] " Nirmoy Das
2 siblings, 0 replies; 25+ messages in thread
From: Matt Roper @ 2023-07-21 19:16 UTC (permalink / raw)
To: Andi Shyti
Cc: Mika Kuoppala, intel-gfx, Jonathan Cavitt, dri-evel, Chris Wilson,
linux-stable, Andrzej Hajda, Nirmoy Das
On Fri, Jul 21, 2023 at 06:15:10PM +0200, Andi Shyti wrote:
> Enable the CCS_FLUSH bit 13 in the control pipe for render and
> compute engines in platforms starting from Meteor Lake (BSPEC
> 43904 and 47112).
>
> Fixes: 972282c4cf24 ("drm/i915/gen12: Add aux table invalidate for all engines")
> Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
> Cc: Jonathan Cavitt <jonathan.cavitt@intel.com>
> Cc: Nirmoy Das <nirmoy.das@intel.com>
> Cc: <stable@vger.kernel.org> # v5.8+
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
> ---
> drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 7 +++++++
> drivers/gpu/drm/i915/gt/intel_gpu_commands.h | 1 +
> 2 files changed, 8 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> index 5d2175e918dd2..139a7e69f5c4d 100644
> --- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> +++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> @@ -230,6 +230,13 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
>
> bit_group_0 |= PIPE_CONTROL0_HDC_PIPELINE_FLUSH;
>
> + /*
> + * When required, in MTL and beyond platforms we
> + * need to set the CCS_FLUSH bit in the pipe control
> + */
> + if (GRAPHICS_VER_FULL(rq->i915) >= IP_VER(12, 70))
> + bit_group_0 |= PIPE_CONTROL_CCS_FLUSH;
> +
> bit_group_1 |= PIPE_CONTROL_TILE_CACHE_FLUSH;
> bit_group_1 |= PIPE_CONTROL_FLUSH_L3;
> bit_group_1 |= PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH;
> diff --git a/drivers/gpu/drm/i915/gt/intel_gpu_commands.h b/drivers/gpu/drm/i915/gt/intel_gpu_commands.h
> index 5d143e2a8db03..5df7cce23197c 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gpu_commands.h
> +++ b/drivers/gpu/drm/i915/gt/intel_gpu_commands.h
> @@ -299,6 +299,7 @@
> #define PIPE_CONTROL_QW_WRITE (1<<14)
> #define PIPE_CONTROL_POST_SYNC_OP_MASK (3<<14)
> #define PIPE_CONTROL_DEPTH_STALL (1<<13)
> +#define PIPE_CONTROL_CCS_FLUSH (1<<13) /* MTL+ */
> #define PIPE_CONTROL_WRITE_FLUSH (1<<12)
> #define PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH (1<<12) /* gen6+ */
> #define PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE (1<<11) /* MBZ on ILK */
> --
> 2.40.1
>
--
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v8 2/9] drm/i915: Add the gen12_needs_ccs_aux_inv helper
2023-07-21 16:15 ` [PATCH v8 2/9] drm/i915: Add the gen12_needs_ccs_aux_inv helper Andi Shyti
2023-07-21 19:12 ` Matt Roper
@ 2023-07-24 7:52 ` Andrzej Hajda
2023-07-24 8:38 ` [Intel-gfx] " Nirmoy Das
2 siblings, 0 replies; 25+ messages in thread
From: Andrzej Hajda @ 2023-07-24 7:52 UTC (permalink / raw)
To: Andi Shyti, Jonathan Cavitt, Matt Roper, Chris Wilson,
Mika Kuoppala, Nirmoy Das
Cc: intel-gfx, linux-stable, dri-evel
On 21.07.2023 18:15, Andi Shyti wrote:
> We always assumed that a device might either have AUX or FLAT
> CCS, but this is an approximation that is not always true, e.g.
> PVC represents an exception.
>
> Set the basis for future finer selection by implementing a
> boolean gen12_needs_ccs_aux_inv() function that tells whether aux
> invalidation is needed or not.
>
> Currently PVC is the only exception to the above mentioned rule.
>
> Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
> Cc: Matt Roper <matthew.d.roper@intel.com>
> Cc: Jonathan Cavitt <jonathan.cavitt@intel.com>
> Cc: <stable@vger.kernel.org> # v5.8+
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Regards
Andrzej
> ---
> drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> index 563efee055602..460c9225a50fc 100644
> --- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> +++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> @@ -165,6 +165,18 @@ static u32 preparser_disable(bool state)
> return MI_ARB_CHECK | 1 << 8 | state;
> }
>
> +static bool gen12_needs_ccs_aux_inv(struct intel_engine_cs *engine)
> +{
> + if (IS_PONTEVECCHIO(engine->i915))
> + return false;
> +
> + /*
> + * so far platforms supported by i915 having
> + * flat ccs do not require AUX invalidation
> + */
> + return !HAS_FLAT_CCS(engine->i915);
> +}
> +
> u32 *gen12_emit_aux_table_inv(struct intel_gt *gt, u32 *cs, const i915_reg_t inv_reg)
> {
> u32 gsi_offset = gt->uncore->gsi_offset;
> @@ -267,7 +279,7 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
> else if (engine->class == COMPUTE_CLASS)
> flags &= ~PIPE_CONTROL_3D_ENGINE_FLAGS;
>
> - if (!HAS_FLAT_CCS(rq->engine->i915))
> + if (gen12_needs_ccs_aux_inv(rq->engine))
> count = 8 + 4;
> else
> count = 8;
> @@ -285,7 +297,7 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
>
> cs = gen8_emit_pipe_control(cs, flags, LRC_PPHWSP_SCRATCH_ADDR);
>
> - if (!HAS_FLAT_CCS(rq->engine->i915)) {
> + if (gen12_needs_ccs_aux_inv(rq->engine)) {
> /* hsdes: 1809175790 */
> cs = gen12_emit_aux_table_inv(rq->engine->gt, cs,
> GEN12_CCS_AUX_INV);
> @@ -307,7 +319,7 @@ int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode)
> if (mode & EMIT_INVALIDATE) {
> cmd += 2;
>
> - if (!HAS_FLAT_CCS(rq->engine->i915) &&
> + if (gen12_needs_ccs_aux_inv(rq->engine) &&
> (rq->engine->class == VIDEO_DECODE_CLASS ||
> rq->engine->class == VIDEO_ENHANCEMENT_CLASS)) {
> aux_inv = rq->engine->mask &
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v8 5/9] drm/i915/gt: Enable the CCS_FLUSH bit in the pipe control
2023-07-21 16:15 ` [PATCH v8 5/9] drm/i915/gt: Enable the CCS_FLUSH bit in the pipe control Andi Shyti
2023-07-21 19:16 ` Matt Roper
@ 2023-07-24 7:53 ` Andrzej Hajda
2023-07-24 8:47 ` [Intel-gfx] " Nirmoy Das
2 siblings, 0 replies; 25+ messages in thread
From: Andrzej Hajda @ 2023-07-24 7:53 UTC (permalink / raw)
To: Andi Shyti, Jonathan Cavitt, Matt Roper, Chris Wilson,
Mika Kuoppala, Nirmoy Das
Cc: intel-gfx, linux-stable, dri-evel
On 21.07.2023 18:15, Andi Shyti wrote:
> Enable the CCS_FLUSH bit 13 in the control pipe for render and
> compute engines in platforms starting from Meteor Lake (BSPEC
> 43904 and 47112).
>
> Fixes: 972282c4cf24 ("drm/i915/gen12: Add aux table invalidate for all engines")
> Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
> Cc: Jonathan Cavitt <jonathan.cavitt@intel.com>
> Cc: Nirmoy Das <nirmoy.das@intel.com>
> Cc: <stable@vger.kernel.org> # v5.8+
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Regards
Andrzej
> ---
> drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 7 +++++++
> drivers/gpu/drm/i915/gt/intel_gpu_commands.h | 1 +
> 2 files changed, 8 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> index 5d2175e918dd2..139a7e69f5c4d 100644
> --- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> +++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> @@ -230,6 +230,13 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
>
> bit_group_0 |= PIPE_CONTROL0_HDC_PIPELINE_FLUSH;
>
> + /*
> + * When required, in MTL and beyond platforms we
> + * need to set the CCS_FLUSH bit in the pipe control
> + */
> + if (GRAPHICS_VER_FULL(rq->i915) >= IP_VER(12, 70))
> + bit_group_0 |= PIPE_CONTROL_CCS_FLUSH;
> +
> bit_group_1 |= PIPE_CONTROL_TILE_CACHE_FLUSH;
> bit_group_1 |= PIPE_CONTROL_FLUSH_L3;
> bit_group_1 |= PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH;
> diff --git a/drivers/gpu/drm/i915/gt/intel_gpu_commands.h b/drivers/gpu/drm/i915/gt/intel_gpu_commands.h
> index 5d143e2a8db03..5df7cce23197c 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gpu_commands.h
> +++ b/drivers/gpu/drm/i915/gt/intel_gpu_commands.h
> @@ -299,6 +299,7 @@
> #define PIPE_CONTROL_QW_WRITE (1<<14)
> #define PIPE_CONTROL_POST_SYNC_OP_MASK (3<<14)
> #define PIPE_CONTROL_DEPTH_STALL (1<<13)
> +#define PIPE_CONTROL_CCS_FLUSH (1<<13) /* MTL+ */
> #define PIPE_CONTROL_WRITE_FLUSH (1<<12)
> #define PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH (1<<12) /* gen6+ */
> #define PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE (1<<11) /* MBZ on ILK */
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v8 6/9] drm/i915/gt: Refactor intel_emit_pipe_control_cs() in a single function
2023-07-21 16:15 ` [PATCH v8 6/9] drm/i915/gt: Refactor intel_emit_pipe_control_cs() in a single function Andi Shyti
@ 2023-07-24 7:54 ` Andrzej Hajda
2023-07-24 9:07 ` Nirmoy Das
1 sibling, 0 replies; 25+ messages in thread
From: Andrzej Hajda @ 2023-07-24 7:54 UTC (permalink / raw)
To: Andi Shyti, Jonathan Cavitt, Matt Roper, Chris Wilson,
Mika Kuoppala, Nirmoy Das
Cc: intel-gfx, linux-stable, dri-evel
On 21.07.2023 18:15, Andi Shyti wrote:
> Just a trivial refactoring for reducing the number of code
> duplicate. This will come at handy in the next commits.
>
> Meantime, propagate the error to the above layers if we fail to
> emit the pipe control.
>
> Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
> Cc: <stable@vger.kernel.org> # v5.8+
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Regards
Andrzej
> ---
> drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 47 +++++++++++++-----------
> 1 file changed, 26 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> index 139a7e69f5c4d..5e19b45a5cabe 100644
> --- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> +++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> @@ -7,6 +7,7 @@
> #include "i915_drv.h"
> #include "intel_engine_regs.h"
> #include "intel_gpu_commands.h"
> +#include "intel_gt_print.h"
> #include "intel_lrc.h"
> #include "intel_ring.h"
>
> @@ -189,23 +190,30 @@ u32 *gen12_emit_aux_table_inv(struct intel_gt *gt, u32 *cs, const i915_reg_t inv
> return cs;
> }
>
> +static int gen12_emit_pipe_control_cs(struct i915_request *rq, u32 bit_group_0,
> + u32 bit_group_1, u32 offset)
> +{
> + u32 *cs;
> +
> + cs = intel_ring_begin(rq, 6);
> + if (IS_ERR(cs))
> + return PTR_ERR(cs);
> +
> + cs = gen12_emit_pipe_control(cs, bit_group_0, bit_group_1,
> + LRC_PPHWSP_SCRATCH_ADDR);
> + intel_ring_advance(rq, cs);
> +
> + return 0;
> +}
> +
> static int mtl_dummy_pipe_control(struct i915_request *rq)
> {
> /* Wa_14016712196 */
> if (IS_MTL_GRAPHICS_STEP(rq->engine->i915, M, STEP_A0, STEP_B0) ||
> - IS_MTL_GRAPHICS_STEP(rq->engine->i915, P, STEP_A0, STEP_B0)) {
> - u32 *cs;
> -
> - /* dummy PIPE_CONTROL + depth flush */
> - cs = intel_ring_begin(rq, 6);
> - if (IS_ERR(cs))
> - return PTR_ERR(cs);
> - cs = gen12_emit_pipe_control(cs,
> - 0,
> - PIPE_CONTROL_DEPTH_CACHE_FLUSH,
> - LRC_PPHWSP_SCRATCH_ADDR);
> - intel_ring_advance(rq, cs);
> - }
> + IS_MTL_GRAPHICS_STEP(rq->engine->i915, P, STEP_A0, STEP_B0))
> + return gen12_emit_pipe_control_cs(rq, 0,
> + PIPE_CONTROL_DEPTH_CACHE_FLUSH,
> + LRC_PPHWSP_SCRATCH_ADDR);
>
> return 0;
> }
> @@ -222,7 +230,6 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
> u32 bit_group_0 = 0;
> u32 bit_group_1 = 0;
> int err;
> - u32 *cs;
>
> err = mtl_dummy_pipe_control(rq);
> if (err)
> @@ -256,13 +263,11 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
> else if (engine->class == COMPUTE_CLASS)
> bit_group_1 &= ~PIPE_CONTROL_3D_ENGINE_FLAGS;
>
> - cs = intel_ring_begin(rq, 6);
> - if (IS_ERR(cs))
> - return PTR_ERR(cs);
> -
> - cs = gen12_emit_pipe_control(cs, bit_group_0, bit_group_1,
> - LRC_PPHWSP_SCRATCH_ADDR);
> - intel_ring_advance(rq, cs);
> + err = gen12_emit_pipe_control_cs(rq, bit_group_0, bit_group_1,
> + LRC_PPHWSP_SCRATCH_ADDR);
> + if (err)
> + gt_warn(engine->gt,
> + "Failed to emit flush pipe control\n");
> }
>
> if (mode & EMIT_INVALIDATE) {
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v8 7/9] drm/i915/gt: Ensure memory quiesced before invalidation for all engines
2023-07-21 16:15 ` [PATCH v8 7/9] drm/i915/gt: Ensure memory quiesced before invalidation for all engines Andi Shyti
@ 2023-07-24 8:19 ` Andrzej Hajda
2023-07-24 9:14 ` Andi Shyti
0 siblings, 1 reply; 25+ messages in thread
From: Andrzej Hajda @ 2023-07-24 8:19 UTC (permalink / raw)
To: Andi Shyti, Jonathan Cavitt, Matt Roper, Chris Wilson,
Mika Kuoppala, Nirmoy Das
Cc: intel-gfx, linux-stable, dri-evel
On 21.07.2023 18:15, Andi Shyti wrote:
> Commit af9e423a8aae ("drm/i915/gt: Ensure memory quiesced before
> invalidation") has made sure that the memory is quiesced before
> invalidating the AUX CCS table. Do it for all the other engines
> and not just RCS.
>
> Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
> Cc: Jonathan Cavitt <jonathan.cavitt@intel.com>
> Cc: Matt Roper <matthew.d.roper@intel.com>
> Cc: <stable@vger.kernel.org> # v5.8+
> ---
> drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 36 ++++++++++++++++--------
> 1 file changed, 25 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> index 5e19b45a5cabe..646151e1b5deb 100644
> --- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> +++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> @@ -331,26 +331,40 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
> int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode)
> {
> intel_engine_mask_t aux_inv = 0;
> - u32 cmd, *cs;
> + u32 cmd_flush = 0;
> + u32 cmd = 4;
> + u32 *cs;
>
> - cmd = 4;
> - if (mode & EMIT_INVALIDATE) {
> + if (mode & EMIT_INVALIDATE)
> cmd += 2;
>
> - if (gen12_needs_ccs_aux_inv(rq->engine) &&
> - (rq->engine->class == VIDEO_DECODE_CLASS ||
> - rq->engine->class == VIDEO_ENHANCEMENT_CLASS)) {
> - aux_inv = rq->engine->mask &
> - ~GENMASK(_BCS(I915_MAX_BCS - 1), BCS0);
> - if (aux_inv)
> - cmd += 4;
> - }
> + if (gen12_needs_ccs_aux_inv(rq->engine))
> + aux_inv = rq->engine->mask &
> + ~GENMASK(_BCS(I915_MAX_BCS - 1), BCS0);
Shouldn't we remove BCS check for MTL? And move it inside
gen12_needs_ccs_aux_inv?
Btw aux_inv is used as bool, make better is to make it bool.
Regards
Andrzej
> +
> + /*
> + * On Aux CCS platforms the invalidation of the Aux
> + * table requires quiescing memory traffic beforehand
> + */
> + if (aux_inv) {
> + cmd += 4; /* for the AUX invalidation */
> + cmd += 2; /* for the engine quiescing */
> +
> + cmd_flush = MI_FLUSH_DW;
> +
> + if (rq->engine->class == COPY_ENGINE_CLASS)
> + cmd_flush |= MI_FLUSH_DW_CCS;
> }
>
> cs = intel_ring_begin(rq, cmd);
> if (IS_ERR(cs))
> return PTR_ERR(cs);
>
> + if (cmd_flush) {
> + *cs++ = cmd_flush;
> + *cs++ = 0;
> + }
> +
> if (mode & EMIT_INVALIDATE)
> *cs++ = preparser_disable(true);
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [Intel-gfx] [PATCH v8 2/9] drm/i915: Add the gen12_needs_ccs_aux_inv helper
2023-07-21 16:15 ` [PATCH v8 2/9] drm/i915: Add the gen12_needs_ccs_aux_inv helper Andi Shyti
2023-07-21 19:12 ` Matt Roper
2023-07-24 7:52 ` Andrzej Hajda
@ 2023-07-24 8:38 ` Nirmoy Das
2 siblings, 0 replies; 25+ messages in thread
From: Nirmoy Das @ 2023-07-24 8:38 UTC (permalink / raw)
To: Andi Shyti, Jonathan Cavitt, Matt Roper, Chris Wilson,
Mika Kuoppala, Nirmoy Das, Andrzej Hajda
Cc: intel-gfx, dri-evel, linux-stable
[-- Attachment #1: Type: text/plain, Size: 2684 bytes --]
On 7/21/2023 6:15 PM, Andi Shyti wrote:
> We always assumed that a device might either have AUX or FLAT
> CCS, but this is an approximation that is not always true, e.g.
> PVC represents an exception.
>
> Set the basis for future finer selection by implementing a
> boolean gen12_needs_ccs_aux_inv() function that tells whether aux
> invalidation is needed or not.
>
> Currently PVC is the only exception to the above mentioned rule.
>
> Signed-off-by: Andi Shyti<andi.shyti@linux.intel.com>
> Cc: Matt Roper<matthew.d.roper@intel.com>
> Cc: Jonathan Cavitt<jonathan.cavitt@intel.com>
> Cc:<stable@vger.kernel.org> # v5.8+
|Reviewed-by: Nirmoy Das <nirmoy.das@intel.com>|
> ---
> drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> index 563efee055602..460c9225a50fc 100644
> --- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> +++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> @@ -165,6 +165,18 @@ static u32 preparser_disable(bool state)
> return MI_ARB_CHECK | 1 << 8 | state;
> }
>
> +static bool gen12_needs_ccs_aux_inv(struct intel_engine_cs *engine)
> +{
> + if (IS_PONTEVECCHIO(engine->i915))
> + return false;
> +
> + /*
> + * so far platforms supported by i915 having
> + * flat ccs do not require AUX invalidation
> + */
> + return !HAS_FLAT_CCS(engine->i915);
> +}
> +
> u32 *gen12_emit_aux_table_inv(struct intel_gt *gt, u32 *cs, const i915_reg_t inv_reg)
> {
> u32 gsi_offset = gt->uncore->gsi_offset;
> @@ -267,7 +279,7 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
> else if (engine->class == COMPUTE_CLASS)
> flags &= ~PIPE_CONTROL_3D_ENGINE_FLAGS;
>
> - if (!HAS_FLAT_CCS(rq->engine->i915))
> + if (gen12_needs_ccs_aux_inv(rq->engine))
> count = 8 + 4;
> else
> count = 8;
> @@ -285,7 +297,7 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
>
> cs = gen8_emit_pipe_control(cs, flags, LRC_PPHWSP_SCRATCH_ADDR);
>
> - if (!HAS_FLAT_CCS(rq->engine->i915)) {
> + if (gen12_needs_ccs_aux_inv(rq->engine)) {
> /* hsdes: 1809175790 */
> cs = gen12_emit_aux_table_inv(rq->engine->gt, cs,
> GEN12_CCS_AUX_INV);
> @@ -307,7 +319,7 @@ int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode)
> if (mode & EMIT_INVALIDATE) {
> cmd += 2;
>
> - if (!HAS_FLAT_CCS(rq->engine->i915) &&
> + if (gen12_needs_ccs_aux_inv(rq->engine) &&
> (rq->engine->class == VIDEO_DECODE_CLASS ||
> rq->engine->class == VIDEO_ENHANCEMENT_CLASS)) {
> aux_inv = rq->engine->mask &
[-- Attachment #2: Type: text/html, Size: 3687 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [Intel-gfx] [PATCH v8 5/9] drm/i915/gt: Enable the CCS_FLUSH bit in the pipe control
2023-07-21 16:15 ` [PATCH v8 5/9] drm/i915/gt: Enable the CCS_FLUSH bit in the pipe control Andi Shyti
2023-07-21 19:16 ` Matt Roper
2023-07-24 7:53 ` Andrzej Hajda
@ 2023-07-24 8:47 ` Nirmoy Das
2 siblings, 0 replies; 25+ messages in thread
From: Nirmoy Das @ 2023-07-24 8:47 UTC (permalink / raw)
To: Andi Shyti, Jonathan Cavitt, Matt Roper, Chris Wilson,
Mika Kuoppala, Nirmoy Das, Andrzej Hajda
Cc: intel-gfx, dri-evel, linux-stable
[-- Attachment #1: Type: text/plain, Size: 2153 bytes --]
On 7/21/2023 6:15 PM, Andi Shyti wrote:
> Enable the CCS_FLUSH bit 13 in the control pipe for render and
> compute engines in platforms starting from Meteor Lake (BSPEC
> 43904 and 47112).
>
> Fixes: 972282c4cf24 ("drm/i915/gen12: Add aux table invalidate for all engines")
> Signed-off-by: Andi Shyti<andi.shyti@linux.intel.com>
> Cc: Jonathan Cavitt<jonathan.cavitt@intel.com>
> Cc: Nirmoy Das<nirmoy.das@intel.com>
> Cc:<stable@vger.kernel.org> # v5.8+
|Reviewed-by: Nirmoy Das <nirmoy.das@intel.com> |
> ---
> drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 7 +++++++
> drivers/gpu/drm/i915/gt/intel_gpu_commands.h | 1 +
> 2 files changed, 8 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> index 5d2175e918dd2..139a7e69f5c4d 100644
> --- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> +++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> @@ -230,6 +230,13 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
>
> bit_group_0 |= PIPE_CONTROL0_HDC_PIPELINE_FLUSH;
>
> + /*
> + * When required, in MTL and beyond platforms we
> + * need to set the CCS_FLUSH bit in the pipe control
> + */
> + if (GRAPHICS_VER_FULL(rq->i915) >= IP_VER(12, 70))
> + bit_group_0 |= PIPE_CONTROL_CCS_FLUSH;
> +
> bit_group_1 |= PIPE_CONTROL_TILE_CACHE_FLUSH;
> bit_group_1 |= PIPE_CONTROL_FLUSH_L3;
> bit_group_1 |= PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH;
> diff --git a/drivers/gpu/drm/i915/gt/intel_gpu_commands.h b/drivers/gpu/drm/i915/gt/intel_gpu_commands.h
> index 5d143e2a8db03..5df7cce23197c 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gpu_commands.h
> +++ b/drivers/gpu/drm/i915/gt/intel_gpu_commands.h
> @@ -299,6 +299,7 @@
> #define PIPE_CONTROL_QW_WRITE (1<<14)
> #define PIPE_CONTROL_POST_SYNC_OP_MASK (3<<14)
> #define PIPE_CONTROL_DEPTH_STALL (1<<13)
> +#define PIPE_CONTROL_CCS_FLUSH (1<<13) /* MTL+ */
> #define PIPE_CONTROL_WRITE_FLUSH (1<<12)
> #define PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH (1<<12) /* gen6+ */
> #define PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE (1<<11) /* MBZ on ILK */
[-- Attachment #2: Type: text/html, Size: 3191 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v8 6/9] drm/i915/gt: Refactor intel_emit_pipe_control_cs() in a single function
2023-07-21 16:15 ` [PATCH v8 6/9] drm/i915/gt: Refactor intel_emit_pipe_control_cs() in a single function Andi Shyti
2023-07-24 7:54 ` Andrzej Hajda
@ 2023-07-24 9:07 ` Nirmoy Das
2023-07-24 9:16 ` Andi Shyti
1 sibling, 1 reply; 25+ messages in thread
From: Nirmoy Das @ 2023-07-24 9:07 UTC (permalink / raw)
To: Andi Shyti, Jonathan Cavitt, Matt Roper, Chris Wilson,
Mika Kuoppala, Nirmoy Das, Andrzej Hajda
Cc: intel-gfx, dri-evel, linux-stable
[-- Attachment #1: Type: text/plain, Size: 3323 bytes --]
Hi Andi,
On 7/21/2023 6:15 PM, Andi Shyti wrote:
> Just a trivial refactoring for reducing the number of code
> duplicate. This will come at handy in the next commits.
>
> Meantime, propagate the error to the above layers if we fail to
> emit the pipe control.
>
> Signed-off-by: Andi Shyti<andi.shyti@linux.intel.com>
> Cc:<stable@vger.kernel.org> # v5.8+
> ---
> drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 47 +++++++++++++-----------
> 1 file changed, 26 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> index 139a7e69f5c4d..5e19b45a5cabe 100644
> --- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> +++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> @@ -7,6 +7,7 @@
> #include "i915_drv.h"
> #include "intel_engine_regs.h"
> #include "intel_gpu_commands.h"
> +#include "intel_gt_print.h"
> #include "intel_lrc.h"
> #include "intel_ring.h"
>
> @@ -189,23 +190,30 @@ u32 *gen12_emit_aux_table_inv(struct intel_gt *gt, u32 *cs, const i915_reg_t inv
> return cs;
> }
>
> +static int gen12_emit_pipe_control_cs(struct i915_request *rq, u32 bit_group_0,
> + u32 bit_group_1, u32 offset)
> +{
> + u32 *cs;
> +
> + cs = intel_ring_begin(rq, 6);
> + if (IS_ERR(cs))
> + return PTR_ERR(cs);
> +
> + cs = gen12_emit_pipe_control(cs, bit_group_0, bit_group_1,
> + LRC_PPHWSP_SCRATCH_ADDR);
> + intel_ring_advance(rq, cs);
> +
> + return 0;
> +}
> +
> static int mtl_dummy_pipe_control(struct i915_request *rq)
> {
> /* Wa_14016712196 */
> if (IS_MTL_GRAPHICS_STEP(rq->engine->i915, M, STEP_A0, STEP_B0) ||
> - IS_MTL_GRAPHICS_STEP(rq->engine->i915, P, STEP_A0, STEP_B0)) {
> - u32 *cs;
> -
> - /* dummy PIPE_CONTROL + depth flush */
> - cs = intel_ring_begin(rq, 6);
> - if (IS_ERR(cs))
> - return PTR_ERR(cs);
> - cs = gen12_emit_pipe_control(cs,
> - 0,
> - PIPE_CONTROL_DEPTH_CACHE_FLUSH,
> - LRC_PPHWSP_SCRATCH_ADDR);
> - intel_ring_advance(rq, cs);
> - }
> + IS_MTL_GRAPHICS_STEP(rq->engine->i915, P, STEP_A0, STEP_B0))
> + return gen12_emit_pipe_control_cs(rq, 0,
> + PIPE_CONTROL_DEPTH_CACHE_FLUSH,
> + LRC_PPHWSP_SCRATCH_ADDR);
Don't think this will get backported to 5.8+. I think mtl introduced
after that.
If that is not an issue for rest of the series and then
|Reviewed-by: Nirmoy Das <nirmoy.das@intel.com> Regards, Nirmoy |
>
> return 0;
> }
> @@ -222,7 +230,6 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
> u32 bit_group_0 = 0;
> u32 bit_group_1 = 0;
> int err;
> - u32 *cs;
>
> err = mtl_dummy_pipe_control(rq);
> if (err)
> @@ -256,13 +263,11 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
> else if (engine->class == COMPUTE_CLASS)
> bit_group_1 &= ~PIPE_CONTROL_3D_ENGINE_FLAGS;
>
> - cs = intel_ring_begin(rq, 6);
> - if (IS_ERR(cs))
> - return PTR_ERR(cs);
> -
> - cs = gen12_emit_pipe_control(cs, bit_group_0, bit_group_1,
> - LRC_PPHWSP_SCRATCH_ADDR);
> - intel_ring_advance(rq, cs);
> + err = gen12_emit_pipe_control_cs(rq, bit_group_0, bit_group_1,
> + LRC_PPHWSP_SCRATCH_ADDR);
> + if (err)
> + gt_warn(engine->gt,
> + "Failed to emit flush pipe control\n");
> }
>
> if (mode & EMIT_INVALIDATE) {
[-- Attachment #2: Type: text/html, Size: 4089 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v8 7/9] drm/i915/gt: Ensure memory quiesced before invalidation for all engines
2023-07-24 8:19 ` Andrzej Hajda
@ 2023-07-24 9:14 ` Andi Shyti
2023-07-24 9:17 ` Andrzej Hajda
0 siblings, 1 reply; 25+ messages in thread
From: Andi Shyti @ 2023-07-24 9:14 UTC (permalink / raw)
To: Andrzej Hajda
Cc: Mika Kuoppala, intel-gfx, Jonathan Cavitt, dri-evel, Chris Wilson,
linux-stable, Andi Shyti, Matt Roper, Nirmoy Das
Hi Andrzej,
> > intel_engine_mask_t aux_inv = 0;
> > - u32 cmd, *cs;
> > + u32 cmd_flush = 0;
> > + u32 cmd = 4;
> > + u32 *cs;
> > - cmd = 4;
> > - if (mode & EMIT_INVALIDATE) {
> > + if (mode & EMIT_INVALIDATE)
> > cmd += 2;
> > - if (gen12_needs_ccs_aux_inv(rq->engine) &&
> > - (rq->engine->class == VIDEO_DECODE_CLASS ||
> > - rq->engine->class == VIDEO_ENHANCEMENT_CLASS)) {
> > - aux_inv = rq->engine->mask &
> > - ~GENMASK(_BCS(I915_MAX_BCS - 1), BCS0);
> > - if (aux_inv)
> > - cmd += 4;
> > - }
> > + if (gen12_needs_ccs_aux_inv(rq->engine))
> > + aux_inv = rq->engine->mask &
> > + ~GENMASK(_BCS(I915_MAX_BCS - 1), BCS0);
>
> Shouldn't we remove BCS check for MTL? And move it inside
> gen12_needs_ccs_aux_inv?
> Btw aux_inv is used as bool, make better is to make it bool.
Both the cleanups come in patch 9. I wanted to move it initially
before, but per engine check come later in the series.
I think would need to re-architecture all the patch structure if
I want to remove it :)
Are you strong with this change?
Andi
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v8 6/9] drm/i915/gt: Refactor intel_emit_pipe_control_cs() in a single function
2023-07-24 9:07 ` Nirmoy Das
@ 2023-07-24 9:16 ` Andi Shyti
2023-07-24 9:37 ` Nirmoy Das
0 siblings, 1 reply; 25+ messages in thread
From: Andi Shyti @ 2023-07-24 9:16 UTC (permalink / raw)
To: Nirmoy Das
Cc: Andrzej Hajda, Mika Kuoppala, intel-gfx, Jonathan Cavitt,
linux-stable, Chris Wilson, dri-evel, Andi Shyti, Matt Roper,
Nirmoy Das
Hi Nirmoy,
> static int mtl_dummy_pipe_control(struct i915_request *rq)
> {
> /* Wa_14016712196 */
> if (IS_MTL_GRAPHICS_STEP(rq->engine->i915, M, STEP_A0, STEP_B0) ||
> - IS_MTL_GRAPHICS_STEP(rq->engine->i915, P, STEP_A0, STEP_B0)) {
> - u32 *cs;
> -
> - /* dummy PIPE_CONTROL + depth flush */
> - cs = intel_ring_begin(rq, 6);
> - if (IS_ERR(cs))
> - return PTR_ERR(cs);
> - cs = gen12_emit_pipe_control(cs,
> - 0,
> - PIPE_CONTROL_DEPTH_CACHE_FLUSH,
> - LRC_PPHWSP_SCRATCH_ADDR);
> - intel_ring_advance(rq, cs);
> - }
> + IS_MTL_GRAPHICS_STEP(rq->engine->i915, P, STEP_A0, STEP_B0))
> + return gen12_emit_pipe_control_cs(rq, 0,
> + PIPE_CONTROL_DEPTH_CACHE_FLUSH,
> + LRC_PPHWSP_SCRATCH_ADDR);
>
> Don't think this will get backported to 5.8+. I think mtl introduced after
> that.
>
> If that is not an issue for rest of the series and then
to be honest I don't think I fully understood the stable
policies, as in this series only two are the patches that are
really fixing things and the rest are only support.
In this case I think this will produce a conflict that will be
eventually fixed (... I guess!).
> Reviewed-by: Nirmoy Das <nirmoy.das@intel.com>
Thanks,
Andi
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v8 7/9] drm/i915/gt: Ensure memory quiesced before invalidation for all engines
2023-07-24 9:14 ` Andi Shyti
@ 2023-07-24 9:17 ` Andrzej Hajda
0 siblings, 0 replies; 25+ messages in thread
From: Andrzej Hajda @ 2023-07-24 9:17 UTC (permalink / raw)
To: Andi Shyti
Cc: Mika Kuoppala, intel-gfx, Jonathan Cavitt, dri-evel, Chris Wilson,
linux-stable, Matt Roper, Nirmoy Das
On 24.07.2023 11:14, Andi Shyti wrote:
> Hi Andrzej,
>
>>> intel_engine_mask_t aux_inv = 0;
>>> - u32 cmd, *cs;
>>> + u32 cmd_flush = 0;
>>> + u32 cmd = 4;
>>> + u32 *cs;
>>> - cmd = 4;
>>> - if (mode & EMIT_INVALIDATE) {
>>> + if (mode & EMIT_INVALIDATE)
>>> cmd += 2;
>>> - if (gen12_needs_ccs_aux_inv(rq->engine) &&
>>> - (rq->engine->class == VIDEO_DECODE_CLASS ||
>>> - rq->engine->class == VIDEO_ENHANCEMENT_CLASS)) {
>>> - aux_inv = rq->engine->mask &
>>> - ~GENMASK(_BCS(I915_MAX_BCS - 1), BCS0);
>>> - if (aux_inv)
>>> - cmd += 4;
>>> - }
>>> + if (gen12_needs_ccs_aux_inv(rq->engine))
>>> + aux_inv = rq->engine->mask &
>>> + ~GENMASK(_BCS(I915_MAX_BCS - 1), BCS0);
>> Shouldn't we remove BCS check for MTL? And move it inside
>> gen12_needs_ccs_aux_inv?
>> Btw aux_inv is used as bool, make better is to make it bool.
> Both the cleanups come in patch 9. I wanted to move it initially
> before, but per engine check come later in the series.
>
> I think would need to re-architecture all the patch structure if
> I want to remove it :)
>
> Are you strong with this change?
Nope, if it finally arrives then OK for me.
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Regards
Andrzej
>
> Andi
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v8 6/9] drm/i915/gt: Refactor intel_emit_pipe_control_cs() in a single function
2023-07-24 9:16 ` Andi Shyti
@ 2023-07-24 9:37 ` Nirmoy Das
0 siblings, 0 replies; 25+ messages in thread
From: Nirmoy Das @ 2023-07-24 9:37 UTC (permalink / raw)
To: Andi Shyti, Nirmoy Das
Cc: Mika Kuoppala, intel-gfx, Jonathan Cavitt, linux-stable,
Chris Wilson, dri-evel, Andrzej Hajda, Matt Roper
Hi Andi
On 7/24/2023 11:16 AM, Andi Shyti wrote:
> Hi Nirmoy,
>
>> static int mtl_dummy_pipe_control(struct i915_request *rq)
>> {
>> /* Wa_14016712196 */
>> if (IS_MTL_GRAPHICS_STEP(rq->engine->i915, M, STEP_A0, STEP_B0) ||
>> - IS_MTL_GRAPHICS_STEP(rq->engine->i915, P, STEP_A0, STEP_B0)) {
>> - u32 *cs;
>> -
>> - /* dummy PIPE_CONTROL + depth flush */
>> - cs = intel_ring_begin(rq, 6);
>> - if (IS_ERR(cs))
>> - return PTR_ERR(cs);
>> - cs = gen12_emit_pipe_control(cs,
>> - 0,
>> - PIPE_CONTROL_DEPTH_CACHE_FLUSH,
>> - LRC_PPHWSP_SCRATCH_ADDR);
>> - intel_ring_advance(rq, cs);
>> - }
>> + IS_MTL_GRAPHICS_STEP(rq->engine->i915, P, STEP_A0, STEP_B0))
>> + return gen12_emit_pipe_control_cs(rq, 0,
>> + PIPE_CONTROL_DEPTH_CACHE_FLUSH,
>> + LRC_PPHWSP_SCRATCH_ADDR);
>>
>> Don't think this will get backported to 5.8+. I think mtl introduced after
>> that.
>>
>> If that is not an issue for rest of the series and then
> to be honest I don't think I fully understood the stable
> policies, as in this series only two are the patches that are
> really fixing things and the rest are only support.
>
> In this case I think this will produce a conflict that will be
> eventually fixed (... I guess!).
As far as I know, it is developer responsibility to port the patch to
stable version if there is conflict.
Regards,
Nirmoy
>
>> Reviewed-by: Nirmoy Das <nirmoy.das@intel.com>
> Thanks,
> Andi
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [Intel-gfx] [PATCH v8 9/9] drm/i915/gt: Support aux invalidation on all engines
2023-07-21 16:15 ` [PATCH v8 9/9] drm/i915/gt: Support aux invalidation on all engines Andi Shyti
@ 2023-07-24 9:42 ` Andrzej Hajda
2023-07-24 14:35 ` Andi Shyti
0 siblings, 1 reply; 25+ messages in thread
From: Andrzej Hajda @ 2023-07-24 9:42 UTC (permalink / raw)
To: Andi Shyti, Jonathan Cavitt, Matt Roper, Chris Wilson,
Mika Kuoppala, Nirmoy Das
Cc: intel-gfx, dri-evel, linux-stable
On 21.07.2023 18:15, Andi Shyti wrote:
> Perform some refactoring with the purpose of keeping in one
> single place all the operations around the aux table
> invalidation.
>
> With this refactoring add more engines where the invalidation
> should be performed.
>
> Fixes: 972282c4cf24 ("drm/i915/gen12: Add aux table invalidate for all engines")
> Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
> Cc: Jonathan Cavitt <jonathan.cavitt@intel.com>
> Cc: Matt Roper <matthew.d.roper@intel.com>
> Cc: <stable@vger.kernel.org> # v5.8+
> ---
> drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 53 ++++++++++++++----------
> drivers/gpu/drm/i915/gt/gen8_engine_cs.h | 3 +-
> drivers/gpu/drm/i915/gt/intel_lrc.c | 17 +-------
> 3 files changed, 36 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> index 6daf7d99700e0..d33462387d1c6 100644
> --- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> +++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> @@ -178,9 +178,36 @@ static bool gen12_needs_ccs_aux_inv(struct intel_engine_cs *engine)
> return !HAS_FLAT_CCS(engine->i915);
> }
>
> -u32 *gen12_emit_aux_table_inv(struct intel_gt *gt, u32 *cs, const i915_reg_t inv_reg)
> +static i915_reg_t gen12_get_aux_inv_reg(struct intel_engine_cs *engine)
> +{
> + if (!gen12_needs_ccs_aux_inv(engine))
> + return INVALID_MMIO_REG;
> +
> + switch (engine->id) {
> + case RCS0:
> + return GEN12_CCS_AUX_INV;
> + case BCS0:
> + return GEN12_BCS0_AUX_INV;
Shouldn't be MTL only?
With that explained/fixed:
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Regards
Andrzej
> + case VCS0:
> + return GEN12_VD0_AUX_INV;
> + case VCS2:
> + return GEN12_VD2_AUX_INV;
> + case VECS0:
> + return GEN12_VE0_AUX_INV;
> + case CCS0:
> + return GEN12_CCS0_AUX_INV;
> + default:
> + return INVALID_MMIO_REG;
> + }
> +}
> +
> +u32 *gen12_emit_aux_table_inv(struct intel_engine_cs *engine, u32 *cs)
> {
> - u32 gsi_offset = gt->uncore->gsi_offset;
> + i915_reg_t inv_reg = gen12_get_aux_inv_reg(engine);
> + u32 gsi_offset = engine->gt->uncore->gsi_offset;
> +
> + if (i915_mmio_reg_valid(inv_reg))
> + return cs;
>
> *cs++ = MI_LOAD_REGISTER_IMM(1) | MI_LRI_MMIO_REMAP_EN;
> *cs++ = i915_mmio_reg_offset(inv_reg) + gsi_offset;
> @@ -322,11 +349,7 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
>
> cs = gen8_emit_pipe_control(cs, flags, LRC_PPHWSP_SCRATCH_ADDR);
>
> - if (gen12_needs_ccs_aux_inv(rq->engine)) {
> - /* hsdes: 1809175790 */
> - cs = gen12_emit_aux_table_inv(rq->engine->gt, cs,
> - GEN12_CCS_AUX_INV);
> - }
> + cs = gen12_emit_aux_table_inv(engine, cs);
>
> *cs++ = preparser_disable(false);
> intel_ring_advance(rq, cs);
> @@ -337,7 +360,6 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
>
> int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode)
> {
> - intel_engine_mask_t aux_inv = 0;
> u32 cmd_flush = 0;
> u32 cmd = 4;
> u32 *cs;
> @@ -345,15 +367,11 @@ int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode)
> if (mode & EMIT_INVALIDATE)
> cmd += 2;
>
> - if (gen12_needs_ccs_aux_inv(rq->engine))
> - aux_inv = rq->engine->mask &
> - ~GENMASK(_BCS(I915_MAX_BCS - 1), BCS0);
> -
> /*
> * On Aux CCS platforms the invalidation of the Aux
> * table requires quiescing memory traffic beforehand
> */
> - if (aux_inv) {
> + if (gen12_needs_ccs_aux_inv(rq->engine)) {
> cmd += 8; /* for the AUX invalidation */
> cmd += 2; /* for the engine quiescing */
>
> @@ -396,14 +414,7 @@ int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode)
> *cs++ = 0; /* upper addr */
> *cs++ = 0; /* value */
>
> - if (aux_inv) { /* hsdes: 1809175790 */
> - if (rq->engine->class == VIDEO_DECODE_CLASS)
> - cs = gen12_emit_aux_table_inv(rq->engine->gt,
> - cs, GEN12_VD0_AUX_INV);
> - else
> - cs = gen12_emit_aux_table_inv(rq->engine->gt,
> - cs, GEN12_VE0_AUX_INV);
> - }
> + cs = gen12_emit_aux_table_inv(rq->engine, cs);
>
> if (mode & EMIT_INVALIDATE)
> *cs++ = preparser_disable(false);
> diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.h b/drivers/gpu/drm/i915/gt/gen8_engine_cs.h
> index a44eda096557c..867ba697aceb8 100644
> --- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.h
> +++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.h
> @@ -13,6 +13,7 @@
> #include "intel_gt_regs.h"
> #include "intel_gpu_commands.h"
>
> +struct intel_engine_cs;
> struct intel_gt;
> struct i915_request;
>
> @@ -46,7 +47,7 @@ u32 *gen8_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs);
> u32 *gen11_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs);
> u32 *gen12_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs);
>
> -u32 *gen12_emit_aux_table_inv(struct intel_gt *gt, u32 *cs, const i915_reg_t inv_reg);
> +u32 *gen12_emit_aux_table_inv(struct intel_engine_cs *engine, u32 *cs);
>
> static inline u32 *
> __gen8_emit_pipe_control(u32 *batch, u32 bit_group_0,
> diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
> index 235f3fab60a98..119deb9f938c7 100644
> --- a/drivers/gpu/drm/i915/gt/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
> @@ -1371,10 +1371,7 @@ gen12_emit_indirect_ctx_rcs(const struct intel_context *ce, u32 *cs)
> IS_DG2_G11(ce->engine->i915))
> cs = gen8_emit_pipe_control(cs, PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE, 0);
>
> - /* hsdes: 1809175790 */
> - if (!HAS_FLAT_CCS(ce->engine->i915))
> - cs = gen12_emit_aux_table_inv(ce->engine->gt,
> - cs, GEN12_CCS_AUX_INV);
> + cs = gen12_emit_aux_table_inv(ce->engine, cs);
>
> /* Wa_16014892111 */
> if (IS_MTL_GRAPHICS_STEP(ce->engine->i915, M, STEP_A0, STEP_B0) ||
> @@ -1399,17 +1396,7 @@ gen12_emit_indirect_ctx_xcs(const struct intel_context *ce, u32 *cs)
> PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE,
> 0);
>
> - /* hsdes: 1809175790 */
> - if (!HAS_FLAT_CCS(ce->engine->i915)) {
> - if (ce->engine->class == VIDEO_DECODE_CLASS)
> - cs = gen12_emit_aux_table_inv(ce->engine->gt,
> - cs, GEN12_VD0_AUX_INV);
> - else if (ce->engine->class == VIDEO_ENHANCEMENT_CLASS)
> - cs = gen12_emit_aux_table_inv(ce->engine->gt,
> - cs, GEN12_VE0_AUX_INV);
> - }
> -
> - return cs;
> + return gen12_emit_aux_table_inv(ce->engine, cs);
> }
>
> static void
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [Intel-gfx] [PATCH v8 9/9] drm/i915/gt: Support aux invalidation on all engines
2023-07-24 9:42 ` [Intel-gfx] " Andrzej Hajda
@ 2023-07-24 14:35 ` Andi Shyti
0 siblings, 0 replies; 25+ messages in thread
From: Andi Shyti @ 2023-07-24 14:35 UTC (permalink / raw)
To: Andrzej Hajda
Cc: Mika Kuoppala, intel-gfx, Jonathan Cavitt, linux-stable,
Chris Wilson, dri-evel, Andi Shyti, Matt Roper, Nirmoy Das
Hi Andrzej,
On Mon, Jul 24, 2023 at 11:42:16AM +0200, Andrzej Hajda wrote:
> On 21.07.2023 18:15, Andi Shyti wrote:
> > Perform some refactoring with the purpose of keeping in one
> > single place all the operations around the aux table
> > invalidation.
> >
> > With this refactoring add more engines where the invalidation
> > should be performed.
> >
> > Fixes: 972282c4cf24 ("drm/i915/gen12: Add aux table invalidate for all engines")
> > Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
> > Cc: Jonathan Cavitt <jonathan.cavitt@intel.com>
> > Cc: Matt Roper <matthew.d.roper@intel.com>
> > Cc: <stable@vger.kernel.org> # v5.8+
> > ---
> > drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 53 ++++++++++++++----------
> > drivers/gpu/drm/i915/gt/gen8_engine_cs.h | 3 +-
> > drivers/gpu/drm/i915/gt/intel_lrc.c | 17 +-------
> > 3 files changed, 36 insertions(+), 37 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> > index 6daf7d99700e0..d33462387d1c6 100644
> > --- a/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> > +++ b/drivers/gpu/drm/i915/gt/gen8_engine_cs.c
> > @@ -178,9 +178,36 @@ static bool gen12_needs_ccs_aux_inv(struct intel_engine_cs *engine)
> > return !HAS_FLAT_CCS(engine->i915);
> > }
> > -u32 *gen12_emit_aux_table_inv(struct intel_gt *gt, u32 *cs, const i915_reg_t inv_reg)
> > +static i915_reg_t gen12_get_aux_inv_reg(struct intel_engine_cs *engine)
> > +{
> > + if (!gen12_needs_ccs_aux_inv(engine))
> > + return INVALID_MMIO_REG;
> > +
> > + switch (engine->id) {
> > + case RCS0:
> > + return GEN12_CCS_AUX_INV;
> > + case BCS0:
> > + return GEN12_BCS0_AUX_INV;
>
> Shouldn't be MTL only?
> With that explained/fixed:
this is actually difficult to be called by the wrong engine, so
that the MTL check is a bit pedantic... I can still add it
though.
> Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Thanks,
Andi
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2023-07-24 14:35 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-21 16:15 [PATCH v8 0/9] Update AUX invalidation sequence Andi Shyti
2023-07-21 16:15 ` [PATCH v8 1/9] drm/i915/gt: Cleanup aux invalidation registers Andi Shyti
2023-07-21 16:15 ` [PATCH v8 2/9] drm/i915: Add the gen12_needs_ccs_aux_inv helper Andi Shyti
2023-07-21 19:12 ` Matt Roper
2023-07-24 7:52 ` Andrzej Hajda
2023-07-24 8:38 ` [Intel-gfx] " Nirmoy Das
2023-07-21 16:15 ` [PATCH v8 3/9] drm/i915/gt: Ensure memory quiesced before invalidation Andi Shyti
2023-07-21 16:15 ` [PATCH v8 4/9] drm/i915/gt: Rename flags with bit_group_X according to the datasheet Andi Shyti
2023-07-21 16:15 ` [PATCH v8 5/9] drm/i915/gt: Enable the CCS_FLUSH bit in the pipe control Andi Shyti
2023-07-21 19:16 ` Matt Roper
2023-07-24 7:53 ` Andrzej Hajda
2023-07-24 8:47 ` [Intel-gfx] " Nirmoy Das
2023-07-21 16:15 ` [PATCH v8 6/9] drm/i915/gt: Refactor intel_emit_pipe_control_cs() in a single function Andi Shyti
2023-07-24 7:54 ` Andrzej Hajda
2023-07-24 9:07 ` Nirmoy Das
2023-07-24 9:16 ` Andi Shyti
2023-07-24 9:37 ` Nirmoy Das
2023-07-21 16:15 ` [PATCH v8 7/9] drm/i915/gt: Ensure memory quiesced before invalidation for all engines Andi Shyti
2023-07-24 8:19 ` Andrzej Hajda
2023-07-24 9:14 ` Andi Shyti
2023-07-24 9:17 ` Andrzej Hajda
2023-07-21 16:15 ` [PATCH v8 8/9] drm/i915/gt: Poll aux invalidation register bit on invalidation Andi Shyti
2023-07-21 16:15 ` [PATCH v8 9/9] drm/i915/gt: Support aux invalidation on all engines Andi Shyti
2023-07-24 9:42 ` [Intel-gfx] " Andrzej Hajda
2023-07-24 14:35 ` Andi Shyti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).