* [PATCH 1/2] dma-buf/sync-file: fix logic error in new fence merge code
@ 2022-03-29 7:00 ` Christian König
0 siblings, 0 replies; 21+ messages in thread
From: Christian König @ 2022-03-29 7:00 UTC (permalink / raw)
To: intel-gfx, dri-devel, linux-media, linaro-mm-sig, ville.syrjala, daniel
Cc: Christian König
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;
--
2.25.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Intel-gfx] [PATCH 1/2] dma-buf/sync-file: fix logic error in new fence merge code
@ 2022-03-29 7:00 ` Christian König
0 siblings, 0 replies; 21+ messages in thread
From: Christian König @ 2022-03-29 7:00 UTC (permalink / raw)
To: intel-gfx, dri-devel, linux-media, linaro-mm-sig, ville.syrjala, daniel
Cc: Christian König
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;
--
2.25.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 2/2] dma-buf: handle empty dma_fence_arrays gracefully
2022-03-29 7:00 ` [Intel-gfx] " Christian König
@ 2022-03-29 7:00 ` Christian König
-1 siblings, 0 replies; 21+ messages in thread
From: Christian König @ 2022-03-29 7:00 UTC (permalink / raw)
To: intel-gfx, dri-devel, linux-media, linaro-mm-sig, ville.syrjala, daniel
Cc: Christian König
A bug inside the new sync-file merge code created empty dma_fence_array instances.
Warn about that and handle those without crashing.
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/dma-buf/dma-fence-array.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
index 52b85d292383..5c8a7084577b 100644
--- a/drivers/dma-buf/dma-fence-array.c
+++ b/drivers/dma-buf/dma-fence-array.c
@@ -159,6 +159,8 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
struct dma_fence_array *array;
size_t size = sizeof(*array);
+ WARN_ON(!num_fences || !fences);
+
/* Allocate the callback structures behind the array. */
size += num_fences * sizeof(struct dma_fence_array_cb);
array = kzalloc(size, GFP_KERNEL);
@@ -231,6 +233,9 @@ struct dma_fence *dma_fence_array_first(struct dma_fence *head)
if (!array)
return head;
+ if (!array->num_fences)
+ return NULL;
+
return array->fences[0];
}
EXPORT_SYMBOL(dma_fence_array_first);
--
2.25.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Intel-gfx] [PATCH 2/2] dma-buf: handle empty dma_fence_arrays gracefully
@ 2022-03-29 7:00 ` Christian König
0 siblings, 0 replies; 21+ messages in thread
From: Christian König @ 2022-03-29 7:00 UTC (permalink / raw)
To: intel-gfx, dri-devel, linux-media, linaro-mm-sig, ville.syrjala, daniel
Cc: Christian König
A bug inside the new sync-file merge code created empty dma_fence_array instances.
Warn about that and handle those without crashing.
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/dma-buf/dma-fence-array.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
index 52b85d292383..5c8a7084577b 100644
--- a/drivers/dma-buf/dma-fence-array.c
+++ b/drivers/dma-buf/dma-fence-array.c
@@ -159,6 +159,8 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
struct dma_fence_array *array;
size_t size = sizeof(*array);
+ WARN_ON(!num_fences || !fences);
+
/* Allocate the callback structures behind the array. */
size += num_fences * sizeof(struct dma_fence_array_cb);
array = kzalloc(size, GFP_KERNEL);
@@ -231,6 +233,9 @@ struct dma_fence *dma_fence_array_first(struct dma_fence *head)
if (!array)
return head;
+ if (!array->num_fences)
+ return NULL;
+
return array->fences[0];
}
EXPORT_SYMBOL(dma_fence_array_first);
--
2.25.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [Intel-gfx] [Linaro-mm-sig] [PATCH 1/2] dma-buf/sync-file: fix logic error in new fence merge code
2022-03-29 7:00 ` [Intel-gfx] " Christian König
@ 2022-03-29 7:07 ` Thomas Hellström
-1 siblings, 0 replies; 21+ messages in thread
From: Thomas Hellström @ 2022-03-29 7:07 UTC (permalink / raw)
To: Christian König, intel-gfx, dri-devel, linux-media,
linaro-mm-sig, ville.syrjala, daniel
Cc: Christian König
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;
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Linaro-mm-sig] [PATCH 1/2] dma-buf/sync-file: fix logic error in new fence merge code
@ 2022-03-29 7:07 ` Thomas Hellström
0 siblings, 0 replies; 21+ messages in thread
From: Thomas Hellström @ 2022-03-29 7:07 UTC (permalink / raw)
To: Christian König, intel-gfx, dri-devel, linux-media,
linaro-mm-sig, ville.syrjala, daniel
Cc: Christian König
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;
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 1/2] dma-buf/sync-file: fix logic error in new fence merge code
2022-03-29 7:00 ` [Intel-gfx] " Christian König
(?)
@ 2022-03-29 8:46 ` Daniel Vetter
-1 siblings, 0 replies; 21+ messages in thread
From: Daniel Vetter @ 2022-03-29 8:46 UTC (permalink / raw)
To: Christian König
Cc: intel-gfx, dri-devel, linux-media, linaro-mm-sig, ville.syrjala,
daniel, Christian König
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
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 1/2] dma-buf/sync-file: fix logic error in new fence merge code
@ 2022-03-29 8:46 ` Daniel Vetter
0 siblings, 0 replies; 21+ messages in thread
From: Daniel Vetter @ 2022-03-29 8:46 UTC (permalink / raw)
To: Christian König
Cc: intel-gfx, dri-devel, linaro-mm-sig, Christian König, linux-media
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
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Intel-gfx] [PATCH 1/2] dma-buf/sync-file: fix logic error in new fence merge code
@ 2022-03-29 8:46 ` Daniel Vetter
0 siblings, 0 replies; 21+ messages in thread
From: Daniel Vetter @ 2022-03-29 8:46 UTC (permalink / raw)
To: Christian König
Cc: intel-gfx, dri-devel, linaro-mm-sig, Christian König, linux-media
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
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/2] dma-buf: handle empty dma_fence_arrays gracefully
2022-03-29 7:00 ` [Intel-gfx] " Christian König
(?)
@ 2022-03-29 8:48 ` Daniel Vetter
-1 siblings, 0 replies; 21+ messages in thread
From: Daniel Vetter @ 2022-03-29 8:48 UTC (permalink / raw)
To: Christian König
Cc: intel-gfx, dri-devel, linux-media, linaro-mm-sig, ville.syrjala,
daniel, Christian König
On Tue, Mar 29, 2022 at 09:00:01AM +0200, Christian König wrote:
> A bug inside the new sync-file merge code created empty dma_fence_array instances.
>
> Warn about that and handle those without crashing.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/dma-buf/dma-fence-array.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
> index 52b85d292383..5c8a7084577b 100644
> --- a/drivers/dma-buf/dma-fence-array.c
> +++ b/drivers/dma-buf/dma-fence-array.c
> @@ -159,6 +159,8 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
> struct dma_fence_array *array;
> size_t size = sizeof(*array);
>
> + WARN_ON(!num_fences || !fences);
WARN_ON and then dying randomly is kinda not nice, I'd wrap this in an
if (WARN_ON)
return NULL;
with that: Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> +
> /* Allocate the callback structures behind the array. */
> size += num_fences * sizeof(struct dma_fence_array_cb);
> array = kzalloc(size, GFP_KERNEL);
> @@ -231,6 +233,9 @@ struct dma_fence *dma_fence_array_first(struct dma_fence *head)
> if (!array)
> return head;
>
> + if (!array->num_fences)
> + return NULL;
> +
> return array->fences[0];
> }
> EXPORT_SYMBOL(dma_fence_array_first);
> --
> 2.25.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/2] dma-buf: handle empty dma_fence_arrays gracefully
@ 2022-03-29 8:48 ` Daniel Vetter
0 siblings, 0 replies; 21+ messages in thread
From: Daniel Vetter @ 2022-03-29 8:48 UTC (permalink / raw)
To: Christian König
Cc: intel-gfx, dri-devel, linaro-mm-sig, Christian König, linux-media
On Tue, Mar 29, 2022 at 09:00:01AM +0200, Christian König wrote:
> A bug inside the new sync-file merge code created empty dma_fence_array instances.
>
> Warn about that and handle those without crashing.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/dma-buf/dma-fence-array.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
> index 52b85d292383..5c8a7084577b 100644
> --- a/drivers/dma-buf/dma-fence-array.c
> +++ b/drivers/dma-buf/dma-fence-array.c
> @@ -159,6 +159,8 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
> struct dma_fence_array *array;
> size_t size = sizeof(*array);
>
> + WARN_ON(!num_fences || !fences);
WARN_ON and then dying randomly is kinda not nice, I'd wrap this in an
if (WARN_ON)
return NULL;
with that: Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> +
> /* Allocate the callback structures behind the array. */
> size += num_fences * sizeof(struct dma_fence_array_cb);
> array = kzalloc(size, GFP_KERNEL);
> @@ -231,6 +233,9 @@ struct dma_fence *dma_fence_array_first(struct dma_fence *head)
> if (!array)
> return head;
>
> + if (!array->num_fences)
> + return NULL;
> +
> return array->fences[0];
> }
> EXPORT_SYMBOL(dma_fence_array_first);
> --
> 2.25.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Intel-gfx] [PATCH 2/2] dma-buf: handle empty dma_fence_arrays gracefully
@ 2022-03-29 8:48 ` Daniel Vetter
0 siblings, 0 replies; 21+ messages in thread
From: Daniel Vetter @ 2022-03-29 8:48 UTC (permalink / raw)
To: Christian König
Cc: intel-gfx, dri-devel, linaro-mm-sig, Christian König, linux-media
On Tue, Mar 29, 2022 at 09:00:01AM +0200, Christian König wrote:
> A bug inside the new sync-file merge code created empty dma_fence_array instances.
>
> Warn about that and handle those without crashing.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/dma-buf/dma-fence-array.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
> index 52b85d292383..5c8a7084577b 100644
> --- a/drivers/dma-buf/dma-fence-array.c
> +++ b/drivers/dma-buf/dma-fence-array.c
> @@ -159,6 +159,8 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
> struct dma_fence_array *array;
> size_t size = sizeof(*array);
>
> + WARN_ON(!num_fences || !fences);
WARN_ON and then dying randomly is kinda not nice, I'd wrap this in an
if (WARN_ON)
return NULL;
with that: Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> +
> /* Allocate the callback structures behind the array. */
> size += num_fences * sizeof(struct dma_fence_array_cb);
> array = kzalloc(size, GFP_KERNEL);
> @@ -231,6 +233,9 @@ struct dma_fence *dma_fence_array_first(struct dma_fence *head)
> if (!array)
> return head;
>
> + if (!array->num_fences)
> + return NULL;
> +
> return array->fences[0];
> }
> EXPORT_SYMBOL(dma_fence_array_first);
> --
> 2.25.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 1/2] dma-buf/sync-file: fix logic error in new fence merge code
2022-03-29 8:46 ` Daniel Vetter
(?)
@ 2022-03-29 8:49 ` Christian König
-1 siblings, 0 replies; 21+ messages in thread
From: Christian König @ 2022-03-29 8:49 UTC (permalink / raw)
To: Daniel Vetter, Christian König
Cc: intel-gfx, dri-devel, linux-media, linaro-mm-sig, ville.syrjala
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
>>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 1/2] dma-buf/sync-file: fix logic error in new fence merge code
@ 2022-03-29 8:49 ` Christian König
0 siblings, 0 replies; 21+ messages in thread
From: Christian König @ 2022-03-29 8:49 UTC (permalink / raw)
To: Daniel Vetter, Christian König
Cc: linaro-mm-sig, intel-gfx, dri-devel, linux-media
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
>>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Intel-gfx] [PATCH 1/2] dma-buf/sync-file: fix logic error in new fence merge code
@ 2022-03-29 8:49 ` Christian König
0 siblings, 0 replies; 21+ messages in thread
From: Christian König @ 2022-03-29 8:49 UTC (permalink / raw)
To: Daniel Vetter, Christian König
Cc: linaro-mm-sig, intel-gfx, dri-devel, linux-media
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
>>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/2] dma-buf: handle empty dma_fence_arrays gracefully
2022-03-29 8:48 ` Daniel Vetter
(?)
@ 2022-03-29 8:49 ` Daniel Vetter
-1 siblings, 0 replies; 21+ messages in thread
From: Daniel Vetter @ 2022-03-29 8:49 UTC (permalink / raw)
To: Christian König
Cc: intel-gfx, dri-devel, linaro-mm-sig, Christian König, linux-media
On Tue, Mar 29, 2022 at 10:48:10AM +0200, Daniel Vetter wrote:
> On Tue, Mar 29, 2022 at 09:00:01AM +0200, Christian König wrote:
> > A bug inside the new sync-file merge code created empty dma_fence_array instances.
> >
> > Warn about that and handle those without crashing.
> >
> > Signed-off-by: Christian König <christian.koenig@amd.com>
>
> > ---
> > drivers/dma-buf/dma-fence-array.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
> > index 52b85d292383..5c8a7084577b 100644
> > --- a/drivers/dma-buf/dma-fence-array.c
> > +++ b/drivers/dma-buf/dma-fence-array.c
> > @@ -159,6 +159,8 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
> > struct dma_fence_array *array;
> > size_t size = sizeof(*array);
> >
> > + WARN_ON(!num_fences || !fences);
>
> WARN_ON and then dying randomly is kinda not nice, I'd wrap this in an
>
> if (WARN_ON)
> return NULL;
>
> with that: Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Uh strike that, you handle it gracefully with the check below.
>
> > +
> > /* Allocate the callback structures behind the array. */
> > size += num_fences * sizeof(struct dma_fence_array_cb);
> > array = kzalloc(size, GFP_KERNEL);
> > @@ -231,6 +233,9 @@ struct dma_fence *dma_fence_array_first(struct dma_fence *head)
> > if (!array)
> > return head;
> >
Maybe add a comment here that this is just defensive programming, like
/* No fences isn't allowed and splats in create, but be defensive */
Either way Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> I guess,
coffee not quite yet working.
-Daniel
> > + if (!array->num_fences)
> > + return NULL;
> > +
> > return array->fences[0];
> > }
> > EXPORT_SYMBOL(dma_fence_array_first);
> > --
> > 2.25.1
> >
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/2] dma-buf: handle empty dma_fence_arrays gracefully
@ 2022-03-29 8:49 ` Daniel Vetter
0 siblings, 0 replies; 21+ messages in thread
From: Daniel Vetter @ 2022-03-29 8:49 UTC (permalink / raw)
To: Christian König
Cc: intel-gfx, dri-devel, linux-media, linaro-mm-sig, ville.syrjala,
daniel, Christian König
On Tue, Mar 29, 2022 at 10:48:10AM +0200, Daniel Vetter wrote:
> On Tue, Mar 29, 2022 at 09:00:01AM +0200, Christian König wrote:
> > A bug inside the new sync-file merge code created empty dma_fence_array instances.
> >
> > Warn about that and handle those without crashing.
> >
> > Signed-off-by: Christian König <christian.koenig@amd.com>
>
> > ---
> > drivers/dma-buf/dma-fence-array.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
> > index 52b85d292383..5c8a7084577b 100644
> > --- a/drivers/dma-buf/dma-fence-array.c
> > +++ b/drivers/dma-buf/dma-fence-array.c
> > @@ -159,6 +159,8 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
> > struct dma_fence_array *array;
> > size_t size = sizeof(*array);
> >
> > + WARN_ON(!num_fences || !fences);
>
> WARN_ON and then dying randomly is kinda not nice, I'd wrap this in an
>
> if (WARN_ON)
> return NULL;
>
> with that: Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Uh strike that, you handle it gracefully with the check below.
>
> > +
> > /* Allocate the callback structures behind the array. */
> > size += num_fences * sizeof(struct dma_fence_array_cb);
> > array = kzalloc(size, GFP_KERNEL);
> > @@ -231,6 +233,9 @@ struct dma_fence *dma_fence_array_first(struct dma_fence *head)
> > if (!array)
> > return head;
> >
Maybe add a comment here that this is just defensive programming, like
/* No fences isn't allowed and splats in create, but be defensive */
Either way Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> I guess,
coffee not quite yet working.
-Daniel
> > + if (!array->num_fences)
> > + return NULL;
> > +
> > return array->fences[0];
> > }
> > EXPORT_SYMBOL(dma_fence_array_first);
> > --
> > 2.25.1
> >
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Intel-gfx] [PATCH 2/2] dma-buf: handle empty dma_fence_arrays gracefully
@ 2022-03-29 8:49 ` Daniel Vetter
0 siblings, 0 replies; 21+ messages in thread
From: Daniel Vetter @ 2022-03-29 8:49 UTC (permalink / raw)
To: Christian König
Cc: intel-gfx, dri-devel, linaro-mm-sig, Christian König, linux-media
On Tue, Mar 29, 2022 at 10:48:10AM +0200, Daniel Vetter wrote:
> On Tue, Mar 29, 2022 at 09:00:01AM +0200, Christian König wrote:
> > A bug inside the new sync-file merge code created empty dma_fence_array instances.
> >
> > Warn about that and handle those without crashing.
> >
> > Signed-off-by: Christian König <christian.koenig@amd.com>
>
> > ---
> > drivers/dma-buf/dma-fence-array.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
> > index 52b85d292383..5c8a7084577b 100644
> > --- a/drivers/dma-buf/dma-fence-array.c
> > +++ b/drivers/dma-buf/dma-fence-array.c
> > @@ -159,6 +159,8 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
> > struct dma_fence_array *array;
> > size_t size = sizeof(*array);
> >
> > + WARN_ON(!num_fences || !fences);
>
> WARN_ON and then dying randomly is kinda not nice, I'd wrap this in an
>
> if (WARN_ON)
> return NULL;
>
> with that: Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Uh strike that, you handle it gracefully with the check below.
>
> > +
> > /* Allocate the callback structures behind the array. */
> > size += num_fences * sizeof(struct dma_fence_array_cb);
> > array = kzalloc(size, GFP_KERNEL);
> > @@ -231,6 +233,9 @@ struct dma_fence *dma_fence_array_first(struct dma_fence *head)
> > if (!array)
> > return head;
> >
Maybe add a comment here that this is just defensive programming, like
/* No fences isn't allowed and splats in create, but be defensive */
Either way Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> I guess,
coffee not quite yet working.
-Daniel
> > + if (!array->num_fences)
> > + return NULL;
> > +
> > return array->fences[0];
> > }
> > EXPORT_SYMBOL(dma_fence_array_first);
> > --
> > 2.25.1
> >
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 1/2] dma-buf/sync-file: fix logic error in new fence merge code
2022-03-29 7:00 ` [Intel-gfx] " Christian König
@ 2022-03-29 8:55 ` Das, Nirmoy
-1 siblings, 0 replies; 21+ messages in thread
From: Das, Nirmoy @ 2022-03-29 8:55 UTC (permalink / raw)
To: Christian König, intel-gfx, dri-devel, linux-media,
linaro-mm-sig, ville.syrjala, daniel
Cc: Christian König
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;
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Intel-gfx] [PATCH 1/2] dma-buf/sync-file: fix logic error in new fence merge code
@ 2022-03-29 8:55 ` Das, Nirmoy
0 siblings, 0 replies; 21+ messages in thread
From: Das, Nirmoy @ 2022-03-29 8:55 UTC (permalink / raw)
To: Christian König, intel-gfx, dri-devel, linux-media,
linaro-mm-sig, ville.syrjala, daniel
Cc: Christian König
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;
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Intel-gfx] ✗ Fi.CI.BAT: failure for series starting with [1/2] dma-buf/sync-file: fix logic error in new fence merge code
2022-03-29 7:00 ` [Intel-gfx] " Christian König
` (4 preceding siblings ...)
(?)
@ 2022-03-29 13:10 ` Patchwork
-1 siblings, 0 replies; 21+ messages in thread
From: Patchwork @ 2022-03-29 13:10 UTC (permalink / raw)
To: Christian König; +Cc: intel-gfx
[-- Attachment #1: Type: text/plain, Size: 668 bytes --]
== Series Details ==
Series: series starting with [1/2] dma-buf/sync-file: fix logic error in new fence merge code
URL : https://patchwork.freedesktop.org/series/101923/
State : failure
== Summary ==
Applying: dma-buf/sync-file: fix logic error in new fence merge code
Using index info to reconstruct a base tree...
M drivers/dma-buf/sync_file.c
Falling back to patching base and 3-way merge...
No changes -- Patch already applied.
Applying: dma-buf: handle empty dma_fence_arrays gracefully
Using index info to reconstruct a base tree...
M drivers/dma-buf/dma-fence-array.c
Falling back to patching base and 3-way merge...
No changes -- Patch already applied.
[-- Attachment #2: Type: text/html, Size: 1195 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2022-03-29 13:10 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29 7:00 [PATCH 1/2] dma-buf/sync-file: fix logic error in new fence merge code Christian König
2022-03-29 7:00 ` [Intel-gfx] " Christian König
2022-03-29 7:00 ` [PATCH 2/2] dma-buf: handle empty dma_fence_arrays gracefully Christian König
2022-03-29 7:00 ` [Intel-gfx] " Christian König
2022-03-29 8:48 ` Daniel Vetter
2022-03-29 8:48 ` [Intel-gfx] " Daniel Vetter
2022-03-29 8:48 ` Daniel Vetter
2022-03-29 8:49 ` Daniel Vetter
2022-03-29 8:49 ` [Intel-gfx] " Daniel Vetter
2022-03-29 8:49 ` Daniel Vetter
2022-03-29 7:07 ` [Intel-gfx] [Linaro-mm-sig] [PATCH 1/2] dma-buf/sync-file: fix logic error in new fence merge code Thomas Hellström
2022-03-29 7:07 ` Thomas Hellström
2022-03-29 8:46 ` Daniel Vetter
2022-03-29 8:46 ` [Intel-gfx] " Daniel Vetter
2022-03-29 8:46 ` Daniel Vetter
2022-03-29 8:49 ` Christian König
2022-03-29 8:49 ` [Intel-gfx] " Christian König
2022-03-29 8:49 ` Christian König
2022-03-29 8:55 ` Das, Nirmoy
2022-03-29 8:55 ` [Intel-gfx] " Das, Nirmoy
2022-03-29 13:10 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for series starting with [1/2] " Patchwork
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.