[4/4] dma-buf: warn about containers in dma_resv object

Message ID 20220119134339.3102-4-christian.koenig@amd.com (mailing list archive)
State Not Applicable, archived
Headers
Series [1/4] dma-buf: consolidate dma_fence subclass checking |

Commit Message

Christian König Jan. 19, 2022, 1:43 p.m. UTC
  Drivers should not add containers as shared fences to the dma_resv
object, instead each fence should be added individually.

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

Comments

Daniel Vetter Jan. 19, 2022, 5:19 p.m. UTC | #1
On Wed, Jan 19, 2022 at 02:43:39PM +0100, Christian König wrote:
> Drivers should not add containers as shared fences to the dma_resv
> object, instead each fence should be added individually.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>  drivers/dma-buf/dma-resv.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
> index 6dd9a40b55d4..e8a0c1d51da2 100644
> --- a/drivers/dma-buf/dma-resv.c
> +++ b/drivers/dma-buf/dma-resv.c
> @@ -256,6 +256,11 @@ void dma_resv_add_shared_fence(struct dma_resv *obj, struct dma_fence *fence)
>  
>  	dma_resv_assert_held(obj);
>  
> +	/* Drivers should not add containers here, instead add each fence
> +	 * individually.
> +	 */
> +	WARN_ON(dma_fence_is_container(fence));

I'm honestly not sure whether this could go boom, so good if we push this
asap and let it soak in linux-next for the entire release cycle.

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

On the change itself, we'll see what it brings.
-Daniel

> +
>  	fobj = dma_resv_shared_list(obj);
>  	count = fobj->shared_count;
>  
> -- 
> 2.25.1
>
  

Patch

diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
index 6dd9a40b55d4..e8a0c1d51da2 100644
--- a/drivers/dma-buf/dma-resv.c
+++ b/drivers/dma-buf/dma-resv.c
@@ -256,6 +256,11 @@  void dma_resv_add_shared_fence(struct dma_resv *obj, struct dma_fence *fence)
 
 	dma_resv_assert_held(obj);
 
+	/* Drivers should not add containers here, instead add each fence
+	 * individually.
+	 */
+	WARN_ON(dma_fence_is_container(fence));
+
 	fobj = dma_resv_shared_list(obj);
 	count = fobj->shared_count;