All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V4 00/13] Enable FW assisted shadowing for GFX11
@ 2023-03-30 19:17 Alex Deucher
  2023-03-30 19:17 ` [PATCH 01/13] drm/amdgpu/gfx11: add FW version check for new CP GFX shadow feature Alex Deucher
                   ` (12 more replies)
  0 siblings, 13 replies; 33+ messages in thread
From: Alex Deucher @ 2023-03-30 19:17 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher

This patch set allows for FW assisted shadowing on supported
platforms.  A new enough CP FW is required.  This feature is
required for mid command buffer preemption and proper SR-IOV
support.  This also simplifies the UMDs by allowing persistent
hardware state when the command submission executes.  UMDs
that use this will have their state retained across command
submissions.

The mesa MR to implement the user mode side of this is:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21986

v2: Integrate feedback from V1.  UMDs now need to specify init_shadow
    on first use.
v3: switch back to legacy mode before fence signalling, fix debugfs
    subsequent MQD access.
v4: Minor code cleanups

Alex Deucher (11):
  drm/amdgpu/gfx11: add FW version check for new CP GFX shadow feature
  drm/amdgpu/gfx11: check the CP FW version CP GFX shadow support
  drm/amdgpu/UAPI: add new CS chunk for GFX shadow buffers
  drm/amdgpu: don't require a job for cond_exec and shadow
  drm/amdgpu: add UAPI to query GFX shadow sizes
  drm/amdgpu: add gfx shadow callback
  drm/amdgpu: add get_gfx_shadow_info callback for gfx11
  drm/amdgpu: add support for new GFX shadow size query
  drm/amdgpu: bump driver version number for CP GFX shadow
  drm/amdgpu: track MQD size for gfx and compute
  drm/amdgpu: add debugfs interface for reading MQDs

Christian König (2):
  drm/amdgpu: add gfx shadow CS IOCTL support
  drm/amdgpu: add gfx11 emit shadow callback

 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c   | 26 +++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c  |  3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c  |  2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h  | 12 +++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c   | 31 ++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.h  |  6 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c  | 13 +++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 60 ++++++++++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h |  4 ++
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c   | 69 ++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/nvd.h         |  5 +-
 include/uapi/drm/amdgpu_drm.h            | 18 +++++++
 12 files changed, 244 insertions(+), 5 deletions(-)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 01/13] drm/amdgpu/gfx11: add FW version check for new CP GFX shadow feature
  2023-03-30 19:17 [PATCH V4 00/13] Enable FW assisted shadowing for GFX11 Alex Deucher
@ 2023-03-30 19:17 ` Alex Deucher
  2023-03-30 19:17 ` [PATCH 02/13] drm/amdgpu/gfx11: check the CP FW version CP GFX shadow support Alex Deucher
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 33+ messages in thread
From: Alex Deucher @ 2023-03-30 19:17 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher

Use this to determine if we support the new SET_Q_PREEMPTION_MODE
packet.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h |  2 ++
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c  | 13 +++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
index de9e7a00bb15..4ad9e225d6e6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
@@ -364,6 +364,8 @@ struct amdgpu_gfx {
 
 	struct amdgpu_ring		sw_gfx_ring[AMDGPU_MAX_SW_GFX_RINGS];
 	struct amdgpu_ring_mux          muxer;
+
+	bool				cp_gfx_shadow; /* for gfx11 */
 };
 
 #define amdgpu_gfx_get_gpu_clock_counter(adev) (adev)->gfx.funcs->get_gpu_clock_counter((adev))
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
index ecf8ceb53311..a0d830dc0d01 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
@@ -463,6 +463,18 @@ static int gfx_v11_0_init_toc_microcode(struct amdgpu_device *adev, const char *
 	return err;
 }
 
+static void gfx_v11_0_check_fw_cp_gfx_shadow(struct amdgpu_device *adev)
+{
+	switch (adev->ip_versions[GC_HWIP][0]) {
+	case IP_VERSION(11, 0, 0):
+	case IP_VERSION(11, 0, 2):
+	case IP_VERSION(11, 0, 3):
+	default:
+		adev->gfx.cp_gfx_shadow = false;
+		break;
+	}
+}
+
 static int gfx_v11_0_init_microcode(struct amdgpu_device *adev)
 {
 	char fw_name[40];
@@ -539,6 +551,7 @@ static int gfx_v11_0_init_microcode(struct amdgpu_device *adev)
 	/* only one MEC for gfx 11.0.0. */
 	adev->gfx.mec2_fw = NULL;
 
+	gfx_v11_0_check_fw_cp_gfx_shadow(adev);
 out:
 	if (err) {
 		amdgpu_ucode_release(&adev->gfx.pfp_fw);
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 02/13] drm/amdgpu/gfx11: check the CP FW version CP GFX shadow support
  2023-03-30 19:17 [PATCH V4 00/13] Enable FW assisted shadowing for GFX11 Alex Deucher
  2023-03-30 19:17 ` [PATCH 01/13] drm/amdgpu/gfx11: add FW version check for new CP GFX shadow feature Alex Deucher
@ 2023-03-30 19:17 ` Alex Deucher
  2023-03-31  6:34   ` Christian König
  2023-03-30 19:17 ` [PATCH 03/13] drm/amdgpu/UAPI: add new CS chunk for GFX shadow buffers Alex Deucher
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 33+ messages in thread
From: Alex Deucher @ 2023-03-30 19:17 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher, Christian König

Only set the supported flag if we have new enough CP FW.

XXX: don't commit this until the CP FW versions are finalized!

Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
index a0d830dc0d01..4a50d0fbcdcf 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
@@ -469,6 +469,15 @@ static void gfx_v11_0_check_fw_cp_gfx_shadow(struct amdgpu_device *adev)
 	case IP_VERSION(11, 0, 0):
 	case IP_VERSION(11, 0, 2):
 	case IP_VERSION(11, 0, 3):
+		/* XXX fix me! */
+		if ((adev->gfx.me_fw_version >= 1498) &&
+		    (adev->gfx.me_feature_version >= 29) &&
+		    (adev->gfx.pfp_fw_version >= 1541) &&
+		    (adev->gfx.pfp_feature_version >= 29) &&
+		    (adev->gfx.mec_fw_version >= 507) &&
+		    (adev->gfx.mec_feature_version >= 29))
+			adev->gfx.cp_gfx_shadow = true;
+		break;
 	default:
 		adev->gfx.cp_gfx_shadow = false;
 		break;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 03/13] drm/amdgpu/UAPI: add new CS chunk for GFX shadow buffers
  2023-03-30 19:17 [PATCH V4 00/13] Enable FW assisted shadowing for GFX11 Alex Deucher
  2023-03-30 19:17 ` [PATCH 01/13] drm/amdgpu/gfx11: add FW version check for new CP GFX shadow feature Alex Deucher
  2023-03-30 19:17 ` [PATCH 02/13] drm/amdgpu/gfx11: check the CP FW version CP GFX shadow support Alex Deucher
@ 2023-03-30 19:17 ` Alex Deucher
  2023-04-06  7:36   ` Marek Olšák
  2023-03-30 19:17 ` [PATCH 04/13] drm/amdgpu: add gfx shadow CS IOCTL support Alex Deucher
                   ` (9 subsequent siblings)
  12 siblings, 1 reply; 33+ messages in thread
From: Alex Deucher @ 2023-03-30 19:17 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher, Christian König

For GFX11, the UMD needs to allocate some shadow buffers
to be used for preemption.  The UMD allocates the buffers
and passes the GPU virtual address to the kernel since the
kernel will program the packet that specified these
addresses as part of its IB submission frame.

v2: UMD passes shadow init to tell kernel when to initialize
    the shadow

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 include/uapi/drm/amdgpu_drm.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
index b6eb90df5d05..3d9474af6566 100644
--- a/include/uapi/drm/amdgpu_drm.h
+++ b/include/uapi/drm/amdgpu_drm.h
@@ -592,6 +592,7 @@ struct drm_amdgpu_gem_va {
 #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES	0x07
 #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT    0x08
 #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL  0x09
+#define AMDGPU_CHUNK_ID_CP_GFX_SHADOW   0x0a
 
 struct drm_amdgpu_cs_chunk {
 	__u32		chunk_id;
@@ -708,6 +709,15 @@ struct drm_amdgpu_cs_chunk_data {
 	};
 };
 
+#define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW         0x1
+
+struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
+	__u64 shadow_va;
+	__u64 csa_va;
+	__u64 gds_va;
+	__u64 flags;
+};
+
 /*
  *  Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
  *
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 04/13] drm/amdgpu: add gfx shadow CS IOCTL support
  2023-03-30 19:17 [PATCH V4 00/13] Enable FW assisted shadowing for GFX11 Alex Deucher
                   ` (2 preceding siblings ...)
  2023-03-30 19:17 ` [PATCH 03/13] drm/amdgpu/UAPI: add new CS chunk for GFX shadow buffers Alex Deucher
@ 2023-03-30 19:17 ` Alex Deucher
  2023-03-31  6:33   ` Christian König
  2023-03-30 19:17 ` [PATCH 05/13] drm/amdgpu: add gfx11 emit shadow callback Alex Deucher
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 33+ messages in thread
From: Alex Deucher @ 2023-03-30 19:17 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher, Christian König

From: Christian König <christian.koenig@amd.com>

Add support for submitting the shadow update packet
when submitting an IB.  Needed for MCBP on GFX11.

v2: update API for CSA (Alex)
v3: fix ordering; SET_Q_PREEMPTION_MODE most come before COND_EXEC
    Add missing check for AMDGPU_CHUNK_ID_CP_GFX_SHADOW in
    amdgpu_cs_pass1()
    Only initialize shadow on first use
    (Alex)
v4: Pass parameters rather than job to new ring callback (Alex)
v5: squash in change to call SET_Q_PREEMPTION_MODE/COND_EXEC
    before RELEASE_MEM to complete the UMDs use of the shadow (Alex)

Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c   | 26 +++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c   | 29 +++++++++++++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.h  |  6 +++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h |  3 +++
 4 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 47763ac0d14a..41bd3a1a1989 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -281,6 +281,7 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p,
 		case AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES:
 		case AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT:
 		case AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL:
+		case AMDGPU_CHUNK_ID_CP_GFX_SHADOW:
 			break;
 
 		default:
@@ -583,6 +584,26 @@ static int amdgpu_cs_p2_syncobj_timeline_signal(struct amdgpu_cs_parser *p,
 	return 0;
 }
 
+static int amdgpu_cs_p2_shadow(struct amdgpu_cs_parser *p,
+			       struct amdgpu_cs_chunk *chunk)
+{
+	struct drm_amdgpu_cs_chunk_cp_gfx_shadow *shadow = chunk->kdata;
+	int i;
+
+	if (shadow->flags & ~AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW)
+		return -EINVAL;
+
+	for (i = 0; i < p->gang_size; ++i) {
+		p->jobs[i]->shadow_va = shadow->shadow_va;
+		p->jobs[i]->csa_va = shadow->csa_va;
+		p->jobs[i]->gds_va = shadow->gds_va;
+		p->jobs[i]->init_shadow =
+			shadow->flags & AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW;
+	}
+
+	return 0;
+}
+
 static int amdgpu_cs_pass2(struct amdgpu_cs_parser *p)
 {
 	unsigned int ce_preempt = 0, de_preempt = 0;
@@ -625,6 +646,11 @@ static int amdgpu_cs_pass2(struct amdgpu_cs_parser *p)
 			if (r)
 				return r;
 			break;
+		case AMDGPU_CHUNK_ID_CP_GFX_SHADOW:
+			r = amdgpu_cs_p2_shadow(p, chunk);
+			if (r)
+				return r;
+			break;
 		}
 	}
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
index bcccc348dbe2..9bee630eb0c9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
@@ -136,7 +136,9 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
 	uint64_t fence_ctx;
 	uint32_t status = 0, alloc_size;
 	unsigned fence_flags = 0;
-	bool secure;
+	bool secure, init_shadow;
+	u64 shadow_va, csa_va, gds_va;
+	int vmid = AMDGPU_JOB_GET_VMID(job);
 
 	unsigned i;
 	int r = 0;
@@ -150,9 +152,17 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
 		vm = job->vm;
 		fence_ctx = job->base.s_fence ?
 			job->base.s_fence->scheduled.context : 0;
+		shadow_va = job->shadow_va;
+		csa_va = job->csa_va;
+		gds_va = job->gds_va;
+		init_shadow = job->init_shadow;
 	} else {
 		vm = NULL;
 		fence_ctx = 0;
+		shadow_va = 0;
+		csa_va = 0;
+		gds_va = 0;
+		init_shadow = false;
 	}
 
 	if (!ring->sched.ready && !ring->is_mes_queue) {
@@ -212,6 +222,11 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
 	}
 
 	amdgpu_ring_ib_begin(ring);
+
+	if (job && ring->funcs->emit_gfx_shadow)
+		amdgpu_ring_emit_gfx_shadow(ring, shadow_va, csa_va, gds_va,
+					    init_shadow, vmid);
+
 	if (job && ring->funcs->init_cond_exec)
 		patch_offset = amdgpu_ring_init_cond_exec(ring);
 
@@ -263,6 +278,18 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
 				       fence_flags | AMDGPU_FENCE_FLAG_64BIT);
 	}
 
+	if (ring->funcs->emit_gfx_shadow) {
+		amdgpu_ring_emit_gfx_shadow(ring, 0, 0, 0, false, 0);
+
+		if (ring->funcs->init_cond_exec) {
+			unsigned ce_offset = ~0;
+
+			ce_offset = amdgpu_ring_init_cond_exec(ring);
+			if (ce_offset != ~0 && ring->funcs->patch_cond_exec)
+				amdgpu_ring_patch_cond_exec(ring, ce_offset);
+		}
+	}
+
 	r = amdgpu_fence_emit(ring, f, job, fence_flags);
 	if (r) {
 		dev_err(adev->dev, "failed to emit fence (%d)\n", r);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h
index 52f2e313ea17..3f9804f956c9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h
@@ -67,6 +67,12 @@ struct amdgpu_job {
 	uint64_t		uf_addr;
 	uint64_t		uf_sequence;
 
+	/* virtual addresses for shadow/GDS/CSA */
+	uint64_t		shadow_va;
+	uint64_t		csa_va;
+	uint64_t		gds_va;
+	bool			init_shadow;
+
 	/* job_run_counter >= 1 means a resubmit job */
 	uint32_t		job_run_counter;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
index 3989e755a5b4..7942cb62e52c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
@@ -212,6 +212,8 @@ struct amdgpu_ring_funcs {
 	void (*end_use)(struct amdgpu_ring *ring);
 	void (*emit_switch_buffer) (struct amdgpu_ring *ring);
 	void (*emit_cntxcntl) (struct amdgpu_ring *ring, uint32_t flags);
+	void (*emit_gfx_shadow)(struct amdgpu_ring *ring, u64 shadow_va, u64 csa_va,
+				u64 gds_va, bool init_shadow, int vmid);
 	void (*emit_rreg)(struct amdgpu_ring *ring, uint32_t reg,
 			  uint32_t reg_val_offs);
 	void (*emit_wreg)(struct amdgpu_ring *ring, uint32_t reg, uint32_t val);
@@ -307,6 +309,7 @@ struct amdgpu_ring {
 #define amdgpu_ring_emit_hdp_flush(r) (r)->funcs->emit_hdp_flush((r))
 #define amdgpu_ring_emit_switch_buffer(r) (r)->funcs->emit_switch_buffer((r))
 #define amdgpu_ring_emit_cntxcntl(r, d) (r)->funcs->emit_cntxcntl((r), (d))
+#define amdgpu_ring_emit_gfx_shadow(r, s, c, g, i, v) (r)->funcs->emit_gfx_shadow((r), (s), (c), (g), (i), (v))
 #define amdgpu_ring_emit_rreg(r, d, o) (r)->funcs->emit_rreg((r), (d), (o))
 #define amdgpu_ring_emit_wreg(r, d, v) (r)->funcs->emit_wreg((r), (d), (v))
 #define amdgpu_ring_emit_reg_wait(r, d, v, m) (r)->funcs->emit_reg_wait((r), (d), (v), (m))
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 05/13] drm/amdgpu: add gfx11 emit shadow callback
  2023-03-30 19:17 [PATCH V4 00/13] Enable FW assisted shadowing for GFX11 Alex Deucher
                   ` (3 preceding siblings ...)
  2023-03-30 19:17 ` [PATCH 04/13] drm/amdgpu: add gfx shadow CS IOCTL support Alex Deucher
@ 2023-03-30 19:17 ` Alex Deucher
  2023-03-30 19:17 ` [PATCH 06/13] drm/amdgpu: don't require a job for cond_exec and shadow Alex Deucher
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 33+ messages in thread
From: Alex Deucher @ 2023-03-30 19:17 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher, Christian König

From: Christian König <christian.koenig@amd.com>

Add ring callback for gfx to update the CP firmware
with the new shadow information before we process the
IB.

v2: add implementation for new packet (Alex)
v3: add current FW version checks (Alex)
v4: only initialize shadow on first use
    Only set IB_VMID when a valid shadow buffer is present
    (Alex)
v5: Pass parameters rather than job to new ring callback (Alex)

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 25 +++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/nvd.h       |  5 ++++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
index 4a50d0fbcdcf..1fc1e941f7df 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
@@ -5598,6 +5598,29 @@ static void gfx_v11_0_ring_emit_cntxcntl(struct amdgpu_ring *ring,
 	amdgpu_ring_write(ring, 0);
 }
 
+static void gfx_v11_0_ring_emit_gfx_shadow(struct amdgpu_ring *ring,
+					   u64 shadow_va, u64 csa_va,
+					   u64 gds_va, bool init_shadow,
+					   int vmid)
+{
+	struct amdgpu_device *adev = ring->adev;
+
+	if (!adev->gfx.cp_gfx_shadow)
+		return;
+
+	amdgpu_ring_write(ring, PACKET3(PACKET3_SET_Q_PREEMPTION_MODE, 7));
+	amdgpu_ring_write(ring, lower_32_bits(shadow_va));
+	amdgpu_ring_write(ring, upper_32_bits(shadow_va));
+	amdgpu_ring_write(ring, lower_32_bits(gds_va));
+	amdgpu_ring_write(ring, upper_32_bits(gds_va));
+	amdgpu_ring_write(ring, lower_32_bits(csa_va));
+	amdgpu_ring_write(ring, upper_32_bits(csa_va));
+	amdgpu_ring_write(ring, shadow_va ?
+			  PACKET3_SET_Q_PREEMPTION_MODE_IB_VMID(vmid): 0);
+	amdgpu_ring_write(ring, init_shadow ?
+			  PACKET3_SET_Q_PREEMPTION_MODE_INIT_SHADOW_MEM : 0);
+}
+
 static unsigned gfx_v11_0_ring_emit_init_cond_exec(struct amdgpu_ring *ring)
 {
 	unsigned ret;
@@ -6219,6 +6242,7 @@ static const struct amdgpu_ring_funcs gfx_v11_0_ring_funcs_gfx = {
 	.set_wptr = gfx_v11_0_ring_set_wptr_gfx,
 	.emit_frame_size = /* totally 242 maximum if 16 IBs */
 		5 + /* COND_EXEC */
+		9 + /* SET_Q_PREEMPTION_MODE */
 		7 + /* PIPELINE_SYNC */
 		SOC15_FLUSH_GPU_TLB_NUM_WREG * 5 +
 		SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 7 +
@@ -6245,6 +6269,7 @@ static const struct amdgpu_ring_funcs gfx_v11_0_ring_funcs_gfx = {
 	.insert_nop = amdgpu_ring_insert_nop,
 	.pad_ib = amdgpu_ring_generic_pad_ib,
 	.emit_cntxcntl = gfx_v11_0_ring_emit_cntxcntl,
+	.emit_gfx_shadow = gfx_v11_0_ring_emit_gfx_shadow,
 	.init_cond_exec = gfx_v11_0_ring_emit_init_cond_exec,
 	.patch_cond_exec = gfx_v11_0_ring_emit_patch_cond_exec,
 	.preempt_ib = gfx_v11_0_ring_preempt_ib,
diff --git a/drivers/gpu/drm/amd/amdgpu/nvd.h b/drivers/gpu/drm/amd/amdgpu/nvd.h
index fd6b58243b03..631dafb92299 100644
--- a/drivers/gpu/drm/amd/amdgpu/nvd.h
+++ b/drivers/gpu/drm/amd/amdgpu/nvd.h
@@ -462,6 +462,9 @@
 #              define PACKET3_QUERY_STATUS_ENG_SEL(x)          ((x) << 25)
 #define	PACKET3_RUN_LIST				0xA5
 #define	PACKET3_MAP_PROCESS_VM				0xA6
-
+/* GFX11 */
+#define	PACKET3_SET_Q_PREEMPTION_MODE			0xF0
+#              define PACKET3_SET_Q_PREEMPTION_MODE_IB_VMID(x)  ((x) << 0)
+#              define PACKET3_SET_Q_PREEMPTION_MODE_INIT_SHADOW_MEM    (1 << 0)
 
 #endif
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 06/13] drm/amdgpu: don't require a job for cond_exec and shadow
  2023-03-30 19:17 [PATCH V4 00/13] Enable FW assisted shadowing for GFX11 Alex Deucher
                   ` (4 preceding siblings ...)
  2023-03-30 19:17 ` [PATCH 05/13] drm/amdgpu: add gfx11 emit shadow callback Alex Deucher
@ 2023-03-30 19:17 ` Alex Deucher
  2023-03-30 19:17 ` [PATCH 07/13] drm/amdgpu: add UAPI to query GFX shadow sizes Alex Deucher
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 33+ messages in thread
From: Alex Deucher @ 2023-03-30 19:17 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher, Christian König

We need to reset the shadow state every time we submit an
IB and there needs to be a COND_EXEC packet after the
SET_Q_PREEMPTION_MODE packet for it to work properly, so
we should emit both of these packets regardless of whether
there is a job present or not.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
index 9bee630eb0c9..7f4c198ac483 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
@@ -223,11 +223,11 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
 
 	amdgpu_ring_ib_begin(ring);
 
-	if (job && ring->funcs->emit_gfx_shadow)
+	if (ring->funcs->emit_gfx_shadow)
 		amdgpu_ring_emit_gfx_shadow(ring, shadow_va, csa_va, gds_va,
 					    init_shadow, vmid);
 
-	if (job && ring->funcs->init_cond_exec)
+	if (ring->funcs->init_cond_exec)
 		patch_offset = amdgpu_ring_init_cond_exec(ring);
 
 	amdgpu_device_flush_hdp(adev, ring);
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 07/13] drm/amdgpu: add UAPI to query GFX shadow sizes
  2023-03-30 19:17 [PATCH V4 00/13] Enable FW assisted shadowing for GFX11 Alex Deucher
                   ` (5 preceding siblings ...)
  2023-03-30 19:17 ` [PATCH 06/13] drm/amdgpu: don't require a job for cond_exec and shadow Alex Deucher
@ 2023-03-30 19:17 ` Alex Deucher
  2023-03-30 19:17 ` [PATCH 08/13] drm/amdgpu: add gfx shadow callback Alex Deucher
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 33+ messages in thread
From: Alex Deucher @ 2023-03-30 19:17 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher, Marek Olšák

Add UAPI to query the GFX shadow buffer requirements
for preemption on GFX11.  UMDs need to specify the shadow
areas for preemption.

v2: move into existing asic info query
    drop GDS as its use is determined by the UMD (Marek)
v3: Update comments to note that alignment is base
    virtual alignment (Alex)

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 include/uapi/drm/amdgpu_drm.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
index 3d9474af6566..72041a51cc27 100644
--- a/include/uapi/drm/amdgpu_drm.h
+++ b/include/uapi/drm/amdgpu_drm.h
@@ -1136,6 +1136,14 @@ struct drm_amdgpu_info_device {
 	__u64 mall_size;            /* AKA infinity cache */
 	/* high 32 bits of the rb pipes mask */
 	__u32 enabled_rb_pipes_mask_hi;
+	/* shadow area size for gfx11 */
+	__u32 shadow_size;
+	/* shadow area base virtual alignment for gfx11 */
+	__u32 shadow_alignment;
+	/* context save area size for gfx11 */
+	__u32 csa_size;
+	/* context save area base virtual alignment for gfx11 */
+	__u32 csa_alignment;
 };
 
 struct drm_amdgpu_info_hw_ip {
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 08/13] drm/amdgpu: add gfx shadow callback
  2023-03-30 19:17 [PATCH V4 00/13] Enable FW assisted shadowing for GFX11 Alex Deucher
                   ` (6 preceding siblings ...)
  2023-03-30 19:17 ` [PATCH 07/13] drm/amdgpu: add UAPI to query GFX shadow sizes Alex Deucher
@ 2023-03-30 19:17 ` Alex Deucher
  2023-03-30 19:17 ` [PATCH 09/13] drm/amdgpu: add get_gfx_shadow_info callback for gfx11 Alex Deucher
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 33+ messages in thread
From: Alex Deucher @ 2023-03-30 19:17 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher, Christian König

To provide IP specific shadow sizes.  UMDs will use
this to query the kernel driver for the size of the
shadow buffers.

v2: make callback return an int (Alex)
v3: drop GDS (Alex)

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
index 4ad9e225d6e6..62047a541c21 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
@@ -219,6 +219,13 @@ struct amdgpu_gfx_ras {
 						struct amdgpu_iv_entry *entry);
 };
 
+struct amdgpu_gfx_shadow_info {
+	u32 shadow_size;
+	u32 shadow_alignment;
+	u32 csa_size;
+	u32 csa_alignment;
+};
+
 struct amdgpu_gfx_funcs {
 	/* get the gpu clock counter */
 	uint64_t (*get_gpu_clock_counter)(struct amdgpu_device *adev);
@@ -236,6 +243,8 @@ struct amdgpu_gfx_funcs {
 				 u32 queue, u32 vmid);
 	void (*init_spm_golden)(struct amdgpu_device *adev);
 	void (*update_perfmon_mgcg)(struct amdgpu_device *adev, bool enable);
+	int (*get_gfx_shadow_info)(struct amdgpu_device *adev,
+				   struct amdgpu_gfx_shadow_info *shadow_info);
 };
 
 struct sq_work {
@@ -372,6 +381,7 @@ struct amdgpu_gfx {
 #define amdgpu_gfx_select_se_sh(adev, se, sh, instance) (adev)->gfx.funcs->select_se_sh((adev), (se), (sh), (instance))
 #define amdgpu_gfx_select_me_pipe_q(adev, me, pipe, q, vmid) (adev)->gfx.funcs->select_me_pipe_q((adev), (me), (pipe), (q), (vmid))
 #define amdgpu_gfx_init_spm_golden(adev) (adev)->gfx.funcs->init_spm_golden((adev))
+#define amdgpu_gfx_get_gfx_shadow_info(adev, si) (adev)->gfx.funcs->get_gfx_shadow_info((adev), (si))
 
 /**
  * amdgpu_gfx_create_bitmask - create a bitmask
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 09/13] drm/amdgpu: add get_gfx_shadow_info callback for gfx11
  2023-03-30 19:17 [PATCH V4 00/13] Enable FW assisted shadowing for GFX11 Alex Deucher
                   ` (7 preceding siblings ...)
  2023-03-30 19:17 ` [PATCH 08/13] drm/amdgpu: add gfx shadow callback Alex Deucher
@ 2023-03-30 19:17 ` Alex Deucher
  2023-04-19 22:11   ` Alex Deucher
  2023-03-30 19:17 ` [PATCH 10/13] drm/amdgpu: add support for new GFX shadow size query Alex Deucher
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 33+ messages in thread
From: Alex Deucher @ 2023-03-30 19:17 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher

Used to get the size and alignment requirements for
the gfx shadow buffer for preemption.

v2: use FW version check to determine whether to
    return a valid size here
    return an error if not supported (Alex)
v3: drop GDS (Alex)
v4: make amdgpu_gfx_shadow_info mandatory (Alex)

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
index 1fc1e941f7df..7a5da13cffa0 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
@@ -822,6 +822,27 @@ static void gfx_v11_0_select_me_pipe_q(struct amdgpu_device *adev,
 	soc21_grbm_select(adev, me, pipe, q, vm);
 }
 
+/* all sizes are in bytes */
+#define MQD_SHADOW_BASE_SIZE      73728
+#define MQD_SHADOW_BASE_ALIGNMENT 256
+#define MQD_FWWORKAREA_SIZE       484
+#define MQD_FWWORKAREA_ALIGNMENT  256
+
+static int gfx_v11_0_get_gfx_shadow_info(struct amdgpu_device *adev,
+					 struct amdgpu_gfx_shadow_info *shadow_info)
+{
+	if (adev->gfx.cp_gfx_shadow) {
+		shadow_info->shadow_size = MQD_SHADOW_BASE_SIZE;
+		shadow_info->shadow_alignment = MQD_SHADOW_BASE_ALIGNMENT;
+		shadow_info->csa_size = MQD_FWWORKAREA_SIZE;
+		shadow_info->csa_alignment = MQD_FWWORKAREA_ALIGNMENT;
+		return 0;
+	} else {
+		memset(shadow_info, 0, sizeof(struct amdgpu_gfx_shadow_info));
+		return -ENOTSUPP;
+	}
+}
+
 static const struct amdgpu_gfx_funcs gfx_v11_0_gfx_funcs = {
 	.get_gpu_clock_counter = &gfx_v11_0_get_gpu_clock_counter,
 	.select_se_sh = &gfx_v11_0_select_se_sh,
@@ -830,6 +851,7 @@ static const struct amdgpu_gfx_funcs gfx_v11_0_gfx_funcs = {
 	.read_wave_vgprs = &gfx_v11_0_read_wave_vgprs,
 	.select_me_pipe_q = &gfx_v11_0_select_me_pipe_q,
 	.update_perfmon_mgcg = &gfx_v11_0_update_perf_clk,
+	.get_gfx_shadow_info = &gfx_v11_0_get_gfx_shadow_info,
 };
 
 static int gfx_v11_0_gpu_early_init(struct amdgpu_device *adev)
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 10/13] drm/amdgpu: add support for new GFX shadow size query
  2023-03-30 19:17 [PATCH V4 00/13] Enable FW assisted shadowing for GFX11 Alex Deucher
                   ` (8 preceding siblings ...)
  2023-03-30 19:17 ` [PATCH 09/13] drm/amdgpu: add get_gfx_shadow_info callback for gfx11 Alex Deucher
@ 2023-03-30 19:17 ` Alex Deucher
  2023-04-19 22:12   ` Alex Deucher
  2023-03-30 19:17 ` [PATCH 11/13] drm/amdgpu: bump driver version number for CP GFX shadow Alex Deucher
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 33+ messages in thread
From: Alex Deucher @ 2023-03-30 19:17 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher

Use the new callback to fetch the data.  Return an error if
not supported.  UMDs should use this query to check whether
shadow buffers are supported and if so what size they
should be.

v2: return an error rather than a zerod structure.
v3: drop GDS, move into dev_info structure.  Data will be
    0 if not supported.
v4: drop local variable r

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 0efb38539d70..fd735df92b9a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -876,6 +876,19 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
 		dev_info->gl2c_cache_size = adev->gfx.config.gc_gl2c_per_gpu;
 		dev_info->mall_size = adev->gmc.mall_size;
 
+
+		if (adev->gfx.funcs->get_gfx_shadow_info) {
+			struct amdgpu_gfx_shadow_info shadow_info;
+
+			ret = amdgpu_gfx_get_gfx_shadow_info(adev, &shadow_info);
+			if (!ret) {
+				dev_info->shadow_size = shadow_info.shadow_size;
+				dev_info->shadow_alignment = shadow_info.shadow_alignment;
+				dev_info->csa_size = shadow_info.csa_size;
+				dev_info->csa_alignment = shadow_info.csa_alignment;
+			}
+		}
+
 		ret = copy_to_user(out, dev_info,
 				   min((size_t)size, sizeof(*dev_info))) ? -EFAULT : 0;
 		kfree(dev_info);
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 11/13] drm/amdgpu: bump driver version number for CP GFX shadow
  2023-03-30 19:17 [PATCH V4 00/13] Enable FW assisted shadowing for GFX11 Alex Deucher
                   ` (9 preceding siblings ...)
  2023-03-30 19:17 ` [PATCH 10/13] drm/amdgpu: add support for new GFX shadow size query Alex Deucher
@ 2023-03-30 19:17 ` Alex Deucher
  2023-04-19 22:12   ` Alex Deucher
  2023-03-30 19:17 ` [PATCH 12/13] drm/amdgpu: track MQD size for gfx and compute Alex Deucher
  2023-03-30 19:17 ` [PATCH 13/13] drm/amdgpu: add debugfs interface for reading MQDs Alex Deucher
  12 siblings, 1 reply; 33+ messages in thread
From: Alex Deucher @ 2023-03-30 19:17 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher

So UMDs can determine whether the kernel supports this.

Mesa MR: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21986

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 917926c8dc5f..c35baee082e6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -111,9 +111,10 @@
  *   3.52.0 - Add AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD, add device_info fields:
  *            tcp_cache_size, num_sqc_per_wgp, sqc_data_cache_size, sqc_inst_cache_size,
  *            gl1c_cache_size, gl2c_cache_size, mall_size, enabled_rb_pipes_mask_hi
+ *   3.53.0 - Support for GFX11 CP GFX shadowing
  */
 #define KMS_DRIVER_MAJOR	3
-#define KMS_DRIVER_MINOR	52
+#define KMS_DRIVER_MINOR	53
 #define KMS_DRIVER_PATCHLEVEL	0
 
 unsigned int amdgpu_vram_limit = UINT_MAX;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 12/13] drm/amdgpu: track MQD size for gfx and compute
  2023-03-30 19:17 [PATCH V4 00/13] Enable FW assisted shadowing for GFX11 Alex Deucher
                   ` (10 preceding siblings ...)
  2023-03-30 19:17 ` [PATCH 11/13] drm/amdgpu: bump driver version number for CP GFX shadow Alex Deucher
@ 2023-03-30 19:17 ` Alex Deucher
  2023-03-30 19:17 ` [PATCH 13/13] drm/amdgpu: add debugfs interface for reading MQDs Alex Deucher
  12 siblings, 0 replies; 33+ messages in thread
From: Alex Deucher @ 2023-03-30 19:17 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher, Christian König

It varies by generation and we need to know the size
to expose this via debugfs.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c  | 2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index c50d59855011..5435f41a3b7f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -404,6 +404,7 @@ int amdgpu_gfx_mqd_sw_init(struct amdgpu_device *adev,
 					return r;
 				}
 
+				ring->mqd_size = mqd_size;
 				/* prepare MQD backup */
 				adev->gfx.me.mqd_backup[i] = kmalloc(mqd_size, GFP_KERNEL);
 				if (!adev->gfx.me.mqd_backup[i])
@@ -424,6 +425,7 @@ int amdgpu_gfx_mqd_sw_init(struct amdgpu_device *adev,
 				return r;
 			}
 
+			ring->mqd_size = mqd_size;
 			/* prepare MQD backup */
 			adev->gfx.mec.mqd_backup[i] = kmalloc(mqd_size, GFP_KERNEL);
 			if (!adev->gfx.mec.mqd_backup[i])
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
index 7942cb62e52c..deb9f7bead02 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
@@ -257,6 +257,7 @@ struct amdgpu_ring {
 	struct amdgpu_bo	*mqd_obj;
 	uint64_t                mqd_gpu_addr;
 	void                    *mqd_ptr;
+	unsigned                mqd_size;
 	uint64_t                eop_gpu_addr;
 	u32			doorbell_index;
 	bool			use_doorbell;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 13/13] drm/amdgpu: add debugfs interface for reading MQDs
  2023-03-30 19:17 [PATCH V4 00/13] Enable FW assisted shadowing for GFX11 Alex Deucher
                   ` (11 preceding siblings ...)
  2023-03-30 19:17 ` [PATCH 12/13] drm/amdgpu: track MQD size for gfx and compute Alex Deucher
@ 2023-03-30 19:17 ` Alex Deucher
  12 siblings, 0 replies; 33+ messages in thread
From: Alex Deucher @ 2023-03-30 19:17 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher, Christian König

Provide a debugfs interface to access the MQD.  Useful for
debugging issues with the CP and MES hardware scheduler.

v2: fix missing unreserve/unmap when pos >= size (Alex)

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 60 +++++++++++++++++++++++-
 1 file changed, 59 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
index dc474b809604..c3b7654678c4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
@@ -478,6 +478,59 @@ static const struct file_operations amdgpu_debugfs_ring_fops = {
 	.llseek = default_llseek
 };
 
+static ssize_t amdgpu_debugfs_mqd_read(struct file *f, char __user *buf,
+				       size_t size, loff_t *pos)
+{
+	struct amdgpu_ring *ring = file_inode(f)->i_private;
+	volatile u32 *mqd;
+	int r;
+	uint32_t value, result;
+
+	if (*pos & 3 || size & 3)
+		return -EINVAL;
+
+	result = 0;
+
+	r = amdgpu_bo_reserve(ring->mqd_obj, false);
+	if (unlikely(r != 0))
+		return r;
+
+	r = amdgpu_bo_kmap(ring->mqd_obj, (void **)&mqd);
+	if (r) {
+		amdgpu_bo_unreserve(ring->mqd_obj);
+		return r;
+	}
+
+	while (size) {
+		if (*pos >= ring->mqd_size)
+			goto done;
+
+		value = mqd[*pos/4];
+		r = put_user(value, (uint32_t *)buf);
+		if (r)
+			goto done;
+		buf += 4;
+		result += 4;
+		size -= 4;
+		*pos += 4;
+	}
+
+done:
+	amdgpu_bo_kunmap(ring->mqd_obj);
+	mqd = NULL;
+	amdgpu_bo_unreserve(ring->mqd_obj);
+	if (r)
+		return r;
+
+	return result;
+}
+
+static const struct file_operations amdgpu_debugfs_mqd_fops = {
+	.owner = THIS_MODULE,
+	.read = amdgpu_debugfs_mqd_read,
+	.llseek = default_llseek
+};
+
 #endif
 
 void amdgpu_debugfs_ring_init(struct amdgpu_device *adev,
@@ -492,7 +545,12 @@ void amdgpu_debugfs_ring_init(struct amdgpu_device *adev,
 	debugfs_create_file_size(name, S_IFREG | S_IRUGO, root, ring,
 				 &amdgpu_debugfs_ring_fops,
 				 ring->ring_size + 12);
-
+	if (ring->mqd_obj) {
+		sprintf(name, "amdgpu_mqd_%s", ring->name);
+		debugfs_create_file_size(name, S_IFREG | S_IRUGO, root, ring,
+					 &amdgpu_debugfs_mqd_fops,
+					 ring->mqd_size);
+	}
 #endif
 }
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH 04/13] drm/amdgpu: add gfx shadow CS IOCTL support
  2023-03-30 19:17 ` [PATCH 04/13] drm/amdgpu: add gfx shadow CS IOCTL support Alex Deucher
@ 2023-03-31  6:33   ` Christian König
  0 siblings, 0 replies; 33+ messages in thread
From: Christian König @ 2023-03-31  6:33 UTC (permalink / raw)
  To: Alex Deucher, amd-gfx

Am 30.03.23 um 21:17 schrieb Alex Deucher:
> From: Christian König <christian.koenig@amd.com>
>
> Add support for submitting the shadow update packet
> when submitting an IB.  Needed for MCBP on GFX11.
>
> v2: update API for CSA (Alex)
> v3: fix ordering; SET_Q_PREEMPTION_MODE most come before COND_EXEC
>      Add missing check for AMDGPU_CHUNK_ID_CP_GFX_SHADOW in
>      amdgpu_cs_pass1()
>      Only initialize shadow on first use
>      (Alex)
> v4: Pass parameters rather than job to new ring callback (Alex)
> v5: squash in change to call SET_Q_PREEMPTION_MODE/COND_EXEC
>      before RELEASE_MEM to complete the UMDs use of the shadow (Alex)
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c   | 26 +++++++++++++++++++++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c   | 29 +++++++++++++++++++++++-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_job.h  |  6 +++++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h |  3 +++
>   4 files changed, 63 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> index 47763ac0d14a..41bd3a1a1989 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> @@ -281,6 +281,7 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p,
>   		case AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES:
>   		case AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT:
>   		case AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL:
> +		case AMDGPU_CHUNK_ID_CP_GFX_SHADOW:
>   			break;
>   
>   		default:
> @@ -583,6 +584,26 @@ static int amdgpu_cs_p2_syncobj_timeline_signal(struct amdgpu_cs_parser *p,
>   	return 0;
>   }
>   
> +static int amdgpu_cs_p2_shadow(struct amdgpu_cs_parser *p,
> +			       struct amdgpu_cs_chunk *chunk)
> +{
> +	struct drm_amdgpu_cs_chunk_cp_gfx_shadow *shadow = chunk->kdata;
> +	int i;
> +
> +	if (shadow->flags & ~AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW)
> +		return -EINVAL;
> +
> +	for (i = 0; i < p->gang_size; ++i) {
> +		p->jobs[i]->shadow_va = shadow->shadow_va;
> +		p->jobs[i]->csa_va = shadow->csa_va;
> +		p->jobs[i]->gds_va = shadow->gds_va;
> +		p->jobs[i]->init_shadow =
> +			shadow->flags & AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW;
> +	}
> +
> +	return 0;
> +}
> +
>   static int amdgpu_cs_pass2(struct amdgpu_cs_parser *p)
>   {
>   	unsigned int ce_preempt = 0, de_preempt = 0;
> @@ -625,6 +646,11 @@ static int amdgpu_cs_pass2(struct amdgpu_cs_parser *p)
>   			if (r)
>   				return r;
>   			break;
> +		case AMDGPU_CHUNK_ID_CP_GFX_SHADOW:
> +			r = amdgpu_cs_p2_shadow(p, chunk);
> +			if (r)
> +				return r;
> +			break;
>   		}
>   	}
>   
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
> index bcccc348dbe2..9bee630eb0c9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
> @@ -136,7 +136,9 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
>   	uint64_t fence_ctx;
>   	uint32_t status = 0, alloc_size;
>   	unsigned fence_flags = 0;
> -	bool secure;
> +	bool secure, init_shadow;
> +	u64 shadow_va, csa_va, gds_va;
> +	int vmid = AMDGPU_JOB_GET_VMID(job);
>   
>   	unsigned i;
>   	int r = 0;
> @@ -150,9 +152,17 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
>   		vm = job->vm;
>   		fence_ctx = job->base.s_fence ?
>   			job->base.s_fence->scheduled.context : 0;
> +		shadow_va = job->shadow_va;
> +		csa_va = job->csa_va;
> +		gds_va = job->gds_va;
> +		init_shadow = job->init_shadow;
>   	} else {
>   		vm = NULL;
>   		fence_ctx = 0;
> +		shadow_va = 0;
> +		csa_va = 0;
> +		gds_va = 0;
> +		init_shadow = false;
>   	}
>   
>   	if (!ring->sched.ready && !ring->is_mes_queue) {
> @@ -212,6 +222,11 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
>   	}
>   
>   	amdgpu_ring_ib_begin(ring);
> +
> +	if (job && ring->funcs->emit_gfx_shadow)
> +		amdgpu_ring_emit_gfx_shadow(ring, shadow_va, csa_va, gds_va,
> +					    init_shadow, vmid);
> +
>   	if (job && ring->funcs->init_cond_exec)
>   		patch_offset = amdgpu_ring_init_cond_exec(ring);
>   
> @@ -263,6 +278,18 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
>   				       fence_flags | AMDGPU_FENCE_FLAG_64BIT);
>   	}
>   
> +	if (ring->funcs->emit_gfx_shadow) {
> +		amdgpu_ring_emit_gfx_shadow(ring, 0, 0, 0, false, 0);
> +
> +		if (ring->funcs->init_cond_exec) {
> +			unsigned ce_offset = ~0;
> +
> +			ce_offset = amdgpu_ring_init_cond_exec(ring);
> +			if (ce_offset != ~0 && ring->funcs->patch_cond_exec)
> +				amdgpu_ring_patch_cond_exec(ring, ce_offset);
> +		}
> +	}
> +
>   	r = amdgpu_fence_emit(ring, f, job, fence_flags);
>   	if (r) {
>   		dev_err(adev->dev, "failed to emit fence (%d)\n", r);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h
> index 52f2e313ea17..3f9804f956c9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h
> @@ -67,6 +67,12 @@ struct amdgpu_job {
>   	uint64_t		uf_addr;
>   	uint64_t		uf_sequence;
>   
> +	/* virtual addresses for shadow/GDS/CSA */
> +	uint64_t		shadow_va;
> +	uint64_t		csa_va;
> +	uint64_t		gds_va;
> +	bool			init_shadow;
> +
>   	/* job_run_counter >= 1 means a resubmit job */
>   	uint32_t		job_run_counter;
>   
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> index 3989e755a5b4..7942cb62e52c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> @@ -212,6 +212,8 @@ struct amdgpu_ring_funcs {
>   	void (*end_use)(struct amdgpu_ring *ring);
>   	void (*emit_switch_buffer) (struct amdgpu_ring *ring);
>   	void (*emit_cntxcntl) (struct amdgpu_ring *ring, uint32_t flags);
> +	void (*emit_gfx_shadow)(struct amdgpu_ring *ring, u64 shadow_va, u64 csa_va,
> +				u64 gds_va, bool init_shadow, int vmid);
>   	void (*emit_rreg)(struct amdgpu_ring *ring, uint32_t reg,
>   			  uint32_t reg_val_offs);
>   	void (*emit_wreg)(struct amdgpu_ring *ring, uint32_t reg, uint32_t val);
> @@ -307,6 +309,7 @@ struct amdgpu_ring {
>   #define amdgpu_ring_emit_hdp_flush(r) (r)->funcs->emit_hdp_flush((r))
>   #define amdgpu_ring_emit_switch_buffer(r) (r)->funcs->emit_switch_buffer((r))
>   #define amdgpu_ring_emit_cntxcntl(r, d) (r)->funcs->emit_cntxcntl((r), (d))
> +#define amdgpu_ring_emit_gfx_shadow(r, s, c, g, i, v) (r)->funcs->emit_gfx_shadow((r), (s), (c), (g), (i), (v))
>   #define amdgpu_ring_emit_rreg(r, d, o) (r)->funcs->emit_rreg((r), (d), (o))
>   #define amdgpu_ring_emit_wreg(r, d, v) (r)->funcs->emit_wreg((r), (d), (v))
>   #define amdgpu_ring_emit_reg_wait(r, d, v, m) (r)->funcs->emit_reg_wait((r), (d), (v), (m))


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/13] drm/amdgpu/gfx11: check the CP FW version CP GFX shadow support
  2023-03-30 19:17 ` [PATCH 02/13] drm/amdgpu/gfx11: check the CP FW version CP GFX shadow support Alex Deucher
@ 2023-03-31  6:34   ` Christian König
  2023-03-31 19:18     ` Alex Deucher
  0 siblings, 1 reply; 33+ messages in thread
From: Christian König @ 2023-03-31  6:34 UTC (permalink / raw)
  To: Alex Deucher, amd-gfx

Am 30.03.23 um 21:17 schrieb Alex Deucher:
> Only set the supported flag if we have new enough CP FW.
>
> XXX: don't commit this until the CP FW versions are finalized!

Maybe commit the rest of this series and just hold back this one?

It should still keep everything working.

Regards,
Christian.

>
> Acked-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> index a0d830dc0d01..4a50d0fbcdcf 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> @@ -469,6 +469,15 @@ static void gfx_v11_0_check_fw_cp_gfx_shadow(struct amdgpu_device *adev)
>   	case IP_VERSION(11, 0, 0):
>   	case IP_VERSION(11, 0, 2):
>   	case IP_VERSION(11, 0, 3):
> +		/* XXX fix me! */
> +		if ((adev->gfx.me_fw_version >= 1498) &&
> +		    (adev->gfx.me_feature_version >= 29) &&
> +		    (adev->gfx.pfp_fw_version >= 1541) &&
> +		    (adev->gfx.pfp_feature_version >= 29) &&
> +		    (adev->gfx.mec_fw_version >= 507) &&
> +		    (adev->gfx.mec_feature_version >= 29))
> +			adev->gfx.cp_gfx_shadow = true;
> +		break;
>   	default:
>   		adev->gfx.cp_gfx_shadow = false;
>   		break;


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/13] drm/amdgpu/gfx11: check the CP FW version CP GFX shadow support
  2023-03-31  6:34   ` Christian König
@ 2023-03-31 19:18     ` Alex Deucher
  0 siblings, 0 replies; 33+ messages in thread
From: Alex Deucher @ 2023-03-31 19:18 UTC (permalink / raw)
  To: Christian König; +Cc: Alex Deucher, amd-gfx

On Fri, Mar 31, 2023 at 2:34 AM Christian König
<christian.koenig@amd.com> wrote:
>
> Am 30.03.23 um 21:17 schrieb Alex Deucher:
> > Only set the supported flag if we have new enough CP FW.
> >
> > XXX: don't commit this until the CP FW versions are finalized!
>
> Maybe commit the rest of this series and just hold back this one?
>
> It should still keep everything working.

Yes, that was my plan.

Alex

>
> Regards,
> Christian.
>
> >
> > Acked-by: Christian König <christian.koenig@amd.com>
> > Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 9 +++++++++
> >   1 file changed, 9 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> > index a0d830dc0d01..4a50d0fbcdcf 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> > @@ -469,6 +469,15 @@ static void gfx_v11_0_check_fw_cp_gfx_shadow(struct amdgpu_device *adev)
> >       case IP_VERSION(11, 0, 0):
> >       case IP_VERSION(11, 0, 2):
> >       case IP_VERSION(11, 0, 3):
> > +             /* XXX fix me! */
> > +             if ((adev->gfx.me_fw_version >= 1498) &&
> > +                 (adev->gfx.me_feature_version >= 29) &&
> > +                 (adev->gfx.pfp_fw_version >= 1541) &&
> > +                 (adev->gfx.pfp_feature_version >= 29) &&
> > +                 (adev->gfx.mec_fw_version >= 507) &&
> > +                 (adev->gfx.mec_feature_version >= 29))
> > +                     adev->gfx.cp_gfx_shadow = true;
> > +             break;
> >       default:
> >               adev->gfx.cp_gfx_shadow = false;
> >               break;
>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/13] drm/amdgpu/UAPI: add new CS chunk for GFX shadow buffers
  2023-03-30 19:17 ` [PATCH 03/13] drm/amdgpu/UAPI: add new CS chunk for GFX shadow buffers Alex Deucher
@ 2023-04-06  7:36   ` Marek Olšák
  2023-04-06  9:09     ` Christian König
  0 siblings, 1 reply; 33+ messages in thread
From: Marek Olšák @ 2023-04-06  7:36 UTC (permalink / raw)
  To: Alex Deucher; +Cc: Christian König, amd-gfx

[-- Attachment #1: Type: text/plain, Size: 1684 bytes --]

gds_va is unnecessary.

Marek

On Thu, Mar 30, 2023 at 3:18 PM Alex Deucher <alexander.deucher@amd.com>
wrote:

> For GFX11, the UMD needs to allocate some shadow buffers
> to be used for preemption.  The UMD allocates the buffers
> and passes the GPU virtual address to the kernel since the
> kernel will program the packet that specified these
> addresses as part of its IB submission frame.
>
> v2: UMD passes shadow init to tell kernel when to initialize
>     the shadow
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>  include/uapi/drm/amdgpu_drm.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
> index b6eb90df5d05..3d9474af6566 100644
> --- a/include/uapi/drm/amdgpu_drm.h
> +++ b/include/uapi/drm/amdgpu_drm.h
> @@ -592,6 +592,7 @@ struct drm_amdgpu_gem_va {
>  #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
>  #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT    0x08
>  #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL  0x09
> +#define AMDGPU_CHUNK_ID_CP_GFX_SHADOW   0x0a
>
>  struct drm_amdgpu_cs_chunk {
>         __u32           chunk_id;
> @@ -708,6 +709,15 @@ struct drm_amdgpu_cs_chunk_data {
>         };
>  };
>
> +#define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW         0x1
> +
> +struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
> +       __u64 shadow_va;
> +       __u64 csa_va;
> +       __u64 gds_va;
> +       __u64 flags;
> +};
> +
>  /*
>   *  Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
>   *
> --
> 2.39.2
>
>

[-- Attachment #2: Type: text/html, Size: 2288 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/13] drm/amdgpu/UAPI: add new CS chunk for GFX shadow buffers
  2023-04-06  7:36   ` Marek Olšák
@ 2023-04-06  9:09     ` Christian König
  2023-04-06  9:43       ` Marek Olšák
  0 siblings, 1 reply; 33+ messages in thread
From: Christian König @ 2023-04-06  9:09 UTC (permalink / raw)
  To: Marek Olšák, Alex Deucher; +Cc: amd-gfx

[-- Attachment #1: Type: text/plain, Size: 1981 bytes --]

Why that?

This is the save buffer for GDS, not the old style GDS BOs.

Christian.

Am 06.04.23 um 09:36 schrieb Marek Olšák:
> gds_va is unnecessary.
>
> Marek
>
> On Thu, Mar 30, 2023 at 3:18 PM Alex Deucher 
> <alexander.deucher@amd.com> wrote:
>
>     For GFX11, the UMD needs to allocate some shadow buffers
>     to be used for preemption.  The UMD allocates the buffers
>     and passes the GPU virtual address to the kernel since the
>     kernel will program the packet that specified these
>     addresses as part of its IB submission frame.
>
>     v2: UMD passes shadow init to tell kernel when to initialize
>         the shadow
>
>     Reviewed-by: Christian König <christian.koenig@amd.com>
>     Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>     ---
>      include/uapi/drm/amdgpu_drm.h | 10 ++++++++++
>      1 file changed, 10 insertions(+)
>
>     diff --git a/include/uapi/drm/amdgpu_drm.h
>     b/include/uapi/drm/amdgpu_drm.h
>     index b6eb90df5d05..3d9474af6566 100644
>     --- a/include/uapi/drm/amdgpu_drm.h
>     +++ b/include/uapi/drm/amdgpu_drm.h
>     @@ -592,6 +592,7 @@ struct drm_amdgpu_gem_va {
>      #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
>      #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT    0x08
>      #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL  0x09
>     +#define AMDGPU_CHUNK_ID_CP_GFX_SHADOW   0x0a
>
>      struct drm_amdgpu_cs_chunk {
>             __u32           chunk_id;
>     @@ -708,6 +709,15 @@ struct drm_amdgpu_cs_chunk_data {
>             };
>      };
>
>     +#define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW    0x1
>     +
>     +struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
>     +       __u64 shadow_va;
>     +       __u64 csa_va;
>     +       __u64 gds_va;
>     +       __u64 flags;
>     +};
>     +
>      /*
>       *  Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
>       *
>     -- 
>     2.39.2
>

[-- Attachment #2: Type: text/html, Size: 3739 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/13] drm/amdgpu/UAPI: add new CS chunk for GFX shadow buffers
  2023-04-06  9:09     ` Christian König
@ 2023-04-06  9:43       ` Marek Olšák
  2023-04-06 10:31         ` Christian König
  0 siblings, 1 reply; 33+ messages in thread
From: Marek Olšák @ 2023-04-06  9:43 UTC (permalink / raw)
  To: Christian König; +Cc: Alex Deucher, amd-gfx

[-- Attachment #1: Type: text/plain, Size: 2047 bytes --]

GDS memory isn't used on gfx11. Only GDS OA is used.

Marek

On Thu, Apr 6, 2023 at 5:09 AM Christian König <christian.koenig@amd.com>
wrote:

> Why that?
>
> This is the save buffer for GDS, not the old style GDS BOs.
>
> Christian.
>
> Am 06.04.23 um 09:36 schrieb Marek Olšák:
>
> gds_va is unnecessary.
>
> Marek
>
> On Thu, Mar 30, 2023 at 3:18 PM Alex Deucher <alexander.deucher@amd.com>
> wrote:
>
>> For GFX11, the UMD needs to allocate some shadow buffers
>> to be used for preemption.  The UMD allocates the buffers
>> and passes the GPU virtual address to the kernel since the
>> kernel will program the packet that specified these
>> addresses as part of its IB submission frame.
>>
>> v2: UMD passes shadow init to tell kernel when to initialize
>>     the shadow
>>
>> Reviewed-by: Christian König <christian.koenig@amd.com>
>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>> ---
>>  include/uapi/drm/amdgpu_drm.h | 10 ++++++++++
>>  1 file changed, 10 insertions(+)
>>
>> diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
>> index b6eb90df5d05..3d9474af6566 100644
>> --- a/include/uapi/drm/amdgpu_drm.h
>> +++ b/include/uapi/drm/amdgpu_drm.h
>> @@ -592,6 +592,7 @@ struct drm_amdgpu_gem_va {
>>  #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
>>  #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT    0x08
>>  #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL  0x09
>> +#define AMDGPU_CHUNK_ID_CP_GFX_SHADOW   0x0a
>>
>>  struct drm_amdgpu_cs_chunk {
>>         __u32           chunk_id;
>> @@ -708,6 +709,15 @@ struct drm_amdgpu_cs_chunk_data {
>>         };
>>  };
>>
>> +#define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW         0x1
>> +
>> +struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
>> +       __u64 shadow_va;
>> +       __u64 csa_va;
>> +       __u64 gds_va;
>> +       __u64 flags;
>> +};
>> +
>>  /*
>>   *  Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
>>   *
>> --
>> 2.39.2
>>
>>
>

[-- Attachment #2: Type: text/html, Size: 3734 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/13] drm/amdgpu/UAPI: add new CS chunk for GFX shadow buffers
  2023-04-06  9:43       ` Marek Olšák
@ 2023-04-06 10:31         ` Christian König
  2023-04-06 15:01           ` Marek Olšák
  0 siblings, 1 reply; 33+ messages in thread
From: Christian König @ 2023-04-06 10:31 UTC (permalink / raw)
  To: Marek Olšák, Christian König; +Cc: Alex Deucher, amd-gfx

[-- Attachment #1: Type: text/plain, Size: 2575 bytes --]

That's what I thought as well, but Mitch/Hans insisted on that.

We should probably double check internally.

Christian.

Am 06.04.23 um 11:43 schrieb Marek Olšák:
> GDS memory isn't used on gfx11. Only GDS OA is used.
>
> Marek
>
> On Thu, Apr 6, 2023 at 5:09 AM Christian König 
> <christian.koenig@amd.com> wrote:
>
>     Why that?
>
>     This is the save buffer for GDS, not the old style GDS BOs.
>
>     Christian.
>
>     Am 06.04.23 um 09:36 schrieb Marek Olšák:
>>     gds_va is unnecessary.
>>
>>     Marek
>>
>>     On Thu, Mar 30, 2023 at 3:18 PM Alex Deucher
>>     <alexander.deucher@amd.com> wrote:
>>
>>         For GFX11, the UMD needs to allocate some shadow buffers
>>         to be used for preemption.  The UMD allocates the buffers
>>         and passes the GPU virtual address to the kernel since the
>>         kernel will program the packet that specified these
>>         addresses as part of its IB submission frame.
>>
>>         v2: UMD passes shadow init to tell kernel when to initialize
>>             the shadow
>>
>>         Reviewed-by: Christian König <christian.koenig@amd.com>
>>         Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>>         ---
>>          include/uapi/drm/amdgpu_drm.h | 10 ++++++++++
>>          1 file changed, 10 insertions(+)
>>
>>         diff --git a/include/uapi/drm/amdgpu_drm.h
>>         b/include/uapi/drm/amdgpu_drm.h
>>         index b6eb90df5d05..3d9474af6566 100644
>>         --- a/include/uapi/drm/amdgpu_drm.h
>>         +++ b/include/uapi/drm/amdgpu_drm.h
>>         @@ -592,6 +592,7 @@ struct drm_amdgpu_gem_va {
>>          #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
>>          #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT    0x08
>>          #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL  0x09
>>         +#define AMDGPU_CHUNK_ID_CP_GFX_SHADOW   0x0a
>>
>>          struct drm_amdgpu_cs_chunk {
>>                 __u32           chunk_id;
>>         @@ -708,6 +709,15 @@ struct drm_amdgpu_cs_chunk_data {
>>                 };
>>          };
>>
>>         +#define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW  0x1
>>         +
>>         +struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
>>         +       __u64 shadow_va;
>>         +       __u64 csa_va;
>>         +       __u64 gds_va;
>>         +       __u64 flags;
>>         +};
>>         +
>>          /*
>>           *  Query h/w info: Flag that this is integrated (a.h.a.
>>         fusion) GPU
>>           *
>>         -- 
>>         2.39.2
>>
>

[-- Attachment #2: Type: text/html, Size: 5505 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/13] drm/amdgpu/UAPI: add new CS chunk for GFX shadow buffers
  2023-04-06 10:31         ` Christian König
@ 2023-04-06 15:01           ` Marek Olšák
  2023-04-09 15:21             ` Christian König
  0 siblings, 1 reply; 33+ messages in thread
From: Marek Olšák @ 2023-04-06 15:01 UTC (permalink / raw)
  To: Christian König; +Cc: Alex Deucher, Christian König, amd-gfx

[-- Attachment #1: Type: text/plain, Size: 2606 bytes --]

There is no GDS shadowing info in the device info uapi, so userspace can't
create any GDS buffer and thus can't have any GDS va. It's a uapi issue,
not what firmware wants to do.

Marek

On Thu, Apr 6, 2023 at 6:31 AM Christian König <
ckoenig.leichtzumerken@gmail.com> wrote:

> That's what I thought as well, but Mitch/Hans insisted on that.
>
> We should probably double check internally.
>
> Christian.
>
> Am 06.04.23 um 11:43 schrieb Marek Olšák:
>
> GDS memory isn't used on gfx11. Only GDS OA is used.
>
> Marek
>
> On Thu, Apr 6, 2023 at 5:09 AM Christian König <christian.koenig@amd.com>
> wrote:
>
>> Why that?
>>
>> This is the save buffer for GDS, not the old style GDS BOs.
>>
>> Christian.
>>
>> Am 06.04.23 um 09:36 schrieb Marek Olšák:
>>
>> gds_va is unnecessary.
>>
>> Marek
>>
>> On Thu, Mar 30, 2023 at 3:18 PM Alex Deucher <alexander.deucher@amd.com>
>> wrote:
>>
>>> For GFX11, the UMD needs to allocate some shadow buffers
>>> to be used for preemption.  The UMD allocates the buffers
>>> and passes the GPU virtual address to the kernel since the
>>> kernel will program the packet that specified these
>>> addresses as part of its IB submission frame.
>>>
>>> v2: UMD passes shadow init to tell kernel when to initialize
>>>     the shadow
>>>
>>> Reviewed-by: Christian König <christian.koenig@amd.com>
>>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>>> ---
>>>  include/uapi/drm/amdgpu_drm.h | 10 ++++++++++
>>>  1 file changed, 10 insertions(+)
>>>
>>> diff --git a/include/uapi/drm/amdgpu_drm.h
>>> b/include/uapi/drm/amdgpu_drm.h
>>> index b6eb90df5d05..3d9474af6566 100644
>>> --- a/include/uapi/drm/amdgpu_drm.h
>>> +++ b/include/uapi/drm/amdgpu_drm.h
>>> @@ -592,6 +592,7 @@ struct drm_amdgpu_gem_va {
>>>  #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
>>>  #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT    0x08
>>>  #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL  0x09
>>> +#define AMDGPU_CHUNK_ID_CP_GFX_SHADOW   0x0a
>>>
>>>  struct drm_amdgpu_cs_chunk {
>>>         __u32           chunk_id;
>>> @@ -708,6 +709,15 @@ struct drm_amdgpu_cs_chunk_data {
>>>         };
>>>  };
>>>
>>> +#define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW         0x1
>>> +
>>> +struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
>>> +       __u64 shadow_va;
>>> +       __u64 csa_va;
>>> +       __u64 gds_va;
>>> +       __u64 flags;
>>> +};
>>> +
>>>  /*
>>>   *  Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
>>>   *
>>> --
>>> 2.39.2
>>>
>>>
>>
>

[-- Attachment #2: Type: text/html, Size: 5576 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/13] drm/amdgpu/UAPI: add new CS chunk for GFX shadow buffers
  2023-04-06 15:01           ` Marek Olšák
@ 2023-04-09 15:21             ` Christian König
  2023-04-13  9:21               ` Marek Olšák
  0 siblings, 1 reply; 33+ messages in thread
From: Christian König @ 2023-04-09 15:21 UTC (permalink / raw)
  To: Marek Olšák, Christian König; +Cc: Alex Deucher, amd-gfx

[-- Attachment #1: Type: text/plain, Size: 3513 bytes --]

We removed the GDS information because they were unnecessary. The GDS 
size was already part of the device info before we added the shadow info.

But as far as I know the firmware needs valid VAs for all three buffers 
or won't work correctly.

Christian.

Am 06.04.23 um 17:01 schrieb Marek Olšák:
> There is no GDS shadowing info in the device info uapi, so userspace 
> can't create any GDS buffer and thus can't have any GDS va. It's a 
> uapi issue, not what firmware wants to do.
>
> Marek
>
> On Thu, Apr 6, 2023 at 6:31 AM Christian König 
> <ckoenig.leichtzumerken@gmail.com> wrote:
>
>     That's what I thought as well, but Mitch/Hans insisted on that.
>
>     We should probably double check internally.
>
>     Christian.
>
>     Am 06.04.23 um 11:43 schrieb Marek Olšák:
>>     GDS memory isn't used on gfx11. Only GDS OA is used.
>>
>>     Marek
>>
>>     On Thu, Apr 6, 2023 at 5:09 AM Christian König
>>     <christian.koenig@amd.com> wrote:
>>
>>         Why that?
>>
>>         This is the save buffer for GDS, not the old style GDS BOs.
>>
>>         Christian.
>>
>>         Am 06.04.23 um 09:36 schrieb Marek Olšák:
>>>         gds_va is unnecessary.
>>>
>>>         Marek
>>>
>>>         On Thu, Mar 30, 2023 at 3:18 PM Alex Deucher
>>>         <alexander.deucher@amd.com> wrote:
>>>
>>>             For GFX11, the UMD needs to allocate some shadow buffers
>>>             to be used for preemption.  The UMD allocates the buffers
>>>             and passes the GPU virtual address to the kernel since the
>>>             kernel will program the packet that specified these
>>>             addresses as part of its IB submission frame.
>>>
>>>             v2: UMD passes shadow init to tell kernel when to initialize
>>>                 the shadow
>>>
>>>             Reviewed-by: Christian König <christian.koenig@amd.com>
>>>             Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>>>             ---
>>>              include/uapi/drm/amdgpu_drm.h | 10 ++++++++++
>>>              1 file changed, 10 insertions(+)
>>>
>>>             diff --git a/include/uapi/drm/amdgpu_drm.h
>>>             b/include/uapi/drm/amdgpu_drm.h
>>>             index b6eb90df5d05..3d9474af6566 100644
>>>             --- a/include/uapi/drm/amdgpu_drm.h
>>>             +++ b/include/uapi/drm/amdgpu_drm.h
>>>             @@ -592,6 +592,7 @@ struct drm_amdgpu_gem_va {
>>>              #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
>>>              #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT    0x08
>>>              #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL  0x09
>>>             +#define AMDGPU_CHUNK_ID_CP_GFX_SHADOW   0x0a
>>>
>>>              struct drm_amdgpu_cs_chunk {
>>>                     __u32           chunk_id;
>>>             @@ -708,6 +709,15 @@ struct drm_amdgpu_cs_chunk_data {
>>>                     };
>>>              };
>>>
>>>             +#define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW
>>>                    0x1
>>>             +
>>>             +struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
>>>             +       __u64 shadow_va;
>>>             +       __u64 csa_va;
>>>             +       __u64 gds_va;
>>>             +       __u64 flags;
>>>             +};
>>>             +
>>>              /*
>>>               *  Query h/w info: Flag that this is integrated
>>>             (a.h.a. fusion) GPU
>>>               *
>>>             -- 
>>>             2.39.2
>>>
>>
>

[-- Attachment #2: Type: text/html, Size: 8114 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/13] drm/amdgpu/UAPI: add new CS chunk for GFX shadow buffers
  2023-04-09 15:21             ` Christian König
@ 2023-04-13  9:21               ` Marek Olšák
  2023-04-13 11:32                 ` Christian König
  0 siblings, 1 reply; 33+ messages in thread
From: Marek Olšák @ 2023-04-13  9:21 UTC (permalink / raw)
  To: Christian König; +Cc: Alex Deucher, amd-gfx mailing list

[-- Attachment #1: Type: text/plain, Size: 3338 bytes --]

That's not why it was removed. It was removed because userspace doesn't use
GDS memory and gds_va is always going to be 0.

Firmware shouldn't use it because using it would increase preemption
latency.

Marek

On Sun, Apr 9, 2023, 11:21 Christian König <ckoenig.leichtzumerken@gmail.com>
wrote:

> We removed the GDS information because they were unnecessary. The GDS size
> was already part of the device info before we added the shadow info.
>
> But as far as I know the firmware needs valid VAs for all three buffers or
> won't work correctly.
>
> Christian.
>
> Am 06.04.23 um 17:01 schrieb Marek Olšák:
>
> There is no GDS shadowing info in the device info uapi, so userspace can't
> create any GDS buffer and thus can't have any GDS va. It's a uapi issue,
> not what firmware wants to do.
>
> Marek
>
> On Thu, Apr 6, 2023 at 6:31 AM Christian König <
> ckoenig.leichtzumerken@gmail.com> wrote:
>
>> That's what I thought as well, but Mitch/Hans insisted on that.
>>
>> We should probably double check internally.
>>
>> Christian.
>>
>> Am 06.04.23 um 11:43 schrieb Marek Olšák:
>>
>> GDS memory isn't used on gfx11. Only GDS OA is used.
>>
>> Marek
>>
>> On Thu, Apr 6, 2023 at 5:09 AM Christian König <christian.koenig@amd.com>
>> wrote:
>>
>>> Why that?
>>>
>>> This is the save buffer for GDS, not the old style GDS BOs.
>>>
>>> Christian.
>>>
>>> Am 06.04.23 um 09:36 schrieb Marek Olšák:
>>>
>>> gds_va is unnecessary.
>>>
>>> Marek
>>>
>>> On Thu, Mar 30, 2023 at 3:18 PM Alex Deucher <alexander.deucher@amd.com>
>>> wrote:
>>>
>>>> For GFX11, the UMD needs to allocate some shadow buffers
>>>> to be used for preemption.  The UMD allocates the buffers
>>>> and passes the GPU virtual address to the kernel since the
>>>> kernel will program the packet that specified these
>>>> addresses as part of its IB submission frame.
>>>>
>>>> v2: UMD passes shadow init to tell kernel when to initialize
>>>>     the shadow
>>>>
>>>> Reviewed-by: Christian König <christian.koenig@amd.com>
>>>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>>>> ---
>>>>  include/uapi/drm/amdgpu_drm.h | 10 ++++++++++
>>>>  1 file changed, 10 insertions(+)
>>>>
>>>> diff --git a/include/uapi/drm/amdgpu_drm.h
>>>> b/include/uapi/drm/amdgpu_drm.h
>>>> index b6eb90df5d05..3d9474af6566 100644
>>>> --- a/include/uapi/drm/amdgpu_drm.h
>>>> +++ b/include/uapi/drm/amdgpu_drm.h
>>>> @@ -592,6 +592,7 @@ struct drm_amdgpu_gem_va {
>>>>  #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
>>>>  #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT    0x08
>>>>  #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL  0x09
>>>> +#define AMDGPU_CHUNK_ID_CP_GFX_SHADOW   0x0a
>>>>
>>>>  struct drm_amdgpu_cs_chunk {
>>>>         __u32           chunk_id;
>>>> @@ -708,6 +709,15 @@ struct drm_amdgpu_cs_chunk_data {
>>>>         };
>>>>  };
>>>>
>>>> +#define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW         0x1
>>>> +
>>>> +struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
>>>> +       __u64 shadow_va;
>>>> +       __u64 csa_va;
>>>> +       __u64 gds_va;
>>>> +       __u64 flags;
>>>> +};
>>>> +
>>>>  /*
>>>>   *  Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
>>>>   *
>>>> --
>>>> 2.39.2
>>>>
>>>>
>>>
>>
>

[-- Attachment #2: Type: text/html, Size: 8083 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/13] drm/amdgpu/UAPI: add new CS chunk for GFX shadow buffers
  2023-04-13  9:21               ` Marek Olšák
@ 2023-04-13 11:32                 ` Christian König
  2023-04-13 12:26                   ` Alex Deucher
  0 siblings, 1 reply; 33+ messages in thread
From: Christian König @ 2023-04-13 11:32 UTC (permalink / raw)
  To: Marek Olšák; +Cc: Alex Deucher, amd-gfx mailing list

[-- Attachment #1: Type: text/plain, Size: 4430 bytes --]

Ok, then we have a problem.

Alex what do you think?

Christian.

Am 13.04.23 um 11:21 schrieb Marek Olšák:
> That's not why it was removed. It was removed because userspace 
> doesn't use GDS memory and gds_va is always going to be 0.
>
> Firmware shouldn't use it because using it would increase preemption 
> latency.
>
> Marek
>
> On Sun, Apr 9, 2023, 11:21 Christian König 
> <ckoenig.leichtzumerken@gmail.com> wrote:
>
>     We removed the GDS information because they were unnecessary. The
>     GDS size was already part of the device info before we added the
>     shadow info.
>
>     But as far as I know the firmware needs valid VAs for all three
>     buffers or won't work correctly.
>
>     Christian.
>
>     Am 06.04.23 um 17:01 schrieb Marek Olšák:
>>     There is no GDS shadowing info in the device info uapi, so
>>     userspace can't create any GDS buffer and thus can't have any GDS
>>     va. It's a uapi issue, not what firmware wants to do.
>>
>>     Marek
>>
>>     On Thu, Apr 6, 2023 at 6:31 AM Christian König
>>     <ckoenig.leichtzumerken@gmail.com> wrote:
>>
>>         That's what I thought as well, but Mitch/Hans insisted on that.
>>
>>         We should probably double check internally.
>>
>>         Christian.
>>
>>         Am 06.04.23 um 11:43 schrieb Marek Olšák:
>>>         GDS memory isn't used on gfx11. Only GDS OA is used.
>>>
>>>         Marek
>>>
>>>         On Thu, Apr 6, 2023 at 5:09 AM Christian König
>>>         <christian.koenig@amd.com> wrote:
>>>
>>>             Why that?
>>>
>>>             This is the save buffer for GDS, not the old style GDS BOs.
>>>
>>>             Christian.
>>>
>>>             Am 06.04.23 um 09:36 schrieb Marek Olšák:
>>>>             gds_va is unnecessary.
>>>>
>>>>             Marek
>>>>
>>>>             On Thu, Mar 30, 2023 at 3:18 PM Alex Deucher
>>>>             <alexander.deucher@amd.com> wrote:
>>>>
>>>>                 For GFX11, the UMD needs to allocate some shadow
>>>>                 buffers
>>>>                 to be used for preemption.  The UMD allocates the
>>>>                 buffers
>>>>                 and passes the GPU virtual address to the kernel
>>>>                 since the
>>>>                 kernel will program the packet that specified these
>>>>                 addresses as part of its IB submission frame.
>>>>
>>>>                 v2: UMD passes shadow init to tell kernel when to
>>>>                 initialize
>>>>                     the shadow
>>>>
>>>>                 Reviewed-by: Christian König <christian.koenig@amd.com>
>>>>                 Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>>>>                 ---
>>>>                  include/uapi/drm/amdgpu_drm.h | 10 ++++++++++
>>>>                  1 file changed, 10 insertions(+)
>>>>
>>>>                 diff --git a/include/uapi/drm/amdgpu_drm.h
>>>>                 b/include/uapi/drm/amdgpu_drm.h
>>>>                 index b6eb90df5d05..3d9474af6566 100644
>>>>                 --- a/include/uapi/drm/amdgpu_drm.h
>>>>                 +++ b/include/uapi/drm/amdgpu_drm.h
>>>>                 @@ -592,6 +592,7 @@ struct drm_amdgpu_gem_va {
>>>>                  #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
>>>>                  #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT   0x08
>>>>                  #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL 0x09
>>>>                 +#define AMDGPU_CHUNK_ID_CP_GFX_SHADOW  0x0a
>>>>
>>>>                  struct drm_amdgpu_cs_chunk {
>>>>                         __u32           chunk_id;
>>>>                 @@ -708,6 +709,15 @@ struct drm_amdgpu_cs_chunk_data {
>>>>                         };
>>>>                  };
>>>>
>>>>                 +#define
>>>>                 AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW    
>>>>                    0x1
>>>>                 +
>>>>                 +struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
>>>>                 +       __u64 shadow_va;
>>>>                 +       __u64 csa_va;
>>>>                 +       __u64 gds_va;
>>>>                 +       __u64 flags;
>>>>                 +};
>>>>                 +
>>>>                  /*
>>>>                   *  Query h/w info: Flag that this is integrated
>>>>                 (a.h.a. fusion) GPU
>>>>                   *
>>>>                 -- 
>>>>                 2.39.2
>>>>
>>>
>>
>

[-- Attachment #2: Type: text/html, Size: 12341 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/13] drm/amdgpu/UAPI: add new CS chunk for GFX shadow buffers
  2023-04-13 11:32                 ` Christian König
@ 2023-04-13 12:26                   ` Alex Deucher
  2023-04-13 15:54                     ` Christian König
  0 siblings, 1 reply; 33+ messages in thread
From: Alex Deucher @ 2023-04-13 12:26 UTC (permalink / raw)
  To: Christian König
  Cc: Alex Deucher, amd-gfx mailing list, Marek Olšák

On Thu, Apr 13, 2023 at 7:32 AM Christian König
<ckoenig.leichtzumerken@gmail.com> wrote:
>
> Ok, then we have a problem.
>
> Alex what do you think?

If you program it to 0, FW skips the GDS backup I think so UMD's can
decide whether they want to use it or not, depending on whether they
use GDS.

Alex


>
> Christian.
>
> Am 13.04.23 um 11:21 schrieb Marek Olšák:
>
> That's not why it was removed. It was removed because userspace doesn't use GDS memory and gds_va is always going to be 0.
>
> Firmware shouldn't use it because using it would increase preemption latency.
>
> Marek
>
> On Sun, Apr 9, 2023, 11:21 Christian König <ckoenig.leichtzumerken@gmail.com> wrote:
>>
>> We removed the GDS information because they were unnecessary. The GDS size was already part of the device info before we added the shadow info.
>>
>> But as far as I know the firmware needs valid VAs for all three buffers or won't work correctly.
>>
>> Christian.
>>
>> Am 06.04.23 um 17:01 schrieb Marek Olšák:
>>
>> There is no GDS shadowing info in the device info uapi, so userspace can't create any GDS buffer and thus can't have any GDS va. It's a uapi issue, not what firmware wants to do.
>>
>> Marek
>>
>> On Thu, Apr 6, 2023 at 6:31 AM Christian König <ckoenig.leichtzumerken@gmail.com> wrote:
>>>
>>> That's what I thought as well, but Mitch/Hans insisted on that.
>>>
>>> We should probably double check internally.
>>>
>>> Christian.
>>>
>>> Am 06.04.23 um 11:43 schrieb Marek Olšák:
>>>
>>> GDS memory isn't used on gfx11. Only GDS OA is used.
>>>
>>> Marek
>>>
>>> On Thu, Apr 6, 2023 at 5:09 AM Christian König <christian.koenig@amd.com> wrote:
>>>>
>>>> Why that?
>>>>
>>>> This is the save buffer for GDS, not the old style GDS BOs.
>>>>
>>>> Christian.
>>>>
>>>> Am 06.04.23 um 09:36 schrieb Marek Olšák:
>>>>
>>>> gds_va is unnecessary.
>>>>
>>>> Marek
>>>>
>>>> On Thu, Mar 30, 2023 at 3:18 PM Alex Deucher <alexander.deucher@amd.com> wrote:
>>>>>
>>>>> For GFX11, the UMD needs to allocate some shadow buffers
>>>>> to be used for preemption.  The UMD allocates the buffers
>>>>> and passes the GPU virtual address to the kernel since the
>>>>> kernel will program the packet that specified these
>>>>> addresses as part of its IB submission frame.
>>>>>
>>>>> v2: UMD passes shadow init to tell kernel when to initialize
>>>>>     the shadow
>>>>>
>>>>> Reviewed-by: Christian König <christian.koenig@amd.com>
>>>>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>>>>> ---
>>>>>  include/uapi/drm/amdgpu_drm.h | 10 ++++++++++
>>>>>  1 file changed, 10 insertions(+)
>>>>>
>>>>> diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
>>>>> index b6eb90df5d05..3d9474af6566 100644
>>>>> --- a/include/uapi/drm/amdgpu_drm.h
>>>>> +++ b/include/uapi/drm/amdgpu_drm.h
>>>>> @@ -592,6 +592,7 @@ struct drm_amdgpu_gem_va {
>>>>>  #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
>>>>>  #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT    0x08
>>>>>  #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL  0x09
>>>>> +#define AMDGPU_CHUNK_ID_CP_GFX_SHADOW   0x0a
>>>>>
>>>>>  struct drm_amdgpu_cs_chunk {
>>>>>         __u32           chunk_id;
>>>>> @@ -708,6 +709,15 @@ struct drm_amdgpu_cs_chunk_data {
>>>>>         };
>>>>>  };
>>>>>
>>>>> +#define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW         0x1
>>>>> +
>>>>> +struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
>>>>> +       __u64 shadow_va;
>>>>> +       __u64 csa_va;
>>>>> +       __u64 gds_va;
>>>>> +       __u64 flags;
>>>>> +};
>>>>> +
>>>>>  /*
>>>>>   *  Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
>>>>>   *
>>>>> --
>>>>> 2.39.2
>>>>>
>>>>
>>>
>>
>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/13] drm/amdgpu/UAPI: add new CS chunk for GFX shadow buffers
  2023-04-13 12:26                   ` Alex Deucher
@ 2023-04-13 15:54                     ` Christian König
  2023-04-13 16:56                       ` Alex Deucher
  0 siblings, 1 reply; 33+ messages in thread
From: Christian König @ 2023-04-13 15:54 UTC (permalink / raw)
  To: Alex Deucher; +Cc: Alex Deucher, amd-gfx mailing list, Marek Olšák

Am 13.04.23 um 14:26 schrieb Alex Deucher:
> On Thu, Apr 13, 2023 at 7:32 AM Christian König
> <ckoenig.leichtzumerken@gmail.com> wrote:
>> Ok, then we have a problem.
>>
>> Alex what do you think?
> If you program it to 0, FW skips the GDS backup I think so UMD's can
> decide whether they want to use it or not, depending on whether they
> use GDS.

Yeah, but when Mesa isn't using it we have a hard way justifying to 
upstream that because it isn't tested at all.

Christian.

>
> Alex
>
>
>> Christian.
>>
>> Am 13.04.23 um 11:21 schrieb Marek Olšák:
>>
>> That's not why it was removed. It was removed because userspace doesn't use GDS memory and gds_va is always going to be 0.
>>
>> Firmware shouldn't use it because using it would increase preemption latency.
>>
>> Marek
>>
>> On Sun, Apr 9, 2023, 11:21 Christian König <ckoenig.leichtzumerken@gmail.com> wrote:
>>> We removed the GDS information because they were unnecessary. The GDS size was already part of the device info before we added the shadow info.
>>>
>>> But as far as I know the firmware needs valid VAs for all three buffers or won't work correctly.
>>>
>>> Christian.
>>>
>>> Am 06.04.23 um 17:01 schrieb Marek Olšák:
>>>
>>> There is no GDS shadowing info in the device info uapi, so userspace can't create any GDS buffer and thus can't have any GDS va. It's a uapi issue, not what firmware wants to do.
>>>
>>> Marek
>>>
>>> On Thu, Apr 6, 2023 at 6:31 AM Christian König <ckoenig.leichtzumerken@gmail.com> wrote:
>>>> That's what I thought as well, but Mitch/Hans insisted on that.
>>>>
>>>> We should probably double check internally.
>>>>
>>>> Christian.
>>>>
>>>> Am 06.04.23 um 11:43 schrieb Marek Olšák:
>>>>
>>>> GDS memory isn't used on gfx11. Only GDS OA is used.
>>>>
>>>> Marek
>>>>
>>>> On Thu, Apr 6, 2023 at 5:09 AM Christian König <christian.koenig@amd.com> wrote:
>>>>> Why that?
>>>>>
>>>>> This is the save buffer for GDS, not the old style GDS BOs.
>>>>>
>>>>> Christian.
>>>>>
>>>>> Am 06.04.23 um 09:36 schrieb Marek Olšák:
>>>>>
>>>>> gds_va is unnecessary.
>>>>>
>>>>> Marek
>>>>>
>>>>> On Thu, Mar 30, 2023 at 3:18 PM Alex Deucher <alexander.deucher@amd.com> wrote:
>>>>>> For GFX11, the UMD needs to allocate some shadow buffers
>>>>>> to be used for preemption.  The UMD allocates the buffers
>>>>>> and passes the GPU virtual address to the kernel since the
>>>>>> kernel will program the packet that specified these
>>>>>> addresses as part of its IB submission frame.
>>>>>>
>>>>>> v2: UMD passes shadow init to tell kernel when to initialize
>>>>>>      the shadow
>>>>>>
>>>>>> Reviewed-by: Christian König <christian.koenig@amd.com>
>>>>>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>>>>>> ---
>>>>>>   include/uapi/drm/amdgpu_drm.h | 10 ++++++++++
>>>>>>   1 file changed, 10 insertions(+)
>>>>>>
>>>>>> diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
>>>>>> index b6eb90df5d05..3d9474af6566 100644
>>>>>> --- a/include/uapi/drm/amdgpu_drm.h
>>>>>> +++ b/include/uapi/drm/amdgpu_drm.h
>>>>>> @@ -592,6 +592,7 @@ struct drm_amdgpu_gem_va {
>>>>>>   #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
>>>>>>   #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT    0x08
>>>>>>   #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL  0x09
>>>>>> +#define AMDGPU_CHUNK_ID_CP_GFX_SHADOW   0x0a
>>>>>>
>>>>>>   struct drm_amdgpu_cs_chunk {
>>>>>>          __u32           chunk_id;
>>>>>> @@ -708,6 +709,15 @@ struct drm_amdgpu_cs_chunk_data {
>>>>>>          };
>>>>>>   };
>>>>>>
>>>>>> +#define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW         0x1
>>>>>> +
>>>>>> +struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
>>>>>> +       __u64 shadow_va;
>>>>>> +       __u64 csa_va;
>>>>>> +       __u64 gds_va;
>>>>>> +       __u64 flags;
>>>>>> +};
>>>>>> +
>>>>>>   /*
>>>>>>    *  Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
>>>>>>    *
>>>>>> --
>>>>>> 2.39.2
>>>>>>


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/13] drm/amdgpu/UAPI: add new CS chunk for GFX shadow buffers
  2023-04-13 15:54                     ` Christian König
@ 2023-04-13 16:56                       ` Alex Deucher
  2023-04-13 18:23                         ` Marek Olšák
  0 siblings, 1 reply; 33+ messages in thread
From: Alex Deucher @ 2023-04-13 16:56 UTC (permalink / raw)
  To: Christian König
  Cc: Alex Deucher, amd-gfx mailing list, Marek Olšák

On Thu, Apr 13, 2023 at 11:54 AM Christian König
<ckoenig.leichtzumerken@gmail.com> wrote:
>
> Am 13.04.23 um 14:26 schrieb Alex Deucher:
> > On Thu, Apr 13, 2023 at 7:32 AM Christian König
> > <ckoenig.leichtzumerken@gmail.com> wrote:
> >> Ok, then we have a problem.
> >>
> >> Alex what do you think?
> > If you program it to 0, FW skips the GDS backup I think so UMD's can
> > decide whether they want to use it or not, depending on whether they
> > use GDS.
>
> Yeah, but when Mesa isn't using it we have a hard way justifying to
> upstream that because it isn't tested at all.

Well, the interface would still get used, it's just that mesa would
likely only ever pass 0 for the virtual address.  It's just a
passthrough to the packet.  If we discover we need it at some point,
it would be nice to not have to add a new interface to add it.

Alex

>
> Christian.
>
> >
> > Alex
> >
> >
> >> Christian.
> >>
> >> Am 13.04.23 um 11:21 schrieb Marek Olšák:
> >>
> >> That's not why it was removed. It was removed because userspace doesn't use GDS memory and gds_va is always going to be 0.
> >>
> >> Firmware shouldn't use it because using it would increase preemption latency.
> >>
> >> Marek
> >>
> >> On Sun, Apr 9, 2023, 11:21 Christian König <ckoenig.leichtzumerken@gmail.com> wrote:
> >>> We removed the GDS information because they were unnecessary. The GDS size was already part of the device info before we added the shadow info.
> >>>
> >>> But as far as I know the firmware needs valid VAs for all three buffers or won't work correctly.
> >>>
> >>> Christian.
> >>>
> >>> Am 06.04.23 um 17:01 schrieb Marek Olšák:
> >>>
> >>> There is no GDS shadowing info in the device info uapi, so userspace can't create any GDS buffer and thus can't have any GDS va. It's a uapi issue, not what firmware wants to do.
> >>>
> >>> Marek
> >>>
> >>> On Thu, Apr 6, 2023 at 6:31 AM Christian König <ckoenig.leichtzumerken@gmail.com> wrote:
> >>>> That's what I thought as well, but Mitch/Hans insisted on that.
> >>>>
> >>>> We should probably double check internally.
> >>>>
> >>>> Christian.
> >>>>
> >>>> Am 06.04.23 um 11:43 schrieb Marek Olšák:
> >>>>
> >>>> GDS memory isn't used on gfx11. Only GDS OA is used.
> >>>>
> >>>> Marek
> >>>>
> >>>> On Thu, Apr 6, 2023 at 5:09 AM Christian König <christian.koenig@amd.com> wrote:
> >>>>> Why that?
> >>>>>
> >>>>> This is the save buffer for GDS, not the old style GDS BOs.
> >>>>>
> >>>>> Christian.
> >>>>>
> >>>>> Am 06.04.23 um 09:36 schrieb Marek Olšák:
> >>>>>
> >>>>> gds_va is unnecessary.
> >>>>>
> >>>>> Marek
> >>>>>
> >>>>> On Thu, Mar 30, 2023 at 3:18 PM Alex Deucher <alexander.deucher@amd.com> wrote:
> >>>>>> For GFX11, the UMD needs to allocate some shadow buffers
> >>>>>> to be used for preemption.  The UMD allocates the buffers
> >>>>>> and passes the GPU virtual address to the kernel since the
> >>>>>> kernel will program the packet that specified these
> >>>>>> addresses as part of its IB submission frame.
> >>>>>>
> >>>>>> v2: UMD passes shadow init to tell kernel when to initialize
> >>>>>>      the shadow
> >>>>>>
> >>>>>> Reviewed-by: Christian König <christian.koenig@amd.com>
> >>>>>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> >>>>>> ---
> >>>>>>   include/uapi/drm/amdgpu_drm.h | 10 ++++++++++
> >>>>>>   1 file changed, 10 insertions(+)
> >>>>>>
> >>>>>> diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
> >>>>>> index b6eb90df5d05..3d9474af6566 100644
> >>>>>> --- a/include/uapi/drm/amdgpu_drm.h
> >>>>>> +++ b/include/uapi/drm/amdgpu_drm.h
> >>>>>> @@ -592,6 +592,7 @@ struct drm_amdgpu_gem_va {
> >>>>>>   #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
> >>>>>>   #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT    0x08
> >>>>>>   #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL  0x09
> >>>>>> +#define AMDGPU_CHUNK_ID_CP_GFX_SHADOW   0x0a
> >>>>>>
> >>>>>>   struct drm_amdgpu_cs_chunk {
> >>>>>>          __u32           chunk_id;
> >>>>>> @@ -708,6 +709,15 @@ struct drm_amdgpu_cs_chunk_data {
> >>>>>>          };
> >>>>>>   };
> >>>>>>
> >>>>>> +#define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW         0x1
> >>>>>> +
> >>>>>> +struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
> >>>>>> +       __u64 shadow_va;
> >>>>>> +       __u64 csa_va;
> >>>>>> +       __u64 gds_va;
> >>>>>> +       __u64 flags;
> >>>>>> +};
> >>>>>> +
> >>>>>>   /*
> >>>>>>    *  Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
> >>>>>>    *
> >>>>>> --
> >>>>>> 2.39.2
> >>>>>>
>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/13] drm/amdgpu/UAPI: add new CS chunk for GFX shadow buffers
  2023-04-13 16:56                       ` Alex Deucher
@ 2023-04-13 18:23                         ` Marek Olšák
  2023-04-13 18:58                           ` Christian König
  0 siblings, 1 reply; 33+ messages in thread
From: Marek Olšák @ 2023-04-13 18:23 UTC (permalink / raw)
  To: Alex Deucher; +Cc: Alex Deucher, Christian König, amd-gfx mailing list

[-- Attachment #1: Type: text/plain, Size: 5070 bytes --]

I'm OK with that.

Marek

On Thu, Apr 13, 2023 at 12:56 PM Alex Deucher <alexdeucher@gmail.com> wrote:

> On Thu, Apr 13, 2023 at 11:54 AM Christian König
> <ckoenig.leichtzumerken@gmail.com> wrote:
> >
> > Am 13.04.23 um 14:26 schrieb Alex Deucher:
> > > On Thu, Apr 13, 2023 at 7:32 AM Christian König
> > > <ckoenig.leichtzumerken@gmail.com> wrote:
> > >> Ok, then we have a problem.
> > >>
> > >> Alex what do you think?
> > > If you program it to 0, FW skips the GDS backup I think so UMD's can
> > > decide whether they want to use it or not, depending on whether they
> > > use GDS.
> >
> > Yeah, but when Mesa isn't using it we have a hard way justifying to
> > upstream that because it isn't tested at all.
>
> Well, the interface would still get used, it's just that mesa would
> likely only ever pass 0 for the virtual address.  It's just a
> passthrough to the packet.  If we discover we need it at some point,
> it would be nice to not have to add a new interface to add it.
>
> Alex
>
> >
> > Christian.
> >
> > >
> > > Alex
> > >
> > >
> > >> Christian.
> > >>
> > >> Am 13.04.23 um 11:21 schrieb Marek Olšák:
> > >>
> > >> That's not why it was removed. It was removed because userspace
> doesn't use GDS memory and gds_va is always going to be 0.
> > >>
> > >> Firmware shouldn't use it because using it would increase preemption
> latency.
> > >>
> > >> Marek
> > >>
> > >> On Sun, Apr 9, 2023, 11:21 Christian König <
> ckoenig.leichtzumerken@gmail.com> wrote:
> > >>> We removed the GDS information because they were unnecessary. The
> GDS size was already part of the device info before we added the shadow
> info.
> > >>>
> > >>> But as far as I know the firmware needs valid VAs for all three
> buffers or won't work correctly.
> > >>>
> > >>> Christian.
> > >>>
> > >>> Am 06.04.23 um 17:01 schrieb Marek Olšák:
> > >>>
> > >>> There is no GDS shadowing info in the device info uapi, so userspace
> can't create any GDS buffer and thus can't have any GDS va. It's a uapi
> issue, not what firmware wants to do.
> > >>>
> > >>> Marek
> > >>>
> > >>> On Thu, Apr 6, 2023 at 6:31 AM Christian König <
> ckoenig.leichtzumerken@gmail.com> wrote:
> > >>>> That's what I thought as well, but Mitch/Hans insisted on that.
> > >>>>
> > >>>> We should probably double check internally.
> > >>>>
> > >>>> Christian.
> > >>>>
> > >>>> Am 06.04.23 um 11:43 schrieb Marek Olšák:
> > >>>>
> > >>>> GDS memory isn't used on gfx11. Only GDS OA is used.
> > >>>>
> > >>>> Marek
> > >>>>
> > >>>> On Thu, Apr 6, 2023 at 5:09 AM Christian König <
> christian.koenig@amd.com> wrote:
> > >>>>> Why that?
> > >>>>>
> > >>>>> This is the save buffer for GDS, not the old style GDS BOs.
> > >>>>>
> > >>>>> Christian.
> > >>>>>
> > >>>>> Am 06.04.23 um 09:36 schrieb Marek Olšák:
> > >>>>>
> > >>>>> gds_va is unnecessary.
> > >>>>>
> > >>>>> Marek
> > >>>>>
> > >>>>> On Thu, Mar 30, 2023 at 3:18 PM Alex Deucher <
> alexander.deucher@amd.com> wrote:
> > >>>>>> For GFX11, the UMD needs to allocate some shadow buffers
> > >>>>>> to be used for preemption.  The UMD allocates the buffers
> > >>>>>> and passes the GPU virtual address to the kernel since the
> > >>>>>> kernel will program the packet that specified these
> > >>>>>> addresses as part of its IB submission frame.
> > >>>>>>
> > >>>>>> v2: UMD passes shadow init to tell kernel when to initialize
> > >>>>>>      the shadow
> > >>>>>>
> > >>>>>> Reviewed-by: Christian König <christian.koenig@amd.com>
> > >>>>>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> > >>>>>> ---
> > >>>>>>   include/uapi/drm/amdgpu_drm.h | 10 ++++++++++
> > >>>>>>   1 file changed, 10 insertions(+)
> > >>>>>>
> > >>>>>> diff --git a/include/uapi/drm/amdgpu_drm.h
> b/include/uapi/drm/amdgpu_drm.h
> > >>>>>> index b6eb90df5d05..3d9474af6566 100644
> > >>>>>> --- a/include/uapi/drm/amdgpu_drm.h
> > >>>>>> +++ b/include/uapi/drm/amdgpu_drm.h
> > >>>>>> @@ -592,6 +592,7 @@ struct drm_amdgpu_gem_va {
> > >>>>>>   #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
> > >>>>>>   #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT    0x08
> > >>>>>>   #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL  0x09
> > >>>>>> +#define AMDGPU_CHUNK_ID_CP_GFX_SHADOW   0x0a
> > >>>>>>
> > >>>>>>   struct drm_amdgpu_cs_chunk {
> > >>>>>>          __u32           chunk_id;
> > >>>>>> @@ -708,6 +709,15 @@ struct drm_amdgpu_cs_chunk_data {
> > >>>>>>          };
> > >>>>>>   };
> > >>>>>>
> > >>>>>> +#define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW
>  0x1
> > >>>>>> +
> > >>>>>> +struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
> > >>>>>> +       __u64 shadow_va;
> > >>>>>> +       __u64 csa_va;
> > >>>>>> +       __u64 gds_va;
> > >>>>>> +       __u64 flags;
> > >>>>>> +};
> > >>>>>> +
> > >>>>>>   /*
> > >>>>>>    *  Query h/w info: Flag that this is integrated (a.h.a.
> fusion) GPU
> > >>>>>>    *
> > >>>>>> --
> > >>>>>> 2.39.2
> > >>>>>>
> >
>

[-- Attachment #2: Type: text/html, Size: 8064 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/13] drm/amdgpu/UAPI: add new CS chunk for GFX shadow buffers
  2023-04-13 18:23                         ` Marek Olšák
@ 2023-04-13 18:58                           ` Christian König
  0 siblings, 0 replies; 33+ messages in thread
From: Christian König @ 2023-04-13 18:58 UTC (permalink / raw)
  To: Marek Olšák, Alex Deucher; +Cc: Alex Deucher, amd-gfx mailing list

[-- Attachment #1: Type: text/plain, Size: 5625 bytes --]

Me as well.

Christian.

Am 13.04.23 um 20:23 schrieb Marek Olšák:
> I'm OK with that.
>
> Marek
>
> On Thu, Apr 13, 2023 at 12:56 PM Alex Deucher <alexdeucher@gmail.com> 
> wrote:
>
>     On Thu, Apr 13, 2023 at 11:54 AM Christian König
>     <ckoenig.leichtzumerken@gmail.com> wrote:
>     >
>     > Am 13.04.23 um 14:26 schrieb Alex Deucher:
>     > > On Thu, Apr 13, 2023 at 7:32 AM Christian König
>     > > <ckoenig.leichtzumerken@gmail.com> wrote:
>     > >> Ok, then we have a problem.
>     > >>
>     > >> Alex what do you think?
>     > > If you program it to 0, FW skips the GDS backup I think so
>     UMD's can
>     > > decide whether they want to use it or not, depending on
>     whether they
>     > > use GDS.
>     >
>     > Yeah, but when Mesa isn't using it we have a hard way justifying to
>     > upstream that because it isn't tested at all.
>
>     Well, the interface would still get used, it's just that mesa would
>     likely only ever pass 0 for the virtual address.  It's just a
>     passthrough to the packet.  If we discover we need it at some point,
>     it would be nice to not have to add a new interface to add it.
>
>     Alex
>
>     >
>     > Christian.
>     >
>     > >
>     > > Alex
>     > >
>     > >
>     > >> Christian.
>     > >>
>     > >> Am 13.04.23 um 11:21 schrieb Marek Olšák:
>     > >>
>     > >> That's not why it was removed. It was removed because
>     userspace doesn't use GDS memory and gds_va is always going to be 0.
>     > >>
>     > >> Firmware shouldn't use it because using it would increase
>     preemption latency.
>     > >>
>     > >> Marek
>     > >>
>     > >> On Sun, Apr 9, 2023, 11:21 Christian König
>     <ckoenig.leichtzumerken@gmail.com> wrote:
>     > >>> We removed the GDS information because they were
>     unnecessary. The GDS size was already part of the device info
>     before we added the shadow info.
>     > >>>
>     > >>> But as far as I know the firmware needs valid VAs for all
>     three buffers or won't work correctly.
>     > >>>
>     > >>> Christian.
>     > >>>
>     > >>> Am 06.04.23 um 17:01 schrieb Marek Olšák:
>     > >>>
>     > >>> There is no GDS shadowing info in the device info uapi, so
>     userspace can't create any GDS buffer and thus can't have any GDS
>     va. It's a uapi issue, not what firmware wants to do.
>     > >>>
>     > >>> Marek
>     > >>>
>     > >>> On Thu, Apr 6, 2023 at 6:31 AM Christian König
>     <ckoenig.leichtzumerken@gmail.com> wrote:
>     > >>>> That's what I thought as well, but Mitch/Hans insisted on that.
>     > >>>>
>     > >>>> We should probably double check internally.
>     > >>>>
>     > >>>> Christian.
>     > >>>>
>     > >>>> Am 06.04.23 um 11:43 schrieb Marek Olšák:
>     > >>>>
>     > >>>> GDS memory isn't used on gfx11. Only GDS OA is used.
>     > >>>>
>     > >>>> Marek
>     > >>>>
>     > >>>> On Thu, Apr 6, 2023 at 5:09 AM Christian König
>     <christian.koenig@amd.com> wrote:
>     > >>>>> Why that?
>     > >>>>>
>     > >>>>> This is the save buffer for GDS, not the old style GDS BOs.
>     > >>>>>
>     > >>>>> Christian.
>     > >>>>>
>     > >>>>> Am 06.04.23 um 09:36 schrieb Marek Olšák:
>     > >>>>>
>     > >>>>> gds_va is unnecessary.
>     > >>>>>
>     > >>>>> Marek
>     > >>>>>
>     > >>>>> On Thu, Mar 30, 2023 at 3:18 PM Alex Deucher
>     <alexander.deucher@amd.com> wrote:
>     > >>>>>> For GFX11, the UMD needs to allocate some shadow buffers
>     > >>>>>> to be used for preemption.  The UMD allocates the buffers
>     > >>>>>> and passes the GPU virtual address to the kernel since the
>     > >>>>>> kernel will program the packet that specified these
>     > >>>>>> addresses as part of its IB submission frame.
>     > >>>>>>
>     > >>>>>> v2: UMD passes shadow init to tell kernel when to initialize
>     > >>>>>>      the shadow
>     > >>>>>>
>     > >>>>>> Reviewed-by: Christian König <christian.koenig@amd.com>
>     > >>>>>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>     > >>>>>> ---
>     > >>>>>>   include/uapi/drm/amdgpu_drm.h | 10 ++++++++++
>     > >>>>>>   1 file changed, 10 insertions(+)
>     > >>>>>>
>     > >>>>>> diff --git a/include/uapi/drm/amdgpu_drm.h
>     b/include/uapi/drm/amdgpu_drm.h
>     > >>>>>> index b6eb90df5d05..3d9474af6566 100644
>     > >>>>>> --- a/include/uapi/drm/amdgpu_drm.h
>     > >>>>>> +++ b/include/uapi/drm/amdgpu_drm.h
>     > >>>>>> @@ -592,6 +592,7 @@ struct drm_amdgpu_gem_va {
>     > >>>>>>   #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
>     > >>>>>>   #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT    0x08
>     > >>>>>>   #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL  0x09
>     > >>>>>> +#define AMDGPU_CHUNK_ID_CP_GFX_SHADOW   0x0a
>     > >>>>>>
>     > >>>>>>   struct drm_amdgpu_cs_chunk {
>     > >>>>>>          __u32  chunk_id;
>     > >>>>>> @@ -708,6 +709,15 @@ struct drm_amdgpu_cs_chunk_data {
>     > >>>>>>          };
>     > >>>>>>   };
>     > >>>>>>
>     > >>>>>> +#define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW 
>            0x1
>     > >>>>>> +
>     > >>>>>> +struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
>     > >>>>>> +       __u64 shadow_va;
>     > >>>>>> +       __u64 csa_va;
>     > >>>>>> +       __u64 gds_va;
>     > >>>>>> +       __u64 flags;
>     > >>>>>> +};
>     > >>>>>> +
>     > >>>>>>   /*
>     > >>>>>>    *  Query h/w info: Flag that this is integrated
>     (a.h.a. fusion) GPU
>     > >>>>>>    *
>     > >>>>>> --
>     > >>>>>> 2.39.2
>     > >>>>>>
>     >
>

[-- Attachment #2: Type: text/html, Size: 11013 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 09/13] drm/amdgpu: add get_gfx_shadow_info callback for gfx11
  2023-03-30 19:17 ` [PATCH 09/13] drm/amdgpu: add get_gfx_shadow_info callback for gfx11 Alex Deucher
@ 2023-04-19 22:11   ` Alex Deucher
  0 siblings, 0 replies; 33+ messages in thread
From: Alex Deucher @ 2023-04-19 22:11 UTC (permalink / raw)
  To: Alex Deucher; +Cc: amd-gfx

Ping?

On Thu, Mar 30, 2023 at 3:18 PM Alex Deucher <alexander.deucher@amd.com> wrote:
>
> Used to get the size and alignment requirements for
> the gfx shadow buffer for preemption.
>
> v2: use FW version check to determine whether to
>     return a valid size here
>     return an error if not supported (Alex)
> v3: drop GDS (Alex)
> v4: make amdgpu_gfx_shadow_info mandatory (Alex)
>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> index 1fc1e941f7df..7a5da13cffa0 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> @@ -822,6 +822,27 @@ static void gfx_v11_0_select_me_pipe_q(struct amdgpu_device *adev,
>         soc21_grbm_select(adev, me, pipe, q, vm);
>  }
>
> +/* all sizes are in bytes */
> +#define MQD_SHADOW_BASE_SIZE      73728
> +#define MQD_SHADOW_BASE_ALIGNMENT 256
> +#define MQD_FWWORKAREA_SIZE       484
> +#define MQD_FWWORKAREA_ALIGNMENT  256
> +
> +static int gfx_v11_0_get_gfx_shadow_info(struct amdgpu_device *adev,
> +                                        struct amdgpu_gfx_shadow_info *shadow_info)
> +{
> +       if (adev->gfx.cp_gfx_shadow) {
> +               shadow_info->shadow_size = MQD_SHADOW_BASE_SIZE;
> +               shadow_info->shadow_alignment = MQD_SHADOW_BASE_ALIGNMENT;
> +               shadow_info->csa_size = MQD_FWWORKAREA_SIZE;
> +               shadow_info->csa_alignment = MQD_FWWORKAREA_ALIGNMENT;
> +               return 0;
> +       } else {
> +               memset(shadow_info, 0, sizeof(struct amdgpu_gfx_shadow_info));
> +               return -ENOTSUPP;
> +       }
> +}
> +
>  static const struct amdgpu_gfx_funcs gfx_v11_0_gfx_funcs = {
>         .get_gpu_clock_counter = &gfx_v11_0_get_gpu_clock_counter,
>         .select_se_sh = &gfx_v11_0_select_se_sh,
> @@ -830,6 +851,7 @@ static const struct amdgpu_gfx_funcs gfx_v11_0_gfx_funcs = {
>         .read_wave_vgprs = &gfx_v11_0_read_wave_vgprs,
>         .select_me_pipe_q = &gfx_v11_0_select_me_pipe_q,
>         .update_perfmon_mgcg = &gfx_v11_0_update_perf_clk,
> +       .get_gfx_shadow_info = &gfx_v11_0_get_gfx_shadow_info,
>  };
>
>  static int gfx_v11_0_gpu_early_init(struct amdgpu_device *adev)
> --
> 2.39.2
>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 10/13] drm/amdgpu: add support for new GFX shadow size query
  2023-03-30 19:17 ` [PATCH 10/13] drm/amdgpu: add support for new GFX shadow size query Alex Deucher
@ 2023-04-19 22:12   ` Alex Deucher
  0 siblings, 0 replies; 33+ messages in thread
From: Alex Deucher @ 2023-04-19 22:12 UTC (permalink / raw)
  To: Alex Deucher; +Cc: amd-gfx

Ping?

On Thu, Mar 30, 2023 at 3:18 PM Alex Deucher <alexander.deucher@amd.com> wrote:
>
> Use the new callback to fetch the data.  Return an error if
> not supported.  UMDs should use this query to check whether
> shadow buffers are supported and if so what size they
> should be.
>
> v2: return an error rather than a zerod structure.
> v3: drop GDS, move into dev_info structure.  Data will be
>     0 if not supported.
> v4: drop local variable r
>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 0efb38539d70..fd735df92b9a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -876,6 +876,19 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
>                 dev_info->gl2c_cache_size = adev->gfx.config.gc_gl2c_per_gpu;
>                 dev_info->mall_size = adev->gmc.mall_size;
>
> +
> +               if (adev->gfx.funcs->get_gfx_shadow_info) {
> +                       struct amdgpu_gfx_shadow_info shadow_info;
> +
> +                       ret = amdgpu_gfx_get_gfx_shadow_info(adev, &shadow_info);
> +                       if (!ret) {
> +                               dev_info->shadow_size = shadow_info.shadow_size;
> +                               dev_info->shadow_alignment = shadow_info.shadow_alignment;
> +                               dev_info->csa_size = shadow_info.csa_size;
> +                               dev_info->csa_alignment = shadow_info.csa_alignment;
> +                       }
> +               }
> +
>                 ret = copy_to_user(out, dev_info,
>                                    min((size_t)size, sizeof(*dev_info))) ? -EFAULT : 0;
>                 kfree(dev_info);
> --
> 2.39.2
>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 11/13] drm/amdgpu: bump driver version number for CP GFX shadow
  2023-03-30 19:17 ` [PATCH 11/13] drm/amdgpu: bump driver version number for CP GFX shadow Alex Deucher
@ 2023-04-19 22:12   ` Alex Deucher
  0 siblings, 0 replies; 33+ messages in thread
From: Alex Deucher @ 2023-04-19 22:12 UTC (permalink / raw)
  To: Alex Deucher; +Cc: amd-gfx

Ping?

On Thu, Mar 30, 2023 at 3:18 PM Alex Deucher <alexander.deucher@amd.com> wrote:
>
> So UMDs can determine whether the kernel supports this.
>
> Mesa MR: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21986
>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index 917926c8dc5f..c35baee082e6 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -111,9 +111,10 @@
>   *   3.52.0 - Add AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD, add device_info fields:
>   *            tcp_cache_size, num_sqc_per_wgp, sqc_data_cache_size, sqc_inst_cache_size,
>   *            gl1c_cache_size, gl2c_cache_size, mall_size, enabled_rb_pipes_mask_hi
> + *   3.53.0 - Support for GFX11 CP GFX shadowing
>   */
>  #define KMS_DRIVER_MAJOR       3
> -#define KMS_DRIVER_MINOR       52
> +#define KMS_DRIVER_MINOR       53
>  #define KMS_DRIVER_PATCHLEVEL  0
>
>  unsigned int amdgpu_vram_limit = UINT_MAX;
> --
> 2.39.2
>

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2023-04-19 22:12 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-30 19:17 [PATCH V4 00/13] Enable FW assisted shadowing for GFX11 Alex Deucher
2023-03-30 19:17 ` [PATCH 01/13] drm/amdgpu/gfx11: add FW version check for new CP GFX shadow feature Alex Deucher
2023-03-30 19:17 ` [PATCH 02/13] drm/amdgpu/gfx11: check the CP FW version CP GFX shadow support Alex Deucher
2023-03-31  6:34   ` Christian König
2023-03-31 19:18     ` Alex Deucher
2023-03-30 19:17 ` [PATCH 03/13] drm/amdgpu/UAPI: add new CS chunk for GFX shadow buffers Alex Deucher
2023-04-06  7:36   ` Marek Olšák
2023-04-06  9:09     ` Christian König
2023-04-06  9:43       ` Marek Olšák
2023-04-06 10:31         ` Christian König
2023-04-06 15:01           ` Marek Olšák
2023-04-09 15:21             ` Christian König
2023-04-13  9:21               ` Marek Olšák
2023-04-13 11:32                 ` Christian König
2023-04-13 12:26                   ` Alex Deucher
2023-04-13 15:54                     ` Christian König
2023-04-13 16:56                       ` Alex Deucher
2023-04-13 18:23                         ` Marek Olšák
2023-04-13 18:58                           ` Christian König
2023-03-30 19:17 ` [PATCH 04/13] drm/amdgpu: add gfx shadow CS IOCTL support Alex Deucher
2023-03-31  6:33   ` Christian König
2023-03-30 19:17 ` [PATCH 05/13] drm/amdgpu: add gfx11 emit shadow callback Alex Deucher
2023-03-30 19:17 ` [PATCH 06/13] drm/amdgpu: don't require a job for cond_exec and shadow Alex Deucher
2023-03-30 19:17 ` [PATCH 07/13] drm/amdgpu: add UAPI to query GFX shadow sizes Alex Deucher
2023-03-30 19:17 ` [PATCH 08/13] drm/amdgpu: add gfx shadow callback Alex Deucher
2023-03-30 19:17 ` [PATCH 09/13] drm/amdgpu: add get_gfx_shadow_info callback for gfx11 Alex Deucher
2023-04-19 22:11   ` Alex Deucher
2023-03-30 19:17 ` [PATCH 10/13] drm/amdgpu: add support for new GFX shadow size query Alex Deucher
2023-04-19 22:12   ` Alex Deucher
2023-03-30 19:17 ` [PATCH 11/13] drm/amdgpu: bump driver version number for CP GFX shadow Alex Deucher
2023-04-19 22:12   ` Alex Deucher
2023-03-30 19:17 ` [PATCH 12/13] drm/amdgpu: track MQD size for gfx and compute Alex Deucher
2023-03-30 19:17 ` [PATCH 13/13] drm/amdgpu: add debugfs interface for reading MQDs Alex Deucher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.