drm/ttm: also export ttm_bo_vm_fault v2
Subsystems (4)
PATCH 1/2 drm/ttm: also export ttm_bo_vm_fault v2
From: Christian König <[email protected]>
That is needed by at least a cleanup in radeon.
v2: also export ttm_bo_vm_access
--- drivers/gpu/drm/ttm/ttm_bo_vm.c | 8 +++++--- include/drm/ttm/ttm_bo_api.h | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_vm.c +5 -3
@@ -308,7 +308,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;
@@ -328,6 +328,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) {
@@ -387,8 +388,8 @@ static int ttm_bo_vm_access_kmap(struct ttm_buffer_object *bo,return len; } -static int ttm_bo_vm_access (struct vm_area_struct *vma,unsigned long addr, -void *buf,int len,int write) +int ttm_bo_vm_access (struct vm_area_struct *vma,unsigned long addr, +void *buf,int len,int write) {unsigned long offset = (addr) - vma->vm_start;struct ttm_buffer_object *bo = vma->vm_private_data;
@@ -424,6 +425,7 @@ static int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,return ret; } +EXPORT_SYMBOL (ttm_bo_vm_access);static const struct vm_operations_struct ttm_bo_vm_ops = { .fault = ttm_bo_vm_fault,
include/drm/ttm/ttm_bo_api.h +6 -0
@@ -734,7 +734,13 @@ 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); + +int ttm_bo_vm_access (struct vm_area_struct *vma,unsigned long addr, +void *buf,int len,int write); +#endif
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/2 drm/radeon: finally fix the racy VMA setup
From: Christian König <[email protected]>
Finally clean up the VMA setup for radeon now that TTM exports the necessary functions.
No 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
@@ -881,9 +881,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;
@@ -891,34 +888,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.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): 20191107120118.2825-2-christian.koenig-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 2/2] drm/radeon: finally fix the racy VMA setup
Hey Alex,
any objections that I merge those two patches through drm-misc-next?
It's a cleanup I wanted to do for years and Thomas finally fixed up TTM for this.
Cheers,
Christian.
Am 07.11.19 um 13:01 schrieb Christian König:
Quoted 66 lines
From: Christian König <[email protected]>
Finally clean up the VMA setup for radeon now that TTM exports the necessary functions.
No functional change, but only compile tested.
Signed-off-by Christian König <[email protected]>Reviewed-by Huang Rui <[email protected]>--- drivers/gpu/drm/radeon/radeon_ttm.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)drivers/gpu/drm/radeon/radeon_ttm.c +13
-9@@ -881,9 +881,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;@@ -891,34 +888,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;
drivers/gpu/drm/radeon/radeon_ttm.c static vm_fault_t radeon_ttm_fault(struct vm_fault *vmf) · line 923
Quoted 10 lines
drivers/gpu/drm/radeon/radeon_ttm.c +1
-6- } -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 ; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Alex Deucher
Acked-byRe: [PATCH 2/2] drm/radeon: finally fix the racy VMA setup
Quoted 7 lines · Christian König
Hey Alex,
any objections that I merge those two patches through drm-misc-next?
It's a cleanup I wanted to do for years and Thomas finally fixed up TTM for this.
Fine with me. Series is:
Quoted 78 lines
Cheers,
Christian.Am 07.11.19 um 13:01 schrieb Christian König:
Quoted 73 lines
From: Christian König <[email protected]>
Finally clean up the VMA setup for radeon now that TTM exports the necessary functions.
No functional change, but only compile tested.
Signed-off-by Christian König <[email protected]>Reviewed-by Huang Rui <[email protected]>--- drivers/gpu/drm/radeon/radeon_ttm.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)drivers/gpu/drm/radeon/radeon_ttm.c +14
-15@@ -881,9 +881,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;@@ -891,34 +888,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; - } +
Quoted 8 lines
drivers/gpu/drm/radeon/radeon_ttm.c static vm_fault_t radeon_ttm_fault(struct vm_fault *vmf) · line 923
Quoted 3 lines
drivers/gpu/drm/radeon/radeon_ttm.c +0
-0vma->vm_ops = &radeon_ttm_vm_ops;return 0 ; }_______________________________________________
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