Skip to contentSkip to conversation

GFX8's meta-data write feature for SRIOV

PATCH In review Monk Liu 3 participants 11 messages Jan 12, 2017 – Jan 16, 2017 7 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Monk Liu

author
#0 lore raw

cover GFX8's meta-data write feature for SRIOV

*** BLURB HERE ***
to enable GFX SRIOV we need insert some new packag in gfx ring which called META-DATA write command, and meta-data is composed by two parts: CE and DE.
CE's meta-data write need prior to CNTX_CNTL package while DE's should following that.

meta-data will notify CP about the CSA address for usage when preeption occured.

Monk Liu (3):
drm/amdgpu:add META_DATA struct for CSA/SRIOV drm/amdgpu:implement META-DATA write routines drm/amdgpu:invoke meta-data write around cntx_cntl

 drivers/gpu/drm/amd/amdgpu/amdgpu.h      |  32 +++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c   |   3 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h |   1 +
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c    |  77 +++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/vi.h          | 112 +++++++++++++++++++++++++++++++
 5 files changed, 225 insertions(+)
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1484206893-18806-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org

author
#2 lore raw

PATCH 1/3 drm/amdgpu:add META_DATA struct for CSA/SRIOV

META-DATA is used in GFX cmd submit, we have two types of META-DATA now, one is legacy and the other is for chained-ib-preemption, which is used in vulkan UMD.

Change-Id I17324905b4822a93fd3ffb3e8f86e544871b89ab
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h |   1 +
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c    |   8 +++
 drivers/gpu/drm/amd/amdgpu/vi.h          | 112 +++++++++++++++++++++++++++++++
 3 files changed, 121 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +1 -0
index fa1d569..cf1c94b 100644
@@ -34,6 +34,7 @@ struct amdgpu_virt {
 	uint32_t caps;
 	struct amdgpu_bo *csa_obj;
 	uint64_t csa_vmid0_addr;
+	bool chained_ib_support;
 };
 
 #define AMDGPU_CSA_SIZE    (8 * 1024)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +8 -0
index a9087f0..375784d 100644
@@ -941,6 +941,14 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev)
 		goto out;
 	cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.me_fw->data;
 	adev->gfx.me_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
+
+	/* chain ib ucode isn't formal released, use fake number 999 should be enough
+	 * we need to change 999 to a correct value after chain ib preemption landed in
+	 * formal ucode release
+	 */
+	if (adev->gfx.me_fw_version > 999) {
+		adev->virt.chained_ib_support = true;
+	}
 	adev->gfx.me_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version);
 
 	snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ce.bin", chip_name);
drivers/gpu/drm/amd/amdgpu/vi.h +112 -0

116 lines not on this page · raw message

Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#3 lore raw

PATCH 2/3 drm/amdgpu:implement META-DATA write routines

In reply to a message not in the archive
Change-Id I66007a7f7e4e27fb129121f36143dce3cfb43738
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   | 31 ++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 61 +++++++++++++++++++++++++++++++++++
 2 files changed, 92 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +31 -0
index e9983fb..2039da7 100644
@@ -1599,6 +1599,37 @@ static inline void amdgpu_ring_write(struct amdgpu_ring *ring, uint32_t v)
 	ring->count_dw--;
 }
 
+static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring, void *src, int count_dw)
+{
+	unsigned occupied, chunk1, chunk2;
+	void *dst;
+
+	if (ring->count_dw < count_dw)
+		DRM_ERROR("amdgpu: writing more dwords to the ring than expected!\n");
+	else {
+		occupied = ring->wptr & ring->ptr_mask;
+		dst = (void *)&ring->ring[occupied];
+		chunk1 = ring->ptr_mask + 1 - occupied;
+		chunk1 = (chunk1 >= count_dw) ? count_dw: chunk1;
+		chunk2 = count_dw - chunk1;
+		chunk1 <<= 2;
+		chunk2 <<= 2;
+		if (chunk1) {
+			memcpy(dst, src, chunk1);
+		}
+
+		if (chunk2) {
+			src += chunk1;
+			dst = (void *)ring->ring;
+			memcpy(dst, src, chunk2);
+		}
+
+		ring->wptr += count_dw;
+		ring->wptr &= ring->ptr_mask;
+		ring->count_dw -= count_dw;
+	}
+}
+
 static inline struct amdgpu_sdma_instance *
 amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
 {
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +61 -0

70 lines not on this page · raw message

Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1484206893-18806-3-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org

#5 lore raw

Re: [PATCH 2/3] drm/amdgpu:implement META-DATA write routines

Am 12.01.2017 um 08:41 schrieb Monk Liu:

Quoted 13 lines
Change-Id I66007a7f7e4e27fb129121f36143dce3cfb43738
---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h   | 31 ++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 61 +++++++++++++++++++++++++++++++++++
  2 files changed, 92 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
index e9983fb..2039da7 100644
@@ -1599,6 +1599,37 @@ static inline void amdgpu_ring_write(struct amdgpu_ring *ring, uint32_t v)
  	ring->count_dw--;

drivers/gpu/drm/amd/amdgpu/amdgpu.h static inline void amdgpu_ring_write(struct amdgpu_ring *ring, uint32_t v) · line 1609

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +8 -0
  }
 
+static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring, void *src, int count_dw)
+{
+	unsigned occupied, chunk1, chunk2;
+	void *dst;
+
+	if (ring->count_dw < count_dw)
+		DRM_ERROR("amdgpu: writing more dwords to the ring than expected!\n");
+	else {

Coding style says when either the "if" or the "else" branch uses "{" and "}" both should use them.

I think even better would be to use a return statement in the "if", cause this is just checking the prerequisites for errors.

Additional to that adding this function should be a separate patch.

Christian.

Quoted 92 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +23 -0
+		occupied = ring->wptr & ring->ptr_mask;
+		dst = (void *)&ring->ring[occupied];
+		chunk1 = ring->ptr_mask + 1 - occupied;
+		chunk1 = (chunk1 >= count_dw) ? count_dw: chunk1;
+		chunk2 = count_dw - chunk1;
+		chunk1 <<= 2;
+		chunk2 <<= 2;
+		if (chunk1) {
+			memcpy(dst, src, chunk1);
+		}
+
+		if (chunk2) {
+			src += chunk1;
+			dst = (void *)ring->ring;
+			memcpy(dst, src, chunk2);
+		}
+
+		ring->wptr += count_dw;
+		ring->wptr &= ring->ptr_mask;
+		ring->count_dw -= count_dw;
+	}
+}
+
  static inline struct amdgpu_sdma_instance *
  amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
  {
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +51 -0
index 375784d..3e8cff3 100644
@@ -657,6 +657,8 @@ static void gfx_v8_0_set_gds_init(struct amdgpu_device *adev);
  static void gfx_v8_0_set_rlc_funcs(struct amdgpu_device *adev);
  static u32 gfx_v8_0_get_csb_size(struct amdgpu_device *adev);
  static void gfx_v8_0_get_cu_info(struct amdgpu_device *adev);
+static void gfx_v8_0_ring_emit_ce_meta_init(struct amdgpu_ring *ring, uint64_t addr);
+static void gfx_v8_0_ring_emit_de_meta_init(struct amdgpu_ring *ring, uint64_t addr);
 
  static void gfx_v8_0_init_golden_registers(struct amdgpu_device *adev)
  {
@@ -7212,3 +7214,62 @@ const struct amdgpu_ip_block_version gfx_v8_1_ip_block =
  	.rev = 0,
  	.funcs = &gfx_v8_0_ip_funcs,
  };
+
+static void gfx_v8_0_ring_emit_ce_meta_init(struct amdgpu_ring *ring, uint64_t csa_addr)
+{
+	uint64_t ce_payload_addr;
+	int cnt_ce;
+	static union {
+		struct amdgpu_ce_ib_state regular;
+		struct amdgpu_ce_ib_state_chained_ib chained;
+	} ce_payload = {0};
+
+	if (ring->adev->virt.chained_ib_support) {
+		ce_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data_chained_ib, ce_payload);
+		cnt_ce = (sizeof(ce_payload.chained) >> 2) + 4 - 2;
+	} else {
+		ce_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data, ce_payload);
+		cnt_ce = (sizeof(ce_payload.regular) >> 2) + 4 - 2;
+	}
+
+	amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt_ce));
+	amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(2) |
+				WRITE_DATA_DST_SEL(8) |
+				WR_CONFIRM) |
+				WRITE_DATA_CACHE_POLICY(0));
+	amdgpu_ring_write(ring, lower_32_bits(ce_payload_addr));
+	amdgpu_ring_write(ring, upper_32_bits(ce_payload_addr));
+	amdgpu_ring_write_multiple(ring, (void *)&ce_payload, cnt_ce - 2);
+}
+
+static void gfx_v8_0_ring_emit_de_meta_init(struct amdgpu_ring *ring, uint64_t csa_addr)
+{
+	uint64_t de_payload_addr, gds_addr;
+	int cnt_de;
+	static union {
+		struct amdgpu_de_ib_state regular;
+		struct amdgpu_de_ib_state_chained_ib chained;
+	} de_payload = {0};
+
+	gds_addr = csa_addr + 4096;
+	if (ring->adev->virt.chained_ib_support) {
+		de_payload.chained.gds_backup_addrlo = lower_32_bits(gds_addr);
+		de_payload.chained.gds_backup_addrhi = upper_32_bits(gds_addr);
+		de_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data_chained_ib, de_payload);
+		cnt_de = (sizeof(de_payload.chained) >> 2) + 4 - 2;
+	} else {
+		de_payload.regular.gds_backup_addrlo = lower_32_bits(gds_addr);
+		de_payload.regular.gds_backup_addrhi = upper_32_bits(gds_addr);
+		de_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data, de_payload);
+		cnt_de = (sizeof(de_payload.regular) >> 2) + 4 - 2;
+	}

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c const struct amdgpu_ip_block_version gfx_v8_1_ip_block = · line 7275

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +10 -0
+
+	amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt_de));
+	amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) |
+				WRITE_DATA_DST_SEL(8) |
+				WR_CONFIRM) |
+				WRITE_DATA_CACHE_POLICY(0));
+	amdgpu_ring_write(ring, lower_32_bits(de_payload_addr));
+	amdgpu_ring_write(ring, upper_32_bits(de_payload_addr));
+	amdgpu_ring_write_multiple(ring, (void *)&de_payload, cnt_de - 2);
+}

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): b750813c-5af3-5353-2f08-5b54e0495375-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

author
#7 lore raw

答复: [PATCH 2/3] drm/amdgpu:implement META-DATA write routines

if ring_write_multiple is organized in a separate patch, doesn't it introduces an function that no client using it ??

fine by me although ...

BR Monk

________________________________
发件人: Christian König <[email protected]>
发送时间: 2017年1月12日 20:27:48
收件人: Liu, Monk; [email protected]
主题: Re: [PATCH 2/3] drm/amdgpu:implement META-DATA write routines

Am 12.01.2017 um 08:41 schrieb Monk Liu:

Quoted 13 lines
Change-Id I66007a7f7e4e27fb129121f36143dce3cfb43738
---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h   | 31 ++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 61 +++++++++++++++++++++++++++++++++++
  2 files changed, 92 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
index e9983fb..2039da7 100644
@@ -1599,6 +1599,37 @@ static inline void amdgpu_ring_write(struct amdgpu_ring *ring, uint32_t v)
       ring->count_dw--;

drivers/gpu/drm/amd/amdgpu/amdgpu.h static inline void amdgpu_ring_write(struct amdgpu_ring *ring, uint32_t v) · line 1609

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +8 -0
  }
 
+static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring, void *src, int count_dw)
+{
+     unsigned occupied, chunk1, chunk2;
+     void *dst;
+
+     if (ring->count_dw < count_dw)
+             DRM_ERROR("amdgpu: writing more dwords to the ring than expected!\n");
+     else {

Coding style says when either the "if" or the "else" branch uses "{" and "}" both should use them.

I think even better would be to use a return statement in the "if", cause this is just checking the prerequisites for errors.

Additional to that adding this function should be a separate patch.

Christian.

Quoted 92 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +23 -0
+             occupied = ring->wptr & ring->ptr_mask;
+             dst = (void *)&ring->ring[occupied];
+             chunk1 = ring->ptr_mask + 1 - occupied;
+             chunk1 = (chunk1 >= count_dw) ? count_dw: chunk1;
+             chunk2 = count_dw - chunk1;
+             chunk1 <<= 2;
+             chunk2 <<= 2;
+             if (chunk1) {
+                     memcpy(dst, src, chunk1);
+             }
+
+             if (chunk2) {
+                     src += chunk1;
+                     dst = (void *)ring->ring;
+                     memcpy(dst, src, chunk2);
+             }
+
+             ring->wptr += count_dw;
+             ring->wptr &= ring->ptr_mask;
+             ring->count_dw -= count_dw;
+     }
+}
+
  static inline struct amdgpu_sdma_instance *
  amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
  {
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +51 -0
index 375784d..3e8cff3 100644
@@ -657,6 +657,8 @@ static void gfx_v8_0_set_gds_init(struct amdgpu_device *adev);
  static void gfx_v8_0_set_rlc_funcs(struct amdgpu_device *adev);
  static u32 gfx_v8_0_get_csb_size(struct amdgpu_device *adev);
  static void gfx_v8_0_get_cu_info(struct amdgpu_device *adev);
+static void gfx_v8_0_ring_emit_ce_meta_init(struct amdgpu_ring *ring, uint64_t addr);
+static void gfx_v8_0_ring_emit_de_meta_init(struct amdgpu_ring *ring, uint64_t addr);
 
  static void gfx_v8_0_init_golden_registers(struct amdgpu_device *adev)
  {
@@ -7212,3 +7214,62 @@ const struct amdgpu_ip_block_version gfx_v8_1_ip_block =
       .rev = 0,
       .funcs = &gfx_v8_0_ip_funcs,
  };
+
+static void gfx_v8_0_ring_emit_ce_meta_init(struct amdgpu_ring *ring, uint64_t csa_addr)
+{
+     uint64_t ce_payload_addr;
+     int cnt_ce;
+     static union {
+             struct amdgpu_ce_ib_state regular;
+             struct amdgpu_ce_ib_state_chained_ib chained;
+     } ce_payload = {0};
+
+     if (ring->adev->virt.chained_ib_support) {
+             ce_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data_chained_ib, ce_payload);
+             cnt_ce = (sizeof(ce_payload.chained) >> 2) + 4 - 2;
+     } else {
+             ce_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data, ce_payload);
+             cnt_ce = (sizeof(ce_payload.regular) >> 2) + 4 - 2;
+     }
+
+     amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt_ce));
+     amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(2) |
+                             WRITE_DATA_DST_SEL(8) |
+                             WR_CONFIRM) |
+                             WRITE_DATA_CACHE_POLICY(0));
+     amdgpu_ring_write(ring, lower_32_bits(ce_payload_addr));
+     amdgpu_ring_write(ring, upper_32_bits(ce_payload_addr));
+     amdgpu_ring_write_multiple(ring, (void *)&ce_payload, cnt_ce - 2);
+}
+
+static void gfx_v8_0_ring_emit_de_meta_init(struct amdgpu_ring *ring, uint64_t csa_addr)
+{
+     uint64_t de_payload_addr, gds_addr;
+     int cnt_de;
+     static union {
+             struct amdgpu_de_ib_state regular;
+             struct amdgpu_de_ib_state_chained_ib chained;
+     } de_payload = {0};
+
+     gds_addr = csa_addr + 4096;
+     if (ring->adev->virt.chained_ib_support) {
+             de_payload.chained.gds_backup_addrlo = lower_32_bits(gds_addr);
+             de_payload.chained.gds_backup_addrhi = upper_32_bits(gds_addr);
+             de_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data_chained_ib, de_payload);
+             cnt_de = (sizeof(de_payload.chained) >> 2) + 4 - 2;
+     } else {
+             de_payload.regular.gds_backup_addrlo = lower_32_bits(gds_addr);
+             de_payload.regular.gds_backup_addrhi = upper_32_bits(gds_addr);
+             de_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data, de_payload);
+             cnt_de = (sizeof(de_payload.regular) >> 2) + 4 - 2;
+     }

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c const struct amdgpu_ip_block_version gfx_v8_1_ip_block = · line 7275

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +10 -0
+
+     amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt_de));
+     amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) |
+                             WRITE_DATA_DST_SEL(8) |
+                             WR_CONFIRM) |
+                             WRITE_DATA_CACHE_POLICY(0));
+     amdgpu_ring_write(ring, lower_32_bits(de_payload_addr));
+     amdgpu_ring_write(ring, upper_32_bits(de_payload_addr));
+     amdgpu_ring_write_multiple(ring, (void *)&de_payload, cnt_de - 2);
+}

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BY2PR1201MB111021CE95196ED42C7694E4847D0-O28G1zQ8oGliQkyLPkmea2rFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/[email protected]

#9 lore raw

Re: 答复: [PATCH 2/3] drm/amdgpu:implement META-DATA write routines

That is perfectly fine as long as you add the code using it in the same set of patches.

What we should avoid is adding a lot of code and then not using for for quite some time, that get certainly removed sooner or later.

Regards,
Christian.

Am 16.01.2017 um 09:20 schrieb Liu, Monk:

Quoted 159 lines

if ring_write_multiple is organized in a separate patch, doesn't it introduces an function that no client using it ??

fine by me although ...

BR Monk

------------------------------------------------------------------------
*发件人:* Christian König <[email protected]> *发送时间:* 2017年1月12日 20:27:48
*收件人:* Liu, Monk; [email protected] *主题:* Re: [PATCH 2/3] drm/amdgpu:implement META-DATA write routines Am 12.01.2017 um 08:41 schrieb Monk Liu:

Quoted 5 lines
Change-Id I66007a7f7e4e27fb129121f36143dce3cfb43738
---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h   | 31 ++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 61 

+++++++++++++++++++++++++++++++++++

Review

Quoted 3 lines
  2 files changed, 92 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu.h

drivers/gpu/drm/amd/amdgpu/amdgpu.h static inline void amdgpu_ring_write(struct

Quoted 4 lines

index e9983fb..2039da7 100644

drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
@@ -1599,6 +1599,37 @@ static inline void amdgpu_ring_write(struct 

amdgpu_ring *ring, uint32_t v)

drivers/gpu/drm/amd/amdgpu/amdgpu.h static inline void amdgpu_ring_write(struct amdgpu_ring *ring, uint32_t v)

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
       ring->count_dw--;
  }
 
+static inline void amdgpu_ring_write_multiple(struct amdgpu_ring 

*ring, void *src, int count_dw)

drivers/gpu/drm/amd/amdgpu/amdgpu.h static inline void amdgpu_ring_write(struct amdgpu_ring *ring, uint32_t v)

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +6 -0
+{
+     unsigned occupied, chunk1, chunk2;
+     void *dst;
+
+     if (ring->count_dw < count_dw)
+             DRM_ERROR("amdgpu: writing more dwords to the ring 

than expected!\n");

drivers/gpu/drm/amd/amdgpu/amdgpu.h static inline void amdgpu_ring_write(struct amdgpu_ring *ring, uint32_t v) · line 1609

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
+     else {

Coding style says when either the "if" or the "else" branch uses "{" and "}" both should use them.

I think even better would be to use a return statement in the "if", cause this is just checking the prerequisites for errors.

Additional to that adding this function should be a separate patch.

Christian.

Review

Quoted 27 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +23 -0
+             occupied = ring->wptr & ring->ptr_mask;
+             dst = (void *)&ring->ring[occupied];
+             chunk1 = ring->ptr_mask + 1 - occupied;
+             chunk1 = (chunk1 >= count_dw) ? count_dw: chunk1;
+             chunk2 = count_dw - chunk1;
+             chunk1 <<= 2;
+             chunk2 <<= 2;
+             if (chunk1) {
+                     memcpy(dst, src, chunk1);
+             }
+
+             if (chunk2) {
+                     src += chunk1;
+                     dst = (void *)ring->ring;
+                     memcpy(dst, src, chunk2);
+             }
+
+             ring->wptr += count_dw;
+             ring->wptr &= ring->ptr_mask;
+             ring->count_dw -= count_dw;
+     }
+}
+
  static inline struct amdgpu_sdma_instance *
  amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
  {
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c static void gfx_v8_0_set_gds_init(struct

Quoted 4 lines

index 375784d..3e8cff3 100644

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -0
@@ -657,6 +657,8 @@ static void gfx_v8_0_set_gds_init(struct 

amdgpu_device *adev);

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c static void gfx_v8_0_set_gds_init(struct amdgpu_device *adev);

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1 -0
  static void gfx_v8_0_set_rlc_funcs(struct amdgpu_device *adev);
  static u32 gfx_v8_0_get_csb_size(struct amdgpu_device *adev);
  static void gfx_v8_0_get_cu_info(struct amdgpu_device *adev);
+static void gfx_v8_0_ring_emit_ce_meta_init(struct amdgpu_ring 

*ring, uint64_t addr);

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c static void gfx_v8_0_set_gds_init(struct · line 661

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1 -0
+static void gfx_v8_0_ring_emit_de_meta_init(struct amdgpu_ring 

*ring, uint64_t addr);

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c const struct amdgpu_ip_block_version

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -0
  static void gfx_v8_0_init_golden_registers(struct amdgpu_device *adev)
  {
@@ -7212,3 +7214,62 @@ const struct amdgpu_ip_block_version 

gfx_v8_1_ip_block =

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c const struct amdgpu_ip_block_version gfx_v8_1_ip_block =

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +2 -0
       .rev = 0,
       .funcs = &gfx_v8_0_ip_funcs,
  };
+
+static void gfx_v8_0_ring_emit_ce_meta_init(struct amdgpu_ring 

*ring, uint64_t csa_addr)

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c const struct amdgpu_ip_block_version gfx_v8_1_ip_block =

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +10 -0
+{
+     uint64_t ce_payload_addr;
+     int cnt_ce;
+     static union {
+             struct amdgpu_ce_ib_state regular;
+             struct amdgpu_ce_ib_state_chained_ib chained;
+     } ce_payload = {0};
+
+     if (ring->adev->virt.chained_ib_support) {
+             ce_payload_addr = csa_addr + offsetof(struct 

amdgpu_gfx_meta_data_chained_ib, ce_payload);

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c const struct amdgpu_ip_block_version gfx_v8_1_ip_block =

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +3 -0
+             cnt_ce = (sizeof(ce_payload.chained) >> 2) + 4 - 2;
+     } else {
+             ce_payload_addr = csa_addr + offsetof(struct 

amdgpu_gfx_meta_data, ce_payload);

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +4 -0
+             cnt_ce = (sizeof(ce_payload.regular) >> 2) + 4 - 2;
+     }
+
+     amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt_ce));

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c const struct amdgpu_ip_block_version gfx_v8_1_ip_block =

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +10 -0
+     amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(2) |
+                             WRITE_DATA_DST_SEL(8) |
+                             WR_CONFIRM) |
+ WRITE_DATA_CACHE_POLICY(0));
+     amdgpu_ring_write(ring, lower_32_bits(ce_payload_addr));
+     amdgpu_ring_write(ring, upper_32_bits(ce_payload_addr));
+     amdgpu_ring_write_multiple(ring, (void *)&ce_payload, cnt_ce - 2);
+}
+
+static void gfx_v8_0_ring_emit_de_meta_init(struct amdgpu_ring 

*ring, uint64_t csa_addr)

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c const struct amdgpu_ip_block_version gfx_v8_1_ip_block =

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +11 -0
+{
+     uint64_t de_payload_addr, gds_addr;
+     int cnt_de;
+     static union {
+             struct amdgpu_de_ib_state regular;
+             struct amdgpu_de_ib_state_chained_ib chained;
+     } de_payload = {0};
+
+     gds_addr = csa_addr + 4096;
+     if (ring->adev->virt.chained_ib_support) {
+             de_payload.chained.gds_backup_addrlo = 

lower_32_bits(gds_addr);

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c const struct amdgpu_ip_block_version · line 7257

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1 -0
+             de_payload.chained.gds_backup_addrhi = 

upper_32_bits(gds_addr);

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c const struct amdgpu_ip_block_version · line 7258

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1 -0
+             de_payload_addr = csa_addr + offsetof(struct 

amdgpu_gfx_meta_data_chained_ib, de_payload);

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c const struct amdgpu_ip_block_version gfx_v8_1_ip_block =

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +3 -0
+             cnt_de = (sizeof(de_payload.chained) >> 2) + 4 - 2;
+     } else {
+             de_payload.regular.gds_backup_addrlo = 

lower_32_bits(gds_addr);

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c const struct amdgpu_ip_block_version · line 7262

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1 -0
+             de_payload.regular.gds_backup_addrhi = 

upper_32_bits(gds_addr);

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c const struct amdgpu_ip_block_version · line 7263

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1 -0
+             de_payload_addr = csa_addr + offsetof(struct 

amdgpu_gfx_meta_data, de_payload);

Quoted 14 lines

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c const struct amdgpu_ip_block_version gfx_v8_1_ip_block = · line 7275

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +12 -0
+             cnt_de = (sizeof(de_payload.regular) >> 2) + 4 - 2;
+     }
+
+     amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt_de));
+     amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) |
+                             WRITE_DATA_DST_SEL(8) |
+                             WR_CONFIRM) |
+ WRITE_DATA_CACHE_POLICY(0));
+     amdgpu_ring_write(ring, lower_32_bits(de_payload_addr));
+     amdgpu_ring_write(ring, upper_32_bits(de_payload_addr));
+     amdgpu_ring_write_multiple(ring, (void *)&de_payload, cnt_de - 2);
+}

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#10 lore raw

Re: [PATCH 2/3] drm/amdgpu:implement META-DATA write routines

In reply to a message not in the archive
Quoted 13 lines · Monk Liu
Change-Id I66007a7f7e4e27fb129121f36143dce3cfb43738
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   | 31 ++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 61 +++++++++++++++++++++++++++++++++++
 2 files changed, 92 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
index e9983fb..2039da7 100644
@@ -1599,6 +1599,37 @@ static inline void amdgpu_ring_write(struct amdgpu_ring *ring, uint32_t v)
        ring->count_dw--;

drivers/gpu/drm/amd/amdgpu/amdgpu.h static inline void amdgpu_ring_write(struct amdgpu_ring *ring, uint32_t v) · line 1609

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +8 -0
 }
 
+static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring, void *src, int count_dw)
+{
+       unsigned occupied, chunk1, chunk2;
+       void *dst;
+
+       if (ring->count_dw < count_dw)
+               DRM_ERROR("amdgpu: writing more dwords to the ring than expected!\n");
+       else {

Parens coding style as noted by Christian. Also, this behavior differs from amdgpu_ring_write() which completes the writes anyway.

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +13 -0
+               occupied = ring->wptr & ring->ptr_mask;
+               dst = (void *)&ring->ring[occupied];
+               chunk1 = ring->ptr_mask + 1 - occupied;
+               chunk1 = (chunk1 >= count_dw) ? count_dw: chunk1;
+               chunk2 = count_dw - chunk1;
+               chunk1 <<= 2;
+               chunk2 <<= 2;
+               if (chunk1) {
+                       memcpy(dst, src, chunk1);
+               }
+
+               if (chunk2) {
+                       src += chunk1;

drivers/gpu/drm/amd/amdgpu/amdgpu.h static inline void amdgpu_ring_write(struct amdgpu_ring *ring, uint32_t v) · line 1632

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +10 -0
+                       dst = (void *)ring->ring;
+                       memcpy(dst, src, chunk2);
+               }
+
+               ring->wptr += count_dw;
+               ring->wptr &= ring->ptr_mask;
+               ring->count_dw -= count_dw;
+       }
+}
+

This hunk should be a separate patch.

Quoted 82 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
 static inline struct amdgpu_sdma_instance *
 amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
 {
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +61 -1
index 375784d..3e8cff3 100644
@@ -657,6 +657,8 @@ static void gfx_v8_0_set_gds_init(struct amdgpu_device *adev);
 static void gfx_v8_0_set_rlc_funcs(struct amdgpu_device *adev);
 static u32 gfx_v8_0_get_csb_size(struct amdgpu_device *adev);
 static void gfx_v8_0_get_cu_info(struct amdgpu_device *adev);
+static void gfx_v8_0_ring_emit_ce_meta_init(struct amdgpu_ring *ring, uint64_t addr);
+static void gfx_v8_0_ring_emit_de_meta_init(struct amdgpu_ring *ring, uint64_t addr);
 
 static void gfx_v8_0_init_golden_registers(struct amdgpu_device *adev)
 {
@@ -7212,3 +7214,62 @@ const struct amdgpu_ip_block_version gfx_v8_1_ip_block =
        .rev = 0,
        .funcs = &gfx_v8_0_ip_funcs,
 };
+
+static void gfx_v8_0_ring_emit_ce_meta_init(struct amdgpu_ring *ring, uint64_t csa_addr)
+{
+       uint64_t ce_payload_addr;
+       int cnt_ce;
+       static union {
+               struct amdgpu_ce_ib_state regular;
+               struct amdgpu_ce_ib_state_chained_ib chained;
+       } ce_payload = {0};
+
+       if (ring->adev->virt.chained_ib_support) {
+               ce_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data_chained_ib, ce_payload);
+               cnt_ce = (sizeof(ce_payload.chained) >> 2) + 4 - 2;
+       } else {
+               ce_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data, ce_payload);
+               cnt_ce = (sizeof(ce_payload.regular) >> 2) + 4 - 2;
+       }
+
+       amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt_ce));
+       amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(2) |
+                               WRITE_DATA_DST_SEL(8) |
+                               WR_CONFIRM) |
+                               WRITE_DATA_CACHE_POLICY(0));
+       amdgpu_ring_write(ring, lower_32_bits(ce_payload_addr));
+       amdgpu_ring_write(ring, upper_32_bits(ce_payload_addr));
+       amdgpu_ring_write_multiple(ring, (void *)&ce_payload, cnt_ce - 2);
+}
+
+static void gfx_v8_0_ring_emit_de_meta_init(struct amdgpu_ring *ring, uint64_t csa_addr)
+{
+       uint64_t de_payload_addr, gds_addr;
+       int cnt_de;
+       static union {
+               struct amdgpu_de_ib_state regular;
+               struct amdgpu_de_ib_state_chained_ib chained;
+       } de_payload = {0};
+
+       gds_addr = csa_addr + 4096;
+       if (ring->adev->virt.chained_ib_support) {
+               de_payload.chained.gds_backup_addrlo = lower_32_bits(gds_addr);
+               de_payload.chained.gds_backup_addrhi = upper_32_bits(gds_addr);
+               de_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data_chained_ib, de_payload);
+               cnt_de = (sizeof(de_payload.chained) >> 2) + 4 - 2;
+       } else {
+               de_payload.regular.gds_backup_addrlo = lower_32_bits(gds_addr);
+               de_payload.regular.gds_backup_addrhi = upper_32_bits(gds_addr);
+               de_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data, de_payload);
+               cnt_de = (sizeof(de_payload.regular) >> 2) + 4 - 2;
+       }
+
+       amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt_de));
+       amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) |
+                               WRITE_DATA_DST_SEL(8) |
+                               WR_CONFIRM) |
+                               WRITE_DATA_CACHE_POLICY(0));
+       amdgpu_ring_write(ring, lower_32_bits(de_payload_addr));
+       amdgpu_ring_write(ring, upper_32_bits(de_payload_addr));
+       amdgpu_ring_write_multiple(ring, (void *)&de_payload, cnt_de - 2);
+}
--

2.7.4

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#11 lore raw

PATCH 3/3 drm/amdgpu:invoke meta-data write around cntx_cntl

In reply to a message not in the archive

ce's META-DATA write need prior to cntx_cntrl package and de's should following.

Change-Id I2bf436d8a16bae38ce484f846f0b399e16cfe80a
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h    | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 3 +++
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c  | 8 ++++++++
 3 files changed, 12 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 2039da7..b7f7679 100644
@@ -953,6 +953,7 @@ struct amdgpu_cs_parser {
 #define AMDGPU_PREAMBLE_IB_PRESENT          (1 << 0) /* bit set means command submit involves a preamble IB */
 #define AMDGPU_PREAMBLE_IB_PRESENT_FIRST    (1 << 1) /* bit set means preamble IB is first presented in belonging context */
 #define AMDGPU_HAVE_CTX_SWITCH              (1 << 2) /* bit set means context switch occured */
+#define AMDGPU_VM_DOMAIN                    (1 << 3) /* bit set means in virtual memory context */
 
 struct amdgpu_job {
 	struct amd_sched_job    base;
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +3 -0
index 16308eb..6939822 100644
@@ -184,6 +184,9 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
 		if (need_ctx_switch)
 			status |= AMDGPU_HAVE_CTX_SWITCH;
 		status |= job->preamble_status;
+
+		if (vm)
+			status |= AMDGPU_VM_DOMAIN;
 		amdgpu_ring_emit_cntxcntl(ring, status);
 	}
 
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +8 -0
index 3e8cff3..8a5c818 100644
@@ -6704,6 +6704,10 @@ static void gfx_v8_ring_emit_cntxcntl(struct amdgpu_ring *ring, uint32_t flags)
 {
 	uint32_t dw2 = 0;
 
+	if (amdgpu_sriov_vf(ring->adev))
+		gfx_v8_0_ring_emit_ce_meta_init(ring,
+			(flags & AMDGPU_VM_DOMAIN) ? AMDGPU_CSA_VADDR : ring->adev->virt.csa_vmid0_addr);
+
 	dw2 |= 0x80000000; /* set load_enable otherwise this package is just NOPs */
 	if (flags & AMDGPU_HAVE_CTX_SWITCH) {
 		gfx_v8_0_ring_emit_vgt_flush(ring);
@@ -6728,6 +6732,10 @@ static void gfx_v8_ring_emit_cntxcntl(struct amdgpu_ring *ring, uint32_t flags)
 	amdgpu_ring_write(ring, PACKET3(PACKET3_CONTEXT_CONTROL, 1));
 	amdgpu_ring_write(ring, dw2);
 	amdgpu_ring_write(ring, 0);
+
+	if (amdgpu_sriov_vf(ring->adev))
+		gfx_v8_0_ring_emit_de_meta_init(ring,
+			(flags & AMDGPU_VM_DOMAIN) ? AMDGPU_CSA_VADDR : ring->adev->virt.csa_vmid0_addr);
 }
 
 static void gfx_v8_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev,
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1484206893-18806-4-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#13 lore raw

Re: [PATCH 3/3] drm/amdgpu:invoke meta-data write around cntx_cntl

Quoted 5 lines · Monk Liu

ce's META-DATA write need prior to cntx_cntrl package and de's should following.

Change-Id I2bf436d8a16bae38ce484f846f0b399e16cfe80a
Quoted 61 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h    | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 3 +++
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c  | 8 ++++++++
 3 files changed, 12 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 2039da7..b7f7679 100644
@@ -953,6 +953,7 @@ struct amdgpu_cs_parser {
 #define AMDGPU_PREAMBLE_IB_PRESENT          (1 << 0) /* bit set means command submit involves a preamble IB */
 #define AMDGPU_PREAMBLE_IB_PRESENT_FIRST    (1 << 1) /* bit set means preamble IB is first presented in belonging context */
 #define AMDGPU_HAVE_CTX_SWITCH              (1 << 2) /* bit set means context switch occured */
+#define AMDGPU_VM_DOMAIN                    (1 << 3) /* bit set means in virtual memory context */
 
 struct amdgpu_job {
        struct amd_sched_job    base;
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +3 -0
index 16308eb..6939822 100644
@@ -184,6 +184,9 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
                if (need_ctx_switch)
                        status |= AMDGPU_HAVE_CTX_SWITCH;
                status |= job->preamble_status;
+
+               if (vm)
+                       status |= AMDGPU_VM_DOMAIN;
                amdgpu_ring_emit_cntxcntl(ring, status);
        }
 
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +8 -1
index 3e8cff3..8a5c818 100644
@@ -6704,6 +6704,10 @@ static void gfx_v8_ring_emit_cntxcntl(struct amdgpu_ring *ring, uint32_t flags)
 {
        uint32_t dw2 = 0;
 
+       if (amdgpu_sriov_vf(ring->adev))
+               gfx_v8_0_ring_emit_ce_meta_init(ring,
+                       (flags & AMDGPU_VM_DOMAIN) ? AMDGPU_CSA_VADDR : ring->adev->virt.csa_vmid0_addr);
+
        dw2 |= 0x80000000; /* set load_enable otherwise this package is just NOPs */
        if (flags & AMDGPU_HAVE_CTX_SWITCH) {
                gfx_v8_0_ring_emit_vgt_flush(ring);
@@ -6728,6 +6732,10 @@ static void gfx_v8_ring_emit_cntxcntl(struct amdgpu_ring *ring, uint32_t flags)
        amdgpu_ring_write(ring, PACKET3(PACKET3_CONTEXT_CONTROL, 1));
        amdgpu_ring_write(ring, dw2);
        amdgpu_ring_write(ring, 0);
+
+       if (amdgpu_sriov_vf(ring->adev))
+               gfx_v8_0_ring_emit_de_meta_init(ring,
+                       (flags & AMDGPU_VM_DOMAIN) ? AMDGPU_CSA_VADDR : ring->adev->virt.csa_vmid0_addr);
 }
 
 static void gfx_v8_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev,
--

2.7.4

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CADnq5_Pe=z1hG9RBXPZ1KGfPHEHqksm9PBJdfeNdKsQDOK59eQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#15 lore raw

Re: [PATCH 3/3] drm/amdgpu:invoke meta-data write around cntx_cntl

Quoted 8 lines · Alex Deucher
Quoted 5 lines · Monk Liu

ce's META-DATA write need prior to cntx_cntrl package and de's should following.

Change-Id I2bf436d8a16bae38ce484f846f0b399e16cfe80a

Actually, I take that back. A few comments below.

Quoted 17 lines
Quoted 17 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h    | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 3 +++
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c  | 8 ++++++++
 3 files changed, 12 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 2039da7..b7f7679 100644
@@ -953,6 +953,7 @@ struct amdgpu_cs_parser {
 #define AMDGPU_PREAMBLE_IB_PRESENT          (1 << 0) /* bit set means command submit involves a preamble IB */
 #define AMDGPU_PREAMBLE_IB_PRESENT_FIRST    (1 << 1) /* bit set means preamble IB is first presented in belonging context */
 #define AMDGPU_HAVE_CTX_SWITCH              (1 << 2) /* bit set means context switch occured */
+#define AMDGPU_VM_DOMAIN                    (1 << 3) /* bit set means in virtual memory context */
 
Quoted 16 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
 struct amdgpu_job {
        struct amd_sched_job    base;
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0 -0
index 16308eb..6939822 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, · line 192

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +3 -0
@@ -184,6 +184,9 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
                if (need_ctx_switch)
                        status |= AMDGPU_HAVE_CTX_SWITCH;
                status |= job->preamble_status;
+
+               if (vm)
+                       status |= AMDGPU_VM_DOMAIN;
                amdgpu_ring_emit_cntxcntl(ring, status);
        }
 

This top chunk should be a separate patch.

Quoted 17 lines
Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +4 -0
index 3e8cff3..8a5c818 100644
@@ -6704,6 +6704,10 @@ static void gfx_v8_ring_emit_cntxcntl(struct amdgpu_ring *ring, uint32_t flags)
 {
        uint32_t dw2 = 0;
 
+       if (amdgpu_sriov_vf(ring->adev))
+               gfx_v8_0_ring_emit_ce_meta_init(ring,
+                       (flags & AMDGPU_VM_DOMAIN) ? AMDGPU_CSA_VADDR : ring->adev->virt.csa_vmid0_addr);
+
        dw2 |= 0x80000000; /* set load_enable otherwise this package is just NOPs */
        if (flags & AMDGPU_HAVE_CTX_SWITCH) {
                gfx_v8_0_ring_emit_vgt_flush(ring);
@@ -6728,6 +6732,10 @@ static void gfx_v8_ring_emit_cntxcntl(struct amdgpu_ring *ring, uint32_t flags)
        amdgpu_ring_write(ring, PACKET3(PACKET3_CONTEXT_CONTROL, 1));
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c static void gfx_v8_ring_emit_cntxcntl(struct amdgpu_ring *ring, uint32_t flags) · line 6740

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +4 -0
        amdgpu_ring_write(ring, dw2);
        amdgpu_ring_write(ring, 0);
+
+       if (amdgpu_sriov_vf(ring->adev))
+               gfx_v8_0_ring_emit_de_meta_init(ring,
+                       (flags & AMDGPU_VM_DOMAIN) ? AMDGPU_CSA_VADDR : ring->adev->virt.csa_vmid0_addr);
 }
 

I think you need to update the emit_frame_size to reflect the larger frame.

Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -1
 static void gfx_v8_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev,
--

2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CADnq5_M3ig9C3N7V6B=5n3XJ8eYy5foucWtG+3V3LqSL80uR2A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

author
#17 lore raw

答复: [PATCH 3/3] drm/amdgpu:invoke meta-data write around cntx_cntl

okay, thanks

________________________________
发件人: Alex Deucher <[email protected]>
发送时间: 2017年1月14日 0:35:45
收件人: Liu, Monk
抄送: amd-gfx list
主题: Re: [PATCH 3/3] drm/amdgpu:invoke meta-data write around cntx_cntl

Quoted 8 lines · Alex Deucher
Quoted 5 lines · Monk Liu

ce's META-DATA write need prior to cntx_cntrl package and de's should following.

Change-Id I2bf436d8a16bae38ce484f846f0b399e16cfe80a

Actually, I take that back. A few comments below.

Quoted 17 lines
Quoted 17 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h    | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 3 +++
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c  | 8 ++++++++
 3 files changed, 12 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 2039da7..b7f7679 100644
@@ -953,6 +953,7 @@ struct amdgpu_cs_parser {
 #define AMDGPU_PREAMBLE_IB_PRESENT          (1 << 0) /* bit set means command submit involves a preamble IB */
 #define AMDGPU_PREAMBLE_IB_PRESENT_FIRST    (1 << 1) /* bit set means preamble IB is first presented in belonging context */
 #define AMDGPU_HAVE_CTX_SWITCH              (1 << 2) /* bit set means context switch occured */
+#define AMDGPU_VM_DOMAIN                    (1 << 3) /* bit set means in virtual memory context */
 
Quoted 16 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
 struct amdgpu_job {
        struct amd_sched_job    base;
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0 -0
index 16308eb..6939822 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, · line 192

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +3 -0
@@ -184,6 +184,9 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
                if (need_ctx_switch)
                        status |= AMDGPU_HAVE_CTX_SWITCH;
                status |= job->preamble_status;
+
+               if (vm)
+                       status |= AMDGPU_VM_DOMAIN;
                amdgpu_ring_emit_cntxcntl(ring, status);
        }
 

This top chunk should be a separate patch.

Quoted 17 lines
Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +4 -0
index 3e8cff3..8a5c818 100644
@@ -6704,6 +6704,10 @@ static void gfx_v8_ring_emit_cntxcntl(struct amdgpu_ring *ring, uint32_t flags)
 {
        uint32_t dw2 = 0;
 
+       if (amdgpu_sriov_vf(ring->adev))
+               gfx_v8_0_ring_emit_ce_meta_init(ring,
+                       (flags & AMDGPU_VM_DOMAIN) ? AMDGPU_CSA_VADDR : ring->adev->virt.csa_vmid0_addr);
+
        dw2 |= 0x80000000; /* set load_enable otherwise this package is just NOPs */
        if (flags & AMDGPU_HAVE_CTX_SWITCH) {
                gfx_v8_0_ring_emit_vgt_flush(ring);
@@ -6728,6 +6732,10 @@ static void gfx_v8_ring_emit_cntxcntl(struct amdgpu_ring *ring, uint32_t flags)
        amdgpu_ring_write(ring, PACKET3(PACKET3_CONTEXT_CONTROL, 1));
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c static void gfx_v8_ring_emit_cntxcntl(struct amdgpu_ring *ring, uint32_t flags) · line 6740

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +4 -0
        amdgpu_ring_write(ring, dw2);
        amdgpu_ring_write(ring, 0);
+
+       if (amdgpu_sriov_vf(ring->adev))
+               gfx_v8_0_ring_emit_de_meta_init(ring,
+                       (flags & AMDGPU_VM_DOMAIN) ? AMDGPU_CSA_VADDR : ring->adev->virt.csa_vmid0_addr);
 }
 

I think you need to update the emit_frame_size to reflect the larger frame.

Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -1
 static void gfx_v8_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev,
--

2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx