Skip to contentSkip to conversation

drm/amdgpu: fix mask in GART location calculation

PATCH In review Christian König 3 participants 5 messages Sep 14, 2018 2 messages not in the archive

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

PATCH 1/2 drm/amdgpu: fix mask in GART location calculation

We need to mask the lower bits not the upper one.

Fixes ec210e3226dc0 drm/amdgpu: put GART away from VRAM v2
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +1 -1
index ae4467113240..9a5b252784a1 100644
@@ -166,7 +166,7 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc)
 	else
 		mc->gart_start = mc->mc_mask - mc->gart_size + 1;
 
-	mc->gart_start &= four_gb - 1;
+	mc->gart_start &= ~(four_gb - 1);
 	mc->gart_end = mc->gart_start + mc->gart_size - 1;
 	dev_info(adev->dev, "GART: %lluM 0x%016llX - 0x%016llX\n",
 			mc->gart_size >> 20, mc->gart_start, mc->gart_end);
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): 20180914105728.1641-1-christian.koenig-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 2/2 drm/amdgpu: revert "stop using gart_start as offset for the GTT domain"

Turned out the commit is incomplete and since we remove using the AGP mapping from the GTT manager it is also not necessary any more.

This reverts commit 22d8bfafcc12dfa17b91d2e8ae4e1898e782003a.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 3 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 7 +++----
 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -2
index c2539f6821c0..da7b1b92d9cf 100644
@@ -143,8 +143,7 @@ static int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man,
 	spin_unlock(&mgr->lock);
 
 	if (!r)
-		mem->start = node->node.start +
-			(adev->gmc.gart_start >> PAGE_SHIFT);
+		mem->start = node->node.start;
 
 	return r;
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -4
index 8a158ee922f7..f12ae6b525b9 100644
@@ -188,7 +188,7 @@ static int amdgpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
 	case TTM_PL_TT:
 		/* GTT memory  */
 		man->func = &amdgpu_gtt_mgr_func;
-		man->gpu_offset = 0;
+		man->gpu_offset = adev->gmc.gart_start;
 		man->available_caching = TTM_PL_MASK_CACHING;
 		man->default_caching = TTM_PL_FLAG_CACHED;
 		man->flags = TTM_MEMTYPE_FLAG_MAPPABLE | TTM_MEMTYPE_FLAG_CMA;
@@ -1060,7 +1060,7 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm,
 	flags = amdgpu_ttm_tt_pte_flags(adev, ttm, bo_mem);
 
 	/* bind pages into GART page tables */
-	gtt->offset = ((u64)bo_mem->start << PAGE_SHIFT) - adev->gmc.gart_start;
+	gtt->offset = (u64)bo_mem->start << PAGE_SHIFT;
 	r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
 		ttm->pages, gtt->ttm.dma_address, flags);
 
@@ -1112,8 +1112,7 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
 		flags = amdgpu_ttm_tt_pte_flags(adev, bo->ttm, &tmp);
 
 		/* Bind pages */
-		gtt->offset = ((u64)tmp.start << PAGE_SHIFT) -
-			adev->gmc.gart_start;
+		gtt->offset = (u64)tmp.start << PAGE_SHIFT;
 		r = amdgpu_ttm_gart_bind(adev, bo, flags);
 		if (unlikely(r)) {
 			ttm_bo_mem_put(bo, &tmp);
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): 20180914105728.1641-2-christian.koenig-5C7GfCeVMHo@public.gmane.org

#4 lore raw

Re: [PATCH 2/2] drm/amdgpu: revert "stop using gart_start as offset for the GTT domain"

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Christian König <[email protected]>
Sent: Friday, September 14, 2018 6:57:28 AM
To: [email protected]
Subject: [PATCH 2/2] drm/amdgpu: revert "stop using gart_start as offset for the GTT domain"

Turned out the commit is incomplete and since we remove using the AGP mapping from the GTT manager it is also not necessary any more.

This reverts commit 22d8bfafcc12dfa17b91d2e8ae4e1898e782003a.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 3 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 7 +++----
 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -2
index c2539f6821c0..da7b1b92d9cf 100644
@@ -143,8 +143,7 @@ static int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man,
         spin_unlock(&mgr->lock);
 
         if (!r)
-               mem->start = node->node.start +
-                       (adev->gmc.gart_start >> PAGE_SHIFT);
+               mem->start = node->node.start;
 
         return r;
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -4
index 8a158ee922f7..f12ae6b525b9 100644
@@ -188,7 +188,7 @@ static int amdgpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
         case TTM_PL_TT:
                 /* GTT memory  */
                 man->func = &amdgpu_gtt_mgr_func;
-               man->gpu_offset = 0;
+               man->gpu_offset = adev->gmc.gart_start;
                 man->available_caching = TTM_PL_MASK_CACHING;
                 man->default_caching = TTM_PL_FLAG_CACHED;
                 man->flags = TTM_MEMTYPE_FLAG_MAPPABLE | TTM_MEMTYPE_FLAG_CMA;
@@ -1060,7 +1060,7 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm,
         flags = amdgpu_ttm_tt_pte_flags(adev, ttm, bo_mem);
 
         /* bind pages into GART page tables */
-       gtt->offset = ((u64)bo_mem->start << PAGE_SHIFT) - adev->gmc.gart_start;
+       gtt->offset = (u64)bo_mem->start << PAGE_SHIFT;
         r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
                 ttm->pages, gtt->ttm.dma_address, flags);
 
@@ -1112,8 +1112,7 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
                 flags = amdgpu_ttm_tt_pte_flags(adev, bo->ttm, &tmp);
 
                 /* Bind pages */
-               gtt->offset = ((u64)tmp.start << PAGE_SHIFT) -
-                       adev->gmc.gart_start;
+               gtt->offset = (u64)tmp.start << PAGE_SHIFT;
                 r = amdgpu_ttm_gart_bind(adev, bo, flags);
                 if (unlikely(r)) {
                         ttm_bo_mem_put(bo, &tmp);

--
2.14.1

_______________________________________________
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
#5 lore raw
In reply to a message not in the archive

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Christian König <[email protected]>
Sent: Friday, September 14, 2018 6:57 AM
To: [email protected]
Subject: [PATCH 1/2] drm/amdgpu: fix mask in GART location calculation

We need to mask the lower bits not the upper one.

Fixes ec210e3226dc0 drm/amdgpu: put GART away from VRAM v2
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +1 -1
index ae4467113240..9a5b252784a1 100644
@@ -166,7 +166,7 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc)
         else
                 mc->gart_start = mc->mc_mask - mc->gart_size + 1;
 
-       mc->gart_start &= four_gb - 1;
+       mc->gart_start &= ~(four_gb - 1);
         mc->gart_end = mc->gart_start + mc->gart_size - 1;
         dev_info(adev->dev, "GART: %lluM 0x%016llX - 0x%016llX\n",
                         mc->gart_size >> 20, mc->gart_start, mc->gart_end);

--
2.14.1

_______________________________________________
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 Tested-by
#6 lore raw
In reply to a message not in the archive

This series are

Quoted 14 lines · Christian König

We need to mask the lower bits not the upper one.

Fixes ec210e3226dc0 drm/amdgpu: put GART away from VRAM v2
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0 -0
index ae4467113240..9a5b252784a1 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc) · line 172

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +1 -1
@@ -166,7 +166,7 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc)
  	else
  		mc->gart_start = mc->mc_mask - mc->gart_size + 1;
 
-	mc->gart_start &= four_gb - 1;
+	mc->gart_start &= ~(four_gb - 1);
  	mc->gart_end = mc->gart_start + mc->gart_size - 1;
  	dev_info(adev->dev, "GART: %lluM 0x%016llX - 0x%016llX\n",
  			mc->gart_size >> 20, mc->gart_start, mc->gart_end);

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