diff mbox

dma-buf: fix reservation_object_wait_timeout_rcu once more

Message ID 20180122193239.7674-1-christian.koenig@amd.com (mailing list archive)
State New, archived
Headers show

Commit Message

Christian König Jan. 22, 2018, 7:32 p.m. UTC
We need to set shared_count even if we already have a fence to wait for.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/dma-buf/reservation.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Lyude Paul Jan. 22, 2018, 7:42 p.m. UTC | #1
Could you please make sure to add Cc: stable@vger.kernel.org for this? This is
causing crashing of wayland sessions on Fedora so we should definitely get
this into stable.

Other then that:

Tested-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>

On Mon, 2018-01-22 at 20:32 +0100, Christian König wrote:
> We need to set shared_count even if we already have a fence to wait for.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>  drivers/dma-buf/reservation.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c
> index 461afa9febd4..649c0cebf5b1 100644
> --- a/drivers/dma-buf/reservation.c
> +++ b/drivers/dma-buf/reservation.c
> @@ -506,14 +506,14 @@ long reservation_object_wait_timeout_rcu(struct
> reservation_object *obj,
>  		fence = NULL;
>  	}
>  
> -	if (!fence && wait_all) {
> +	if (wait_all) {
>  		struct reservation_object_list *fobj =
>  						rcu_dereference(obj-
> >fence);
>  
>  		if (fobj)
>  			shared_count = fobj->shared_count;
>  
> -		for (i = 0; i < shared_count; ++i) {
> +		for (i = 0; !fence && i < shared_count; ++i) {
>  			struct dma_fence *lfence = rcu_dereference(fobj-
> >shared[i]);
>  
>  			if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
Chris Wilson Jan. 22, 2018, 7:47 p.m. UTC | #2
Quoting Christian König (2018-01-22 19:32:39)
> We need to set shared_count even if we already have a fence to wait for.

You mean for the

if (ret > 0 && wait_all && (i + 1 < shared_count)

clause.

In the case of having the exclusive fence, i=0 (erm, once), but
shared_count may still be just 1 and so we still fail to wait for the
shared fence in addition to the exclusive fence.
-Chris
Christian König Jan. 22, 2018, 7:48 p.m. UTC | #3
Am 22.01.2018 um 20:42 schrieb Lyude Paul:
> Could you please make sure to add Cc: stable@vger.kernel.org for this?
Sure, just pushed into our upstream branch.

Alex can you pick that up for your next drm-fixes pull request?

Sorry for the noise,
Christian.

>   This is
> causing crashing of wayland sessions on Fedora so we should definitely get
> this into stable.
>
> Other then that:
>
> Tested-by: Lyude Paul <lyude@redhat.com>
> Reviewed-by: Lyude Paul <lyude@redhat.com>
>
> On Mon, 2018-01-22 at 20:32 +0100, Christian König wrote:
>> We need to set shared_count even if we already have a fence to wait for.
>>
>> Signed-off-by: Christian König <christian.koenig@amd.com>
>> ---
>>   drivers/dma-buf/reservation.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c
>> index 461afa9febd4..649c0cebf5b1 100644
>> --- a/drivers/dma-buf/reservation.c
>> +++ b/drivers/dma-buf/reservation.c
>> @@ -506,14 +506,14 @@ long reservation_object_wait_timeout_rcu(struct
>> reservation_object *obj,
>>   		fence = NULL;
>>   	}
>>   
>> -	if (!fence && wait_all) {
>> +	if (wait_all) {
>>   		struct reservation_object_list *fobj =
>>   						rcu_dereference(obj-
>>> fence);
>>   
>>   		if (fobj)
>>   			shared_count = fobj->shared_count;
>>   
>> -		for (i = 0; i < shared_count; ++i) {
>> +		for (i = 0; !fence && i < shared_count; ++i) {
>>   			struct dma_fence *lfence = rcu_dereference(fobj-
>>> shared[i]);
>>   
>>   			if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
Christian König Jan. 22, 2018, 8:01 p.m. UTC | #4
Am 22.01.2018 um 20:47 schrieb Chris Wilson:
> Quoting Christian König (2018-01-22 19:32:39)
>> We need to set shared_count even if we already have a fence to wait for.
> You mean for the
>
> if (ret > 0 && wait_all && (i + 1 < shared_count)
>
> clause.
>
> In the case of having the exclusive fence, i=0 (erm, once), but
> shared_count may still be just 1 and so we still fail to wait for the
> shared fence in addition to the exclusive fence.

Ah, crap. Good point. V2 is on the list, please take a look.

Thanks,
Christian.

> -Chris
diff mbox

Patch

diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c
index 461afa9febd4..649c0cebf5b1 100644
--- a/drivers/dma-buf/reservation.c
+++ b/drivers/dma-buf/reservation.c
@@ -506,14 +506,14 @@  long reservation_object_wait_timeout_rcu(struct reservation_object *obj,
 		fence = NULL;
 	}
 
-	if (!fence && wait_all) {
+	if (wait_all) {
 		struct reservation_object_list *fobj =
 						rcu_dereference(obj->fence);
 
 		if (fobj)
 			shared_count = fobj->shared_count;
 
-		for (i = 0; i < shared_count; ++i) {
+		for (i = 0; !fence && i < shared_count; ++i) {
 			struct dma_fence *lfence = rcu_dereference(fobj->shared[i]);
 
 			if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT,