Re: [PATCH 1/2] dma-fence: export dma_fence_might_wait

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 06, 2021 at 10:05:58AM +0100, Matthew Auld wrote:
> It might be useful for drivers to annotate a path where hitting the
> actual wait path might be difficult or unlikely through normal testing.
> 
> Suggested-by: Daniel Vetter <daniel.vetter@xxxxxxxx>
> Signed-off-by: Matthew Auld <matthew.auld@xxxxxxxxx>
> Cc: Thomas Hellström <thomas.hellstrom@xxxxxxxxxxxxxxx>
> ---
>  drivers/dma-buf/dma-fence.c | 19 ++++++++++++++++---
>  include/linux/dma-fence.h   |  2 ++
>  2 files changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
> index ce0f5eff575d..f2cd036b5243 100644
> --- a/drivers/dma-buf/dma-fence.c
> +++ b/drivers/dma-buf/dma-fence.c
> @@ -335,6 +335,21 @@ void __dma_fence_might_wait(void)
>  }
>  #endif
>  
> +/**
> + * dma_fence_might_wait - entering a section which might wait on DMA fence
> + * critical section.
> + *
> + * This is also potentially useful for drivers to call directly, when annotating
> + * a path where hitting the actual wait path might be difficult or unlikely
> + * through normal testing.

Maybe also add a

"See also dma_fence_begin_signalling() and dma_fence_end_signalling."

here and a similar note the these two functions pointing at
dma_fence_might_wait()? I do like to link things together when there's a
group of functions.

With that: Reviewed-by: Daniel Vetter <daniel.vetter@xxxxxxxx>

> + */
> +void dma_fence_might_wait(void)
> +{
> +	might_sleep();
> +	__dma_fence_might_wait();
> +}
> +EXPORT_SYMBOL(dma_fence_might_wait);
> +
>  
>  /**
>   * dma_fence_signal_timestamp_locked - signal completion of a fence
> @@ -495,9 +510,7 @@ dma_fence_wait_timeout(struct dma_fence *fence, bool intr, signed long timeout)
>  	if (WARN_ON(timeout < 0))
>  		return -EINVAL;
>  
> -	might_sleep();
> -
> -	__dma_fence_might_wait();
> +	dma_fence_might_wait();
>  
>  	trace_dma_fence_wait_start(fence);
>  	if (fence->ops->wait)
> diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
> index 6ffb4b2c6371..37bf4beed93f 100644
> --- a/include/linux/dma-fence.h
> +++ b/include/linux/dma-fence.h
> @@ -370,6 +370,8 @@ static inline void dma_fence_end_signalling(bool cookie) {}
>  static inline void __dma_fence_might_wait(void) {}
>  #endif
>  
> +void dma_fence_might_wait(void);
> +
>  int dma_fence_signal(struct dma_fence *fence);
>  int dma_fence_signal_locked(struct dma_fence *fence);
>  int dma_fence_signal_timestamp(struct dma_fence *fence, ktime_t timestamp);
> -- 
> 2.26.3
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux