mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
	Rob Clark <robdclark@gmail.com>,
	dri-devel@lists.freedesktop.org
Cc: "Rob Clark" <robdclark@chromium.org>,
	"Gustavo Padovan" <gustavo@padovan.org>,
	"Tvrtko Ursulin" <tvrtko.ursulin@intel.com>,
	"Michel Dänzer" <michel@daenzer.net>,
	"open list" <linux-kernel@vger.kernel.org>,
	"Sumit Semwal" <sumit.semwal@linaro.org>,
	"moderated list:DMA BUFFER SHARING FRAMEWORK"
	<linaro-mm-sig@lists.linaro.org>,
	"Pekka Paalanen" <ppaalanen@gmail.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	freedreno@lists.freedesktop.org,
	"Christian König" <christian.koenig@amd.com>,
	"open list:SYNC FILE FRAMEWORK" <linux-media@vger.kernel.org>
Subject: Re: [PATCH v4 01/14] dma-buf/dma-fence: Add deadline awareness
Date: Wed, 22 Feb 2023 16:28:40 +0100	[thread overview]
Message-ID: <21f36640-3229-0b46-31a2-a47efc5be934@amd.com> (raw)
In-Reply-To: <b65a2fe2-6f68-2116-9599-2940e66d166b@linux.intel.com>

Am 22.02.23 um 11:23 schrieb Tvrtko Ursulin:
>
> On 18/02/2023 21:15, Rob Clark wrote:
>> From: Rob Clark <robdclark@chromium.org>
>>
>> Add a way to hint to the fence signaler of an upcoming deadline, such as
>> vblank, which the fence waiter would prefer not to miss.  This is to aid
>> the fence signaler in making power management decisions, like boosting
>> frequency as the deadline approaches and awareness of missing deadlines
>> so that can be factored in to the frequency scaling.
>>
>> v2: Drop dma_fence::deadline and related logic to filter duplicate
>>      deadlines, to avoid increasing dma_fence size.  The fence-context
>>      implementation will need similar logic to track deadlines of all
>>      the fences on the same timeline.  [ckoenig]
>> v3: Clarify locking wrt. set_deadline callback
>>
>> Signed-off-by: Rob Clark <robdclark@chromium.org>
>> Reviewed-by: Christian König <christian.koenig@amd.com>
>> ---
>>   drivers/dma-buf/dma-fence.c | 20 ++++++++++++++++++++
>>   include/linux/dma-fence.h   | 20 ++++++++++++++++++++
>>   2 files changed, 40 insertions(+)
>>
>> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
>> index 0de0482cd36e..763b32627684 100644
>> --- a/drivers/dma-buf/dma-fence.c
>> +++ b/drivers/dma-buf/dma-fence.c
>> @@ -912,6 +912,26 @@ dma_fence_wait_any_timeout(struct dma_fence 
>> **fences, uint32_t count,
>>   }
>>   EXPORT_SYMBOL(dma_fence_wait_any_timeout);
>>   +
>> +/**
>> + * dma_fence_set_deadline - set desired fence-wait deadline
>> + * @fence:    the fence that is to be waited on
>> + * @deadline: the time by which the waiter hopes for the fence to be
>> + *            signaled
>> + *
>> + * Inform the fence signaler of an upcoming deadline, such as 
>> vblank, by
>> + * which point the waiter would prefer the fence to be signaled by.  
>> This
>> + * is intended to give feedback to the fence signaler to aid in power
>> + * management decisions, such as boosting GPU frequency if a periodic
>> + * vblank deadline is approaching.
>> + */
>> +void dma_fence_set_deadline(struct dma_fence *fence, ktime_t deadline)
>> +{
>> +    if (fence->ops->set_deadline && !dma_fence_is_signaled(fence))
>> +        fence->ops->set_deadline(fence, deadline);
>> +}
>> +EXPORT_SYMBOL(dma_fence_set_deadline);
>> +
>>   /**
>>    * dma_fence_describe - Dump fence describtion into seq_file
>>    * @fence: the 6fence to describe
>> diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
>> index 775cdc0b4f24..d77f6591c453 100644
>> --- a/include/linux/dma-fence.h
>> +++ b/include/linux/dma-fence.h
>> @@ -99,6 +99,7 @@ enum dma_fence_flag_bits {
>>       DMA_FENCE_FLAG_SIGNALED_BIT,
>>       DMA_FENCE_FLAG_TIMESTAMP_BIT,
>>       DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
>> +    DMA_FENCE_FLAG_HAS_DEADLINE_BIT,
>
> Would this bit be better left out from core implementation, given how 
> the approach is the component which implements dma-fence has to track 
> the actual deadline and all?
>
> Also taking a step back - are we all okay with starting to expand the 
> relatively simple core synchronisation primitive with side channel 
> data like this? What would be the criteria for what side channel data 
> would be acceptable? Taking note the thing lives outside drivers/gpu/.

I had similar concerns and it took me a moment as well to understand the 
background why this is necessary. I essentially don't see much other 
approach we could do.

Yes, this is GPU/CRTC specific, but we somehow need a common interface 
for communicating it between drivers and that's the dma_fence object as 
far as I can see.

Regards,
Christian.

>
> Regards,
>
> Tvrtko
>
>>       DMA_FENCE_FLAG_USER_BITS, /* must always be last member */
>>   };
>>   @@ -257,6 +258,23 @@ struct dma_fence_ops {
>>        */
>>       void (*timeline_value_str)(struct dma_fence *fence,
>>                      char *str, int size);
>> +
>> +    /**
>> +     * @set_deadline:
>> +     *
>> +     * Callback to allow a fence waiter to inform the fence signaler of
>> +     * an upcoming deadline, such as vblank, by which point the waiter
>> +     * would prefer the fence to be signaled by.  This is intended to
>> +     * give feedback to the fence signaler to aid in power management
>> +     * decisions, such as boosting GPU frequency.
>> +     *
>> +     * This is called without &dma_fence.lock held, it can be called
>> +     * multiple times and from any context.  Locking is up to the 
>> callee
>> +     * if it has some state to manage.
>> +     *
>> +     * This callback is optional.
>> +     */
>> +    void (*set_deadline)(struct dma_fence *fence, ktime_t deadline);
>>   };
>>     void dma_fence_init(struct dma_fence *fence, const struct 
>> dma_fence_ops *ops,
>> @@ -583,6 +601,8 @@ static inline signed long dma_fence_wait(struct 
>> dma_fence *fence, bool intr)
>>       return ret < 0 ? ret : 0;
>>   }
>>   +void dma_fence_set_deadline(struct dma_fence *fence, ktime_t 
>> deadline);
>> +
>>   struct dma_fence *dma_fence_get_stub(void);
>>   struct dma_fence *dma_fence_allocate_private_stub(void);
>>   u64 dma_fence_context_alloc(unsigned num);


  reply	other threads:[~2023-02-22 15:28 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-18 21:15 [PATCH v4 00/14] dma-fence: Deadline awareness Rob Clark
2023-02-18 21:15 ` [PATCH v4 01/14] dma-buf/dma-fence: Add deadline awareness Rob Clark
2023-02-22 10:23   ` Tvrtko Ursulin
2023-02-22 15:28     ` Christian König [this message]
2023-02-22 17:04       ` Tvrtko Ursulin
2023-02-22 17:16         ` Rob Clark
2023-02-22 17:33           ` Tvrtko Ursulin
2023-02-22 18:57             ` Rob Clark
2023-02-22 11:01   ` Luben Tuikov
2023-02-18 21:15 ` [PATCH v4 02/14] dma-buf/fence-array: Add fence deadline support Rob Clark
2023-02-18 21:15 ` [PATCH v4 03/14] dma-buf/fence-chain: " Rob Clark
2023-02-22 10:27   ` Tvrtko Ursulin
2023-02-22 15:55     ` Rob Clark
2023-02-18 21:15 ` [PATCH v4 04/14] dma-buf/dma-resv: Add a way to set fence deadline Rob Clark
2023-02-20  8:16   ` Christian König
2023-02-18 21:15 ` [PATCH v4 05/14] dma-buf/sync_file: Add SET_DEADLINE ioctl Rob Clark
2023-02-20  8:27   ` Christian König
2023-02-20 16:09     ` Rob Clark
2023-02-21  8:41       ` Pekka Paalanen
2023-02-23  9:19       ` Christian König
2023-02-20  8:48   ` Pekka Paalanen
2023-02-18 21:15 ` [PATCH v4 06/14] dma-buf/sync_file: Support (E)POLLPRI Rob Clark
2023-02-20  8:31   ` Christian König
2023-02-21  8:38     ` Pekka Paalanen
2023-02-20  8:53   ` Pekka Paalanen
2023-02-20 16:14     ` Rob Clark
2023-02-21  8:37       ` Pekka Paalanen
2023-02-21 16:01         ` Sebastian Wick
2023-02-21 17:55           ` Rob Clark
2023-02-21 16:48       ` Luben Tuikov
2023-02-21 17:53         ` Rob Clark
2023-02-22  9:49           ` Pekka Paalanen
2023-02-22 10:26             ` Luben Tuikov
2023-02-22 15:37             ` Rob Clark
2023-02-23  9:38               ` Pekka Paalanen
2023-02-23 18:51                 ` Rob Clark
2023-02-24  9:26                   ` Pekka Paalanen
2023-02-24  9:41                     ` Tvrtko Ursulin
2023-02-24 10:24                       ` Pekka Paalanen
2023-02-24 10:50                         ` Tvrtko Ursulin
2023-02-24 11:00                           ` Pekka Paalanen
2023-02-24 11:37                             ` Tvrtko Ursulin
2023-02-24 15:26                               ` Luben Tuikov
2023-02-24 17:59                                 ` Rob Clark
2023-02-27 21:35                                   ` Rodrigo Vivi
2023-02-27 22:20                                     ` Rob Clark
2023-02-27 22:44                                       ` Sebastian Wick
2023-02-27 23:48                                         ` Rob Clark
2023-02-28 14:30                                           ` Sebastian Wick
2023-02-28 22:52                                             ` Rob Clark
2023-03-01 15:31                                               ` Sebastian Wick
2023-03-01 16:02                                                 ` Rob Clark
2023-03-01 15:45                                       ` Rodrigo Vivi
2023-02-24 16:59                         ` Rob Clark
2023-02-24 19:44                         ` Rob Clark
2023-02-27  9:34                           ` Pekka Paalanen
2023-02-27 18:43                             ` Rob Clark
2023-02-18 21:15 ` [PATCH v4 07/14] dma-buf/sw_sync: Add fence deadline support Rob Clark
2023-02-20  8:29   ` Christian König
2023-02-18 21:15 ` [PATCH v4 08/14] drm/scheduler: " Rob Clark
2023-02-21 19:40   ` Luben Tuikov
2023-02-18 21:15 ` [PATCH v4 09/14] drm/syncobj: Add deadline support for syncobj waits Rob Clark
2023-02-19 16:09   ` Rob Clark
2023-02-20  9:05   ` Pekka Paalanen
2023-02-20 16:20     ` Rob Clark
2023-02-24  9:51   ` Tvrtko Ursulin
2023-02-18 21:15 ` [PATCH v4 10/14] drm/vblank: Add helper to get next vblank time Rob Clark
2023-02-20  9:08   ` Pekka Paalanen
2023-02-20 15:55     ` Rob Clark
2023-02-21  8:45       ` Pekka Paalanen
2023-02-21 13:01         ` Ville Syrjälä
2023-02-21 13:11           ` Pekka Paalanen
2023-02-21 13:42             ` Ville Syrjälä
2023-02-21 17:50           ` Rob Clark
2023-02-22  9:57             ` Pekka Paalanen
2023-02-22 15:44               ` Rob Clark
2023-02-22 15:55                 ` Ville Syrjälä
2023-02-21 19:54           ` Rob Clark
2023-02-21 21:39             ` Ville Syrjälä
2023-02-21 21:48               ` Ville Syrjälä
2023-02-21 22:28                 ` [Freedreno] " Rob Clark
2023-02-21 22:46                   ` Ville Syrjälä
2023-02-21 23:20                     ` Rob Clark
2023-02-21 23:25                       ` Rob Clark
2023-02-22 10:37   ` Luben Tuikov
2023-02-22 15:48     ` Rob Clark
2023-02-18 21:15 ` [PATCH v4 11/14] drm/atomic-helper: Set fence deadline for vblank Rob Clark
2023-02-22 10:46   ` Luben Tuikov
2023-02-22 15:50     ` Rob Clark
2023-02-18 21:15 ` [PATCH v4 12/14] drm/msm: Add deadline based boost support Rob Clark
2023-02-18 21:15 ` [PATCH v4 13/14] drm/msm: Add wait-boost support Rob Clark
2023-02-18 21:15 ` [PATCH v4 14/14] drm/i915: Add deadline based boost support Rob Clark
2023-02-20 15:46   ` Tvrtko Ursulin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21f36640-3229-0b46-31a2-a47efc5be934@amd.com \
    --to=christian.koenig@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=gustavo@padovan.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=michel@daenzer.net \
    --cc=ppaalanen@gmail.com \
    --cc=robdclark@chromium.org \
    --cc=robdclark@gmail.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=sumit.semwal@linaro.org \
    --cc=tvrtko.ursulin@intel.com \
    --cc=tvrtko.ursulin@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®