Skip to contentSkip to conversation

drm/amdgpu: add GDS, GWS and OA debugfs files

PATCH In review Christian König 3 participants 18 messages Sep 14, 2018 – Sep 17, 2018 10 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/7 drm/amdgpu: add GDS, GWS and OA debugfs files

Additional to the existing files for VRAM and GTT.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +6 -6
index f12ae6b525b9..1565344cc139 100644
@@ -2208,7 +2208,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
 static int amdgpu_mm_dump_table(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = (struct drm_info_node *)m->private;
-	unsigned ttm_pl = *(int *)node->info_ent->data;
+	unsigned ttm_pl = (uintptr_t)node->info_ent->data;
 	struct drm_device *dev = node->minor->dev;
 	struct amdgpu_device *adev = dev->dev_private;
 	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[ttm_pl];
@@ -2218,12 +2218,12 @@ static int amdgpu_mm_dump_table(struct seq_file *m, void *data)
 	return 0;
 }
 
-static int ttm_pl_vram = TTM_PL_VRAM;
-static int ttm_pl_tt = TTM_PL_TT;
-
 static const struct drm_info_list amdgpu_ttm_debugfs_list[] = {
-	{"amdgpu_vram_mm", amdgpu_mm_dump_table, 0, &ttm_pl_vram},
-	{"amdgpu_gtt_mm", amdgpu_mm_dump_table, 0, &ttm_pl_tt},
+	{"amdgpu_vram_mm", amdgpu_mm_dump_table, 0, (void *)TTM_PL_VRAM},
+	{"amdgpu_gtt_mm", amdgpu_mm_dump_table, 0, (void *)TTM_PL_TT},
+	{"amdgpu_gds_mm", amdgpu_mm_dump_table, 0, (void *)AMDGPU_PL_GDS},
+	{"amdgpu_gws_mm", amdgpu_mm_dump_table, 0, (void *)AMDGPU_PL_GWS},
+	{"amdgpu_oa_mm", amdgpu_mm_dump_table, 0, (void *)AMDGPU_PL_OA},
 	{"ttm_page_pool", ttm_page_alloc_debugfs, 0, NULL},
 #ifdef CONFIG_SWIOTLB
 	{"ttm_dma_page_pool", ttm_dma_page_alloc_debugfs, 0, NULL}
Signature · 6 lines
2.14.1

_______________________________________________
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): 20180914191246.1609-1-christian.koenig-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 2/7 drm/amdgpu: fix up GDS/GWS/OA shifting

That only worked by pure coincident. Completely remove the shifting and always apply correct PAGE_SHIFT.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c     | 12 ++++++------
 drivers/gpu/drm/amd/amdgpu/amdgpu_gds.h    |  7 -------
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c    | 12 +++---------
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    | 14 +++++++-------
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |  6 +++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    | 15 +++------------
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c      |  9 ---------
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c      |  9 ---------
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c      | 12 +-----------
 9 files changed, 25 insertions(+), 71 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +6 -6
index d762d78e5102..8836186eb5ef 100644
@@ -721,16 +721,16 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
 		e->bo_va = amdgpu_vm_bo_find(vm, ttm_to_amdgpu_bo(e->tv.bo));
 
 	if (gds) {
-		p->job->gds_base = amdgpu_bo_gpu_offset(gds);
-		p->job->gds_size = amdgpu_bo_size(gds);
+		p->job->gds_base = amdgpu_bo_gpu_offset(gds) >> PAGE_SHIFT;
+		p->job->gds_size = amdgpu_bo_size(gds) >> PAGE_SHIFT;
 	}
 	if (gws) {
-		p->job->gws_base = amdgpu_bo_gpu_offset(gws);
-		p->job->gws_size = amdgpu_bo_size(gws);
+		p->job->gws_base = amdgpu_bo_gpu_offset(gws) >> PAGE_SHIFT;
+		p->job->gws_size = amdgpu_bo_size(gws) >> PAGE_SHIFT;
 	}
 	if (oa) {
-		p->job->oa_base = amdgpu_bo_gpu_offset(oa);
-		p->job->oa_size = amdgpu_bo_size(oa);
+		p->job->oa_base = amdgpu_bo_gpu_offset(oa) >> PAGE_SHIFT;
+		p->job->oa_size = amdgpu_bo_size(oa) >> PAGE_SHIFT;
 	}
 
 	if (!r && p->uf_entry.tv.bo) {
drivers/gpu/drm/amd/amdgpu/amdgpu_gds.h +0 -7
index e73728d90388..ecbcefe49a98 100644
@@ -24,13 +24,6 @@
 #ifndef __AMDGPU_GDS_H__
 #define __AMDGPU_GDS_H__
 
-/* Because TTM request that alloacted buffer should be PAGE_SIZE aligned,
- * we should report GDS/GWS/OA size as PAGE_SIZE aligned
- * */
-#define AMDGPU_GDS_SHIFT	2
-#define AMDGPU_GWS_SHIFT	PAGE_SHIFT
-#define AMDGPU_OA_SHIFT		PAGE_SHIFT
-
 struct amdgpu_ring;
 struct amdgpu_bo;
 
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3 -9
index d30a0838851b..7b3d1ebda9df 100644
@@ -244,16 +244,10 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
 			return -EINVAL;
 		}
 		flags |= AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
-		if (args->in.domains == AMDGPU_GEM_DOMAIN_GDS)
-			size = size << AMDGPU_GDS_SHIFT;
-		else if (args->in.domains == AMDGPU_GEM_DOMAIN_GWS)
-			size = size << AMDGPU_GWS_SHIFT;
-		else if (args->in.domains == AMDGPU_GEM_DOMAIN_OA)
-			size = size << AMDGPU_OA_SHIFT;
-		else
-			return -EINVAL;
+		/* GDS allocations must be DW aligned */
+		if (args->in.domains & AMDGPU_GEM_DOMAIN_GDS)
+			size = ALIGN(size, 4);
 	}
-	size = roundup(size, PAGE_SIZE);
 
 	if (flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID) {
 		r = amdgpu_bo_reserve(vm->root.base.bo, false);
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +7 -7
index b766270d86cb..64cc483db973 100644
@@ -528,13 +528,13 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
 		struct drm_amdgpu_info_gds gds_info;
 
 		memset(&gds_info, 0, sizeof(gds_info));
-		gds_info.gds_gfx_partition_size = adev->gds.mem.gfx_partition_size >> AMDGPU_GDS_SHIFT;
-		gds_info.compute_partition_size = adev->gds.mem.cs_partition_size >> AMDGPU_GDS_SHIFT;
-		gds_info.gds_total_size = adev->gds.mem.total_size >> AMDGPU_GDS_SHIFT;
-		gds_info.gws_per_gfx_partition = adev->gds.gws.gfx_partition_size >> AMDGPU_GWS_SHIFT;
-		gds_info.gws_per_compute_partition = adev->gds.gws.cs_partition_size >> AMDGPU_GWS_SHIFT;
-		gds_info.oa_per_gfx_partition = adev->gds.oa.gfx_partition_size >> AMDGPU_OA_SHIFT;
-		gds_info.oa_per_compute_partition = adev->gds.oa.cs_partition_size >> AMDGPU_OA_SHIFT;
+		gds_info.gds_gfx_partition_size = adev->gds.mem.gfx_partition_size;
+		gds_info.compute_partition_size = adev->gds.mem.cs_partition_size;
+		gds_info.gds_total_size = adev->gds.mem.total_size;
+		gds_info.gws_per_gfx_partition = adev->gds.gws.gfx_partition_size;
+		gds_info.gws_per_compute_partition = adev->gds.gws.cs_partition_size;
+		gds_info.oa_per_gfx_partition = adev->gds.oa.gfx_partition_size;
+		gds_info.oa_per_compute_partition = adev->gds.oa.cs_partition_size;
 		return copy_to_user(out, &gds_info,
 				    min((size_t)size, sizeof(gds_info))) ? -EFAULT : 0;
 	}
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +5 -1
index e6909252aefa..e1f32a196f6d 100644
@@ -433,7 +433,11 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
 	int r;
 
 	page_align = roundup(bp->byte_align, PAGE_SIZE) >> PAGE_SHIFT;
-	size = ALIGN(size, PAGE_SIZE);
+	if (bp->domain & (AMDGPU_GEM_DOMAIN_GDS | AMDGPU_GEM_DOMAIN_GWS |
+			  AMDGPU_GEM_DOMAIN_OA))
+		size <<= PAGE_SHIFT;
+	else
+		size = ALIGN(size, PAGE_SIZE);
 
 	if (!amdgpu_bo_validate_size(adev, size, bp->domain))
 		return -ENOMEM;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -12
index 1565344cc139..c691275cd1f0 100644
@@ -1825,19 +1825,10 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
 		 (unsigned)(gtt_size / (1024 * 1024)));
 
 	/* Initialize various on-chip memory pools */
-	adev->gds.mem.total_size = adev->gds.mem.total_size << AMDGPU_GDS_SHIFT;
-	adev->gds.mem.gfx_partition_size = adev->gds.mem.gfx_partition_size << AMDGPU_GDS_SHIFT;
-	adev->gds.mem.cs_partition_size = adev->gds.mem.cs_partition_size << AMDGPU_GDS_SHIFT;
-	adev->gds.gws.total_size = adev->gds.gws.total_size << AMDGPU_GWS_SHIFT;
-	adev->gds.gws.gfx_partition_size = adev->gds.gws.gfx_partition_size << AMDGPU_GWS_SHIFT;
-	adev->gds.gws.cs_partition_size = adev->gds.gws.cs_partition_size << AMDGPU_GWS_SHIFT;
-	adev->gds.oa.total_size = adev->gds.oa.total_size << AMDGPU_OA_SHIFT;
-	adev->gds.oa.gfx_partition_size = adev->gds.oa.gfx_partition_size << AMDGPU_OA_SHIFT;
-	adev->gds.oa.cs_partition_size = adev->gds.oa.cs_partition_size << AMDGPU_OA_SHIFT;
 	/* GDS Memory */
 	if (adev->gds.mem.total_size) {
 		r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GDS,
-				   adev->gds.mem.total_size >> PAGE_SHIFT);
+				   adev->gds.mem.total_size);
 		if (r) {
 			DRM_ERROR("Failed initializing GDS heap.\n");
 			return r;
@@ -1847,7 +1838,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
 	/* GWS */
 	if (adev->gds.gws.total_size) {
 		r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GWS,
-				   adev->gds.gws.total_size >> PAGE_SHIFT);
+				   adev->gds.gws.total_size);
 		if (r) {
 			DRM_ERROR("Failed initializing gws heap.\n");
 			return r;
@@ -1857,7 +1848,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
 	/* OA */
 	if (adev->gds.oa.total_size) {
 		r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_OA,
-				   adev->gds.oa.total_size >> PAGE_SHIFT);
+				   adev->gds.oa.total_size);
 		if (r) {
 			DRM_ERROR("Failed initializing oa heap.\n");
 			return r;
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0 -9
index a15d9c0f233b..c0f9732cbaf7 100644
@@ -4170,15 +4170,6 @@ static void gfx_v7_0_ring_emit_gds_switch(struct amdgpu_ring *ring,
 					  uint32_t gws_base, uint32_t gws_size,
 					  uint32_t oa_base, uint32_t oa_size)
 {
-	gds_base = gds_base >> AMDGPU_GDS_SHIFT;
-	gds_size = gds_size >> AMDGPU_GDS_SHIFT;
-
-	gws_base = gws_base >> AMDGPU_GWS_SHIFT;
-	gws_size = gws_size >> AMDGPU_GWS_SHIFT;
-
-	oa_base = oa_base >> AMDGPU_OA_SHIFT;
-	oa_size = oa_size >> AMDGPU_OA_SHIFT;
-
 	/* GDS Base */
 	amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
 	amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -9
index 3882689b2d8f..57e4b14e3bd1 100644
@@ -5396,15 +5396,6 @@ static void gfx_v8_0_ring_emit_gds_switch(struct amdgpu_ring *ring,
 					  uint32_t gws_base, uint32_t gws_size,
 					  uint32_t oa_base, uint32_t oa_size)
 {
-	gds_base = gds_base >> AMDGPU_GDS_SHIFT;
-	gds_size = gds_size >> AMDGPU_GDS_SHIFT;
-
-	gws_base = gws_base >> AMDGPU_GWS_SHIFT;
-	gws_size = gws_size >> AMDGPU_GWS_SHIFT;
-
-	oa_base = oa_base >> AMDGPU_OA_SHIFT;
-	oa_size = oa_size >> AMDGPU_OA_SHIFT;
-
 	/* GDS Base */
 	amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
 	amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -11
index 75a91663019f..d31a2bc00d61 100644
@@ -1527,8 +1527,7 @@ static int gfx_v9_0_ngg_en(struct amdgpu_device *adev)
 	gfx_v9_0_write_data_to_reg(ring, 0, false,
 				   SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE),
 			           (adev->gds.mem.total_size +
-				    adev->gfx.ngg.gds_reserve_size) >>
-				   AMDGPU_GDS_SHIFT);
+				    adev->gfx.ngg.gds_reserve_size));
 
 	amdgpu_ring_write(ring, PACKET3(PACKET3_DMA_DATA, 5));
 	amdgpu_ring_write(ring, (PACKET3_DMA_DATA_CP_SYNC |
@@ -3472,15 +3471,6 @@ static void gfx_v9_0_ring_emit_gds_switch(struct amdgpu_ring *ring,
 {
 	struct amdgpu_device *adev = ring->adev;
 
-	gds_base = gds_base >> AMDGPU_GDS_SHIFT;
-	gds_size = gds_size >> AMDGPU_GDS_SHIFT;
-
-	gws_base = gws_base >> AMDGPU_GWS_SHIFT;
-	gws_size = gws_size >> AMDGPU_GWS_SHIFT;
-
-	oa_base = oa_base >> AMDGPU_OA_SHIFT;
-	oa_size = oa_size >> AMDGPU_OA_SHIFT;
-
 	/* GDS Base */
 	gfx_v9_0_write_data_to_reg(ring, 0, false,
 				   SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_BASE) + 2 * vmid,
Signature · 6 lines
2.14.1

_______________________________________________
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): 20180914191246.1609-2-christian.koenig-5C7GfCeVMHo@public.gmane.org

#4 lore raw

Re: [PATCH 2/7] drm/amdgpu: fix up GDS/GWS/OA shifting

Quoted 116 lines · Christian König

That only worked by pure coincident. Completely remove the shifting and always apply correct PAGE_SHIFT.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c     | 12 ++++++------
 drivers/gpu/drm/amd/amdgpu/amdgpu_gds.h    |  7 -------
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c    | 12 +++---------
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    | 14 +++++++-------
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |  6 +++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    | 15 +++------------
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c      |  9 ---------
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c      |  9 ---------
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c      | 12 +-----------
 9 files changed, 25 insertions(+), 71 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +6 -6
index d762d78e5102..8836186eb5ef 100644
@@ -721,16 +721,16 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
                e->bo_va = amdgpu_vm_bo_find(vm, ttm_to_amdgpu_bo(e->tv.bo));
 
        if (gds) {
-               p->job->gds_base = amdgpu_bo_gpu_offset(gds);
-               p->job->gds_size = amdgpu_bo_size(gds);
+               p->job->gds_base = amdgpu_bo_gpu_offset(gds) >> PAGE_SHIFT;
+               p->job->gds_size = amdgpu_bo_size(gds) >> PAGE_SHIFT;
        }
        if (gws) {
-               p->job->gws_base = amdgpu_bo_gpu_offset(gws);
-               p->job->gws_size = amdgpu_bo_size(gws);
+               p->job->gws_base = amdgpu_bo_gpu_offset(gws) >> PAGE_SHIFT;
+               p->job->gws_size = amdgpu_bo_size(gws) >> PAGE_SHIFT;
        }
        if (oa) {
-               p->job->oa_base = amdgpu_bo_gpu_offset(oa);
-               p->job->oa_size = amdgpu_bo_size(oa);
+               p->job->oa_base = amdgpu_bo_gpu_offset(oa) >> PAGE_SHIFT;
+               p->job->oa_size = amdgpu_bo_size(oa) >> PAGE_SHIFT;
        }
 
        if (!r && p->uf_entry.tv.bo) {
drivers/gpu/drm/amd/amdgpu/amdgpu_gds.h +0 -7
index e73728d90388..ecbcefe49a98 100644
@@ -24,13 +24,6 @@
 #ifndef __AMDGPU_GDS_H__
 #define __AMDGPU_GDS_H__
 
-/* Because TTM request that alloacted buffer should be PAGE_SIZE aligned,
- * we should report GDS/GWS/OA size as PAGE_SIZE aligned
- * */
-#define AMDGPU_GDS_SHIFT       2
-#define AMDGPU_GWS_SHIFT       PAGE_SHIFT
-#define AMDGPU_OA_SHIFT                PAGE_SHIFT
-
 struct amdgpu_ring;
 struct amdgpu_bo;
 
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3 -9
index d30a0838851b..7b3d1ebda9df 100644
@@ -244,16 +244,10 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
                        return -EINVAL;
                }
                flags |= AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
-               if (args->in.domains == AMDGPU_GEM_DOMAIN_GDS)
-                       size = size << AMDGPU_GDS_SHIFT;
-               else if (args->in.domains == AMDGPU_GEM_DOMAIN_GWS)
-                       size = size << AMDGPU_GWS_SHIFT;
-               else if (args->in.domains == AMDGPU_GEM_DOMAIN_OA)
-                       size = size << AMDGPU_OA_SHIFT;
-               else
-                       return -EINVAL;
+               /* GDS allocations must be DW aligned */
+               if (args->in.domains & AMDGPU_GEM_DOMAIN_GDS)
+                       size = ALIGN(size, 4);
        }
-       size = roundup(size, PAGE_SIZE);
 
        if (flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID) {
                r = amdgpu_bo_reserve(vm->root.base.bo, false);
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +7 -7
index b766270d86cb..64cc483db973 100644
@@ -528,13 +528,13 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
                struct drm_amdgpu_info_gds gds_info;
 
                memset(&gds_info, 0, sizeof(gds_info));
-               gds_info.gds_gfx_partition_size = adev->gds.mem.gfx_partition_size >> AMDGPU_GDS_SHIFT;
-               gds_info.compute_partition_size = adev->gds.mem.cs_partition_size >> AMDGPU_GDS_SHIFT;
-               gds_info.gds_total_size = adev->gds.mem.total_size >> AMDGPU_GDS_SHIFT;
-               gds_info.gws_per_gfx_partition = adev->gds.gws.gfx_partition_size >> AMDGPU_GWS_SHIFT;
-               gds_info.gws_per_compute_partition = adev->gds.gws.cs_partition_size >> AMDGPU_GWS_SHIFT;
-               gds_info.oa_per_gfx_partition = adev->gds.oa.gfx_partition_size >> AMDGPU_OA_SHIFT;
-               gds_info.oa_per_compute_partition = adev->gds.oa.cs_partition_size >> AMDGPU_OA_SHIFT;
+               gds_info.gds_gfx_partition_size = adev->gds.mem.gfx_partition_size;
+               gds_info.compute_partition_size = adev->gds.mem.cs_partition_size;
+               gds_info.gds_total_size = adev->gds.mem.total_size;
+               gds_info.gws_per_gfx_partition = adev->gds.gws.gfx_partition_size;
+               gds_info.gws_per_compute_partition = adev->gds.gws.cs_partition_size;
+               gds_info.oa_per_gfx_partition = adev->gds.oa.gfx_partition_size;
+               gds_info.oa_per_compute_partition = adev->gds.oa.cs_partition_size;
                return copy_to_user(out, &gds_info,
                                    min((size_t)size, sizeof(gds_info))) ? -EFAULT : 0;
        }
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
index e6909252aefa..e1f32a196f6d 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static int amdgpu_bo_do_create(struct amdgpu_device *adev, · line 440

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +5 -1
@@ -433,7 +433,11 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
        int r;
 
        page_align = roundup(bp->byte_align, PAGE_SIZE) >> PAGE_SHIFT;
-       size = ALIGN(size, PAGE_SIZE);
+       if (bp->domain & (AMDGPU_GEM_DOMAIN_GDS | AMDGPU_GEM_DOMAIN_GWS |
+                         AMDGPU_GEM_DOMAIN_OA))
+               size <<= PAGE_SHIFT;
+       else
+               size = ALIGN(size, PAGE_SIZE);

Is this right for GDS? I think we need to be in 4K units regardless of the page size. I have to admit, all the shifting is mixing me up.

Alex

Quoted 119 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
        if (!amdgpu_bo_validate_size(adev, size, bp->domain))
                return -ENOMEM;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -12
index 1565344cc139..c691275cd1f0 100644
@@ -1825,19 +1825,10 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
                 (unsigned)(gtt_size / (1024 * 1024)));
 
        /* Initialize various on-chip memory pools */
-       adev->gds.mem.total_size = adev->gds.mem.total_size << AMDGPU_GDS_SHIFT;
-       adev->gds.mem.gfx_partition_size = adev->gds.mem.gfx_partition_size << AMDGPU_GDS_SHIFT;
-       adev->gds.mem.cs_partition_size = adev->gds.mem.cs_partition_size << AMDGPU_GDS_SHIFT;
-       adev->gds.gws.total_size = adev->gds.gws.total_size << AMDGPU_GWS_SHIFT;
-       adev->gds.gws.gfx_partition_size = adev->gds.gws.gfx_partition_size << AMDGPU_GWS_SHIFT;
-       adev->gds.gws.cs_partition_size = adev->gds.gws.cs_partition_size << AMDGPU_GWS_SHIFT;
-       adev->gds.oa.total_size = adev->gds.oa.total_size << AMDGPU_OA_SHIFT;
-       adev->gds.oa.gfx_partition_size = adev->gds.oa.gfx_partition_size << AMDGPU_OA_SHIFT;
-       adev->gds.oa.cs_partition_size = adev->gds.oa.cs_partition_size << AMDGPU_OA_SHIFT;
        /* GDS Memory */
        if (adev->gds.mem.total_size) {
                r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GDS,
-                                  adev->gds.mem.total_size >> PAGE_SHIFT);
+                                  adev->gds.mem.total_size);
                if (r) {
                        DRM_ERROR("Failed initializing GDS heap.\n");
                        return r;
@@ -1847,7 +1838,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
        /* GWS */
        if (adev->gds.gws.total_size) {
                r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GWS,
-                                  adev->gds.gws.total_size >> PAGE_SHIFT);
+                                  adev->gds.gws.total_size);
                if (r) {
                        DRM_ERROR("Failed initializing gws heap.\n");
                        return r;
@@ -1857,7 +1848,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
        /* OA */
        if (adev->gds.oa.total_size) {
                r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_OA,
-                                  adev->gds.oa.total_size >> PAGE_SHIFT);
+                                  adev->gds.oa.total_size);
                if (r) {
                        DRM_ERROR("Failed initializing oa heap.\n");
                        return r;
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0 -9
index a15d9c0f233b..c0f9732cbaf7 100644
@@ -4170,15 +4170,6 @@ static void gfx_v7_0_ring_emit_gds_switch(struct amdgpu_ring *ring,
                                          uint32_t gws_base, uint32_t gws_size,
                                          uint32_t oa_base, uint32_t oa_size)
 {
-       gds_base = gds_base >> AMDGPU_GDS_SHIFT;
-       gds_size = gds_size >> AMDGPU_GDS_SHIFT;
-
-       gws_base = gws_base >> AMDGPU_GWS_SHIFT;
-       gws_size = gws_size >> AMDGPU_GWS_SHIFT;
-
-       oa_base = oa_base >> AMDGPU_OA_SHIFT;
-       oa_size = oa_size >> AMDGPU_OA_SHIFT;
-
        /* GDS Base */
        amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
        amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -9
index 3882689b2d8f..57e4b14e3bd1 100644
@@ -5396,15 +5396,6 @@ static void gfx_v8_0_ring_emit_gds_switch(struct amdgpu_ring *ring,
                                          uint32_t gws_base, uint32_t gws_size,
                                          uint32_t oa_base, uint32_t oa_size)
 {
-       gds_base = gds_base >> AMDGPU_GDS_SHIFT;
-       gds_size = gds_size >> AMDGPU_GDS_SHIFT;
-
-       gws_base = gws_base >> AMDGPU_GWS_SHIFT;
-       gws_size = gws_size >> AMDGPU_GWS_SHIFT;
-
-       oa_base = oa_base >> AMDGPU_OA_SHIFT;
-       oa_size = oa_size >> AMDGPU_OA_SHIFT;
-
        /* GDS Base */
        amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
        amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -12
index 75a91663019f..d31a2bc00d61 100644
@@ -1527,8 +1527,7 @@ static int gfx_v9_0_ngg_en(struct amdgpu_device *adev)
        gfx_v9_0_write_data_to_reg(ring, 0, false,
                                   SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE),
                                   (adev->gds.mem.total_size +
-                                   adev->gfx.ngg.gds_reserve_size) >>
-                                  AMDGPU_GDS_SHIFT);
+                                   adev->gfx.ngg.gds_reserve_size));
 
        amdgpu_ring_write(ring, PACKET3(PACKET3_DMA_DATA, 5));
        amdgpu_ring_write(ring, (PACKET3_DMA_DATA_CP_SYNC |
@@ -3472,15 +3471,6 @@ static void gfx_v9_0_ring_emit_gds_switch(struct amdgpu_ring *ring,
 {
        struct amdgpu_device *adev = ring->adev;
 
-       gds_base = gds_base >> AMDGPU_GDS_SHIFT;
-       gds_size = gds_size >> AMDGPU_GDS_SHIFT;
-
-       gws_base = gws_base >> AMDGPU_GWS_SHIFT;
-       gws_size = gws_size >> AMDGPU_GWS_SHIFT;
-
-       oa_base = oa_base >> AMDGPU_OA_SHIFT;
-       oa_size = oa_size >> AMDGPU_OA_SHIFT;
-
        /* GDS Base */
        gfx_v9_0_write_data_to_reg(ring, 0, false,
                                   SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_BASE) + 2 * vmid,
--

2.14.1

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_PjhBf1_DB6bgTiafPf=DE_g3AY+FsuZ0pj+4VDNPhRJg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#6 lore raw

Re: [PATCH 2/7] drm/amdgpu: fix up GDS/GWS/OA shifting

Am 14.09.2018 um 22:26 schrieb Alex Deucher:

Quoted 119 lines
Quoted 117 lines · Christian König

That only worked by pure coincident. Completely remove the shifting and always apply correct PAGE_SHIFT.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c     | 12 ++++++------
  drivers/gpu/drm/amd/amdgpu/amdgpu_gds.h    |  7 -------
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c    | 12 +++---------
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    | 14 +++++++-------
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |  6 +++++-
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    | 15 +++------------
  drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c      |  9 ---------
  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c      |  9 ---------
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c      | 12 +-----------
  9 files changed, 25 insertions(+), 71 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +6 -6
index d762d78e5102..8836186eb5ef 100644
@@ -721,16 +721,16 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
                 e->bo_va = amdgpu_vm_bo_find(vm, ttm_to_amdgpu_bo(e->tv.bo));
 
         if (gds) {
-               p->job->gds_base = amdgpu_bo_gpu_offset(gds);
-               p->job->gds_size = amdgpu_bo_size(gds);
+               p->job->gds_base = amdgpu_bo_gpu_offset(gds) >> PAGE_SHIFT;
+               p->job->gds_size = amdgpu_bo_size(gds) >> PAGE_SHIFT;
         }
         if (gws) {
-               p->job->gws_base = amdgpu_bo_gpu_offset(gws);
-               p->job->gws_size = amdgpu_bo_size(gws);
+               p->job->gws_base = amdgpu_bo_gpu_offset(gws) >> PAGE_SHIFT;
+               p->job->gws_size = amdgpu_bo_size(gws) >> PAGE_SHIFT;
         }
         if (oa) {
-               p->job->oa_base = amdgpu_bo_gpu_offset(oa);
-               p->job->oa_size = amdgpu_bo_size(oa);
+               p->job->oa_base = amdgpu_bo_gpu_offset(oa) >> PAGE_SHIFT;
+               p->job->oa_size = amdgpu_bo_size(oa) >> PAGE_SHIFT;
         }
 
         if (!r && p->uf_entry.tv.bo) {
drivers/gpu/drm/amd/amdgpu/amdgpu_gds.h +0 -7
index e73728d90388..ecbcefe49a98 100644
@@ -24,13 +24,6 @@
  #ifndef __AMDGPU_GDS_H__
  #define __AMDGPU_GDS_H__
 
-/* Because TTM request that alloacted buffer should be PAGE_SIZE aligned,
- * we should report GDS/GWS/OA size as PAGE_SIZE aligned
- * */
-#define AMDGPU_GDS_SHIFT       2
-#define AMDGPU_GWS_SHIFT       PAGE_SHIFT
-#define AMDGPU_OA_SHIFT                PAGE_SHIFT
-
  struct amdgpu_ring;
  struct amdgpu_bo;
 
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3 -9
index d30a0838851b..7b3d1ebda9df 100644
@@ -244,16 +244,10 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
                         return -EINVAL;
                 }
                 flags |= AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
-               if (args->in.domains == AMDGPU_GEM_DOMAIN_GDS)
-                       size = size << AMDGPU_GDS_SHIFT;
-               else if (args->in.domains == AMDGPU_GEM_DOMAIN_GWS)
-                       size = size << AMDGPU_GWS_SHIFT;
-               else if (args->in.domains == AMDGPU_GEM_DOMAIN_OA)
-                       size = size << AMDGPU_OA_SHIFT;
-               else
-                       return -EINVAL;
+               /* GDS allocations must be DW aligned */
+               if (args->in.domains & AMDGPU_GEM_DOMAIN_GDS)
+                       size = ALIGN(size, 4);
         }
-       size = roundup(size, PAGE_SIZE);
 
         if (flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID) {
                 r = amdgpu_bo_reserve(vm->root.base.bo, false);
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +7 -7
index b766270d86cb..64cc483db973 100644
@@ -528,13 +528,13 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
                 struct drm_amdgpu_info_gds gds_info;
 
                 memset(&gds_info, 0, sizeof(gds_info));
-               gds_info.gds_gfx_partition_size = adev->gds.mem.gfx_partition_size >> AMDGPU_GDS_SHIFT;
-               gds_info.compute_partition_size = adev->gds.mem.cs_partition_size >> AMDGPU_GDS_SHIFT;
-               gds_info.gds_total_size = adev->gds.mem.total_size >> AMDGPU_GDS_SHIFT;
-               gds_info.gws_per_gfx_partition = adev->gds.gws.gfx_partition_size >> AMDGPU_GWS_SHIFT;
-               gds_info.gws_per_compute_partition = adev->gds.gws.cs_partition_size >> AMDGPU_GWS_SHIFT;
-               gds_info.oa_per_gfx_partition = adev->gds.oa.gfx_partition_size >> AMDGPU_OA_SHIFT;
-               gds_info.oa_per_compute_partition = adev->gds.oa.cs_partition_size >> AMDGPU_OA_SHIFT;
+               gds_info.gds_gfx_partition_size = adev->gds.mem.gfx_partition_size;
+               gds_info.compute_partition_size = adev->gds.mem.cs_partition_size;
+               gds_info.gds_total_size = adev->gds.mem.total_size;
+               gds_info.gws_per_gfx_partition = adev->gds.gws.gfx_partition_size;
+               gds_info.gws_per_compute_partition = adev->gds.gws.cs_partition_size;
+               gds_info.oa_per_gfx_partition = adev->gds.oa.gfx_partition_size;
+               gds_info.oa_per_compute_partition = adev->gds.oa.cs_partition_size;
                 return copy_to_user(out, &gds_info,
                                     min((size_t)size, sizeof(gds_info))) ? -EFAULT : 0;
         }
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
index e6909252aefa..e1f32a196f6d 100644
@@ -433,7 +433,11 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
         int r;
 
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static int amdgpu_bo_do_create(struct amdgpu_device *adev, · line 440

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +5 -1
         page_align = roundup(bp->byte_align, PAGE_SIZE) >> PAGE_SHIFT;
-       size = ALIGN(size, PAGE_SIZE);
+       if (bp->domain & (AMDGPU_GEM_DOMAIN_GDS | AMDGPU_GEM_DOMAIN_GWS |
+                         AMDGPU_GEM_DOMAIN_OA))
+               size <<= PAGE_SHIFT;
+       else
+               size = ALIGN(size, PAGE_SIZE);

Is this right for GDS? I think we need to be in 4K units regardless of the page size. I have to admit, all the shifting is mixing me up.

Yeah, that is indeed correct. GDS only needs DW alignment.

The shifting is purely done because TTM wants to work with pages and not bytes.

Andrey already said he wanted to clean that up when there is time.

Christian.

Quoted 121 lines

Alex

Quoted 118 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
         if (!amdgpu_bo_validate_size(adev, size, bp->domain))
                 return -ENOMEM;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -12
index 1565344cc139..c691275cd1f0 100644
@@ -1825,19 +1825,10 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
                  (unsigned)(gtt_size / (1024 * 1024)));
 
         /* Initialize various on-chip memory pools */
-       adev->gds.mem.total_size = adev->gds.mem.total_size << AMDGPU_GDS_SHIFT;
-       adev->gds.mem.gfx_partition_size = adev->gds.mem.gfx_partition_size << AMDGPU_GDS_SHIFT;
-       adev->gds.mem.cs_partition_size = adev->gds.mem.cs_partition_size << AMDGPU_GDS_SHIFT;
-       adev->gds.gws.total_size = adev->gds.gws.total_size << AMDGPU_GWS_SHIFT;
-       adev->gds.gws.gfx_partition_size = adev->gds.gws.gfx_partition_size << AMDGPU_GWS_SHIFT;
-       adev->gds.gws.cs_partition_size = adev->gds.gws.cs_partition_size << AMDGPU_GWS_SHIFT;
-       adev->gds.oa.total_size = adev->gds.oa.total_size << AMDGPU_OA_SHIFT;
-       adev->gds.oa.gfx_partition_size = adev->gds.oa.gfx_partition_size << AMDGPU_OA_SHIFT;
-       adev->gds.oa.cs_partition_size = adev->gds.oa.cs_partition_size << AMDGPU_OA_SHIFT;
         /* GDS Memory */
         if (adev->gds.mem.total_size) {
                 r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GDS,
-                                  adev->gds.mem.total_size >> PAGE_SHIFT);
+                                  adev->gds.mem.total_size);
                 if (r) {
                         DRM_ERROR("Failed initializing GDS heap.\n");
                         return r;
@@ -1847,7 +1838,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
         /* GWS */
         if (adev->gds.gws.total_size) {
                 r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GWS,
-                                  adev->gds.gws.total_size >> PAGE_SHIFT);
+                                  adev->gds.gws.total_size);
                 if (r) {
                         DRM_ERROR("Failed initializing gws heap.\n");
                         return r;
@@ -1857,7 +1848,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
         /* OA */
         if (adev->gds.oa.total_size) {
                 r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_OA,
-                                  adev->gds.oa.total_size >> PAGE_SHIFT);
+                                  adev->gds.oa.total_size);
                 if (r) {
                         DRM_ERROR("Failed initializing oa heap.\n");
                         return r;
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0 -9
index a15d9c0f233b..c0f9732cbaf7 100644
@@ -4170,15 +4170,6 @@ static void gfx_v7_0_ring_emit_gds_switch(struct amdgpu_ring *ring,
                                           uint32_t gws_base, uint32_t gws_size,
                                           uint32_t oa_base, uint32_t oa_size)
  {
-       gds_base = gds_base >> AMDGPU_GDS_SHIFT;
-       gds_size = gds_size >> AMDGPU_GDS_SHIFT;
-
-       gws_base = gws_base >> AMDGPU_GWS_SHIFT;
-       gws_size = gws_size >> AMDGPU_GWS_SHIFT;
-
-       oa_base = oa_base >> AMDGPU_OA_SHIFT;
-       oa_size = oa_size >> AMDGPU_OA_SHIFT;
-
         /* GDS Base */
         amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
         amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -9
index 3882689b2d8f..57e4b14e3bd1 100644
@@ -5396,15 +5396,6 @@ static void gfx_v8_0_ring_emit_gds_switch(struct amdgpu_ring *ring,
                                           uint32_t gws_base, uint32_t gws_size,
                                           uint32_t oa_base, uint32_t oa_size)
  {
-       gds_base = gds_base >> AMDGPU_GDS_SHIFT;
-       gds_size = gds_size >> AMDGPU_GDS_SHIFT;
-
-       gws_base = gws_base >> AMDGPU_GWS_SHIFT;
-       gws_size = gws_size >> AMDGPU_GWS_SHIFT;
-
-       oa_base = oa_base >> AMDGPU_OA_SHIFT;
-       oa_size = oa_size >> AMDGPU_OA_SHIFT;
-
         /* GDS Base */
         amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
         amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -12
index 75a91663019f..d31a2bc00d61 100644
@@ -1527,8 +1527,7 @@ static int gfx_v9_0_ngg_en(struct amdgpu_device *adev)
         gfx_v9_0_write_data_to_reg(ring, 0, false,
                                    SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE),
                                    (adev->gds.mem.total_size +
-                                   adev->gfx.ngg.gds_reserve_size) >>
-                                  AMDGPU_GDS_SHIFT);
+                                   adev->gfx.ngg.gds_reserve_size));
 
         amdgpu_ring_write(ring, PACKET3(PACKET3_DMA_DATA, 5));
         amdgpu_ring_write(ring, (PACKET3_DMA_DATA_CP_SYNC |
@@ -3472,15 +3471,6 @@ static void gfx_v9_0_ring_emit_gds_switch(struct amdgpu_ring *ring,
  {
         struct amdgpu_device *adev = ring->adev;
 
-       gds_base = gds_base >> AMDGPU_GDS_SHIFT;
-       gds_size = gds_size >> AMDGPU_GDS_SHIFT;
-
-       gws_base = gws_base >> AMDGPU_GWS_SHIFT;
-       gws_size = gws_size >> AMDGPU_GWS_SHIFT;
-
-       oa_base = oa_base >> AMDGPU_OA_SHIFT;
-       oa_size = oa_size >> AMDGPU_OA_SHIFT;
-
         /* GDS Base */
         gfx_v9_0_write_data_to_reg(ring, 0, false,
                                    SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_BASE) + 2 * vmid,
--

2.14.1

Quoted 4 lines
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): aac8a166-b879-2694-6938-f7104f1903b9-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#8 lore raw

Re: [PATCH 2/7] drm/amdgpu: fix up GDS/GWS/OA shifting

Am 15.09.2018 um 09:52 schrieb Christian König:

Quoted 152 lines

Am 14.09.2018 um 22:26 schrieb Alex Deucher:

Quoted 140 lines
Quoted 138 lines · Christian König

That only worked by pure coincident. Completely remove the shifting and always apply correct PAGE_SHIFT.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c     | 12 ++++++------

  drivers/gpu/drm/amd/amdgpu/amdgpu_gds.h    |  7 -------
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c    | 12 +++---------
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    | 14 +++++++-------
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |  6 +++++-
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    | 15 +++------------
  drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c      |  9 ---------
  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c      |  9 ---------
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c      | 12 +-----------
  9 files changed, 25 insertions(+), 71 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +5 -6
index d762d78e5102..8836186eb5ef 100644
@@ -721,16 +721,16 @@ static int amdgpu_cs_parser_bos(struct 
 amdgpu_cs_parser *p,
                  e->bo_va = amdgpu_vm_bo_find(vm, ttm_to_amdgpu_bo(e->tv.bo));
 
          if (gds) {
-               p->job->gds_base = amdgpu_bo_gpu_offset(gds);
-               p->job->gds_size = amdgpu_bo_size(gds);
+               p->job->gds_base = amdgpu_bo_gpu_offset(gds) >> 
 PAGE_SHIFT;
+               p->job->gds_size = amdgpu_bo_size(gds) >> PAGE_SHIFT;
          }
          if (gws) {
-               p->job->gws_base = amdgpu_bo_gpu_offset(gws);
-               p->job->gws_size = amdgpu_bo_size(gws);
+               p->job->gws_base = amdgpu_bo_gpu_offset(gws) >> 
 PAGE_SHIFT;
+               p->job->gws_size = amdgpu_bo_size(gws) >> PAGE_SHIFT;
          }
          if (oa) {
-               p->job->oa_base = amdgpu_bo_gpu_offset(oa);
-               p->job->oa_size = amdgpu_bo_size(oa);
+               p->job->oa_base = amdgpu_bo_gpu_offset(oa) >> 

PAGE_SHIFT;
+               p->job->oa_size = amdgpu_bo_size(oa) >> PAGE_SHIFT; }

         if (!r && p->uf_entry.tv.bo) {

drivers/gpu/drm/amd/amdgpu/amdgpu_gds.h +0 -7
index e73728d90388..ecbcefe49a98 100644
@@ -24,13 +24,6 @@
   #ifndef __AMDGPU_GDS_H__
   #define __AMDGPU_GDS_H__
 
-/* Because TTM request that alloacted buffer should be PAGE_SIZE 
 aligned,
- * we should report GDS/GWS/OA size as PAGE_SIZE aligned
- * */
-#define AMDGPU_GDS_SHIFT       2
-#define AMDGPU_GWS_SHIFT       PAGE_SHIFT
-#define AMDGPU_OA_SHIFT                PAGE_SHIFT
-
   struct amdgpu_ring;
   struct amdgpu_bo;
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3 -9
index d30a0838851b..7b3d1ebda9df 100644
@@ -244,16 +244,10 @@ int amdgpu_gem_create_ioctl(struct drm_device 
 *dev, void *data,
                          return -EINVAL;
                  }
                  flags |= AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
-               if (args->in.domains == AMDGPU_GEM_DOMAIN_GDS)
-                       size = size << AMDGPU_GDS_SHIFT;
-               else if (args->in.domains == AMDGPU_GEM_DOMAIN_GWS)
-                       size = size << AMDGPU_GWS_SHIFT;
-               else if (args->in.domains == AMDGPU_GEM_DOMAIN_OA)
-                       size = size << AMDGPU_OA_SHIFT;
-               else
-                       return -EINVAL;
+               /* GDS allocations must be DW aligned */
+               if (args->in.domains & AMDGPU_GEM_DOMAIN_GDS)
+                       size = ALIGN(size, 4);
          }
-       size = roundup(size, PAGE_SIZE);
 
          if (flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID) {

                 r = amdgpu_bo_reserve(vm->root.base.bo, false);

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -5
index b766270d86cb..64cc483db973 100644
@@ -528,13 +528,13 @@ static int amdgpu_info_ioctl(struct drm_device 
 *dev, void *data, struct drm_file
                  struct drm_amdgpu_info_gds gds_info;
 
                  memset(&gds_info, 0, sizeof(gds_info));
-               gds_info.gds_gfx_partition_size = 
 adev->gds.mem.gfx_partition_size >> AMDGPU_GDS_SHIFT;
-               gds_info.compute_partition_size = 
 adev->gds.mem.cs_partition_size >> AMDGPU_GDS_SHIFT;
-               gds_info.gds_total_size = adev->gds.mem.total_size 
 >> AMDGPU_GDS_SHIFT;
-               gds_info.gws_per_gfx_partition = 
 adev->gds.gws.gfx_partition_size >> AMDGPU_GWS_SHIFT;
-               gds_info.gws_per_compute_partition = 

adev->gds.gws.cs_partition_size >> AMDGPU_GWS_SHIFT;
-               gds_info.oa_per_gfx_partition = adev->gds.oa.gfx_partition_size >> AMDGPU_OA_SHIFT;
-               gds_info.oa_per_compute_partition = adev->gds.oa.cs_partition_size >> AMDGPU_OA_SHIFT;
+               gds_info.gds_gfx_partition_size = adev->gds.mem.gfx_partition_size;
+               gds_info.compute_partition_size = adev->gds.mem.cs_partition_size;
+               gds_info.gds_total_size = adev->gds.mem.total_size;
+               gds_info.gws_per_gfx_partition = adev->gds.gws.gfx_partition_size;
+               gds_info.gws_per_compute_partition = adev->gds.gws.cs_partition_size;
+               gds_info.oa_per_gfx_partition = adev->gds.oa.gfx_partition_size;
+               gds_info.oa_per_compute_partition = adev->gds.oa.cs_partition_size;
                 return copy_to_user(out, &gds_info,
                                     min((size_t)size, sizeof(gds_info))) ? -EFAULT : 0; }

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
index e6909252aefa..e1f32a196f6d 100644
@@ -433,7 +433,11 @@ static int amdgpu_bo_do_create(struct 
 amdgpu_device *adev,
          int r;
 
Quoted 10 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
          page_align = roundup(bp->byte_align, PAGE_SIZE) >> PAGE_SHIFT;
-       size = ALIGN(size, PAGE_SIZE);
+       if (bp->domain & (AMDGPU_GEM_DOMAIN_GDS | 

AMDGPU_GEM_DOMAIN_GWS |
+                         AMDGPU_GEM_DOMAIN_OA))
+               size <<= PAGE_SHIFT;
+       else
+               size = ALIGN(size, PAGE_SIZE);

Is this right for GDS?  I think we need to be in 4K units regardless of the page size.  I have to admit, all the shifting is mixing me up.

Quoted 1 line

Yeah, that is indeed correct. GDS only needs DW alignment.

Can anybody give me an rb or ab? Only things left in to review in this series.

Christian.

Quoted 144 lines

The shifting is purely done because TTM wants to work with pages and not bytes.

Andrey already said he wanted to clean that up when there is time.

Christian.

Quoted 137 lines

Alex

Quoted 134 lines

         if (!amdgpu_bo_validate_size(adev, size, bp->domain)) return -ENOMEM;

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -8
index 1565344cc139..c691275cd1f0 100644
@@ -1825,19 +1825,10 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
                   (unsigned)(gtt_size / (1024 * 1024)));
 
          /* Initialize various on-chip memory pools */
-       adev->gds.mem.total_size = adev->gds.mem.total_size << 
 AMDGPU_GDS_SHIFT;
-       adev->gds.mem.gfx_partition_size = 
 adev->gds.mem.gfx_partition_size << AMDGPU_GDS_SHIFT;
-       adev->gds.mem.cs_partition_size = 
 adev->gds.mem.cs_partition_size << AMDGPU_GDS_SHIFT;
-       adev->gds.gws.total_size = adev->gds.gws.total_size << 
 AMDGPU_GWS_SHIFT;
-       adev->gds.gws.gfx_partition_size = 
 adev->gds.gws.gfx_partition_size << AMDGPU_GWS_SHIFT;
-       adev->gds.gws.cs_partition_size = 
 adev->gds.gws.cs_partition_size << AMDGPU_GWS_SHIFT;
-       adev->gds.oa.total_size = adev->gds.oa.total_size << 
 AMDGPU_OA_SHIFT;
-       adev->gds.oa.gfx_partition_size = 

adev->gds.oa.gfx_partition_size << AMDGPU_OA_SHIFT;
-       adev->gds.oa.cs_partition_size = adev->gds.oa.cs_partition_size << AMDGPU_OA_SHIFT;
         /* GDS Memory */
         if (adev->gds.mem.total_size) {
                 r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GDS, -                                  adev->gds.mem.total_size >> PAGE_SHIFT);
+ adev->gds.mem.total_size);
                 if (r) {
                         DRM_ERROR("Failed initializing GDS heap.\n"); return r;

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
@@ -1847,7 +1838,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
          /* GWS */
          if (adev->gds.gws.total_size) {
                  r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GWS,
-                                  adev->gds.gws.total_size >> 
 PAGE_SHIFT);
+ adev->gds.gws.total_size);
                  if (r) {
                          DRM_ERROR("Failed initializing gws heap.\n");

                         return r;

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
@@ -1857,7 +1848,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
          /* OA */
          if (adev->gds.oa.total_size) {
                  r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_OA,
-                                  adev->gds.oa.total_size >> 
 PAGE_SHIFT);
+ adev->gds.oa.total_size);
                  if (r) {
                          DRM_ERROR("Failed initializing oa heap.\n");

                         return r;

drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0 -9
index a15d9c0f233b..c0f9732cbaf7 100644
@@ -4170,15 +4170,6 @@ static void 
 gfx_v7_0_ring_emit_gds_switch(struct amdgpu_ring *ring,
                                            uint32_t gws_base, uint32_t gws_size,
                                            uint32_t oa_base, uint32_t oa_size)
   {
-       gds_base = gds_base >> AMDGPU_GDS_SHIFT;
-       gds_size = gds_size >> AMDGPU_GDS_SHIFT;
-
-       gws_base = gws_base >> AMDGPU_GWS_SHIFT;
-       gws_size = gws_size >> AMDGPU_GWS_SHIFT;
-
-       oa_base = oa_base >> AMDGPU_OA_SHIFT;
-       oa_size = oa_size >> AMDGPU_OA_SHIFT;
-
          /* GDS Base */
          amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));

         amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -9
index 3882689b2d8f..57e4b14e3bd1 100644
@@ -5396,15 +5396,6 @@ static void 
 gfx_v8_0_ring_emit_gds_switch(struct amdgpu_ring *ring,
                                            uint32_t gws_base, uint32_t gws_size,
                                            uint32_t oa_base, uint32_t oa_size)
   {
-       gds_base = gds_base >> AMDGPU_GDS_SHIFT;
-       gds_size = gds_size >> AMDGPU_GDS_SHIFT;
-
-       gws_base = gws_base >> AMDGPU_GWS_SHIFT;
-       gws_size = gws_size >> AMDGPU_GWS_SHIFT;
-
-       oa_base = oa_base >> AMDGPU_OA_SHIFT;
-       oa_size = oa_size >> AMDGPU_OA_SHIFT;
-
          /* GDS Base */
          amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));

         amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -0
index 75a91663019f..d31a2bc00d61 100644
@@ -1527,8 +1527,7 @@ static int gfx_v9_0_ngg_en(struct 
 amdgpu_device *adev)
          gfx_v9_0_write_data_to_reg(ring, 0, false,
                                     SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE),

(adev->gds.mem.total_size +
- adev->gfx.ngg.gds_reserve_size) >>
-                                  AMDGPU_GDS_SHIFT);
+ adev->gfx.ngg.gds_reserve_size));

         amdgpu_ring_write(ring, PACKET3(PACKET3_DMA_DATA, 5)); amdgpu_ring_write(ring, (PACKET3_DMA_DATA_CP_SYNC |

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -9
@@ -3472,15 +3471,6 @@ static void 
 gfx_v9_0_ring_emit_gds_switch(struct amdgpu_ring *ring,
   {
          struct amdgpu_device *adev = ring->adev;
 
-       gds_base = gds_base >> AMDGPU_GDS_SHIFT;
-       gds_size = gds_size >> AMDGPU_GDS_SHIFT;
-
-       gws_base = gws_base >> AMDGPU_GWS_SHIFT;
-       gws_size = gws_size >> AMDGPU_GWS_SHIFT;
-
-       oa_base = oa_base >> AMDGPU_OA_SHIFT;
-       oa_size = oa_size >> AMDGPU_OA_SHIFT;
-
          /* GDS Base */
          gfx_v9_0_write_data_to_reg(ring, 0, false,

                                    SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_BASE) + 2 * vmid,

Signature · 1 line
2.14.1
Quoted 5 lines
Quoted 4 lines
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

Acked-by Alex Deucher
#9 lore raw

RE: [PATCH 2/7] drm/amdgpu: fix up GDS/GWS/OA shifting

In reply to a message not in the archive
Quoted 165 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Christian König
Sent: Saturday, September 15, 2018 3:52 AM
To: Alex Deucher <[email protected]>
Cc: amd-gfx list <[email protected]>
Subject: Re: [PATCH 2/7] drm/amdgpu: fix up GDS/GWS/OA shifting

Am 14.09.2018 um 22:26 schrieb Alex Deucher:

Quoted 18 lines
Quoted 16 lines · Christian König

That only worked by pure coincident. Completely remove the shifting and always apply correct PAGE_SHIFT.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c     | 12 ++++++------
  drivers/gpu/drm/amd/amdgpu/amdgpu_gds.h    |  7 -------
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c    | 12 +++---------
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    | 14 +++++++-------
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |  6 +++++-
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    | 15 +++------------
  drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c      |  9 ---------
  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c      |  9 ---------
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c      | 12 +-----------
  9 files changed, 25 insertions(+), 71 deletions(-)
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static int amdgpu_cs_parser_bos(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
index d762d78e5102..8836186eb5ef 100644
@@ -721,16 +721,16 @@ static int amdgpu_cs_parser_bos(struct

amdgpu_cs_parser *p,

Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -2
                 e->bo_va = amdgpu_vm_bo_find(vm,
 ttm_to_amdgpu_bo(e->tv.bo));
 
         if (gds) {
-               p->job->gds_base = amdgpu_bo_gpu_offset(gds);
-               p->job->gds_size = amdgpu_bo_size(gds);
+               p->job->gds_base = amdgpu_bo_gpu_offset(gds) >>

PAGE_SHIFT;

Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -2
+               p->job->gds_size = amdgpu_bo_size(gds) >> PAGE_SHIFT;
         }
         if (gws) {
-               p->job->gws_base = amdgpu_bo_gpu_offset(gws);
-               p->job->gws_size = amdgpu_bo_size(gws);
+               p->job->gws_base = amdgpu_bo_gpu_offset(gws) >>

PAGE_SHIFT;

Quoted 30 lines
Quoted 30 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +3 -2
+               p->job->gws_size = amdgpu_bo_size(gws) >> PAGE_SHIFT;
         }
         if (oa) {
-               p->job->oa_base = amdgpu_bo_gpu_offset(oa);
-               p->job->oa_size = amdgpu_bo_size(oa);
+               p->job->oa_base = amdgpu_bo_gpu_offset(oa) >> PAGE_SHIFT;
+               p->job->oa_size = amdgpu_bo_size(oa) >> PAGE_SHIFT;
         }
 
         if (!r && p->uf_entry.tv.bo) { diff --git

a/drivers/gpu/drm/amd/amdgpu/amdgpu_gds.h
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gds.h
index e73728d90388..ecbcefe49a98 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gds.h +0 -7
@@ -24,13 +24,6 @@
  #ifndef __AMDGPU_GDS_H__
  #define __AMDGPU_GDS_H__
 
-/* Because TTM request that alloacted buffer should be PAGE_SIZE
 aligned,
- * we should report GDS/GWS/OA size as PAGE_SIZE aligned
- * */
-#define AMDGPU_GDS_SHIFT       2
-#define AMDGPU_GWS_SHIFT       PAGE_SHIFT
-#define AMDGPU_OA_SHIFT                PAGE_SHIFT
-
  struct amdgpu_ring;
  struct amdgpu_bo;
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_create_ioctl(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
index d30a0838851b..7b3d1ebda9df 100644
@@ -244,16 +244,10 @@ int amdgpu_gem_create_ioctl(struct

drm_device *dev, void *data,

Quoted 17 lines
Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3 -9
                         return -EINVAL;
                 }
                 flags |= AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
-               if (args->in.domains == AMDGPU_GEM_DOMAIN_GDS)
-                       size = size << AMDGPU_GDS_SHIFT;
-               else if (args->in.domains == AMDGPU_GEM_DOMAIN_GWS)
-                       size = size << AMDGPU_GWS_SHIFT;
-               else if (args->in.domains == AMDGPU_GEM_DOMAIN_OA)
-                       size = size << AMDGPU_OA_SHIFT;
-               else
-                       return -EINVAL;
+               /* GDS allocations must be DW aligned */
+               if (args->in.domains & AMDGPU_GEM_DOMAIN_GDS)
+                       size = ALIGN(size, 4);
         }
-       size = roundup(size, PAGE_SIZE);
 
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -1
         if (flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID) {
                 r = amdgpu_bo_reserve(vm->root.base.bo, false); diff
--git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index b766270d86cb..64cc483db973 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -0
@@ -528,13 +528,13 @@ static int amdgpu_info_ioctl(struct drm_device

*dev, void *data, struct drm_file

Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -1
                 struct drm_amdgpu_info_gds gds_info;
 
                 memset(&gds_info, 0, sizeof(gds_info));
-               gds_info.gds_gfx_partition_size = adev-

gds.mem.gfx_partition_size >> AMDGPU_GDS_SHIFT;

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device · line 532

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -1
-               gds_info.compute_partition_size = adev-

gds.mem.cs_partition_size >> AMDGPU_GDS_SHIFT;

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -1
-               gds_info.gds_total_size = adev->gds.mem.total_size >>

AMDGPU_GDS_SHIFT;

Quoted 19 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device · line 534

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -1
-               gds_info.gws_per_gfx_partition = adev-

gds.gws.gfx_partition_size >> AMDGPU_GWS_SHIFT;

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device · line 535

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -1
-               gds_info.gws_per_compute_partition = adev-

gds.gws.cs_partition_size >> AMDGPU_GWS_SHIFT;

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device · line 538

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -2
-               gds_info.oa_per_gfx_partition = adev->gds.oa.gfx_partition_size
 AMDGPU_OA_SHIFT;
-               gds_info.oa_per_compute_partition = adev-

gds.oa.cs_partition_size >> AMDGPU_OA_SHIFT;

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device · line 532

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -0
+               gds_info.gds_gfx_partition_size = adev-

gds.mem.gfx_partition_size;

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device · line 533

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -0
+               gds_info.compute_partition_size = adev-

gds.mem.cs_partition_size;

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device · line 535

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2 -0
+               gds_info.gds_total_size = adev->gds.mem.total_size;
+               gds_info.gws_per_gfx_partition = adev-

gds.gws.gfx_partition_size;

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device · line 536

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -0
+               gds_info.gws_per_compute_partition = adev-

gds.gws.cs_partition_size;

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device · line 537

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -0
+               gds_info.oa_per_gfx_partition = adev-

gds.oa.gfx_partition_size;

Quoted 11 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static int amdgpu_bo_do_create(struct

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2 -0
+               gds_info.oa_per_compute_partition =
+ adev->gds.oa.cs_partition_size;
                 return copy_to_user(out, &gds_info,
                                     min((size_t)size, sizeof(gds_info))) ? -EFAULT : 0;
         }
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
index e6909252aefa..e1f32a196f6d 100644
@@ -433,7 +433,11 @@ static int amdgpu_bo_do_create(struct

amdgpu_device *adev,

Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static int amdgpu_bo_do_create(struct amdgpu_device *adev,

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
         int r;
 
         page_align = roundup(bp->byte_align, PAGE_SIZE) >> PAGE_SHIFT;
-       size = ALIGN(size, PAGE_SIZE);
+       if (bp->domain & (AMDGPU_GEM_DOMAIN_GDS |

AMDGPU_GEM_DOMAIN_GWS |

Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static int amdgpu_bo_do_create(struct amdgpu_device *adev, · line 440

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +4 -0
+                         AMDGPU_GEM_DOMAIN_OA))
+               size <<= PAGE_SHIFT;
+       else
+               size = ALIGN(size, PAGE_SIZE);

Is this right for GDS? I think we need to be in 4K units regardless of the page size. I have to admit, all the shifting is mixing me up.

Quoted 6 lines

Yeah, that is indeed correct. GDS only needs DW alignment.

The shifting is purely done because TTM wants to work with pages and not bytes.

Andrey already said he wanted to clean that up when there is time.

Quoted 145 lines

Christian.

Quoted 11 lines

Alex

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_init(struct amdgpu_device

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
         if (!amdgpu_bo_validate_size(adev, size, bp->domain))
                 return -ENOMEM;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
index 1565344cc139..c691275cd1f0 100644
@@ -1825,19 +1825,10 @@ int amdgpu_ttm_init(struct amdgpu_device

*adev)

Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_init(struct amdgpu_device *adev)

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
                  (unsigned)(gtt_size / (1024 * 1024)));
 
         /* Initialize various on-chip memory pools */
-       adev->gds.mem.total_size = adev->gds.mem.total_size <<

AMDGPU_GDS_SHIFT;

Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_init(struct amdgpu_device · line 1829

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
-       adev->gds.mem.gfx_partition_size = adev-

gds.mem.gfx_partition_size << AMDGPU_GDS_SHIFT;

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_init(struct amdgpu_device · line 1830

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
-       adev->gds.mem.cs_partition_size = adev-

gds.mem.cs_partition_size << AMDGPU_GDS_SHIFT;

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
-       adev->gds.gws.total_size = adev->gds.gws.total_size <<

AMDGPU_GWS_SHIFT;

Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_init(struct amdgpu_device · line 1832

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
-       adev->gds.gws.gfx_partition_size = adev-

gds.gws.gfx_partition_size << AMDGPU_GWS_SHIFT;

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
-       adev->gds.gws.cs_partition_size = adev->gds.gws.cs_partition_size

<< AMDGPU_GWS_SHIFT;

Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_init(struct amdgpu_device · line 1834

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
-       adev->gds.oa.total_size = adev->gds.oa.total_size <<

AMDGPU_OA_SHIFT;

Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_init(struct amdgpu_device · line 1835

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
-       adev->gds.oa.gfx_partition_size = adev->gds.oa.gfx_partition_size

<< AMDGPU_OA_SHIFT;

Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_init(struct amdgpu_device · line 1836

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
-       adev->gds.oa.cs_partition_size = adev->gds.oa.cs_partition_size <<

AMDGPU_OA_SHIFT;

Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_init(struct amdgpu_device

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
         /* GDS Memory */
         if (adev->gds.mem.total_size) {
                 r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GDS,
-                                  adev->gds.mem.total_size >> PAGE_SHIFT);
+                                  adev->gds.mem.total_size);
                 if (r) {
                         DRM_ERROR("Failed initializing GDS heap.\n");
                         return r;
@@ -1847,7 +1838,7 @@ int amdgpu_ttm_init(struct amdgpu_device

*adev)

Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_init(struct amdgpu_device

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
         /* GWS */
         if (adev->gds.gws.total_size) {
                 r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GWS,
-                                  adev->gds.gws.total_size >> PAGE_SHIFT);
+                                  adev->gds.gws.total_size);
                 if (r) {
                         DRM_ERROR("Failed initializing gws heap.\n");
                         return r;
@@ -1857,7 +1848,7 @@ int amdgpu_ttm_init(struct amdgpu_device

*adev)

Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
         /* OA */
         if (adev->gds.oa.total_size) {
                 r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_OA,
-                                  adev->gds.oa.total_size >> PAGE_SHIFT);
+                                  adev->gds.oa.total_size);
                 if (r) {
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c static void

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
                         DRM_ERROR("Failed initializing oa heap.\n");
                         return r;
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0 -0
index a15d9c0f233b..c0f9732cbaf7 100644
@@ -4170,15 +4170,6 @@ static void

gfx_v7_0_ring_emit_gds_switch(struct amdgpu_ring *ring,

Quoted 13 lines
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0 -9
                                           uint32_t gws_base, uint32_t gws_size,
                                           uint32_t oa_base, uint32_t oa_size)
  {
-       gds_base = gds_base >> AMDGPU_GDS_SHIFT;
-       gds_size = gds_size >> AMDGPU_GDS_SHIFT;
-
-       gws_base = gws_base >> AMDGPU_GWS_SHIFT;
-       gws_size = gws_size >> AMDGPU_GWS_SHIFT;
-
-       oa_base = oa_base >> AMDGPU_OA_SHIFT;
-       oa_size = oa_size >> AMDGPU_OA_SHIFT;
-
         /* GDS Base */
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c static void

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0 -1
         amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
         amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | diff
--git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c

b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index 3882689b2d8f..57e4b14e3bd1 100644

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -0
@@ -5396,15 +5396,6 @@ static void

gfx_v8_0_ring_emit_gds_switch(struct amdgpu_ring *ring,

Quoted 13 lines
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -9
                                           uint32_t gws_base, uint32_t gws_size,
                                           uint32_t oa_base, uint32_t oa_size)
  {
-       gds_base = gds_base >> AMDGPU_GDS_SHIFT;
-       gds_size = gds_size >> AMDGPU_GDS_SHIFT;
-
-       gws_base = gws_base >> AMDGPU_GWS_SHIFT;
-       gws_size = gws_size >> AMDGPU_GWS_SHIFT;
-
-       oa_base = oa_base >> AMDGPU_OA_SHIFT;
-       oa_size = oa_size >> AMDGPU_OA_SHIFT;
-
         /* GDS Base */
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static int gfx_v9_0_ngg_en(struct

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -1
         amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
         amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | diff
--git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c

b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 75a91663019f..d31a2bc00d61 100644

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -0
@@ -1527,8 +1527,7 @@ static int gfx_v9_0_ngg_en(struct

amdgpu_device *adev)

Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static int gfx_v9_0_ngg_en(struct amdgpu_device *adev)

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -3
         gfx_v9_0_write_data_to_reg(ring, 0, false,
                                    SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE),
                                    (adev->gds.mem.total_size +
-                                   adev->gfx.ngg.gds_reserve_size) >>
-                                  AMDGPU_GDS_SHIFT);
+                                   adev->gfx.ngg.gds_reserve_size));
 
         amdgpu_ring_write(ring, PACKET3(PACKET3_DMA_DATA, 5));
         amdgpu_ring_write(ring, (PACKET3_DMA_DATA_CP_SYNC | @@
-3472,15 +3471,6 @@ static void gfx_v9_0_ring_emit_gds_switch(struct

amdgpu_ring *ring,

Quoted 19 lines
Quoted 19 lines
  {
         struct amdgpu_device *adev = ring->adev;
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -9
-       gds_base = gds_base >> AMDGPU_GDS_SHIFT;
-       gds_size = gds_size >> AMDGPU_GDS_SHIFT;
-
-       gws_base = gws_base >> AMDGPU_GWS_SHIFT;
-       gws_size = gws_size >> AMDGPU_GWS_SHIFT;
-
-       oa_base = oa_base >> AMDGPU_OA_SHIFT;
-       oa_size = oa_size >> AMDGPU_OA_SHIFT;
-
         /* GDS Base */
         gfx_v9_0_write_data_to_reg(ring, 0, false,
                                    SOC15_REG_OFFSET(GC, 0,

mmGDS_VMID0_BASE) + 2 * vmid,
--
2.14.1

Quoted 9 lines
Quoted 4 lines
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

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

#10 lore raw

PATCH 3/7 drm/amdgpu: stop crashing on GDS/GWS/OA eviction

In reply to a message not in the archive

Simply ignore any copying here.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +18 -0
index c691275cd1f0..3e450159fe1f 100644
@@ -256,6 +256,13 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,
 
 	abo = ttm_to_amdgpu_bo(bo);
 	switch (bo->mem.mem_type) {
+	case AMDGPU_PL_GDS:
+	case AMDGPU_PL_GWS:
+	case AMDGPU_PL_OA:
+		placement->num_placement = 0;
+		placement->num_busy_placement = 0;
+		return;
+
 	case TTM_PL_VRAM:
 		if (!adev->mman.buffer_funcs_enabled) {
 			/* Move to system memory */
@@ -283,6 +290,7 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,
 	case TTM_PL_TT:
 	default:
 		amdgpu_bo_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_CPU);
+		break;
 	}
 	*placement = abo->placement;
 }
@@ -675,6 +683,16 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
 		amdgpu_move_null(bo, new_mem);
 		return 0;
 	}
+	if (old_mem->mem_type == AMDGPU_PL_GDS ||
+	    old_mem->mem_type == AMDGPU_PL_GWS ||
+	    old_mem->mem_type == AMDGPU_PL_OA ||
+	    new_mem->mem_type == AMDGPU_PL_GDS ||
+	    new_mem->mem_type == AMDGPU_PL_GWS ||
+	    new_mem->mem_type == AMDGPU_PL_OA) {
+		/* Nothing to save here */
+		amdgpu_move_null(bo, new_mem);
+		return 0;
+	}
 
 	if (!adev->mman.buffer_funcs_enabled)
 		goto memcpy;
Signature · 6 lines
2.14.1

_______________________________________________
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): 20180914191246.1609-3-christian.koenig-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#12 lore raw

Re: [PATCH 3/7] drm/amdgpu: stop crashing on GDS/GWS/OA eviction

Quoted 4 lines · Christian König

Simply ignore any copying here.

Quoted 50 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +18 -1
index c691275cd1f0..3e450159fe1f 100644
@@ -256,6 +256,13 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,
 
        abo = ttm_to_amdgpu_bo(bo);
        switch (bo->mem.mem_type) {
+       case AMDGPU_PL_GDS:
+       case AMDGPU_PL_GWS:
+       case AMDGPU_PL_OA:
+               placement->num_placement = 0;
+               placement->num_busy_placement = 0;
+               return;
+
        case TTM_PL_VRAM:
                if (!adev->mman.buffer_funcs_enabled) {
                        /* Move to system memory */
@@ -283,6 +290,7 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,
        case TTM_PL_TT:
        default:
                amdgpu_bo_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_CPU);
+               break;
        }
        *placement = abo->placement;
 }
@@ -675,6 +683,16 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
                amdgpu_move_null(bo, new_mem);
                return 0;
        }
+       if (old_mem->mem_type == AMDGPU_PL_GDS ||
+           old_mem->mem_type == AMDGPU_PL_GWS ||
+           old_mem->mem_type == AMDGPU_PL_OA ||
+           new_mem->mem_type == AMDGPU_PL_GDS ||
+           new_mem->mem_type == AMDGPU_PL_GWS ||
+           new_mem->mem_type == AMDGPU_PL_OA) {
+               /* Nothing to save here */
+               amdgpu_move_null(bo, new_mem);
+               return 0;
+       }
 
        if (!adev->mman.buffer_funcs_enabled)
                goto memcpy;
--

2.14.1

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

#13 lore raw

PATCH 4/7 drm/amdgpu: initialize GDS/GWS/OA domains even when they are zero sized

In reply to a message not in the archive

Stops crashing on SI.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 48 +++++++++++++--------------------
 1 file changed, 18 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +18 -30
index 3e450159fe1f..710e7751c567 100644
@@ -1843,34 +1843,25 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
 		 (unsigned)(gtt_size / (1024 * 1024)));
 
 	/* Initialize various on-chip memory pools */
-	/* GDS Memory */
-	if (adev->gds.mem.total_size) {
-		r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GDS,
-				   adev->gds.mem.total_size);
-		if (r) {
-			DRM_ERROR("Failed initializing GDS heap.\n");
-			return r;
-		}
+	r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GDS,
+			   adev->gds.mem.total_size);
+	if (r) {
+		DRM_ERROR("Failed initializing GDS heap.\n");
+		return r;
 	}
 
-	/* GWS */
-	if (adev->gds.gws.total_size) {
-		r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GWS,
-				   adev->gds.gws.total_size);
-		if (r) {
-			DRM_ERROR("Failed initializing gws heap.\n");
-			return r;
-		}
+	r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GWS,
+			   adev->gds.gws.total_size);
+	if (r) {
+		DRM_ERROR("Failed initializing gws heap.\n");
+		return r;
 	}
 
-	/* OA */
-	if (adev->gds.oa.total_size) {
-		r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_OA,
-				   adev->gds.oa.total_size);
-		if (r) {
-			DRM_ERROR("Failed initializing oa heap.\n");
-			return r;
-		}
+	r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_OA,
+			   adev->gds.oa.total_size);
+	if (r) {
+		DRM_ERROR("Failed initializing oa heap.\n");
+		return r;
 	}
 
 	/* Register debugfs entries for amdgpu_ttm */
@@ -1907,12 +1898,9 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
 
 	ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_VRAM);
 	ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_TT);
-	if (adev->gds.mem.total_size)
-		ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_GDS);
-	if (adev->gds.gws.total_size)
-		ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_GWS);
-	if (adev->gds.oa.total_size)
-		ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_OA);
+	ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_GDS);
+	ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_GWS);
+	ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_OA);
 	ttm_bo_device_release(&adev->mman.bdev);
 	amdgpu_ttm_global_fini(adev);
 	adev->mman.initialized = false;
Signature · 6 lines
2.14.1

_______________________________________________
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): 20180914191246.1609-4-christian.koenig-5C7GfCeVMHo@public.gmane.org

Acked-by
#15 lore raw

Re: [PATCH 4/7] drm/amdgpu: initialize GDS/GWS/OA domains even when they are zero sized

Quoted 4 lines · Christian König

Stops crashing on SI.

Presumably ttm allows this?

Quoted 77 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 48 +++++++++++++--------------------
 1 file changed, 18 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +18 -31
index 3e450159fe1f..710e7751c567 100644
@@ -1843,34 +1843,25 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
                 (unsigned)(gtt_size / (1024 * 1024)));
 
        /* Initialize various on-chip memory pools */
-       /* GDS Memory */
-       if (adev->gds.mem.total_size) {
-               r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GDS,
-                                  adev->gds.mem.total_size);
-               if (r) {
-                       DRM_ERROR("Failed initializing GDS heap.\n");
-                       return r;
-               }
+       r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GDS,
+                          adev->gds.mem.total_size);
+       if (r) {
+               DRM_ERROR("Failed initializing GDS heap.\n");
+               return r;
        }
 
-       /* GWS */
-       if (adev->gds.gws.total_size) {
-               r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GWS,
-                                  adev->gds.gws.total_size);
-               if (r) {
-                       DRM_ERROR("Failed initializing gws heap.\n");
-                       return r;
-               }
+       r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GWS,
+                          adev->gds.gws.total_size);
+       if (r) {
+               DRM_ERROR("Failed initializing gws heap.\n");
+               return r;
        }
 
-       /* OA */
-       if (adev->gds.oa.total_size) {
-               r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_OA,
-                                  adev->gds.oa.total_size);
-               if (r) {
-                       DRM_ERROR("Failed initializing oa heap.\n");
-                       return r;
-               }
+       r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_OA,
+                          adev->gds.oa.total_size);
+       if (r) {
+               DRM_ERROR("Failed initializing oa heap.\n");
+               return r;
        }
 
        /* Register debugfs entries for amdgpu_ttm */
@@ -1907,12 +1898,9 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
 
        ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_VRAM);
        ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_TT);
-       if (adev->gds.mem.total_size)
-               ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_GDS);
-       if (adev->gds.gws.total_size)
-               ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_GWS);
-       if (adev->gds.oa.total_size)
-               ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_OA);
+       ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_GDS);
+       ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_GWS);
+       ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_OA);
        ttm_bo_device_release(&adev->mman.bdev);
        amdgpu_ttm_global_fini(adev);
        adev->mman.initialized = false;
--

2.14.1

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_OEi6MBaHp7qx_0dS9SbxCrXiyKPSx5xKdq-3FwtTBsNg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#17 lore raw

Re: [PATCH 4/7] drm/amdgpu: initialize GDS/GWS/OA domains even when they are zero sized

Am 14.09.2018 um 22:14 schrieb Alex Deucher:

Quoted 6 lines
Quoted 3 lines · Christian König

Stops crashing on SI.

Presumably ttm allows this?

Yes, actually explicitly tested this.

Christian.

Quoted 79 lines
Quoted 77 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 48 +++++++++++++--------------------
  1 file changed, 18 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +18 -31
index 3e450159fe1f..710e7751c567 100644
@@ -1843,34 +1843,25 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
                  (unsigned)(gtt_size / (1024 * 1024)));
 
         /* Initialize various on-chip memory pools */
-       /* GDS Memory */
-       if (adev->gds.mem.total_size) {
-               r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GDS,
-                                  adev->gds.mem.total_size);
-               if (r) {
-                       DRM_ERROR("Failed initializing GDS heap.\n");
-                       return r;
-               }
+       r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GDS,
+                          adev->gds.mem.total_size);
+       if (r) {
+               DRM_ERROR("Failed initializing GDS heap.\n");
+               return r;
         }
 
-       /* GWS */
-       if (adev->gds.gws.total_size) {
-               r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GWS,
-                                  adev->gds.gws.total_size);
-               if (r) {
-                       DRM_ERROR("Failed initializing gws heap.\n");
-                       return r;
-               }
+       r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GWS,
+                          adev->gds.gws.total_size);
+       if (r) {
+               DRM_ERROR("Failed initializing gws heap.\n");
+               return r;
         }
 
-       /* OA */
-       if (adev->gds.oa.total_size) {
-               r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_OA,
-                                  adev->gds.oa.total_size);
-               if (r) {
-                       DRM_ERROR("Failed initializing oa heap.\n");
-                       return r;
-               }
+       r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_OA,
+                          adev->gds.oa.total_size);
+       if (r) {
+               DRM_ERROR("Failed initializing oa heap.\n");
+               return r;
         }
 
         /* Register debugfs entries for amdgpu_ttm */
@@ -1907,12 +1898,9 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
 
         ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_VRAM);
         ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_TT);
-       if (adev->gds.mem.total_size)
-               ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_GDS);
-       if (adev->gds.gws.total_size)
-               ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_GWS);
-       if (adev->gds.oa.total_size)
-               ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_OA);
+       ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_GDS);
+       ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_GWS);
+       ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_OA);
         ttm_bo_device_release(&adev->mman.bdev);
         amdgpu_ttm_global_fini(adev);
         adev->mman.initialized = false;
--

2.14.1

Quoted 4 lines
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

#18 lore raw

PATCH 5/7 drm/amdgpu: don't allocate zero sized kernel BOs

In reply to a message not in the archive

Just free the BO if the size is should be zero.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +5 -0
index e1f32a196f6d..d282e923d1b4 100644
@@ -250,6 +250,11 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
 	bool free = false;
 	int r;
 
+	if (!size) {
+		amdgpu_bo_unref(bo_ptr);
+		return 0;
+	}
+
 	memset(&bp, 0, sizeof(bp));
 	bp.size = size;
 	bp.byte_align = align;
Signature · 6 lines
2.14.1

_______________________________________________
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): 20180914191246.1609-5-christian.koenig-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#20 lore raw

Re: [PATCH 5/7] drm/amdgpu: don't allocate zero sized kernel BOs

Quoted 4 lines · Christian König

Just free the BO if the size is should be zero.

Quoted 23 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +5 -1
index e1f32a196f6d..d282e923d1b4 100644
@@ -250,6 +250,11 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
        bool free = false;
        int r;
 
+       if (!size) {
+               amdgpu_bo_unref(bo_ptr);
+               return 0;
+       }
+
        memset(&bp, 0, sizeof(bp));
        bp.size = size;
        bp.byte_align = align;
--

2.14.1

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

#21 lore raw

PATCH 6/7 drm/amdgpu: drop size check

In reply to a message not in the archive

We no don't allocate zero sized kernel BOs any longer.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +6 -8
index 710e7751c567..438390fce714 100644
@@ -1809,14 +1809,12 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
 	 * This is used for VGA emulation and pre-OS scanout buffers to
 	 * avoid display artifacts while transitioning between pre-OS
 	 * and driver.  */
-	if (adev->gmc.stolen_size) {
-		r = amdgpu_bo_create_kernel(adev, adev->gmc.stolen_size, PAGE_SIZE,
-					    AMDGPU_GEM_DOMAIN_VRAM,
-					    &adev->stolen_vga_memory,
-					    NULL, NULL);
-		if (r)
-			return r;
-	}
+	r = amdgpu_bo_create_kernel(adev, adev->gmc.stolen_size, PAGE_SIZE,
+				    AMDGPU_GEM_DOMAIN_VRAM,
+				    &adev->stolen_vga_memory,
+				    NULL, NULL);
+	if (r)
+		return r;
 	DRM_INFO("amdgpu: %uM of VRAM memory ready\n",
 		 (unsigned) (adev->gmc.real_vram_size / (1024 * 1024)));
 
Signature · 6 lines
2.14.1

_______________________________________________
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): 20180914191246.1609-6-christian.koenig-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#23 lore raw

Re: [PATCH 6/7] drm/amdgpu: drop size check

Quoted 4 lines · Christian König

We no don't allocate zero sized kernel BOs any longer.

Quoted 32 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +6 -9
index 710e7751c567..438390fce714 100644
@@ -1809,14 +1809,12 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
         * This is used for VGA emulation and pre-OS scanout buffers to
         * avoid display artifacts while transitioning between pre-OS
         * and driver.  */
-       if (adev->gmc.stolen_size) {
-               r = amdgpu_bo_create_kernel(adev, adev->gmc.stolen_size, PAGE_SIZE,
-                                           AMDGPU_GEM_DOMAIN_VRAM,
-                                           &adev->stolen_vga_memory,
-                                           NULL, NULL);
-               if (r)
-                       return r;
-       }
+       r = amdgpu_bo_create_kernel(adev, adev->gmc.stolen_size, PAGE_SIZE,
+                                   AMDGPU_GEM_DOMAIN_VRAM,
+                                   &adev->stolen_vga_memory,
+                                   NULL, NULL);
+       if (r)
+               return r;
        DRM_INFO("amdgpu: %uM of VRAM memory ready\n",
                 (unsigned) (adev->gmc.real_vram_size / (1024 * 1024)));
 
--

2.14.1

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

#24 lore raw

PATCH 7/7 drm/amdgpu: move reserving GDS/GWS/OA into common code

In reply to a message not in the archive

We don't need that in the per ASIC code.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 18 ++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c   | 19 -------------------
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c   | 19 -------------------
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c   | 19 -------------------
 4 files changed, 18 insertions(+), 57 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +18 -0
index 438390fce714..cf93a9831318 100644
@@ -1848,6 +1848,12 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
 		return r;
 	}
 
+	r = amdgpu_bo_create_kernel(adev, adev->gds.mem.gfx_partition_size,
+				    PAGE_SIZE, AMDGPU_GEM_DOMAIN_GDS,
+				    &adev->gds.gds_gfx_bo, NULL, NULL);
+	if (r)
+		return r;
+
 	r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GWS,
 			   adev->gds.gws.total_size);
 	if (r) {
@@ -1855,6 +1861,12 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
 		return r;
 	}
 
+	r = amdgpu_bo_create_kernel(adev, adev->gds.gws.gfx_partition_size,
+				    PAGE_SIZE, AMDGPU_GEM_DOMAIN_GWS,
+				    &adev->gds.gws_gfx_bo, NULL, NULL);
+	if (r)
+		return r;
+
 	r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_OA,
 			   adev->gds.oa.total_size);
 	if (r) {
@@ -1862,6 +1874,12 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
 		return r;
 	}
 
+	r = amdgpu_bo_create_kernel(adev, adev->gds.oa.gfx_partition_size,
+				    PAGE_SIZE, AMDGPU_GEM_DOMAIN_OA,
+				    &adev->gds.oa_gfx_bo, NULL, NULL);
+	if (r)
+		return r;
+
 	/* Register debugfs entries for amdgpu_ttm */
 	r = amdgpu_ttm_debugfs_init(adev);
 	if (r) {
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0 -19
index c0f9732cbaf7..fc39ebbc9d9f 100644
@@ -4582,25 +4582,6 @@ static int gfx_v7_0_sw_init(void *handle)
 		}
 	}
 
-	/* reserve GDS, GWS and OA resource for gfx */
-	r = amdgpu_bo_create_kernel(adev, adev->gds.mem.gfx_partition_size,
-				    PAGE_SIZE, AMDGPU_GEM_DOMAIN_GDS,
-				    &adev->gds.gds_gfx_bo, NULL, NULL);
-	if (r)
-		return r;
-
-	r = amdgpu_bo_create_kernel(adev, adev->gds.gws.gfx_partition_size,
-				    PAGE_SIZE, AMDGPU_GEM_DOMAIN_GWS,
-				    &adev->gds.gws_gfx_bo, NULL, NULL);
-	if (r)
-		return r;
-
-	r = amdgpu_bo_create_kernel(adev, adev->gds.oa.gfx_partition_size,
-				    PAGE_SIZE, AMDGPU_GEM_DOMAIN_OA,
-				    &adev->gds.oa_gfx_bo, NULL, NULL);
-	if (r)
-		return r;
-
 	adev->gfx.ce_ram_size = 0x8000;
 
 	gfx_v7_0_gpu_early_init(adev);
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -19
index 57e4b14e3bd1..5d9fd2c2c244 100644
@@ -2161,25 +2161,6 @@ static int gfx_v8_0_sw_init(void *handle)
 	if (r)
 		return r;
 
-	/* reserve GDS, GWS and OA resource for gfx */
-	r = amdgpu_bo_create_kernel(adev, adev->gds.mem.gfx_partition_size,
-				    PAGE_SIZE, AMDGPU_GEM_DOMAIN_GDS,
-				    &adev->gds.gds_gfx_bo, NULL, NULL);
-	if (r)
-		return r;
-
-	r = amdgpu_bo_create_kernel(adev, adev->gds.gws.gfx_partition_size,
-				    PAGE_SIZE, AMDGPU_GEM_DOMAIN_GWS,
-				    &adev->gds.gws_gfx_bo, NULL, NULL);
-	if (r)
-		return r;
-
-	r = amdgpu_bo_create_kernel(adev, adev->gds.oa.gfx_partition_size,
-				    PAGE_SIZE, AMDGPU_GEM_DOMAIN_OA,
-				    &adev->gds.oa_gfx_bo, NULL, NULL);
-	if (r)
-		return r;
-
 	adev->gfx.ce_ram_size = 0x8000;
 
 	r = gfx_v8_0_gpu_early_init(adev);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -19
index d31a2bc00d61..c075c0b6bb2b 100644
@@ -1700,25 +1700,6 @@ static int gfx_v9_0_sw_init(void *handle)
 	if (r)
 		return r;
 
-	/* reserve GDS, GWS and OA resource for gfx */
-	r = amdgpu_bo_create_kernel(adev, adev->gds.mem.gfx_partition_size,
-				    PAGE_SIZE, AMDGPU_GEM_DOMAIN_GDS,
-				    &adev->gds.gds_gfx_bo, NULL, NULL);
-	if (r)
-		return r;
-
-	r = amdgpu_bo_create_kernel(adev, adev->gds.gws.gfx_partition_size,
-				    PAGE_SIZE, AMDGPU_GEM_DOMAIN_GWS,
-				    &adev->gds.gws_gfx_bo, NULL, NULL);
-	if (r)
-		return r;
-
-	r = amdgpu_bo_create_kernel(adev, adev->gds.oa.gfx_partition_size,
-				    PAGE_SIZE, AMDGPU_GEM_DOMAIN_OA,
-				    &adev->gds.oa_gfx_bo, NULL, NULL);
-	if (r)
-		return r;
-
 	adev->gfx.ce_ram_size = 0x8000;
 
 	r = gfx_v9_0_gpu_early_init(adev);
Signature · 6 lines
2.14.1

_______________________________________________
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): 20180914191246.1609-7-christian.koenig-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#26 lore raw

Re: [PATCH 7/7] drm/amdgpu: move reserving GDS/GWS/OA into common code

Quoted 4 lines · Christian König

We don't need that in the per ASIC code.

Quoted 143 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 18 ++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c   | 19 -------------------
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c   | 19 -------------------
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c   | 19 -------------------
 4 files changed, 18 insertions(+), 57 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +18 -0
index 438390fce714..cf93a9831318 100644
@@ -1848,6 +1848,12 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
                return r;
        }
 
+       r = amdgpu_bo_create_kernel(adev, adev->gds.mem.gfx_partition_size,
+                                   PAGE_SIZE, AMDGPU_GEM_DOMAIN_GDS,
+                                   &adev->gds.gds_gfx_bo, NULL, NULL);
+       if (r)
+               return r;
+
        r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GWS,
                           adev->gds.gws.total_size);
        if (r) {
@@ -1855,6 +1861,12 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
                return r;
        }
 
+       r = amdgpu_bo_create_kernel(adev, adev->gds.gws.gfx_partition_size,
+                                   PAGE_SIZE, AMDGPU_GEM_DOMAIN_GWS,
+                                   &adev->gds.gws_gfx_bo, NULL, NULL);
+       if (r)
+               return r;
+
        r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_OA,
                           adev->gds.oa.total_size);
        if (r) {
@@ -1862,6 +1874,12 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
                return r;
        }
 
+       r = amdgpu_bo_create_kernel(adev, adev->gds.oa.gfx_partition_size,
+                                   PAGE_SIZE, AMDGPU_GEM_DOMAIN_OA,
+                                   &adev->gds.oa_gfx_bo, NULL, NULL);
+       if (r)
+               return r;
+
        /* Register debugfs entries for amdgpu_ttm */
        r = amdgpu_ttm_debugfs_init(adev);
        if (r) {
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0 -19
index c0f9732cbaf7..fc39ebbc9d9f 100644
@@ -4582,25 +4582,6 @@ static int gfx_v7_0_sw_init(void *handle)
                }
        }
 
-       /* reserve GDS, GWS and OA resource for gfx */
-       r = amdgpu_bo_create_kernel(adev, adev->gds.mem.gfx_partition_size,
-                                   PAGE_SIZE, AMDGPU_GEM_DOMAIN_GDS,
-                                   &adev->gds.gds_gfx_bo, NULL, NULL);
-       if (r)
-               return r;
-
-       r = amdgpu_bo_create_kernel(adev, adev->gds.gws.gfx_partition_size,
-                                   PAGE_SIZE, AMDGPU_GEM_DOMAIN_GWS,
-                                   &adev->gds.gws_gfx_bo, NULL, NULL);
-       if (r)
-               return r;
-
-       r = amdgpu_bo_create_kernel(adev, adev->gds.oa.gfx_partition_size,
-                                   PAGE_SIZE, AMDGPU_GEM_DOMAIN_OA,
-                                   &adev->gds.oa_gfx_bo, NULL, NULL);
-       if (r)
-               return r;
-
        adev->gfx.ce_ram_size = 0x8000;
 
        gfx_v7_0_gpu_early_init(adev);
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -19
index 57e4b14e3bd1..5d9fd2c2c244 100644
@@ -2161,25 +2161,6 @@ static int gfx_v8_0_sw_init(void *handle)
        if (r)
                return r;
 
-       /* reserve GDS, GWS and OA resource for gfx */
-       r = amdgpu_bo_create_kernel(adev, adev->gds.mem.gfx_partition_size,
-                                   PAGE_SIZE, AMDGPU_GEM_DOMAIN_GDS,
-                                   &adev->gds.gds_gfx_bo, NULL, NULL);
-       if (r)
-               return r;
-
-       r = amdgpu_bo_create_kernel(adev, adev->gds.gws.gfx_partition_size,
-                                   PAGE_SIZE, AMDGPU_GEM_DOMAIN_GWS,
-                                   &adev->gds.gws_gfx_bo, NULL, NULL);
-       if (r)
-               return r;
-
-       r = amdgpu_bo_create_kernel(adev, adev->gds.oa.gfx_partition_size,
-                                   PAGE_SIZE, AMDGPU_GEM_DOMAIN_OA,
-                                   &adev->gds.oa_gfx_bo, NULL, NULL);
-       if (r)
-               return r;
-
        adev->gfx.ce_ram_size = 0x8000;
 
        r = gfx_v8_0_gpu_early_init(adev);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -20
index d31a2bc00d61..c075c0b6bb2b 100644
@@ -1700,25 +1700,6 @@ static int gfx_v9_0_sw_init(void *handle)
        if (r)
                return r;
 
-       /* reserve GDS, GWS and OA resource for gfx */
-       r = amdgpu_bo_create_kernel(adev, adev->gds.mem.gfx_partition_size,
-                                   PAGE_SIZE, AMDGPU_GEM_DOMAIN_GDS,
-                                   &adev->gds.gds_gfx_bo, NULL, NULL);
-       if (r)
-               return r;
-
-       r = amdgpu_bo_create_kernel(adev, adev->gds.gws.gfx_partition_size,
-                                   PAGE_SIZE, AMDGPU_GEM_DOMAIN_GWS,
-                                   &adev->gds.gws_gfx_bo, NULL, NULL);
-       if (r)
-               return r;
-
-       r = amdgpu_bo_create_kernel(adev, adev->gds.oa.gfx_partition_size,
-                                   PAGE_SIZE, AMDGPU_GEM_DOMAIN_OA,
-                                   &adev->gds.oa_gfx_bo, NULL, NULL);
-       if (r)
-               return r;
-
        adev->gfx.ce_ram_size = 0x8000;
 
        r = gfx_v9_0_gpu_early_init(adev);
--

2.14.1

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

Reviewed-by
#27 lore raw
In reply to a message not in the archive
Quoted 4 lines · Christian König

Additional to the existing files for VRAM and GTT.

Quoted 38 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +6 -7
index f12ae6b525b9..1565344cc139 100644
@@ -2208,7 +2208,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
 static int amdgpu_mm_dump_table(struct seq_file *m, void *data)
 {
        struct drm_info_node *node = (struct drm_info_node *)m->private;
-       unsigned ttm_pl = *(int *)node->info_ent->data;
+       unsigned ttm_pl = (uintptr_t)node->info_ent->data;
        struct drm_device *dev = node->minor->dev;
        struct amdgpu_device *adev = dev->dev_private;
        struct ttm_mem_type_manager *man = &adev->mman.bdev.man[ttm_pl];
@@ -2218,12 +2218,12 @@ static int amdgpu_mm_dump_table(struct seq_file *m, void *data)
        return 0;
 }
 
-static int ttm_pl_vram = TTM_PL_VRAM;
-static int ttm_pl_tt = TTM_PL_TT;
-
 static const struct drm_info_list amdgpu_ttm_debugfs_list[] = {
-       {"amdgpu_vram_mm", amdgpu_mm_dump_table, 0, &ttm_pl_vram},
-       {"amdgpu_gtt_mm", amdgpu_mm_dump_table, 0, &ttm_pl_tt},
+       {"amdgpu_vram_mm", amdgpu_mm_dump_table, 0, (void *)TTM_PL_VRAM},
+       {"amdgpu_gtt_mm", amdgpu_mm_dump_table, 0, (void *)TTM_PL_TT},
+       {"amdgpu_gds_mm", amdgpu_mm_dump_table, 0, (void *)AMDGPU_PL_GDS},
+       {"amdgpu_gws_mm", amdgpu_mm_dump_table, 0, (void *)AMDGPU_PL_GWS},
+       {"amdgpu_oa_mm", amdgpu_mm_dump_table, 0, (void *)AMDGPU_PL_OA},
        {"ttm_page_pool", ttm_page_alloc_debugfs, 0, NULL},
 #ifdef CONFIG_SWIOTLB
        {"ttm_dma_page_pool", ttm_dma_page_alloc_debugfs, 0, NULL}
--

2.14.1

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