Message ID | 1502372495-1666-1-git-send-email-deathsimple@vodafone.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
> -----Original Message----- > From: amd-gfx [mailto:amd-gfx-bounces@lists.freedesktop.org] On Behalf > Of Christian König > Sent: Thursday, August 10, 2017 9:42 AM > To: amd-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org > Subject: [PATCH] dma-buf: handle NULL src_list in > reservation_object_copy_fences > > From: Christian König <christian.koenig@amd.com> > > The list of shared fences can be NULL and that needs to be handled as well. > > Signed-off-by: Christian König <christian.koenig@amd.com> I'll squash this with the original patch for upstream. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> > --- > drivers/dma-buf/reservation.c | 28 +++++++++++++++------------- > 1 file changed, 15 insertions(+), 13 deletions(-) > > diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c > index 302c137..dec3a81 100644 > --- a/drivers/dma-buf/reservation.c > +++ b/drivers/dma-buf/reservation.c > @@ -279,23 +279,25 @@ int reservation_object_copy_fences(struct > reservation_object *dst, > > src_list = reservation_object_get_list(src); > > - /* > - * resize dst->fence or allocate if it doesn't exist, > - * noop if already correct size > - */ > - size = offsetof(typeof(*src_list), shared[src_list->shared_count]); > - dst_list = kmalloc(size, GFP_KERNEL); > - if (!dst_list) > - return -ENOMEM; > + if (src_list) { > + size = offsetof(typeof(*src_list), > + shared[src_list->shared_count]); > + dst_list = kmalloc(size, GFP_KERNEL); > + if (!dst_list) > + return -ENOMEM; > + > + dst_list->shared_count = src_list->shared_count; > + dst_list->shared_max = src_list->shared_count; > + for (i = 0; i < src_list->shared_count; ++i) > + dst_list->shared[i] = > + dma_fence_get(src_list->shared[i]); > + } else { > + dst_list = NULL; > + } > > kfree(dst->staged); > dst->staged = NULL; > > - dst_list->shared_count = src_list->shared_count; > - dst_list->shared_max = src_list->shared_count; > - for (i = 0; i < src_list->shared_count; ++i) > - dst_list->shared[i] = dma_fence_get(src_list->shared[i]); > - > src_list = reservation_object_get_list(dst); > > old = reservation_object_get_excl(dst); > -- > 2.7.4 > > _______________________________________________ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 10.08.2017 um 16:40 schrieb Deucher, Alexander: >> -----Original Message----- >> From: amd-gfx [mailto:amd-gfx-bounces@lists.freedesktop.org] On Behalf >> Of Christian König >> Sent: Thursday, August 10, 2017 9:42 AM >> To: amd-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org >> Subject: [PATCH] dma-buf: handle NULL src_list in >> reservation_object_copy_fences >> >> From: Christian König <christian.koenig@amd.com> >> >> The list of shared fences can be NULL and that needs to be handled as well. >> >> Signed-off-by: Christian König <christian.koenig@amd.com> > I'll squash this with the original patch for upstream. > > Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Please note that I haven't tested this very well. You really need a prime setup for testing and that's not on my desk right now. So please ping whoever reported that problem to retest. Thanks, Christian. > >> --- >> drivers/dma-buf/reservation.c | 28 +++++++++++++++------------- >> 1 file changed, 15 insertions(+), 13 deletions(-) >> >> diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c >> index 302c137..dec3a81 100644 >> --- a/drivers/dma-buf/reservation.c >> +++ b/drivers/dma-buf/reservation.c >> @@ -279,23 +279,25 @@ int reservation_object_copy_fences(struct >> reservation_object *dst, >> >> src_list = reservation_object_get_list(src); >> >> - /* >> - * resize dst->fence or allocate if it doesn't exist, >> - * noop if already correct size >> - */ >> - size = offsetof(typeof(*src_list), shared[src_list->shared_count]); >> - dst_list = kmalloc(size, GFP_KERNEL); >> - if (!dst_list) >> - return -ENOMEM; >> + if (src_list) { >> + size = offsetof(typeof(*src_list), >> + shared[src_list->shared_count]); >> + dst_list = kmalloc(size, GFP_KERNEL); >> + if (!dst_list) >> + return -ENOMEM; >> + >> + dst_list->shared_count = src_list->shared_count; >> + dst_list->shared_max = src_list->shared_count; >> + for (i = 0; i < src_list->shared_count; ++i) >> + dst_list->shared[i] = >> + dma_fence_get(src_list->shared[i]); >> + } else { >> + dst_list = NULL; >> + } >> >> kfree(dst->staged); >> dst->staged = NULL; >> >> - dst_list->shared_count = src_list->shared_count; >> - dst_list->shared_max = src_list->shared_count; >> - for (i = 0; i < src_list->shared_count; ++i) >> - dst_list->shared[i] = dma_fence_get(src_list->shared[i]); >> - >> src_list = reservation_object_get_list(dst); >> >> old = reservation_object_get_excl(dst); >> -- >> 2.7.4 >> >> _______________________________________________ >> amd-gfx mailing list >> amd-gfx@lists.freedesktop.org >> https://lists.freedesktop.org/mailman/listinfo/amd-gfx > _______________________________________________ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
> -----Original Message----- > From: Christian König [mailto:deathsimple@vodafone.de] > Sent: Thursday, August 10, 2017 10:44 AM > To: Deucher, Alexander; amd-gfx@lists.freedesktop.org; dri- > devel@lists.freedesktop.org > Subject: Re: [PATCH] dma-buf: handle NULL src_list in > reservation_object_copy_fences > > Am 10.08.2017 um 16:40 schrieb Deucher, Alexander: > >> -----Original Message----- > >> From: amd-gfx [mailto:amd-gfx-bounces@lists.freedesktop.org] On > Behalf > >> Of Christian König > >> Sent: Thursday, August 10, 2017 9:42 AM > >> To: amd-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org > >> Subject: [PATCH] dma-buf: handle NULL src_list in > >> reservation_object_copy_fences > >> > >> From: Christian König <christian.koenig@amd.com> > >> > >> The list of shared fences can be NULL and that needs to be handled as > well. > >> > >> Signed-off-by: Christian König <christian.koenig@amd.com> > > I'll squash this with the original patch for upstream. > > > > Reviewed-by: Alex Deucher <alexander.deucher@amd.com> > > Please note that I haven't tested this very well. You really need a > prime setup for testing and that's not on my desk right now. > > So please ping whoever reported that problem to retest. FWIW, the issue was reported on a single card. Alex > > Thanks, > Christian. > > > > >> --- > >> drivers/dma-buf/reservation.c | 28 +++++++++++++++------------- > >> 1 file changed, 15 insertions(+), 13 deletions(-) > >> > >> diff --git a/drivers/dma-buf/reservation.c b/drivers/dma- > buf/reservation.c > >> index 302c137..dec3a81 100644 > >> --- a/drivers/dma-buf/reservation.c > >> +++ b/drivers/dma-buf/reservation.c > >> @@ -279,23 +279,25 @@ int reservation_object_copy_fences(struct > >> reservation_object *dst, > >> > >> src_list = reservation_object_get_list(src); > >> > >> - /* > >> - * resize dst->fence or allocate if it doesn't exist, > >> - * noop if already correct size > >> - */ > >> - size = offsetof(typeof(*src_list), shared[src_list->shared_count]); > >> - dst_list = kmalloc(size, GFP_KERNEL); > >> - if (!dst_list) > >> - return -ENOMEM; > >> + if (src_list) { > >> + size = offsetof(typeof(*src_list), > >> + shared[src_list->shared_count]); > >> + dst_list = kmalloc(size, GFP_KERNEL); > >> + if (!dst_list) > >> + return -ENOMEM; > >> + > >> + dst_list->shared_count = src_list->shared_count; > >> + dst_list->shared_max = src_list->shared_count; > >> + for (i = 0; i < src_list->shared_count; ++i) > >> + dst_list->shared[i] = > >> + dma_fence_get(src_list->shared[i]); > >> + } else { > >> + dst_list = NULL; > >> + } > >> > >> kfree(dst->staged); > >> dst->staged = NULL; > >> > >> - dst_list->shared_count = src_list->shared_count; > >> - dst_list->shared_max = src_list->shared_count; > >> - for (i = 0; i < src_list->shared_count; ++i) > >> - dst_list->shared[i] = dma_fence_get(src_list->shared[i]); > >> - > >> src_list = reservation_object_get_list(dst); > >> > >> old = reservation_object_get_excl(dst); > >> -- > >> 2.7.4 > >> > >> _______________________________________________ > >> amd-gfx mailing list > >> amd-gfx@lists.freedesktop.org > >> https://lists.freedesktop.org/mailman/listinfo/amd-gfx > > _______________________________________________ > > amd-gfx mailing list > > amd-gfx@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/amd-gfx >
diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index 302c137..dec3a81 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -279,23 +279,25 @@ int reservation_object_copy_fences(struct reservation_object *dst, src_list = reservation_object_get_list(src); - /* - * resize dst->fence or allocate if it doesn't exist, - * noop if already correct size - */ - size = offsetof(typeof(*src_list), shared[src_list->shared_count]); - dst_list = kmalloc(size, GFP_KERNEL); - if (!dst_list) - return -ENOMEM; + if (src_list) { + size = offsetof(typeof(*src_list), + shared[src_list->shared_count]); + dst_list = kmalloc(size, GFP_KERNEL); + if (!dst_list) + return -ENOMEM; + + dst_list->shared_count = src_list->shared_count; + dst_list->shared_max = src_list->shared_count; + for (i = 0; i < src_list->shared_count; ++i) + dst_list->shared[i] = + dma_fence_get(src_list->shared[i]); + } else { + dst_list = NULL; + } kfree(dst->staged); dst->staged = NULL; - dst_list->shared_count = src_list->shared_count; - dst_list->shared_max = src_list->shared_count; - for (i = 0; i < src_list->shared_count; ++i) - dst_list->shared[i] = dma_fence_get(src_list->shared[i]); - src_list = reservation_object_get_list(dst); old = reservation_object_get_excl(dst);