* [PATCH 05/62] dma-buf: Convert dma_buf_import_sync_file() to the early-return style [not found] <20260223220102.2158611-1-bart.vanassche@linux.dev> @ 2026-02-23 22:00 ` Bart Van Assche 2026-02-23 22:00 ` [PATCH 06/62] dma-buf: Handle all dma_resv_lock() errors Bart Van Assche 1 sibling, 0 replies; 6+ messages in thread From: Bart Van Assche @ 2026-02-23 22:00 UTC (permalink / raw) To: Peter Zijlstra Cc: Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long, linux-kernel, Marco Elver, Christoph Hellwig, Steven Rostedt, Nick Desaulniers, Nathan Chancellor, Kees Cook, Jann Horn, Bart Van Assche, Sumit Semwal, Christian König, linux-media From: Bart Van Assche <bvanassche@acm.org> Before making changes in dma_buf_import_sync_file(), convert it to the early-return coding style. No functionality has been changed. Cc: Sumit Semwal <sumit.semwal@linaro.org> Cc: Christian König <christian.koenig@amd.com> Cc: linux-media@vger.kernel.org Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- drivers/dma-buf/dma-buf.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 11711874a325..1666133ac8b8 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -523,11 +523,13 @@ static long dma_buf_import_sync_file(struct dma_buf *dmabuf, dma_resv_lock(dmabuf->resv, NULL); ret = dma_resv_reserve_fences(dmabuf->resv, num_fences); - if (!ret) { - dma_fence_unwrap_for_each(f, &iter, fence) - dma_resv_add_fence(dmabuf->resv, f, usage); - } + if (ret) + goto unlock; + + dma_fence_unwrap_for_each(f, &iter, fence) + dma_resv_add_fence(dmabuf->resv, f, usage); +unlock: dma_resv_unlock(dmabuf->resv); } ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 06/62] dma-buf: Handle all dma_resv_lock() errors [not found] <20260223220102.2158611-1-bart.vanassche@linux.dev> 2026-02-23 22:00 ` [PATCH 05/62] dma-buf: Convert dma_buf_import_sync_file() to the early-return style Bart Van Assche @ 2026-02-23 22:00 ` Bart Van Assche 1 sibling, 0 replies; 6+ messages in thread From: Bart Van Assche @ 2026-02-23 22:00 UTC (permalink / raw) To: Peter Zijlstra Cc: Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long, linux-kernel, Marco Elver, Christoph Hellwig, Steven Rostedt, Nick Desaulniers, Nathan Chancellor, Kees Cook, Jann Horn, Bart Van Assche, Sumit Semwal, Christian König, linux-media From: Bart Van Assche <bvanassche@acm.org> Instead of assuming that dma_resv_lock() only returns 0 or -EDEADLK, handle all possible dma_resv_lock() return values. This patch prepares for enabling compile-time thread-safety analysis. This will cause the compiler to check whether all dma_resv_lock() return values are handled. Cc: Sumit Semwal <sumit.semwal@linaro.org> Cc: Christian König <christian.koenig@amd.com> Cc: linux-media@vger.kernel.org Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- drivers/dma-buf/dma-resv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index bea3e9858aca..b4710f730e9b 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -792,6 +792,8 @@ static int __init dma_resv_lockdep(void) ret = dma_resv_lock(&obj, &ctx); if (ret == -EDEADLK) dma_resv_lock_slow(&obj, &ctx); + else if (ret) + goto fini; fs_reclaim_acquire(GFP_KERNEL); /* for unmap_mapping_range on trylocked buffer objects in shrinkers */ i_mmap_lock_write(&mapping); @@ -805,12 +807,14 @@ static int __init dma_resv_lockdep(void) #endif fs_reclaim_release(GFP_KERNEL); ww_mutex_unlock(&obj.lock); + +fini: ww_acquire_fini(&ctx); mmap_read_unlock(mm); mmput(mm); - return 0; + return ret; } subsys_initcall(dma_resv_lockdep); #endif ^ permalink raw reply related [flat|nested] 6+ messages in thread
[parent not found: <20260223215118.2154194-1-bvanassche@acm.org>]
* [PATCH 05/62] dma-buf: Convert dma_buf_import_sync_file() to the early-return style [not found] <20260223215118.2154194-1-bvanassche@acm.org> @ 2026-02-23 21:50 ` Bart Van Assche 0 siblings, 0 replies; 6+ messages in thread From: Bart Van Assche @ 2026-02-23 21:50 UTC (permalink / raw) To: Peter Zijlstra Cc: Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long, linux-kernel, Marco Elver, Christoph Hellwig, Steven Rostedt, Nick Desaulniers, Nathan Chancellor, Kees Cook, Jann Horn, Bart Van Assche, Sumit Semwal, Christian König, linux-media Before making changes in dma_buf_import_sync_file(), convert it to the early-return coding style. No functionality has been changed. Cc: Sumit Semwal <sumit.semwal@linaro.org> Cc: Christian König <christian.koenig@amd.com> Cc: linux-media@vger.kernel.org Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- drivers/dma-buf/dma-buf.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 11711874a325..1666133ac8b8 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -523,11 +523,13 @@ static long dma_buf_import_sync_file(struct dma_buf *dmabuf, dma_resv_lock(dmabuf->resv, NULL); ret = dma_resv_reserve_fences(dmabuf->resv, num_fences); - if (!ret) { - dma_fence_unwrap_for_each(f, &iter, fence) - dma_resv_add_fence(dmabuf->resv, f, usage); - } + if (ret) + goto unlock; + + dma_fence_unwrap_for_each(f, &iter, fence) + dma_resv_add_fence(dmabuf->resv, f, usage); +unlock: dma_resv_unlock(dmabuf->resv); } ^ permalink raw reply related [flat|nested] 6+ messages in thread
[parent not found: <20260223214950.2153735-1-bvanassche@acm.org>]
* [PATCH 05/62] dma-buf: Convert dma_buf_import_sync_file() to the early-return style [not found] <20260223214950.2153735-1-bvanassche@acm.org> @ 2026-02-23 21:48 ` Bart Van Assche 2026-02-24 7:56 ` Christian König 0 siblings, 1 reply; 6+ messages in thread From: Bart Van Assche @ 2026-02-23 21:48 UTC (permalink / raw) To: Peter Zijlstra Cc: Bart Van Assche, Sumit Semwal, Christian König, linux-media Before making changes in dma_buf_import_sync_file(), convert it to the early-return coding style. No functionality has been changed. Cc: Sumit Semwal <sumit.semwal@linaro.org> Cc: Christian König <christian.koenig@amd.com> Cc: linux-media@vger.kernel.org Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- drivers/dma-buf/dma-buf.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 11711874a325..1666133ac8b8 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -523,11 +523,13 @@ static long dma_buf_import_sync_file(struct dma_buf *dmabuf, dma_resv_lock(dmabuf->resv, NULL); ret = dma_resv_reserve_fences(dmabuf->resv, num_fences); - if (!ret) { - dma_fence_unwrap_for_each(f, &iter, fence) - dma_resv_add_fence(dmabuf->resv, f, usage); - } + if (ret) + goto unlock; + + dma_fence_unwrap_for_each(f, &iter, fence) + dma_resv_add_fence(dmabuf->resv, f, usage); +unlock: dma_resv_unlock(dmabuf->resv); } ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 05/62] dma-buf: Convert dma_buf_import_sync_file() to the early-return style 2026-02-23 21:48 ` Bart Van Assche @ 2026-02-24 7:56 ` Christian König 2026-02-25 21:58 ` Bart Van Assche 0 siblings, 1 reply; 6+ messages in thread From: Christian König @ 2026-02-24 7:56 UTC (permalink / raw) To: Bart Van Assche, Peter Zijlstra; +Cc: Sumit Semwal, linux-media On 2/23/26 22:48, Bart Van Assche wrote: > Before making changes in dma_buf_import_sync_file(), convert it to > the early-return coding style. No functionality has been changed. > > Cc: Sumit Semwal <sumit.semwal@linaro.org> > Cc: Christian König <christian.koenig@amd.com> > Cc: linux-media@vger.kernel.org > Signed-off-by: Bart Van Assche <bvanassche@acm.org> > --- > drivers/dma-buf/dma-buf.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c > index 11711874a325..1666133ac8b8 100644 > --- a/drivers/dma-buf/dma-buf.c > +++ b/drivers/dma-buf/dma-buf.c > @@ -523,11 +523,13 @@ static long dma_buf_import_sync_file(struct dma_buf *dmabuf, > dma_resv_lock(dmabuf->resv, NULL); > > ret = dma_resv_reserve_fences(dmabuf->resv, num_fences); > - if (!ret) { > - dma_fence_unwrap_for_each(f, &iter, fence) > - dma_resv_add_fence(dmabuf->resv, f, usage); > - } > + if (ret) > + goto unlock; > + > + dma_fence_unwrap_for_each(f, &iter, fence) > + dma_resv_add_fence(dmabuf->resv, f, usage); Mhm, I don't see what this is good for? While this might look a little bit nicer we don't enforce this coding style and it adds more loc. Regards, Christian. > > +unlock: > dma_resv_unlock(dmabuf->resv); > } > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 05/62] dma-buf: Convert dma_buf_import_sync_file() to the early-return style 2026-02-24 7:56 ` Christian König @ 2026-02-25 21:58 ` Bart Van Assche 0 siblings, 0 replies; 6+ messages in thread From: Bart Van Assche @ 2026-02-25 21:58 UTC (permalink / raw) To: Christian König, Peter Zijlstra; +Cc: Sumit Semwal, linux-media On 2/23/26 11:56 PM, Christian König wrote: > On 2/23/26 22:48, Bart Van Assche wrote: >> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c >> index 11711874a325..1666133ac8b8 100644 >> --- a/drivers/dma-buf/dma-buf.c >> +++ b/drivers/dma-buf/dma-buf.c >> @@ -523,11 +523,13 @@ static long dma_buf_import_sync_file(struct dma_buf *dmabuf, >> dma_resv_lock(dmabuf->resv, NULL); >> >> ret = dma_resv_reserve_fences(dmabuf->resv, num_fences); >> - if (!ret) { >> - dma_fence_unwrap_for_each(f, &iter, fence) >> - dma_resv_add_fence(dmabuf->resv, f, usage); >> - } >> + if (ret) >> + goto unlock; >> + >> + dma_fence_unwrap_for_each(f, &iter, fence) >> + dma_resv_add_fence(dmabuf->resv, f, usage); > > Mhm, I don't see what this is good for? > > While this might look a little bit nicer we don't enforce this coding style and it adds more loc. Hi Christian, I will drop this change. Thanks, Bart. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-02-25 21:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260223220102.2158611-1-bart.vanassche@linux.dev>
2026-02-23 22:00 ` [PATCH 05/62] dma-buf: Convert dma_buf_import_sync_file() to the early-return style Bart Van Assche
2026-02-23 22:00 ` [PATCH 06/62] dma-buf: Handle all dma_resv_lock() errors Bart Van Assche
[not found] <20260223215118.2154194-1-bvanassche@acm.org>
2026-02-23 21:50 ` [PATCH 05/62] dma-buf: Convert dma_buf_import_sync_file() to the early-return style Bart Van Assche
[not found] <20260223214950.2153735-1-bvanassche@acm.org>
2026-02-23 21:48 ` Bart Van Assche
2026-02-24 7:56 ` Christian König
2026-02-25 21:58 ` Bart Van Assche
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox