drm/lima: simplify driver by using more drm helpers
Subsystems (5)
Qiang Yu
maintainerv2 cover drm/lima: simplify driver by using more drm helpers
By using shared drm helpers:
1. drm_gem_objects_lookup
2. drm_gem_(un)lock_reservations
3. drm_gem_shmem_helpers
we can simplify lima driver a lot and benifit from updates to these functions.
drm_gem_objects_lookup need a refine in order to be used by lima.
Note:
1. changes to panfrost and v3d are just compile tested.
2. patch series is based on drm-misc-next branch
v2:
Add drm_gem_objects_lookup_user and use it for driver which pass user GEM handles in contious array.
Qiang Yu (6):
drm/gem: refine drm_gem_objects_lookup drm/v3d: use drm_gem_objects_lookup_user drm/lima: use drm_gem_objects_lookup drm/lima: use drm_gem_shmem_helpers drm/lima: use drm_gem_(un)lock_reservations drm/lima: add __GFP_NOWARN flag to all dma_alloc_wc
drivers/gpu/drm/drm_gem.c | 57 ++++-- drivers/gpu/drm/lima/Kconfig | 1 + drivers/gpu/drm/lima/Makefile | 4 +- drivers/gpu/drm/lima/lima_device.c | 2 +- drivers/gpu/drm/lima/lima_drv.c | 27 +-- drivers/gpu/drm/lima/lima_gem.c | 254 ++++++++++-------------- drivers/gpu/drm/lima/lima_gem.h | 32 ++- drivers/gpu/drm/lima/lima_gem_prime.c | 46 ----- drivers/gpu/drm/lima/lima_gem_prime.h | 13 -- drivers/gpu/drm/lima/lima_mmu.c | 1 - drivers/gpu/drm/lima/lima_object.c | 119 ----------- drivers/gpu/drm/lima/lima_object.h | 35 ---- drivers/gpu/drm/lima/lima_sched.c | 6 +- drivers/gpu/drm/lima/lima_vm.c | 87 ++++---- drivers/gpu/drm/panfrost/panfrost_drv.c | 6 +- drivers/gpu/drm/v3d/v3d_gem.c | 49 +---- include/drm/drm_gem.h | 4 +- 17 files changed, 239 insertions(+), 504 deletions(-) delete mode 100644 drivers/gpu/drm/lima/lima_gem_prime.c delete mode 100644 drivers/gpu/drm/lima/lima_gem_prime.h delete mode 100644 drivers/gpu/drm/lima/lima_object.c delete mode 100644 drivers/gpu/drm/lima/lima_object.h
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Qiang Yu
maintainerPATCH v2 1/6 drm/gem: refine drm_gem_objects_lookup
drm_gem_objects_lookup does not use user space bo handles directly and left the user to kernel copy work to a new interface drm_gem_objects_lookup_user.
This is for driver like lima which does not pass gem bo handles continously in an array in ioctl argument.
v2:
1. add drm_gem_objects_lookup_user
2. remove none-zero check as all caller will check before calling this function
--- drivers/gpu/drm/drm_gem.c | 57 +++++++++++++++++++------ drivers/gpu/drm/panfrost/panfrost_drv.c | 6 +-- include/drm/drm_gem.h | 4 +- 3 files changed, 49 insertions(+), 18 deletions(-)
drivers/gpu/drm/drm_gem.c +43 -14
@@ -679,11 +679,11 @@ static int objects_lookup(struct drm_file *filp, u32 *handle, int count,/** * drm_gem_objects_lookup - look up GEM objects from an array of handles * @filp: DRM file private date -* @bo_handles: user pointer to array of userspace handle +* @bo_handles: array of GEM object handles * @count: size of handle array * @objs_out: returned pointer to array of drm_gem_object pointers * -* Takes an array of userspace handles and returns a newly allocated array of +* Takes an array of GEM object handles and returns a newly allocated array of * GEM objects. * * For a single handle lookup, use drm_gem_object_lookup().
@@ -695,26 +695,56 @@ static int objects_lookup(struct drm_file *filp, u32 *handle, int count,* failure. 0 is returned on success. * */ -int drm_gem_objects_lookup (struct drm_file *filp,void __user *bo_handles, +int drm_gem_objects_lookup (struct drm_file *filp,u32 *bo_handles,int count,struct drm_gem_object ***objs_out) {int ret; -u32 *handles;struct drm_gem_object **objs; -if (!count) -return 0 ; - objs =kvmalloc_array (count,sizeof (struct drm_gem_object *),GFP_KERNEL | __GFP_ZERO);if (!objs)return -ENOMEM ; + ret =objects_lookup (filp, bo_handles, count, objs); +if (ret) +kvfree (objs); +else + *objs_out = objs; + +return ret; + +} +EXPORT_SYMBOL (drm_gem_objects_lookup); + +/** +* drm_gem_objects_lookup_user - look up GEM objects from an array of handles +* @filp: DRM file private date +* @bo_handles: user pointer to array of userspace handle +* @count: size of handle array +* @objs_out: returned pointer to array of drm_gem_object pointers +* +* Takes an array of userspace handles and returns a newly allocated array of +* GEM objects. +* +* For a single handle lookup, use drm_gem_object_lookup(). +* +* Returns: +* +* @objs filled in with GEM object pointers. Returned GEM objects need to be +* released with drm_gem_object_put(). -ENOENT is returned on a lookup +* failure. 0 is returned on success. +* +*/ +int drm_gem_objects_lookup_user (struct drm_file *filp,void __user *bo_handles, +int count,struct drm_gem_object ***objs_out) +{ +int ret; +u32 *handles; + handles =kvmalloc_array (count,sizeof (u32),GFP_KERNEL ); -if (!handles) { - ret = -ENOMEM ; - goto out; - } +if (!handles) +return -ENOMEM ;if (copy_from_user (handles, bo_handles, count *sizeof (u32))) { ret = -EFAULT ;
@@ -722,15 +752,14 @@ int drm_gem_objects_lookup(struct drm_file *filp, void __user *bo_handles, goto out; } - ret =objects_lookup (filp, handles, count, objs); - *objs_out = objs; + ret =drm_gem_objects_lookup (filp, handles, count, objs_out); out:kvfree (handles);return ret; } -EXPORT_SYMBOL (drm_gem_objects_lookup); +EXPORT_SYMBOL (drm_gem_objects_lookup_user);/** * drm_gem_object_lookup - look up a GEM object from its handle
drivers/gpu/drm/panfrost/panfrost_drv.c +3 -3
@@ -130,9 +130,9 @@ panfrost_lookup_bos(struct drm_device *dev,if (!job->implicit_fences)return -ENOMEM ; -return drm_gem_objects_lookup (file_priv, - (void __user *)(uintptr_t )args->bo_handles, - job->bo_count, &job->bos); +return drm_gem_objects_lookup_user (file_priv, + (void __user *)(uintptr_t )args->bo_handles, + job->bo_count, &job->bos); }/**
include/drm/drm_gem.h +3 -1
@@ -387,8 +387,10 @@ struct page **drm_gem_get_pages(struct drm_gem_object *obj);void drm_gem_put_pages (struct drm_gem_object *obj,struct page **pages,bool dirty,bool accessed); -int drm_gem_objects_lookup (struct drm_file *filp,void __user *bo_handles, +int drm_gem_objects_lookup (struct drm_file *filp,u32 *bo_handles,int count,struct drm_gem_object ***objs_out); +int drm_gem_objects_lookup_user (struct drm_file *filp,void __user *bo_handles, +int count,struct drm_gem_object ***objs_out);struct drm_gem_object *drm_gem_object_lookup (struct drm_file *filp,u32 handle);long drm_gem_dma_resv_wait (struct drm_file *filep,u32 handle,bool wait_all,unsigned long timeout);
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 1/6] drm/gem: refine drm_gem_objects_lookup
Quoted 6 lines · Qiang Yu
drm_gem_objects_lookupdoes not use user space bo handles directly and left the user to kernel copy work to a new interfacedrm_gem_objects_lookup_user.This is for driver like lima which does not pass gem bo handles continously in an array in ioctl argument.
Nit: It would be good to mention in the commit message that this adds drm_gem_objects_lookup_user() as it helps grepping commits. Also if you're rewriting it - it would be good to point out that you are _changing_ the behvaviour of drm_gem_objects_lookpu() to not use user space handles.
Quoted 6 lines
v2:
1. adddrm_gem_objects_lookup_user
2. remove none-zero check as all caller will check before calling this function
Quoted 6 lines
Cc Rob Herring <[email protected]>Cc Tomeu Vizoso <[email protected]>Cc Steven Price <[email protected]>Cc Alyssa Rosenzweig <[email protected]>Suggested-by Rob Herring <[email protected]>Signed-off-by Qiang Yu <[email protected]>
Quoted 132 lines
--- drivers/gpu/drm/drm_gem.c | 57 +++++++++++++++++++------ drivers/gpu/drm/panfrost/panfrost_drv.c | 6 +-- include/drm/drm_gem.h | 4 +- 3 files changed, 49 insertions(+), 18 deletions(-)drivers/gpu/drm/drm_gem.c +43
-14@@ -679,11 +679,11 @@ static int objects_lookup(struct drm_file *filp, u32 *handle, int count,/** * drm_gem_objects_lookup - look up GEM objects from an array of handles * @filp: DRM file private date -* @bo_handles: user pointer to array of userspace handle +* @bo_handles: array of GEM object handles * @count: size of handle array * @objs_out: returned pointer to array of drm_gem_object pointers * -* Takes an array of userspace handles and returns a newly allocated array of +* Takes an array of GEM object handles and returns a newly allocated array of * GEM objects. * * For a single handle lookup, use drm_gem_object_lookup(). @@ -695,26 +695,56 @@ static int objects_lookup(struct drm_file *filp, u32 *handle, int count,* failure. 0 is returned on success. * */ -int drm_gem_objects_lookup (struct drm_file *filp,void __user *bo_handles, +int drm_gem_objects_lookup (struct drm_file *filp,u32 *bo_handles,int count,struct drm_gem_object ***objs_out) {int ret; -u32 *handles;struct drm_gem_object **objs; -if (!count) -return 0 ; - objs =kvmalloc_array (count,sizeof (struct drm_gem_object *),GFP_KERNEL | __GFP_ZERO);if (!objs)return -ENOMEM ; + ret =objects_lookup (filp, bo_handles, count, objs); +if (ret) +kvfree (objs); +else + *objs_out = objs; + +return ret; + +} +EXPORT_SYMBOL (drm_gem_objects_lookup); + +/** +* drm_gem_objects_lookup_user - look up GEM objects from an array of handles +* @filp: DRM file private date +* @bo_handles: user pointer to array of userspace handle +* @count: size of handle array +* @objs_out: returned pointer to array of drm_gem_object pointers +* +* Takes an array of userspace handles and returns a newly allocated array of +* GEM objects. +* +* For a single handle lookup, use drm_gem_object_lookup(). +* +* Returns: +* +* @objs filled in with GEM object pointers. Returned GEM objects need to be +* released with drm_gem_object_put(). -ENOENT is returned on a lookup +* failure. 0 is returned on success. +* +*/ +int drm_gem_objects_lookup_user (struct drm_file *filp,void __user *bo_handles, +int count,struct drm_gem_object ***objs_out) +{ +int ret; +u32 *handles; + handles =kvmalloc_array (count,sizeof (u32),GFP_KERNEL ); -if (!handles) { - ret = -ENOMEM ; - goto out; - } +if (!handles) +return -ENOMEM ;if (copy_from_user (handles, bo_handles, count *sizeof (u32))) { ret = -EFAULT ;@@ -722,15 +752,14 @@ int drm_gem_objects_lookup(struct drm_file *filp, void __user *bo_handles, goto out; } - ret =objects_lookup (filp, handles, count, objs); - *objs_out = objs; + ret =drm_gem_objects_lookup (filp, handles, count, objs_out); out:kvfree (handles);return ret; } -EXPORT_SYMBOL (drm_gem_objects_lookup); +EXPORT_SYMBOL (drm_gem_objects_lookup_user);/** * drm_gem_object_lookup - look up a GEM object from its handle drivers/gpu/drm/panfrost/panfrost_drv.c +3
-3@@ -130,9 +130,9 @@ panfrost_lookup_bos(struct drm_device *dev,if (!job->implicit_fences)return -ENOMEM ; -return drm_gem_objects_lookup (file_priv, - (void __user *)(uintptr_t )args->bo_handles, - job->bo_count, &job->bos); +return drm_gem_objects_lookup_user (file_priv, + (void __user *)(uintptr_t )args->bo_handles, + job->bo_count, &job->bos); }/** include/drm/drm_gem.h +0
-0@@ -387,8 +387,10 @@ struct page **drm_gem_get_pages(struct drm_gem_object *obj); void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages,
include/drm/drm_gem.h struct page **drm_gem_get_pages(struct drm_gem_object *obj); · line 396
Quoted 10 lines
include/drm/drm_gem.h +3
-1bool dirty, bool accessed); -int drm_gem_objects_lookup (struct drm_file *filp,void __user *bo_handles, +int drm_gem_objects_lookup (struct drm_file *filp,u32 *bo_handles,int count,struct drm_gem_object ***objs_out); +int drm_gem_objects_lookup_user (struct drm_file *filp,void __user *bo_handles, +int count,struct drm_gem_object ***objs_out);struct drm_gem_object *drm_gem_object_lookup (struct drm_file *filp,u32 handle);long drm_gem_dma_resv_wait (struct drm_file *filep,u32 handle,bool wait_all,unsigned long timeout);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Qiang Yu
maintainerRe: [PATCH v2 1/6] drm/gem: refine drm_gem_objects_lookup
Quoted 6 lines · Steven Price
Quoted 4 lines · Qiang Yu
drm_gem_objects_lookupdoes not use user space bo handles directly and left the user to kernel copy work to a new interfacedrm_gem_objects_lookup_user.
Quoted 9 lines
Quoted 2 lines
This is for driver like lima which does not pass gem bo handles continously in an array in ioctl argument.
Nit: It would be good to mention in the commit message that this adds
drm_gem_objects_lookup_user()as it helps grepping commits. Also if you're rewriting it - it would be good to point out that you are _changing_ the behvaviour ofdrm_gem_objects_lookpu()to not use user space handles.
OK, I can improve the comments of two patches in v3.
Thanks,
Qiang
Quoted 148 lines
Quoted 6 lines
v2:
1. adddrm_gem_objects_lookup_user
2. remove none-zero check as all caller will check before calling this functionQuoted 6 lines
Cc Rob Herring <[email protected]>Cc Tomeu Vizoso <[email protected]>Cc Steven Price <[email protected]>Cc Alyssa Rosenzweig <[email protected]>Suggested-by Rob Herring <[email protected]>Signed-off-by Qiang Yu <[email protected]>Reviewed-by Steven Price <[email protected]>Quoted 133 lines
--- drivers/gpu/drm/drm_gem.c | 57 +++++++++++++++++++------ drivers/gpu/drm/panfrost/panfrost_drv.c | 6 +-- include/drm/drm_gem.h | 4 +- 3 files changed, 49 insertions(+), 18 deletions(-)drivers/gpu/drm/drm_gem.c +43
-14@@ -679,11 +679,11 @@ static int objects_lookup(struct drm_file *filp, u32 *handle, int count,/** * drm_gem_objects_lookup - look up GEM objects from an array of handles * @filp: DRM file private date -* @bo_handles: user pointer to array of userspace handle +* @bo_handles: array of GEM object handles * @count: size of handle array * @objs_out: returned pointer to array of drm_gem_object pointers * -* Takes an array of userspace handles and returns a newly allocated array of +* Takes an array of GEM object handles and returns a newly allocated array of * GEM objects. * * For a single handle lookup, use drm_gem_object_lookup(). @@ -695,26 +695,56 @@ static int objects_lookup(struct drm_file *filp, u32 *handle, int count,* failure. 0 is returned on success. * */ -int drm_gem_objects_lookup (struct drm_file *filp,void __user *bo_handles, +int drm_gem_objects_lookup (struct drm_file *filp,u32 *bo_handles,int count,struct drm_gem_object ***objs_out) {int ret; -u32 *handles;struct drm_gem_object **objs; -if (!count) -return 0 ; - objs =kvmalloc_array (count,sizeof (struct drm_gem_object *),GFP_KERNEL | __GFP_ZERO);if (!objs)return -ENOMEM ; + ret =objects_lookup (filp, bo_handles, count, objs); +if (ret) +kvfree (objs); +else + *objs_out = objs; + +return ret; + +} +EXPORT_SYMBOL (drm_gem_objects_lookup); + +/** +* drm_gem_objects_lookup_user - look up GEM objects from an array of handles +* @filp: DRM file private date +* @bo_handles: user pointer to array of userspace handle +* @count: size of handle array +* @objs_out: returned pointer to array of drm_gem_object pointers +* +* Takes an array of userspace handles and returns a newly allocated array of +* GEM objects. +* +* For a single handle lookup, use drm_gem_object_lookup(). +* +* Returns: +* +* @objs filled in with GEM object pointers. Returned GEM objects need to be +* released with drm_gem_object_put(). -ENOENT is returned on a lookup +* failure. 0 is returned on success. +* +*/ +int drm_gem_objects_lookup_user (struct drm_file *filp,void __user *bo_handles, +int count,struct drm_gem_object ***objs_out) +{ +int ret; +u32 *handles; + handles =kvmalloc_array (count,sizeof (u32),GFP_KERNEL ); -if (!handles) { - ret = -ENOMEM ; - goto out; - } +if (!handles) +return -ENOMEM ;if (copy_from_user (handles, bo_handles, count *sizeof (u32))) { ret = -EFAULT ;@@ -722,15 +752,14 @@ int drm_gem_objects_lookup(struct drm_file *filp, void __user *bo_handles, goto out; } - ret =objects_lookup (filp, handles, count, objs); - *objs_out = objs; + ret =drm_gem_objects_lookup (filp, handles, count, objs_out); out:kvfree (handles);return ret; } -EXPORT_SYMBOL (drm_gem_objects_lookup); +EXPORT_SYMBOL (drm_gem_objects_lookup_user);/** * drm_gem_object_lookup - look up a GEM object from its handle drivers/gpu/drm/panfrost/panfrost_drv.c +3
-3@@ -130,9 +130,9 @@ panfrost_lookup_bos(struct drm_device *dev,if (!job->implicit_fences)return -ENOMEM ; -return drm_gem_objects_lookup (file_priv, - (void __user *)(uintptr_t )args->bo_handles, - job->bo_count, &job->bos); +return drm_gem_objects_lookup_user (file_priv, + (void __user *)(uintptr_t )args->bo_handles, + job->bo_count, &job->bos); }/** include/drm/drm_gem.h +0
-0@@ -387,8 +387,10 @@ struct page **drm_gem_get_pages(struct drm_gem_object *obj);void drm_gem_put_pages (struct drm_gem_object *obj,struct page **pages,bool dirty,bool accessed);
Quoted 10 lines
include/drm/drm_gem.h struct page **drm_gem_get_pages(struct drm_gem_object *obj); · line 396
Quoted 9 lines
include/drm/drm_gem.h +3
-1-int drm_gem_objects_lookup (struct drm_file *filp,void __user *bo_handles, +int drm_gem_objects_lookup (struct drm_file *filp,u32 *bo_handles,int count,struct drm_gem_object ***objs_out); +int drm_gem_objects_lookup_user (struct drm_file *filp,void __user *bo_handles, +int count,struct drm_gem_object ***objs_out);struct drm_gem_object *drm_gem_object_lookup (struct drm_file *filp,u32 handle);long drm_gem_dma_resv_wait (struct drm_file *filep,u32 handle,bool wait_all,unsigned long timeout);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 1/6] drm/gem: refine drm_gem_objects_lookup
In reply to Qiang YuQuoted 43 lines · Qiang Yu
drm_gem_objects_lookupdoes not use user space bo handles directly and left the user to kernel copy work to a new interfacedrm_gem_objects_lookup_user.This is for driver like lima which does not pass gem bo handles continously in an array in ioctl argument.
v2:
1. adddrm_gem_objects_lookup_user
2. remove none-zero check as all caller will check before calling this functionCc Rob Herring <[email protected]>Cc Tomeu Vizoso <[email protected]>Cc Steven Price <[email protected]>Cc Alyssa Rosenzweig <[email protected]>Suggested-by Rob Herring <[email protected]>Signed-off-by Qiang Yu <[email protected]>--- drivers/gpu/drm/drm_gem.c | 57 +++++++++++++++++++------ drivers/gpu/drm/panfrost/panfrost_drv.c | 6 +-- include/drm/drm_gem.h | 4 +- 3 files changed, 49 insertions(+), 18 deletions(-)drivers/gpu/drm/drm_gem.c +2
-2@@ -679,11 +679,11 @@ static int objects_lookup(struct drm_file *filp, u32 *handle, int count,/** * drm_gem_objects_lookup - look up GEM objects from an array of handles * @filp: DRM file private date -* @bo_handles: user pointer to array of userspace handle +* @bo_handles: array of GEM object handles * @count: size of handle array * @objs_out: returned pointer to array of drm_gem_object pointers * -* Takes an array of userspace handles and returns a newly allocated array of +* Takes an array of GEM object handles and returns a newly allocated array of * GEM objects. * * For a single handle lookup, use drm_gem_object_lookup().
drivers/gpu/drm/drm_gem.c static int objects_lookup(struct drm_file *filp, u32 *handle, int count, · line 699
Quoted 6 lines
drivers/gpu/drm/drm_gem.c +1
-1@@ -695,26 +695,56 @@ static int objects_lookup(struct drm_file *filp, u32 *handle, int count,* failure. 0 is returned on success. * */ -int drm_gem_objects_lookup (struct drm_file *filp,void __user *bo_handles, +int drm_gem_objects_lookup (struct drm_file *filp,u32 *bo_handles,int count,struct drm_gem_object ***objs_out)
You can't do this change without updating all the drivers. Simpler to keep this one as-is, and create a new function with an _internal suffix. -Daniel
Quoted 113 lines
drivers/gpu/drm/drm_gem.c +40
-11{int ret; -u32 *handles;struct drm_gem_object **objs; -if (!count) -return 0 ; - objs =kvmalloc_array (count,sizeof (struct drm_gem_object *),GFP_KERNEL | __GFP_ZERO);if (!objs)return -ENOMEM ; + ret =objects_lookup (filp, bo_handles, count, objs); +if (ret) +kvfree (objs); +else + *objs_out = objs; + +return ret; + +} +EXPORT_SYMBOL (drm_gem_objects_lookup); + +/** +* drm_gem_objects_lookup_user - look up GEM objects from an array of handles +* @filp: DRM file private date +* @bo_handles: user pointer to array of userspace handle +* @count: size of handle array +* @objs_out: returned pointer to array of drm_gem_object pointers +* +* Takes an array of userspace handles and returns a newly allocated array of +* GEM objects. +* +* For a single handle lookup, use drm_gem_object_lookup(). +* +* Returns: +* +* @objs filled in with GEM object pointers. Returned GEM objects need to be +* released with drm_gem_object_put(). -ENOENT is returned on a lookup +* failure. 0 is returned on success. +* +*/ +int drm_gem_objects_lookup_user (struct drm_file *filp,void __user *bo_handles, +int count,struct drm_gem_object ***objs_out) +{ +int ret; +u32 *handles; + handles =kvmalloc_array (count,sizeof (u32),GFP_KERNEL ); -if (!handles) { - ret = -ENOMEM ; - goto out; - } +if (!handles) +return -ENOMEM ;if (copy_from_user (handles, bo_handles, count *sizeof (u32))) { ret = -EFAULT ;@@ -722,15 +752,14 @@ int drm_gem_objects_lookup(struct drm_file *filp, void __user *bo_handles, goto out; } - ret =objects_lookup (filp, handles, count, objs); - *objs_out = objs; + ret =drm_gem_objects_lookup (filp, handles, count, objs_out); out:kvfree (handles);return ret; } -EXPORT_SYMBOL (drm_gem_objects_lookup); +EXPORT_SYMBOL (drm_gem_objects_lookup_user);/** * drm_gem_object_lookup - look up a GEM object from its handle drivers/gpu/drm/panfrost/panfrost_drv.c +3
-3@@ -130,9 +130,9 @@ panfrost_lookup_bos(struct drm_device *dev,if (!job->implicit_fences)return -ENOMEM ; -return drm_gem_objects_lookup (file_priv, - (void __user *)(uintptr_t )args->bo_handles, - job->bo_count, &job->bos); +return drm_gem_objects_lookup_user (file_priv, + (void __user *)(uintptr_t )args->bo_handles, + job->bo_count, &job->bos); }/** include/drm/drm_gem.h +3
-1@@ -387,8 +387,10 @@ struct page **drm_gem_get_pages(struct drm_gem_object *obj);void drm_gem_put_pages (struct drm_gem_object *obj,struct page **pages,bool dirty,bool accessed); -int drm_gem_objects_lookup (struct drm_file *filp,void __user *bo_handles, +int drm_gem_objects_lookup (struct drm_file *filp,u32 *bo_handles,int count,struct drm_gem_object ***objs_out); +int drm_gem_objects_lookup_user (struct drm_file *filp,void __user *bo_handles, +int count,struct drm_gem_object ***objs_out);struct drm_gem_object *drm_gem_object_lookup (struct drm_file *filp,u32 handle);long drm_gem_dma_resv_wait (struct drm_file *filep,u32 handle,bool wait_all,unsigned long timeout);Signature · 1 line
2.17.1
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Rob Herring
maintainerRe: [PATCH v2 1/6] drm/gem: refine drm_gem_objects_lookup
Quoted 46 lines · Daniel Vetter
Quoted 44 lines · Qiang Yu
drm_gem_objects_lookupdoes not use user space bo handles directly and left the user to kernel copy work to a new interfacedrm_gem_objects_lookup_user.This is for driver like lima which does not pass gem bo handles continously in an array in ioctl argument.
v2:
1. adddrm_gem_objects_lookup_user
2. remove none-zero check as all caller will check before calling this functionCc Rob Herring <[email protected]>Cc Tomeu Vizoso <[email protected]>Cc Steven Price <[email protected]>Cc Alyssa Rosenzweig <[email protected]>Suggested-by Rob Herring <[email protected]>Signed-off-by Qiang Yu <[email protected]>--- drivers/gpu/drm/drm_gem.c | 57 +++++++++++++++++++------ drivers/gpu/drm/panfrost/panfrost_drv.c | 6 +-- include/drm/drm_gem.h | 4 +- 3 files changed, 49 insertions(+), 18 deletions(-)drivers/gpu/drm/drm_gem.c +2
-2@@ -679,11 +679,11 @@ static int objects_lookup(struct drm_file *filp, u32 *handle, int count,/** * drm_gem_objects_lookup - look up GEM objects from an array of handles * @filp: DRM file private date -* @bo_handles: user pointer to array of userspace handle +* @bo_handles: array of GEM object handles * @count: size of handle array * @objs_out: returned pointer to array of drm_gem_object pointers * -* Takes an array of userspace handles and returns a newly allocated array of +* Takes an array of GEM object handles and returns a newly allocated array of * GEM objects. * * For a single handle lookup, use drm_gem_object_lookup(). @@ -695,26 +695,56 @@ static int objects_lookup(struct drm_file *filp, u32 *handle, int count,* failure. 0 is returned on success.
Quoted 8 lines
drivers/gpu/drm/drm_gem.c static int objects_lookup(struct drm_file *filp, u32 *handle, int count, · line 699
Quoted 5 lines
drivers/gpu/drm/drm_gem.c +1
-1* */ -int drm_gem_objects_lookup (struct drm_file *filp,void __user *bo_handles, +int drm_gem_objects_lookup (struct drm_file *filp,u32 *bo_handles,int count,struct drm_gem_object ***objs_out)You can't do this change without updating all the drivers. Simpler to keep this one as-is, and create a new function with an
_internalsuffix.
The only driver currently is panfrost and it is updated in this patch.
Rob
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 1/6] drm/gem: refine drm_gem_objects_lookup
Quoted 56 lines · Rob Herring
Quoted 46 lines · Daniel Vetter
Quoted 44 lines · Qiang Yu
drm_gem_objects_lookupdoes not use user space bo handles directly and left the user to kernel copy work to a new interfacedrm_gem_objects_lookup_user.This is for driver like lima which does not pass gem bo handles continously in an array in ioctl argument.
v2:
1. adddrm_gem_objects_lookup_user
2. remove none-zero check as all caller will check before calling this functionCc Rob Herring <[email protected]>Cc Tomeu Vizoso <[email protected]>Cc Steven Price <[email protected]>Cc Alyssa Rosenzweig <[email protected]>Suggested-by Rob Herring <[email protected]>Signed-off-by Qiang Yu <[email protected]>--- drivers/gpu/drm/drm_gem.c | 57 +++++++++++++++++++------ drivers/gpu/drm/panfrost/panfrost_drv.c | 6 +-- include/drm/drm_gem.h | 4 +- 3 files changed, 49 insertions(+), 18 deletions(-)drivers/gpu/drm/drm_gem.c +2
-2@@ -679,11 +679,11 @@ static int objects_lookup(struct drm_file *filp, u32 *handle, int count,/** * drm_gem_objects_lookup - look up GEM objects from an array of handles * @filp: DRM file private date -* @bo_handles: user pointer to array of userspace handle +* @bo_handles: array of GEM object handles * @count: size of handle array * @objs_out: returned pointer to array of drm_gem_object pointers * -* Takes an array of userspace handles and returns a newly allocated array of +* Takes an array of GEM object handles and returns a newly allocated array of * GEM objects. * * For a single handle lookup, use drm_gem_object_lookup(). @@ -695,26 +695,56 @@ static int objects_lookup(struct drm_file *filp, u32 *handle, int count,* failure. 0 is returned on success. Quoted 8 lines
drivers/gpu/drm/drm_gem.c static int objects_lookup(struct drm_file *filp, u32 *handle, int count, · line 699
Quoted 5 lines
drivers/gpu/drm/drm_gem.c +1
-1* */ -int drm_gem_objects_lookup (struct drm_file *filp,void __user *bo_handles, +int drm_gem_objects_lookup (struct drm_file *filp,u32 *bo_handles,int count,struct drm_gem_object ***objs_out)You can't do this change without updating all the drivers. Simpler to keep this one as-is, and create a new function with an
_internalsuffix.
Quoted 1 line
The only driver currently is panfrost and it is updated in this patch.
Oops sry missed that in the diffstat somehow.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Qiang Yu
maintainerPATCH v2 2/6 drm/v3d: use drm_gem_objects_lookup_user
In reply to Qiang Yuv2:
use drm_gem_objects_lookup_user instead ofdrm_gem_objects_lookup.
--- drivers/gpu/drm/v3d/v3d_gem.c | 49 +++-------------------------------- 1 file changed, 3 insertions(+), 46 deletions(-)
drivers/gpu/drm/v3d/v3d_gem.c +3 -46
@@ -290,10 +290,6 @@ v3d_lookup_bos(struct drm_device *dev, u64 bo_handles, u32 bo_count) { -u32 *handles; -int ret =0 ; -int i; - job->bo_count = bo_count;if (!job->bo_count) {
@@ -304,48 +300,9 @@ v3d_lookup_bos(struct drm_device *dev,return -EINVAL ; } - job->bo =kvmalloc_array (job->bo_count, -sizeof (struct drm_gem_cma_object *), -GFP_KERNEL | __GFP_ZERO); -if (!job->bo) { -DRM_DEBUG ("Failed to allocate validated BO pointers\n" ); -return -ENOMEM ; - } - - handles =kvmalloc_array (job->bo_count,sizeof (u32),GFP_KERNEL ); -if (!handles) { - ret = -ENOMEM ; -DRM_DEBUG ("Failed to allocate incoming GEM handles\n" ); - goto fail; - } - -if (copy_from_user (handles, - (void __user *)(uintptr_t )bo_handles, - job->bo_count *sizeof (u32))) { - ret = -EFAULT ; -DRM_DEBUG ("Failed to copy in GEM handles\n" ); - goto fail; - } - -spin_lock (&file_priv->table_lock); -for (i =0 ; i < job->bo_count; i++) { -struct drm_gem_object *bo =idr_find (&file_priv->object_idr, - handles[i]); -if (!bo) { -DRM_DEBUG ("Failed to look up GEM BO %d: %d\n" , - i, handles[i]); - ret = -ENOENT ; -spin_unlock (&file_priv->table_lock); - goto fail; - } -drm_gem_object_get (bo); - job->bo[i] = bo; - } -spin_unlock (&file_priv->table_lock); - -fail: -kvfree (handles); -return ret; +return drm_gem_objects_lookup_user (file_priv, + (void __user *)(uintptr_t )bo_handles, + job->bo_count, &job->bo); } static void
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 2/6] drm/v3d: use drm_gem_objects_lookup_user
Quoted 6 lines · Qiang Yu
v2:
usedrm_gem_objects_lookup_userinstead ofdrm_gem_objects_lookup.Cc Eric Anholt <[email protected]>Signed-off-by Qiang Yu <[email protected]>
Looks familiar :)
Nit: please write a commit message. But otherwise:
Quoted 62 lines
--- drivers/gpu/drm/v3d/v3d_gem.c | 49 +++-------------------------------- 1 file changed, 3 insertions(+), 46 deletions(-)drivers/gpu/drm/v3d/v3d_gem.c +0
-42@@ -290,10 +290,6 @@ v3d_lookup_bos(struct drm_device *dev, u64 bo_handles, u32 bo_count) { -u32 *handles; -int ret =0 ; -int i; - job->bo_count = bo_count;if (!job->bo_count) {@@ -304,48 +300,9 @@ v3d_lookup_bos(struct drm_device *dev,return -EINVAL ; } - job->bo =kvmalloc_array (job->bo_count, -sizeof (struct drm_gem_cma_object *), -GFP_KERNEL | __GFP_ZERO); -if (!job->bo) { -DRM_DEBUG ("Failed to allocate validated BO pointers\n" ); -return -ENOMEM ; - } - - handles =kvmalloc_array (job->bo_count,sizeof (u32),GFP_KERNEL ); -if (!handles) { - ret = -ENOMEM ; -DRM_DEBUG ("Failed to allocate incoming GEM handles\n" ); - goto fail; - } - -if (copy_from_user (handles, - (void __user *)(uintptr_t )bo_handles, - job->bo_count *sizeof (u32))) { - ret = -EFAULT ; -DRM_DEBUG ("Failed to copy in GEM handles\n" ); - goto fail; - } - -spin_lock (&file_priv->table_lock); -for (i =0 ; i < job->bo_count; i++) { -struct drm_gem_object *bo =idr_find (&file_priv->object_idr, - handles[i]); -if (!bo) { -DRM_DEBUG ("Failed to look up GEM BO %d: %d\n" , - i, handles[i]); - ret = -ENOENT ; -spin_unlock (&file_priv->table_lock); - goto fail; - } -drm_gem_object_get (bo); - job->bo[i] = bo; - } -spin_unlock (&file_priv->table_lock);
drivers/gpu/drm/v3d/v3d_gem.c v3d_lookup_bos(struct drm_device *dev, · line 308
Quoted 10 lines
drivers/gpu/drm/v3d/v3d_gem.c +3
-4- -fail: -kvfree (handles); -return ret; +return drm_gem_objects_lookup_user (file_priv, + (void __user *)(uintptr_t )bo_handles, + job->bo_count, &job->bo); } static void
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Qiang Yu
maintainerPATCH v2 3/6 drm/lima: use drm_gem_objects_lookup
In reply to Qiang Yu--- drivers/gpu/drm/lima/lima_drv.c | 5 ++- drivers/gpu/drm/lima/lima_gem.c | 73 +++++++++++++++++++-------------- 2 files changed, 46 insertions(+), 32 deletions(-)
drivers/gpu/drm/lima/lima_drv.c +3 -2
@@ -108,7 +108,7 @@ static int lima_ioctl_gem_submit(struct drm_device *dev, void *data, struct drm_if (args->frame_size != pipe->frame_size)return -EINVAL ; - bos =kvcalloc (args->nr_bos,sizeof (*submit.bos) +sizeof (*submit.lbos),GFP_KERNEL ); + bos =kvcalloc (args->nr_bos,sizeof (*submit.bos),GFP_KERNEL );if (!bos)return -ENOMEM ;
@@ -142,7 +142,6 @@ static int lima_ioctl_gem_submit(struct drm_device *dev, void *data, struct drm_ submit.pipe = args->pipe; submit.bos = bos; - submit.lbos = (void *)bos + size; submit.nr_bos = args->nr_bos; submit.task = task; submit.ctx = ctx;
@@ -159,6 +158,8 @@ static int lima_ioctl_gem_submit(struct drm_device *dev, void *data, struct drm_kmem_cache_free (pipe->task_slab, task); out0:kvfree (bos); +if (submit.lbos) +kvfree (submit.lbos);return err; }
drivers/gpu/drm/lima/lima_gem.c +43 -30
123 lines not on this page · raw message
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Qiang Yu
maintainerPATCH v2 4/6 drm/lima: use drm_gem_shmem_helpers
In reply to Qiang YuDo not need to maintain our own shmem memory management code as drm_gem_shmem_helpers provides it. And we can also benifit from the work of others with shared code.
This is also a preparation for implementing buffer madv.
--- drivers/gpu/drm/lima/Kconfig | 1 + drivers/gpu/drm/lima/Makefile | 4 +- drivers/gpu/drm/lima/lima_drv.c | 22 +--- drivers/gpu/drm/lima/lima_gem.c | 141 +++++++++++++------------- drivers/gpu/drm/lima/lima_gem.h | 32 ++++-- drivers/gpu/drm/lima/lima_gem_prime.c | 46 --------- drivers/gpu/drm/lima/lima_gem_prime.h | 13 --- drivers/gpu/drm/lima/lima_mmu.c | 1 - drivers/gpu/drm/lima/lima_object.c | 119 ---------------------- drivers/gpu/drm/lima/lima_object.h | 35 ------- drivers/gpu/drm/lima/lima_sched.c | 6 +- drivers/gpu/drm/lima/lima_vm.c | 85 ++++++++-------- 12 files changed, 145 insertions(+), 360 deletions(-) delete mode 100644 drivers/gpu/drm/lima/lima_gem_prime.c delete mode 100644 drivers/gpu/drm/lima/lima_gem_prime.h delete mode 100644 drivers/gpu/drm/lima/lima_object.c delete mode 100644 drivers/gpu/drm/lima/lima_object.h
drivers/gpu/drm/lima/Kconfig +1 -0
@@ -9,5 +9,6 @@ config DRM_LIMA depends on COMMON_CLK depends on OF select DRM_SCHED + select DRM_GEM_SHMEM_HELPER help DRM driver for ARM Mali 400/450 GPUs.
drivers/gpu/drm/lima/Makefile +1 -3
@@ -13,9 +13,7 @@ lima-y := \ lima_vm.o \ lima_sched.o \ lima_ctx.o \ - lima_gem_prime.o \ lima_dlbu.o \ - lima_bcast.o \ - lima_object.o + lima_bcast.o obj-$(CONFIG_DRM_LIMA) += lima.o
drivers/gpu/drm/lima/lima_drv.c +4 -18
@@ -12,7 +12,6 @@#include "lima_drv.h" #include "lima_gem.h" -#include "lima_gem_prime.h" #include "lima_vm.h" int lima_sched_timeout_ms;
@@ -241,16 +240,7 @@ static const struct drm_ioctl_desc lima_drm_driver_ioctls[] = {DRM_IOCTL_DEF_DRV (LIMA_CTX_FREE , lima_ioctl_ctx_free,DRM_RENDER_ALLOW ), }; -static const struct file_operations lima_drm_driver_fops = { - .owner =THIS_MODULE , - .open = drm_open, - .release = drm_release, - .unlocked_ioctl = drm_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = drm_compat_ioctl, -#endif - .mmap = lima_gem_mmap, -}; +DEFINE_DRM_GEM_SHMEM_FOPS (lima_drm_driver_fops);static struct drm_driver lima_drm_driver = { .driver_features = DRIVER_RENDER | DRIVER_GEM | DRIVER_SYNCOBJ,
@@ -259,10 +249,6 @@ static struct drm_driver lima_drm_driver = { .ioctls = lima_drm_driver_ioctls, .num_ioctls = ARRAY_SIZE(lima_drm_driver_ioctls), .fops = &lima_drm_driver_fops, - .gem_free_object_unlocked = lima_gem_free_object, - .gem_open_object = lima_gem_object_open, - .gem_close_object = lima_gem_object_close, - .gem_vm_ops = &lima_gem_vm_ops, .name = "lima", .desc = "lima DRM", .date = "20190217",
@@ -270,11 +256,11 @@ static struct drm_driver lima_drm_driver = { .minor = 0, .patchlevel = 0, + .gem_create_object = lima_gem_create_object, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, - .gem_prime_import_sg_table = lima_gem_prime_import_sg_table, + .gem_prime_import_sg_table = drm_gem_shmem_prime_import_sg_table, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, - .gem_prime_get_sg_table = lima_gem_prime_get_sg_table, - .gem_prime_mmap = lima_gem_prime_mmap, + .gem_prime_mmap = drm_gem_prime_mmap, };static int lima_pdev_probe (struct platform_device *pdev)
drivers/gpu/drm/lima/lima_gem.c +70 -71
255 lines not on this page · raw message
drivers/gpu/drm/lima/lima_gem.h +25 -7
@@ -4,19 +4,37 @@#ifndef __LIMA_GEM_H__#define __LIMA_GEM_H__ -struct lima_bo ; +#include <drm/drm_gem_shmem_helper.h> +struct lima_submit ; -extern const struct vm_operations_struct lima_gem_vm_ops; +struct lima_bo { +struct drm_gem_shmem_object base; + +struct mutex lock; +struct list_head va; +}; + +static inline struct lima_bo * +to_lima_bo (struct drm_gem_object *obj) +{ + return container_of(to_drm_gem_shmem_obj(obj), struct lima_bo, base); +} + +static inline size_t lima_bo_size (struct lima_bo *bo) +{ +return bo->base.base.size; +} + +static inline struct dma_resv *lima_bo_resv (struct lima_bo *bo) +{ +return bo->base.base.resv; +} -struct lima_bo *lima_gem_create_bo (struct drm_device *dev,u32 size,u32 flags); +struct drm_gem_object *lima_gem_create_object (struct drm_device *dev,size_t size);int lima_gem_create_handle (struct drm_device *dev,struct drm_file *file,u32 size,u32 flags,u32 *handle); -void lima_gem_free_object (struct drm_gem_object *obj); -int lima_gem_object_open (struct drm_gem_object *obj,struct drm_file *file); -void lima_gem_object_close (struct drm_gem_object *obj,struct drm_file *file);int lima_gem_get_info (struct drm_file *file,u32 handle,u32 *va,u64 *offset); -int lima_gem_mmap (struct file *filp,struct vm_area_struct *vma);int lima_gem_submit (struct drm_file *file,struct lima_submit *submit);int lima_gem_wait (struct drm_file *file,u32 handle,u32 op,s64 timeout_ns);
drivers/gpu/drm/lima/lima_gem_prime.c deleted +0 -46
46 lines not on this page · raw message
drivers/gpu/drm/lima/lima_gem_prime.h deleted +0 -13
@@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR MIT */ -/* Copyright 2018-2019 Qiang Yu <[email protected]> */ - -#ifndef __LIMA_GEM_PRIME_H__ -#define __LIMA_GEM_PRIME_H__ - -struct drm_gem_object *lima_gem_prime_import_sg_table ( -struct drm_device *dev,struct dma_buf_attachment *attach, -struct sg_table *sgt); -struct sg_table *lima_gem_prime_get_sg_table (struct drm_gem_object *obj); -int lima_gem_prime_mmap (struct drm_gem_object *obj,struct vm_area_struct *vma); - -#endif
drivers/gpu/drm/lima/lima_mmu.c +0 -1
@@ -8,7 +8,6 @@#include "lima_device.h" #include "lima_mmu.h" #include "lima_vm.h" -#include "lima_object.h" #include "lima_regs.h" #define mmu_write (reg, data) writel(data, ip->iomem + reg)
drivers/gpu/drm/lima/lima_object.c deleted +0 -119
119 lines not on this page · raw message
drivers/gpu/drm/lima/lima_object.h deleted +0 -35
@@ -1,35 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR MIT */ -/* Copyright 2018-2019 Qiang Yu <[email protected]> */ - -#ifndef __LIMA_OBJECT_H__ -#define __LIMA_OBJECT_H__ - -#include <drm/drm_gem.h> - -#include "lima_device.h" - -struct lima_bo { -struct drm_gem_object gem; - -struct page **pages; -dma_addr_t *pages_dma_addr; -struct sg_table *sgt; -void *vaddr; - -struct mutex lock; -struct list_head va; -}; - -static inline struct lima_bo * -to_lima_bo (struct drm_gem_object *obj) -{ - return container_of(obj, struct lima_bo, gem); -} - -struct lima_bo *lima_bo_create (struct lima_device *dev,u32 size, -u32 flags,struct sg_table *sgt); -void lima_bo_destroy (struct lima_bo *bo); -void *lima_bo_vmap (struct lima_bo *bo); -void lima_bo_vunmap (struct lima_bo *bo); - -#endif
drivers/gpu/drm/lima/lima_sched.c +3 -3
@@ -10,7 +10,7 @@#include "lima_vm.h" #include "lima_mmu.h" #include "lima_l2_cache.h" -#include "lima_object.h" +#include "lima_gem.h" struct lima_fence {struct dma_fence base;
@@ -117,7 +117,7 @@ int lima_sched_task_init(struct lima_sched_task *task,return -ENOMEM ;for (i =0 ; i < num_bos; i++) -drm_gem_object_get (&bos[i]->gem); +drm_gem_object_get (&bos[i]->base.base); err =drm_sched_job_init (&task->base, &context->base, vm);if (err) {
@@ -148,7 +148,7 @@ void lima_sched_task_fini(struct lima_sched_task *task)if (task->bos) {for (i =0 ; i < task->num_bos; i++) -drm_gem_object_put_unlocked (&task->bos[i]->gem); +drm_gem_object_put_unlocked (&task->bos[i]->base.base);kfree (task->bos); }
drivers/gpu/drm/lima/lima_vm.c +41 -44
140 lines not on this page · raw message
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Qiang Yu
maintainerPATCH v2 5/6 drm/lima: use drm_gem_(un)lock_reservations
In reply to Qiang Yu--- drivers/gpu/drm/lima/lima_gem.c | 64 ++++----------------------------- 1 file changed, 6 insertions(+), 58 deletions(-)
drivers/gpu/drm/lima/lima_gem.c +6 -58
@@ -166,61 +166,6 @@ static int lima_gem_sync_bo(struct lima_sched_task *task, struct lima_bo *bo,return drm_gem_fence_array_add_implicit (&task->deps, &bo->base.base, write); } -static int lima_gem_lock_bos (struct lima_bo **bos,u32 nr_bos, -struct ww_acquire_ctx *ctx) -{ -int i, ret =0 , contended, slow_locked =-1 ; - -ww_acquire_init (ctx, &reservation_ww_class); - -retry: -for (i =0 ; i < nr_bos; i++) { -if (i == slow_locked) { - slow_locked =-1 ; -continue ; - } - - ret =ww_mutex_lock_interruptible (&lima_bo_resv (bos[i])->lock, ctx); -if (ret <0 ) { - contended = i; - goto err; - } - } - -ww_acquire_done (ctx); -return 0 ; - -err: -for (i--; i >=0 ; i--) -ww_mutex_unlock (&lima_bo_resv (bos[i])->lock); - -if (slow_locked >=0 ) -ww_mutex_unlock (&lima_bo_resv (bos[slow_locked])->lock); - -if (ret == -EDEADLK ) { -/* we lost out in a seqno race, lock and retry.. */ - ret =ww_mutex_lock_slow_interruptible ( - &lima_bo_resv (bos[contended])->lock, ctx); -if (!ret) { - slow_locked = contended; - goto retry; - } - } -ww_acquire_fini (ctx); - -return ret; -} - -static void lima_gem_unlock_bos (struct lima_bo **bos,u32 nr_bos, -struct ww_acquire_ctx *ctx) -{ -int i; - -for (i =0 ; i < nr_bos; i++) -ww_mutex_unlock (&lima_bo_resv (bos[i])->lock); -ww_acquire_fini (ctx); -} -static int lima_gem_add_deps (struct drm_file *file,struct lima_submit *submit) {int i, err;
@@ -280,7 +225,8 @@ int lima_gem_submit(struct drm_file *file, struct lima_submit *submit) } } - err =lima_gem_lock_bos (bos, submit->nr_bos, &ctx); + err =drm_gem_lock_reservations ((struct drm_gem_object **)bos, + submit->nr_bos, &ctx);if (err) goto err_out2;
@@ -313,7 +259,8 @@ int lima_gem_submit(struct drm_file *file, struct lima_submit *submit)dma_resv_add_shared_fence (lima_bo_resv (bos[i]), fence); } -lima_gem_unlock_bos (bos, submit->nr_bos, &ctx); +drm_gem_unlock_reservations ((struct drm_gem_object **)bos, + submit->nr_bos, &ctx);for (i =0 ; i < submit->nr_bos; i++)drm_gem_object_put_unlocked (&bos[i]->base.base);
@@ -330,7 +277,8 @@ int lima_gem_submit(struct drm_file *file, struct lima_submit *submit) err_out4:lima_sched_task_fini (submit->task); err_out3: -lima_gem_unlock_bos (bos, submit->nr_bos, &ctx); +drm_gem_unlock_reservations ((struct drm_gem_object **)bos, + submit->nr_bos, &ctx); err_out2:for (i =0 ; i < submit->nr_bos; i++)lima_vm_bo_del (vm, bos[i]);
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Qiang Yu
maintainerPATCH v2 6/6 drm/lima: add __GFP_NOWARN flag to all dma_alloc_wc
In reply to Qiang YuThis prevent CMA printing dumy "PFNs busy" info which is caused by alloc fail re-try case.
--- drivers/gpu/drm/lima/lima_device.c | 2 +- drivers/gpu/drm/lima/lima_vm.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/lima/lima_device.c +1 -1
@@ -313,7 +313,7 @@ int lima_device_init(struct lima_device *ldev) ldev->va_end =LIMA_VA_RESERVE_START ; ldev->dlbu_cpu =dma_alloc_wc ( ldev->dev,LIMA_PAGE_SIZE , - &ldev->dlbu_dma,GFP_KERNEL ); + &ldev->dlbu_dma,GFP_KERNEL | __GFP_NOWARN);if (!ldev->dlbu_cpu) { err = -ENOMEM ; goto err_out2;
drivers/gpu/drm/lima/lima_vm.c +2 -2
@@ -56,7 +56,7 @@ static int lima_vm_map_page(struct lima_vm *vm, dma_addr_t pa, u32 va) vm->bts[pbe].cpu =dma_alloc_wc ( vm->dev->dev,LIMA_PAGE_SIZE <<LIMA_VM_NUM_PT_PER_BT_SHIFT , - &vm->bts[pbe].dma,GFP_KERNEL | __GFP_ZERO); + &vm->bts[pbe].dma,GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO);if (!vm->bts[pbe].cpu)return -ENOMEM ;
@@ -208,7 +208,7 @@ struct lima_vm *lima_vm_create(struct lima_device *dev)kref_init (&vm->refcount); vm->pd.cpu =dma_alloc_wc (dev->dev,LIMA_PAGE_SIZE , &vm->pd.dma, -GFP_KERNEL | __GFP_ZERO); +GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO);if (!vm->pd.cpu) goto err_out0;
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel