All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dma-fence: add get_signaled_timestamp to fence ops
@ 2020-09-17 21:45 ` Veera Sundaram Sankaran
  0 siblings, 0 replies; 4+ messages in thread
From: Veera Sundaram Sankaran @ 2020-09-17 21:45 UTC (permalink / raw)
  To: dri-devel, linux-media, sumit.semwal
  Cc: Veera Sundaram Sankaran, robdclark, pdhaval, abhinavk, jsanka

Add an optional fence ops to allow drivers to be able to set the
timestamp for a fence. Some drivers have hardware capability to get
the precise timestamp of certain events based on which the fences
are triggered. This allows it to set accurate timestamp factoring
out any software and IRQ latencies. The get_signaled_timestamp ops,
if defined by the driver would be used during fence signaling to set
the timestamp, before setting the flag DMA_FENCE_FLAG_TIMESTAMP_BIT.
If the callback is not defined, ktime_get is used to set the fence
timestamp.

Signed-off-by: Veera Sundaram Sankaran <veeras@codeaurora.org>
---
 drivers/dma-buf/dma-fence.c |  6 +++++-
 include/linux/dma-fence.h   | 13 +++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
index 43624b4..95c6ab0 100644
--- a/drivers/dma-buf/dma-fence.c
+++ b/drivers/dma-buf/dma-fence.c
@@ -4,6 +4,7 @@
  *
  * Copyright (C) 2012 Canonical Ltd
  * Copyright (C) 2012 Texas Instruments
+ * Copyright (c) 2020 The Linux Foundation. All rights reserved.
  *
  * Authors:
  * Rob Clark <robdclark@gmail.com>
@@ -340,7 +341,10 @@ int dma_fence_signal_locked(struct dma_fence *fence)
 	/* Stash the cb_list before replacing it with the timestamp */
 	list_replace(&fence->cb_list, &cb_list);
 
-	fence->timestamp = ktime_get();
+	if (fence->ops->get_signaled_timestamp)
+		fence->timestamp = fence->ops->get_signaled_timestamp(fence);
+	else
+		fence->timestamp = ktime_get();
 	set_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags);
 	trace_dma_fence_signaled(fence);
 
diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
index 09e23ad..ce73aba 100644
--- a/include/linux/dma-fence.h
+++ b/include/linux/dma-fence.h
@@ -4,6 +4,7 @@
  *
  * Copyright (C) 2012 Canonical Ltd
  * Copyright (C) 2012 Texas Instruments
+ * Copyright (c) 2020 The Linux Foundation. All rights reserved.
  *
  * Authors:
  * Rob Clark <robdclark@gmail.com>
@@ -261,6 +262,18 @@ struct dma_fence_ops {
 	 */
 	void (*timeline_value_str)(struct dma_fence *fence,
 				   char *str, int size);
+
+	/**
+	 * @get_signaled_timestamp:
+	 *
+	 * Allows the driver to fill in precise timestamp for a fence.
+	 * This ops would be used during fence signalling to set the timestamp,
+	 * before setting the flag DMA_FENCE_FLAG_TIMESTAMP_BIT.
+	 *
+	 * This callback is optional. If this callback is not present,
+	 * ktime_get is used to fill in the timestamp.
+	 */
+	ktime_t (*get_signaled_timestamp)(struct dma_fence *fence);
 };
 
 void dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] dma-fence: add get_signaled_timestamp to fence ops
@ 2020-09-17 21:45 ` Veera Sundaram Sankaran
  0 siblings, 0 replies; 4+ messages in thread
From: Veera Sundaram Sankaran @ 2020-09-17 21:45 UTC (permalink / raw)
  To: dri-devel, linux-media, sumit.semwal
  Cc: pdhaval, Veera Sundaram Sankaran, abhinavk

Add an optional fence ops to allow drivers to be able to set the
timestamp for a fence. Some drivers have hardware capability to get
the precise timestamp of certain events based on which the fences
are triggered. This allows it to set accurate timestamp factoring
out any software and IRQ latencies. The get_signaled_timestamp ops,
if defined by the driver would be used during fence signaling to set
the timestamp, before setting the flag DMA_FENCE_FLAG_TIMESTAMP_BIT.
If the callback is not defined, ktime_get is used to set the fence
timestamp.

Signed-off-by: Veera Sundaram Sankaran <veeras@codeaurora.org>
---
 drivers/dma-buf/dma-fence.c |  6 +++++-
 include/linux/dma-fence.h   | 13 +++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
index 43624b4..95c6ab0 100644
--- a/drivers/dma-buf/dma-fence.c
+++ b/drivers/dma-buf/dma-fence.c
@@ -4,6 +4,7 @@
  *
  * Copyright (C) 2012 Canonical Ltd
  * Copyright (C) 2012 Texas Instruments
+ * Copyright (c) 2020 The Linux Foundation. All rights reserved.
  *
  * Authors:
  * Rob Clark <robdclark@gmail.com>
@@ -340,7 +341,10 @@ int dma_fence_signal_locked(struct dma_fence *fence)
 	/* Stash the cb_list before replacing it with the timestamp */
 	list_replace(&fence->cb_list, &cb_list);
 
-	fence->timestamp = ktime_get();
+	if (fence->ops->get_signaled_timestamp)
+		fence->timestamp = fence->ops->get_signaled_timestamp(fence);
+	else
+		fence->timestamp = ktime_get();
 	set_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags);
 	trace_dma_fence_signaled(fence);
 
diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
index 09e23ad..ce73aba 100644
--- a/include/linux/dma-fence.h
+++ b/include/linux/dma-fence.h
@@ -4,6 +4,7 @@
  *
  * Copyright (C) 2012 Canonical Ltd
  * Copyright (C) 2012 Texas Instruments
+ * Copyright (c) 2020 The Linux Foundation. All rights reserved.
  *
  * Authors:
  * Rob Clark <robdclark@gmail.com>
@@ -261,6 +262,18 @@ struct dma_fence_ops {
 	 */
 	void (*timeline_value_str)(struct dma_fence *fence,
 				   char *str, int size);
+
+	/**
+	 * @get_signaled_timestamp:
+	 *
+	 * Allows the driver to fill in precise timestamp for a fence.
+	 * This ops would be used during fence signalling to set the timestamp,
+	 * before setting the flag DMA_FENCE_FLAG_TIMESTAMP_BIT.
+	 *
+	 * This callback is optional. If this callback is not present,
+	 * ktime_get is used to fill in the timestamp.
+	 */
+	ktime_t (*get_signaled_timestamp)(struct dma_fence *fence);
 };
 
 void dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] dma-fence: add get_signaled_timestamp to fence ops
  2020-09-17 21:45 ` Veera Sundaram Sankaran
@ 2020-09-18 12:45   ` Daniel Vetter
  -1 siblings, 0 replies; 4+ messages in thread
From: Daniel Vetter @ 2020-09-18 12:45 UTC (permalink / raw)
  To: Veera Sundaram Sankaran
  Cc: dri-devel, linux-media, sumit.semwal, pdhaval, abhinavk

On Thu, Sep 17, 2020 at 02:45:38PM -0700, Veera Sundaram Sankaran wrote:
> Add an optional fence ops to allow drivers to be able to set the
> timestamp for a fence. Some drivers have hardware capability to get
> the precise timestamp of certain events based on which the fences
> are triggered. This allows it to set accurate timestamp factoring
> out any software and IRQ latencies. The get_signaled_timestamp ops,
> if defined by the driver would be used during fence signaling to set
> the timestamp, before setting the flag DMA_FENCE_FLAG_TIMESTAMP_BIT.
> If the callback is not defined, ktime_get is used to set the fence
> timestamp.
> 
> Signed-off-by: Veera Sundaram Sankaran <veeras@codeaurora.org>

We don't add hooks without implementations, please submit a complete patch
series (and yes that would need to be with upstream drm/msm drivers if
this is for qcom platforms).

Thanks, Daniel

> ---
>  drivers/dma-buf/dma-fence.c |  6 +++++-
>  include/linux/dma-fence.h   | 13 +++++++++++++
>  2 files changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
> index 43624b4..95c6ab0 100644
> --- a/drivers/dma-buf/dma-fence.c
> +++ b/drivers/dma-buf/dma-fence.c
> @@ -4,6 +4,7 @@
>   *
>   * Copyright (C) 2012 Canonical Ltd
>   * Copyright (C) 2012 Texas Instruments
> + * Copyright (c) 2020 The Linux Foundation. All rights reserved.
>   *
>   * Authors:
>   * Rob Clark <robdclark@gmail.com>
> @@ -340,7 +341,10 @@ int dma_fence_signal_locked(struct dma_fence *fence)
>  	/* Stash the cb_list before replacing it with the timestamp */
>  	list_replace(&fence->cb_list, &cb_list);
>  
> -	fence->timestamp = ktime_get();
> +	if (fence->ops->get_signaled_timestamp)
> +		fence->timestamp = fence->ops->get_signaled_timestamp(fence);
> +	else
> +		fence->timestamp = ktime_get();
>  	set_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags);
>  	trace_dma_fence_signaled(fence);
>  
> diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
> index 09e23ad..ce73aba 100644
> --- a/include/linux/dma-fence.h
> +++ b/include/linux/dma-fence.h
> @@ -4,6 +4,7 @@
>   *
>   * Copyright (C) 2012 Canonical Ltd
>   * Copyright (C) 2012 Texas Instruments
> + * Copyright (c) 2020 The Linux Foundation. All rights reserved.
>   *
>   * Authors:
>   * Rob Clark <robdclark@gmail.com>
> @@ -261,6 +262,18 @@ struct dma_fence_ops {
>  	 */
>  	void (*timeline_value_str)(struct dma_fence *fence,
>  				   char *str, int size);
> +
> +	/**
> +	 * @get_signaled_timestamp:
> +	 *
> +	 * Allows the driver to fill in precise timestamp for a fence.
> +	 * This ops would be used during fence signalling to set the timestamp,
> +	 * before setting the flag DMA_FENCE_FLAG_TIMESTAMP_BIT.
> +	 *
> +	 * This callback is optional. If this callback is not present,
> +	 * ktime_get is used to fill in the timestamp.
> +	 */
> +	ktime_t (*get_signaled_timestamp)(struct dma_fence *fence);
>  };
>  
>  void dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dma-fence: add get_signaled_timestamp to fence ops
@ 2020-09-18 12:45   ` Daniel Vetter
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Vetter @ 2020-09-18 12:45 UTC (permalink / raw)
  To: Veera Sundaram Sankaran; +Cc: pdhaval, abhinavk, dri-devel, linux-media

On Thu, Sep 17, 2020 at 02:45:38PM -0700, Veera Sundaram Sankaran wrote:
> Add an optional fence ops to allow drivers to be able to set the
> timestamp for a fence. Some drivers have hardware capability to get
> the precise timestamp of certain events based on which the fences
> are triggered. This allows it to set accurate timestamp factoring
> out any software and IRQ latencies. The get_signaled_timestamp ops,
> if defined by the driver would be used during fence signaling to set
> the timestamp, before setting the flag DMA_FENCE_FLAG_TIMESTAMP_BIT.
> If the callback is not defined, ktime_get is used to set the fence
> timestamp.
> 
> Signed-off-by: Veera Sundaram Sankaran <veeras@codeaurora.org>

We don't add hooks without implementations, please submit a complete patch
series (and yes that would need to be with upstream drm/msm drivers if
this is for qcom platforms).

Thanks, Daniel

> ---
>  drivers/dma-buf/dma-fence.c |  6 +++++-
>  include/linux/dma-fence.h   | 13 +++++++++++++
>  2 files changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
> index 43624b4..95c6ab0 100644
> --- a/drivers/dma-buf/dma-fence.c
> +++ b/drivers/dma-buf/dma-fence.c
> @@ -4,6 +4,7 @@
>   *
>   * Copyright (C) 2012 Canonical Ltd
>   * Copyright (C) 2012 Texas Instruments
> + * Copyright (c) 2020 The Linux Foundation. All rights reserved.
>   *
>   * Authors:
>   * Rob Clark <robdclark@gmail.com>
> @@ -340,7 +341,10 @@ int dma_fence_signal_locked(struct dma_fence *fence)
>  	/* Stash the cb_list before replacing it with the timestamp */
>  	list_replace(&fence->cb_list, &cb_list);
>  
> -	fence->timestamp = ktime_get();
> +	if (fence->ops->get_signaled_timestamp)
> +		fence->timestamp = fence->ops->get_signaled_timestamp(fence);
> +	else
> +		fence->timestamp = ktime_get();
>  	set_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags);
>  	trace_dma_fence_signaled(fence);
>  
> diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
> index 09e23ad..ce73aba 100644
> --- a/include/linux/dma-fence.h
> +++ b/include/linux/dma-fence.h
> @@ -4,6 +4,7 @@
>   *
>   * Copyright (C) 2012 Canonical Ltd
>   * Copyright (C) 2012 Texas Instruments
> + * Copyright (c) 2020 The Linux Foundation. All rights reserved.
>   *
>   * Authors:
>   * Rob Clark <robdclark@gmail.com>
> @@ -261,6 +262,18 @@ struct dma_fence_ops {
>  	 */
>  	void (*timeline_value_str)(struct dma_fence *fence,
>  				   char *str, int size);
> +
> +	/**
> +	 * @get_signaled_timestamp:
> +	 *
> +	 * Allows the driver to fill in precise timestamp for a fence.
> +	 * This ops would be used during fence signalling to set the timestamp,
> +	 * before setting the flag DMA_FENCE_FLAG_TIMESTAMP_BIT.
> +	 *
> +	 * This callback is optional. If this callback is not present,
> +	 * ktime_get is used to fill in the timestamp.
> +	 */
> +	ktime_t (*get_signaled_timestamp)(struct dma_fence *fence);
>  };
>  
>  void dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-18 12:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 21:45 [PATCH] dma-fence: add get_signaled_timestamp to fence ops Veera Sundaram Sankaran
2020-09-17 21:45 ` Veera Sundaram Sankaran
2020-09-18 12:45 ` Daniel Vetter
2020-09-18 12:45   ` Daniel Vetter

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.