Skip to contentSkip to conversation

drm/ttm: also export ttm_bo_vm_fault

PATCH In review Christian König 3 participants 5 messages Sep 27, 2019 – Oct 2, 2019 2 messages not in the archive

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

PATCH 1/2 drm/ttm: also export ttm_bo_vm_fault

That is needed by at least a cleanup in radeon.

---
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 3 ++-
 include/drm/ttm/ttm_bo_api.h    | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo_vm.c +2 -1
index cb3120cd5aa1..525046bbcb6b 100644
@@ -316,7 +316,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
 }
 EXPORT_SYMBOL(ttm_bo_vm_fault_reserved);
 
-static vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
+vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
 {
 	struct vm_area_struct *vma = vmf->vma;
 	pgprot_t prot;
@@ -336,6 +336,7 @@ static vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
 
 	return ret;
 }
+EXPORT_SYMBOL(ttm_bo_vm_fault);
 
 void ttm_bo_vm_open(struct vm_area_struct *vma)
 {
include/drm/ttm/ttm_bo_api.h +2 -0
index 851260cbbb2f..dad41cf5cd64 100644
@@ -796,6 +796,8 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
 				    pgprot_t prot,
 				    pgoff_t num_prefault);
 
+vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf);
+
 void ttm_bo_vm_open(struct vm_area_struct *vma);
 
 void ttm_bo_vm_close(struct vm_area_struct *vma);
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): 20190927123425.17513-1-christian.koenig-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 2/2 drm/radeon: finally fix the racy VMA setup

Finally clean up the VMA setup for radeon now that TTM exports the necessary functions.

Not functional change, but only compile tested.

---
 drivers/gpu/drm/radeon/radeon_ttm.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +14 -15
index a05e10724d46..f3ef304a67ee 100644
@@ -880,9 +880,6 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
 	man->size = size >> PAGE_SHIFT;
 }
 
-static struct vm_operations_struct radeon_ttm_vm_ops;
-static const struct vm_operations_struct *ttm_vm_ops = NULL;
-
 static vm_fault_t radeon_ttm_fault(struct vm_fault *vmf)
 {
 	struct ttm_buffer_object *bo;
@@ -890,34 +887,36 @@ static vm_fault_t radeon_ttm_fault(struct vm_fault *vmf)
 	vm_fault_t ret;
 
 	bo = (struct ttm_buffer_object *)vmf->vma->vm_private_data;
-	if (bo == NULL) {
+	if (bo == NULL)
 		return VM_FAULT_NOPAGE;
-	}
+
 	rdev = radeon_get_rdev(bo->bdev);
 	down_read(&rdev->pm.mclk_lock);
-	ret = ttm_vm_ops->fault(vmf);
+	ret = ttm_bo_vm_fault(vmf);
 	up_read(&rdev->pm.mclk_lock);
 	return ret;
 }
 
+static struct vm_operations_struct radeon_ttm_vm_ops = {
+	.fault = radeon_ttm_fault,
+	.open = ttm_bo_vm_open,
+	.close = ttm_bo_vm_close,
+	.access = ttm_bo_vm_access
+};
+
 int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
 {
 	int r;
 	struct drm_file *file_priv = filp->private_data;
 	struct radeon_device *rdev = file_priv->minor->dev->dev_private;
 
-	if (rdev == NULL) {
+	if (rdev == NULL)
 		return -EINVAL;
-	}
+
 	r = ttm_bo_mmap(filp, vma, &rdev->mman.bdev);
-	if (unlikely(r != 0)) {
+	if (unlikely(r != 0))
 		return r;
-	}
-	if (unlikely(ttm_vm_ops == NULL)) {
-		ttm_vm_ops = vma->vm_ops;
-		radeon_ttm_vm_ops = *ttm_vm_ops;
-		radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
-	}
+
 	vma->vm_ops = &radeon_ttm_vm_ops;
 	return 0;
 }
Signature · 6 lines
2.14.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by on v1 2/2
#3 lore raw

RE: [PATCH 2/2] drm/radeon: finally fix the racy VMA setup

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Christian König
Sent: Friday, September 27, 2019 8:34 AM
To: [email protected]; [email protected]
Subject: [PATCH 2/2] drm/radeon: finally fix the racy VMA setup

Finally clean up the VMA setup for radeon now that TTM exports the necessary functions.

Not functional change, but only compile tested.

---
 drivers/gpu/drm/radeon/radeon_ttm.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +14 -15
index a05e10724d46..f3ef304a67ee 100644
@@ -880,9 +880,6 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
 	man->size = size >> PAGE_SHIFT;
 }
 
-static struct vm_operations_struct radeon_ttm_vm_ops; -static const struct vm_operations_struct *ttm_vm_ops = NULL;
-
 static vm_fault_t radeon_ttm_fault(struct vm_fault *vmf)  {
 	struct ttm_buffer_object *bo;
@@ -890,34 +887,36 @@ static vm_fault_t radeon_ttm_fault(struct vm_fault *vmf)
 	vm_fault_t ret;
 
 	bo = (struct ttm_buffer_object *)vmf->vma->vm_private_data;
-	if (bo == NULL) {
+	if (bo == NULL)
 		return VM_FAULT_NOPAGE;
-	}
+
 	rdev = radeon_get_rdev(bo->bdev);
 	down_read(&rdev->pm.mclk_lock);
-	ret = ttm_vm_ops->fault(vmf);
+	ret = ttm_bo_vm_fault(vmf);
 	up_read(&rdev->pm.mclk_lock);
 	return ret;
 }
 
+static struct vm_operations_struct radeon_ttm_vm_ops = {
+	.fault = radeon_ttm_fault,
+	.open = ttm_bo_vm_open,
+	.close = ttm_bo_vm_close,
+	.access = ttm_bo_vm_access
+};
+
 int radeon_mmap(struct file *filp, struct vm_area_struct *vma)  {
 	int r;
 	struct drm_file *file_priv = filp->private_data;
 	struct radeon_device *rdev = file_priv->minor->dev->dev_private;
 
-	if (rdev == NULL) {
+	if (rdev == NULL)
 		return -EINVAL;
-	}
+
 	r = ttm_bo_mmap(filp, vma, &rdev->mman.bdev);
-	if (unlikely(r != 0)) {
+	if (unlikely(r != 0))
 		return r;
-	}
-	if (unlikely(ttm_vm_ops == NULL)) {
-		ttm_vm_ops = vma->vm_ops;
-		radeon_ttm_vm_ops = *ttm_vm_ops;
-		radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
-	}
+
 	vma->vm_ops = &radeon_ttm_vm_ops;
 	return 0;
 }
--

2.14.1

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

#4 lore raw
In reply to a message not in the archive

Just a gentle ping on this. Everybody on XDC, or can we get this comitted?

Am 27.09.19 um 14:34 schrieb Christian König:

Quoted 34 lines

That is needed by at least a cleanup in radeon.

---
  drivers/gpu/drm/ttm/ttm_bo_vm.c | 3 ++-
  include/drm/ttm/ttm_bo_api.h    | 2 ++
  2 files changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo_vm.c +2 -1
index cb3120cd5aa1..525046bbcb6b 100644
@@ -316,7 +316,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
  }
  EXPORT_SYMBOL(ttm_bo_vm_fault_reserved);
 
-static vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
+vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
  {
  	struct vm_area_struct *vma = vmf->vma;
  	pgprot_t prot;
@@ -336,6 +336,7 @@ static vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
 
  	return ret;
  }
+EXPORT_SYMBOL(ttm_bo_vm_fault);
 
  void ttm_bo_vm_open(struct vm_area_struct *vma)
  {
include/drm/ttm/ttm_bo_api.h +0 -0
index 851260cbbb2f..dad41cf5cd64 100644

include/drm/ttm/ttm_bo_api.h vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf, · line 803

Quoted 8 lines
include/drm/ttm/ttm_bo_api.h +2 -0
@@ -796,6 +796,8 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
  				    pgprot_t prot,
  				    pgoff_t num_prefault);
 
+vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf);
+
  void ttm_bo_vm_open(struct vm_area_struct *vma);
 
  void ttm_bo_vm_close(struct vm_area_struct *vma);

_______________________________________________
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): 8758219e-884d-1205-f2e0-7e304049707a-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

Reviewed-by Huang Rui
#6 lore raw

Ahh. 😊

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Christian König
Sent: Wednesday, October 2, 2019 4:38 AM
To: [email protected]; [email protected]
Subject: Re: [PATCH 1/2] drm/ttm: also export ttm_bo_vm_fault

Just a gentle ping on this. Everybody on XDC, or can we get this comitted?

Am 27.09.19 um 14:34 schrieb Christian König:

Quoted 36 lines

That is needed by at least a cleanup in radeon.

---
  drivers/gpu/drm/ttm/ttm_bo_vm.c | 3 ++-
  include/drm/ttm/ttm_bo_api.h    | 2 ++
  2 files changed, 4 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/ttm/ttm_bo_vm.c index cb3120cd5aa1..525046bbcb6b 100644

drivers/gpu/drm/ttm/ttm_bo_vm.c +2 -1
@@ -316,7 +316,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
  }
  EXPORT_SYMBOL(ttm_bo_vm_fault_reserved);
 
-static vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
+vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
  {
  	struct vm_area_struct *vma = vmf->vma;
  	pgprot_t prot;
@@ -336,6 +336,7 @@ static vm_fault_t ttm_bo_vm_fault(struct vm_fault 
 *vmf)
 
  	return ret;
  }
+EXPORT_SYMBOL(ttm_bo_vm_fault);
 
  void ttm_bo_vm_open(struct vm_area_struct *vma)

{

(quoted diff) +0 -0

b/include/drm/ttm/ttm_bo_api.h index 851260cbbb2f..dad41cf5cd64 100644

include/drm/ttm/ttm_bo_api.h vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf, · line 803

Quoted 8 lines
include/drm/ttm/ttm_bo_api.h +2 -0
@@ -796,6 +796,8 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
  				    pgprot_t prot,
  				    pgoff_t num_prefault);
 
+vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf);
+
  void ttm_bo_vm_open(struct vm_area_struct *vma);
 
  void ttm_bo_vm_close(struct vm_area_struct *vma);

_______________________________________________
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