Message ID | 20211005113742.1101-24-christian.koenig@amd.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [01/28] dma-buf: add dma_resv_for_each_fence_unlocked v8 | expand |
On Tue, Oct 05, 2021 at 01:37:37PM +0200, Christian König wrote: > Simplifying the code a bit. > > v2: add missing rcu_read_lock()/unlock() > v3: switch to locked version > > Signed-off-by: Christian König <christian.koenig@amd.com> > Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Please make sure you also apply this to the new copy of this code in drm/sched. This one here is up for deletion, once I get all the driver conversions I have landed ... -Daniel > --- > drivers/gpu/drm/drm_gem.c | 26 +++++--------------------- > 1 file changed, 5 insertions(+), 21 deletions(-) > > diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c > index 09c820045859..4dcdec6487bb 100644 > --- a/drivers/gpu/drm/drm_gem.c > +++ b/drivers/gpu/drm/drm_gem.c > @@ -1340,31 +1340,15 @@ int drm_gem_fence_array_add_implicit(struct xarray *fence_array, > struct drm_gem_object *obj, > bool write) > { > - int ret; > - struct dma_fence **fences; > - unsigned int i, fence_count; > - > - if (!write) { > - struct dma_fence *fence = > - dma_resv_get_excl_unlocked(obj->resv); > - > - return drm_gem_fence_array_add(fence_array, fence); > - } > + struct dma_resv_iter cursor; > + struct dma_fence *fence; > + int ret = 0; > > - ret = dma_resv_get_fences(obj->resv, NULL, > - &fence_count, &fences); > - if (ret || !fence_count) > - return ret; > - > - for (i = 0; i < fence_count; i++) { > - ret = drm_gem_fence_array_add(fence_array, fences[i]); > + dma_resv_for_each_fence(&cursor, obj->resv, write, fence) { > + ret = drm_gem_fence_array_add(fence_array, fence); > if (ret) > break; > } > - > - for (; i < fence_count; i++) > - dma_fence_put(fences[i]); > - kfree(fences); > return ret; > } > EXPORT_SYMBOL(drm_gem_fence_array_add_implicit); > -- > 2.25.1 >
Am 13.10.21 um 16:21 schrieb Daniel Vetter: > On Tue, Oct 05, 2021 at 01:37:37PM +0200, Christian König wrote: >> Simplifying the code a bit. >> >> v2: add missing rcu_read_lock()/unlock() >> v3: switch to locked version >> >> Signed-off-by: Christian König <christian.koenig@amd.com> >> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> > Please make sure you also apply this to the new copy of this code in > drm/sched. This one here is up for deletion, once I get all the driver > conversions I have landed ... Yeah, I do have that. Only added this patch here for completeness so that I could at least consider dropping the old access functions. Put I will hold it back, just ping me when the code in question is removed. Christian. > -Daniel > >> --- >> drivers/gpu/drm/drm_gem.c | 26 +++++--------------------- >> 1 file changed, 5 insertions(+), 21 deletions(-) >> >> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c >> index 09c820045859..4dcdec6487bb 100644 >> --- a/drivers/gpu/drm/drm_gem.c >> +++ b/drivers/gpu/drm/drm_gem.c >> @@ -1340,31 +1340,15 @@ int drm_gem_fence_array_add_implicit(struct xarray *fence_array, >> struct drm_gem_object *obj, >> bool write) >> { >> - int ret; >> - struct dma_fence **fences; >> - unsigned int i, fence_count; >> - >> - if (!write) { >> - struct dma_fence *fence = >> - dma_resv_get_excl_unlocked(obj->resv); >> - >> - return drm_gem_fence_array_add(fence_array, fence); >> - } >> + struct dma_resv_iter cursor; >> + struct dma_fence *fence; >> + int ret = 0; >> >> - ret = dma_resv_get_fences(obj->resv, NULL, >> - &fence_count, &fences); >> - if (ret || !fence_count) >> - return ret; >> - >> - for (i = 0; i < fence_count; i++) { >> - ret = drm_gem_fence_array_add(fence_array, fences[i]); >> + dma_resv_for_each_fence(&cursor, obj->resv, write, fence) { >> + ret = drm_gem_fence_array_add(fence_array, fence); >> if (ret) >> break; >> } >> - >> - for (; i < fence_count; i++) >> - dma_fence_put(fences[i]); >> - kfree(fences); >> return ret; >> } >> EXPORT_SYMBOL(drm_gem_fence_array_add_implicit); >> -- >> 2.25.1 >>
On Tue, Oct 19, 2021 at 02:54:04PM +0200, Christian König wrote: > Am 13.10.21 um 16:21 schrieb Daniel Vetter: > > On Tue, Oct 05, 2021 at 01:37:37PM +0200, Christian König wrote: > > > Simplifying the code a bit. > > > > > > v2: add missing rcu_read_lock()/unlock() > > > v3: switch to locked version > > > > > > Signed-off-by: Christian König <christian.koenig@amd.com> > > > Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> > > Please make sure you also apply this to the new copy of this code in > > drm/sched. This one here is up for deletion, once I get all the driver > > conversions I have landed ... > > Yeah, I do have that. Only added this patch here for completeness so that I > could at least consider dropping the old access functions. > > Put I will hold it back, just ping me when the code in question is removed. Imo go ahead and push this, the rebasing is trivial since I just delete code. That way I don't have to remember to do anything :-) -Daniel > > Christian. > > > -Daniel > > > > > --- > > > drivers/gpu/drm/drm_gem.c | 26 +++++--------------------- > > > 1 file changed, 5 insertions(+), 21 deletions(-) > > > > > > diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c > > > index 09c820045859..4dcdec6487bb 100644 > > > --- a/drivers/gpu/drm/drm_gem.c > > > +++ b/drivers/gpu/drm/drm_gem.c > > > @@ -1340,31 +1340,15 @@ int drm_gem_fence_array_add_implicit(struct xarray *fence_array, > > > struct drm_gem_object *obj, > > > bool write) > > > { > > > - int ret; > > > - struct dma_fence **fences; > > > - unsigned int i, fence_count; > > > - > > > - if (!write) { > > > - struct dma_fence *fence = > > > - dma_resv_get_excl_unlocked(obj->resv); > > > - > > > - return drm_gem_fence_array_add(fence_array, fence); > > > - } > > > + struct dma_resv_iter cursor; > > > + struct dma_fence *fence; > > > + int ret = 0; > > > - ret = dma_resv_get_fences(obj->resv, NULL, > > > - &fence_count, &fences); > > > - if (ret || !fence_count) > > > - return ret; > > > - > > > - for (i = 0; i < fence_count; i++) { > > > - ret = drm_gem_fence_array_add(fence_array, fences[i]); > > > + dma_resv_for_each_fence(&cursor, obj->resv, write, fence) { > > > + ret = drm_gem_fence_array_add(fence_array, fence); > > > if (ret) > > > break; > > > } > > > - > > > - for (; i < fence_count; i++) > > > - dma_fence_put(fences[i]); > > > - kfree(fences); > > > return ret; > > > } > > > EXPORT_SYMBOL(drm_gem_fence_array_add_implicit); > > > -- > > > 2.25.1 > > > >
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 09c820045859..4dcdec6487bb 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -1340,31 +1340,15 @@ int drm_gem_fence_array_add_implicit(struct xarray *fence_array, struct drm_gem_object *obj, bool write) { - int ret; - struct dma_fence **fences; - unsigned int i, fence_count; - - if (!write) { - struct dma_fence *fence = - dma_resv_get_excl_unlocked(obj->resv); - - return drm_gem_fence_array_add(fence_array, fence); - } + struct dma_resv_iter cursor; + struct dma_fence *fence; + int ret = 0; - ret = dma_resv_get_fences(obj->resv, NULL, - &fence_count, &fences); - if (ret || !fence_count) - return ret; - - for (i = 0; i < fence_count; i++) { - ret = drm_gem_fence_array_add(fence_array, fences[i]); + dma_resv_for_each_fence(&cursor, obj->resv, write, fence) { + ret = drm_gem_fence_array_add(fence_array, fence); if (ret) break; } - - for (; i < fence_count; i++) - dma_fence_put(fences[i]); - kfree(fences); return ret; } EXPORT_SYMBOL(drm_gem_fence_array_add_implicit);