Skip to contentSkip to conversation

drm/amdgpu: simplify pinning into visible VRAM

PATCH In review Christian König 3 participants 3 messages Sep 13, 2017 – Sep 21, 2017 2 messages not in the archive

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

PATCH 1/1 drm/amdgpu: simplify pinning into visible VRAM

From: Christian König <[email protected]>

Just set the CPU access required flag when we pin it.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +8 -15
index 726a662..6982bae 100644
@@ -635,7 +635,6 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
 {
 	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
 	int r, i;
-	unsigned fpfn, lpfn;
 
 	if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm))
 		return -EPERM;
@@ -667,22 +666,16 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
 	}
 
 	bo->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
+	/* force to pin into visible video ram */
+	if (!(bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS))
+		bo->flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
 	amdgpu_ttm_placement_from_domain(bo, domain);
 	for (i = 0; i < bo->placement.num_placement; i++) {
-		/* force to pin into visible video ram */
-		if ((bo->placements[i].flags & TTM_PL_FLAG_VRAM) &&
-		    !(bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) &&
-		    (!max_offset || max_offset >
-		     adev->mc.visible_vram_size)) {
-			if (WARN_ON_ONCE(min_offset >
-					 adev->mc.visible_vram_size))
-				return -EINVAL;
-			fpfn = min_offset >> PAGE_SHIFT;
-			lpfn = adev->mc.visible_vram_size >> PAGE_SHIFT;
-		} else {
-			fpfn = min_offset >> PAGE_SHIFT;
-			lpfn = max_offset >> PAGE_SHIFT;
-		}
+		unsigned fpfn, lpfn;
+
+		fpfn = min_offset >> PAGE_SHIFT;
+		lpfn = max_offset >> PAGE_SHIFT;
+
 		if (fpfn > bo->placements[i].fpfn)
 			bo->placements[i].fpfn = fpfn;
 		if (!bo->placements[i].lpfn ||
Signature · 6 lines
2.7.4

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

A message that is not in the archive (sent off-list or not yet received): 1505291545-8682-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#2 lore raw

Ping?

Am 13.09.2017 um 10:32 schrieb Christian König:

Quoted 42 lines

From: Christian König <[email protected]>

Just set the CPU access required flag when we pin it.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 23 ++++++++---------------
  1 file changed, 8 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3 -13
index 726a662..6982bae 100644
@@ -635,7 +635,6 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
  {
  	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
  	int r, i;
-	unsigned fpfn, lpfn;
 
  	if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm))
  		return -EPERM;
@@ -667,22 +666,16 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
  	}
 
  	bo->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
+	/* force to pin into visible video ram */
+	if (!(bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS))
+		bo->flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
  	amdgpu_ttm_placement_from_domain(bo, domain);
  	for (i = 0; i < bo->placement.num_placement; i++) {
-		/* force to pin into visible video ram */
-		if ((bo->placements[i].flags & TTM_PL_FLAG_VRAM) &&
-		    !(bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) &&
-		    (!max_offset || max_offset >
-		     adev->mc.visible_vram_size)) {
-			if (WARN_ON_ONCE(min_offset >
-					 adev->mc.visible_vram_size))
-				return -EINVAL;
-			fpfn = min_offset >> PAGE_SHIFT;
-			lpfn = adev->mc.visible_vram_size >> PAGE_SHIFT;
-		} else {
-			fpfn = min_offset >> PAGE_SHIFT;

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, · line 681

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +5 -2
-			lpfn = max_offset >> PAGE_SHIFT;
-		}
+		unsigned fpfn, lpfn;
+
+		fpfn = min_offset >> PAGE_SHIFT;
+		lpfn = max_offset >> PAGE_SHIFT;
+
  		if (fpfn > bo->placements[i].fpfn)
  			bo->placements[i].fpfn = fpfn;
  		if (!bo->placements[i].lpfn ||

_______________________________________________
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): 1dfb0b17-8654-f468-e557-a3373c646f98-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

Reviewed-by Alex Deucher
#4 lore raw
Quoted 8 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
Sent: Thursday, September 21, 2017 4:32 AM
To: Christian König; [email protected]
Subject: Re: [PATCH] drm/amdgpu: simplify pinning into visible VRAM

Ping?

Quoted 58 lines

Am 13.09.2017 um 10:32 schrieb Christian König:

Quoted 7 lines

From: Christian König <[email protected]>

Just set the CPU access required flag when we pin it.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 23 ++++++++-----------

----

Review

Quoted 3 lines
  1 file changed, 8 insertions(+), 15 deletions(-)
(quoted diff) +0 -0

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

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_pin_restricted(struct amdgpu_bo

Quoted 4 lines

index 726a662..6982bae 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
@@ -635,7 +635,6 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo

*bo, u32 domain,

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_pin_restricted(struct amdgpu_bo

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -1
  {
  	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
  	int r, i;
-	unsigned fpfn, lpfn;
 
  	if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm))
  		return -EPERM;
@@ -667,22 +666,16 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo

*bo, u32 domain,

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3 -0
  	}
 
  	bo->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
+	/* force to pin into visible video ram */
+	if (!(bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS))
+		bo->flags |=

AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -3
  	amdgpu_ttm_placement_from_domain(bo, domain);
  	for (i = 0; i < bo->placement.num_placement; i++) {
-		/* force to pin into visible video ram */
-		if ((bo->placements[i].flags & TTM_PL_FLAG_VRAM) &&
-		    !(bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)

&&

Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +5 -11
-		    (!max_offset || max_offset >
-		     adev->mc.visible_vram_size)) {
-			if (WARN_ON_ONCE(min_offset >
-					 adev->mc.visible_vram_size))
-				return -EINVAL;
-			fpfn = min_offset >> PAGE_SHIFT;
-			lpfn = adev->mc.visible_vram_size >> PAGE_SHIFT;
-		} else {
-			fpfn = min_offset >> PAGE_SHIFT;
-			lpfn = max_offset >> PAGE_SHIFT;
-		}
+		unsigned fpfn, lpfn;
+
+		fpfn = min_offset >> PAGE_SHIFT;
+		lpfn = max_offset >> PAGE_SHIFT;
+
  		if (fpfn > bo->placements[i].fpfn)
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, · line 681

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
  			bo->placements[i].fpfn = fpfn;
  		if (!bo->placements[i].lpfn ||

_______________________________________________
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