[1/2] dma-buf/sync-file: fix logic error in new fence merge code

Message ID 20220329070001.134180-1-christian.koenig@amd.com (mailing list archive)
State Not Applicable
Headers
Series [1/2] dma-buf/sync-file: fix logic error in new fence merge code |

Commit Message

Christian König March 29, 2022, 7 a.m. UTC
  When the array is empty because everything is signaled we can't use
add_fence() to add something because that would filter the signaled
fence again.

Signed-off-by: Christian König <christian.koenig@amd.com>
Fixes: 519f490db07e ("dma-buf/sync-file: fix warning about fence containers")
---
 drivers/dma-buf/sync_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Thomas Hellström March 29, 2022, 7:07 a.m. UTC | #1
For the series,

Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>


On 3/29/22 09:00, Christian König wrote:
> When the array is empty because everything is signaled we can't use
> add_fence() to add something because that would filter the signaled
> fence again.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> Fixes: 519f490db07e ("dma-buf/sync-file: fix warning about fence containers")
> ---
>   drivers/dma-buf/sync_file.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
> index b8dea4ec123b..514d213261df 100644
> --- a/drivers/dma-buf/sync_file.c
> +++ b/drivers/dma-buf/sync_file.c
> @@ -262,7 +262,7 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
>   	}
>   
>   	if (index == 0)
> -		add_fence(fences, &index, dma_fence_get_stub());
> +		fences[index++] = dma_fence_get_stub();
>   
>   	if (num_fences > index) {
>   		struct dma_fence **tmp;
  
Daniel Vetter March 29, 2022, 8:46 a.m. UTC | #2
On Tue, Mar 29, 2022 at 09:00:00AM +0200, Christian König wrote:
> When the array is empty because everything is signaled we can't use
> add_fence() to add something because that would filter the signaled
> fence again.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>
> Fixes: 519f490db07e ("dma-buf/sync-file: fix warning about fence containers")
> ---
>  drivers/dma-buf/sync_file.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
> index b8dea4ec123b..514d213261df 100644
> --- a/drivers/dma-buf/sync_file.c
> +++ b/drivers/dma-buf/sync_file.c
> @@ -262,7 +262,7 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
>  	}
>  
>  	if (index == 0)
> -		add_fence(fences, &index, dma_fence_get_stub());
> +		fences[index++] = dma_fence_get_stub();

Uh idiot me wondered about this and somehow convinced myself that adding a
random fences instead of a singalled stub is ok. I should have checked
more carefully :-/

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

>  
>  	if (num_fences > index) {
>  		struct dma_fence **tmp;
> -- 
> 2.25.1
>
  
Christian König March 29, 2022, 8:49 a.m. UTC | #3
Am 29.03.22 um 10:46 schrieb Daniel Vetter:
> On Tue, Mar 29, 2022 at 09:00:00AM +0200, Christian König wrote:
>> When the array is empty because everything is signaled we can't use
>> add_fence() to add something because that would filter the signaled
>> fence again.
>>
>> Signed-off-by: Christian König <christian.koenig@amd.com>
>> Fixes: 519f490db07e ("dma-buf/sync-file: fix warning about fence containers")
>> ---
>>   drivers/dma-buf/sync_file.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
>> index b8dea4ec123b..514d213261df 100644
>> --- a/drivers/dma-buf/sync_file.c
>> +++ b/drivers/dma-buf/sync_file.c
>> @@ -262,7 +262,7 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
>>   	}
>>   
>>   	if (index == 0)
>> -		add_fence(fences, &index, dma_fence_get_stub());
>> +		fences[index++] = dma_fence_get_stub();
> Uh idiot me wondered about this and somehow convinced myself that adding a
> random fences instead of a singalled stub is ok. I should have checked
> more carefully :-/

Well idiot me wanted to clean that up fully and move all of that into 
sync_file_set_fence(), but then I though "Na, that patch is for 
next-fixes, don't make it too complicate" and then changed the code 
anyway just out of habit.

Cheers,
Christian.

>
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>
>>   
>>   	if (num_fences > index) {
>>   		struct dma_fence **tmp;
>> -- 
>> 2.25.1
>>
  
Das, Nirmoy March 29, 2022, 8:55 a.m. UTC | #4
I finally managed to find a machine and tested this series. If it is not 
too late

The series is Tested-by: Nirmoy Das <nirmoy.das@intel.com>

On 3/29/2022 9:00 AM, Christian König wrote:
> When the array is empty because everything is signaled we can't use
> add_fence() to add something because that would filter the signaled
> fence again.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> Fixes: 519f490db07e ("dma-buf/sync-file: fix warning about fence containers")
> ---
>   drivers/dma-buf/sync_file.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
> index b8dea4ec123b..514d213261df 100644
> --- a/drivers/dma-buf/sync_file.c
> +++ b/drivers/dma-buf/sync_file.c
> @@ -262,7 +262,7 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
>   	}
>   
>   	if (index == 0)
> -		add_fence(fences, &index, dma_fence_get_stub());
> +		fences[index++] = dma_fence_get_stub();
>   
>   	if (num_fences > index) {
>   		struct dma_fence **tmp;
  

Patch

diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
index b8dea4ec123b..514d213261df 100644
--- a/drivers/dma-buf/sync_file.c
+++ b/drivers/dma-buf/sync_file.c
@@ -262,7 +262,7 @@  static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
 	}
 
 	if (index == 0)
-		add_fence(fences, &index, dma_fence_get_stub());
+		fences[index++] = dma_fence_get_stub();
 
 	if (num_fences > index) {
 		struct dma_fence **tmp;