Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Rob Clark <robdclark@gmail.com>
Cc: dri-devel@lists.freedesktop.org,
	Peter Zijlstra <peterz@infradead.org>, Tejun Heo <tj@kernel.org>,
	timmurray@google.com, linux-arm-msm@vger.kernel.org,
	Rob Clark <robdclark@chromium.org>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/3] drm/atomic: Use kthread worker for nonblocking commits
Date: Mon, 21 Sep 2020 11:23:22 +0200	[thread overview]
Message-ID: <20200921092322.GK438822@phenom.ffwll.local> (raw)
In-Reply-To: <20200919193727.2093945-3-robdclark@gmail.com>

On Sat, Sep 19, 2020 at 12:37:25PM -0700, Rob Clark wrote:
> From: Rob Clark <robdclark@chromium.org>
> 
> This will allow us to more easily switch scheduling rules based on what
> userspace wants.
> 
> Signed-off-by: Rob Clark <robdclark@chromium.org>

I still think switching to the highpriority systemwq as a start (like i915
already does) would be a good first step no matter what we end up doing
for the android thing.
-Daniel

> ---
>  drivers/gpu/drm/drm_atomic_helper.c | 13 ++++++++----
>  include/drm/drm_atomic.h            | 31 +++++++++++++++++++++++++++++
>  2 files changed, 40 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 9e1ad493e689..75eeec5e7b10 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -1659,11 +1659,11 @@ static void commit_tail(struct drm_atomic_state *old_state)
>  	drm_atomic_state_put(old_state);
>  }
>  
> -static void commit_work(struct work_struct *work)
> +static void commit_work(struct kthread_work *work)
>  {
>  	struct drm_atomic_state *state = container_of(work,
>  						      struct drm_atomic_state,
> -						      commit_work);
> +						      commit_kwork);
>  	commit_tail(state);
>  }
>  
> @@ -1797,6 +1797,7 @@ int drm_atomic_helper_commit(struct drm_device *dev,
>  			     struct drm_atomic_state *state,
>  			     bool nonblock)
>  {
> +	struct kthread_worker *worker = NULL;
>  	int ret;
>  
>  	if (state->async_update) {
> @@ -1814,7 +1815,7 @@ int drm_atomic_helper_commit(struct drm_device *dev,
>  	if (ret)
>  		return ret;
>  
> -	INIT_WORK(&state->commit_work, commit_work);
> +	kthread_init_work(&state->commit_kwork, commit_work);
>  
>  	ret = drm_atomic_helper_prepare_planes(dev, state);
>  	if (ret)
> @@ -1857,8 +1858,12 @@ int drm_atomic_helper_commit(struct drm_device *dev,
>  	 */
>  
>  	drm_atomic_state_get(state);
> +
>  	if (nonblock)
> -		queue_work(system_unbound_wq, &state->commit_work);
> +		worker = drm_atomic_pick_worker(state);
> +
> +	if (worker)
> +		kthread_queue_work(worker, &state->commit_kwork);
>  	else
>  		commit_tail(state);
>  
> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> index d07c851d255b..8d0ee19953df 100644
> --- a/include/drm/drm_atomic.h
> +++ b/include/drm/drm_atomic.h
> @@ -373,8 +373,18 @@ struct drm_atomic_state {
>  	 *
>  	 * Work item which can be used by the driver or helpers to execute the
>  	 * commit without blocking.
> +	 *
> +	 * This is deprecated, use commit_kwork.
>  	 */
>  	struct work_struct commit_work;
> +
> +	/**
> +	 * @commit_kwork:
> +	 *
> +	 * Work item which can be used by the driver or helpers to execute the
> +	 * commit without blocking.
> +	 */
> +	struct kthread_work commit_kwork;
>  };
>  
>  void __drm_crtc_commit_free(struct kref *kref);
> @@ -954,6 +964,27 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>  		      (new_obj_state) = (__state)->private_objs[__i].new_state, 1); \
>  	     (__i)++)
>  
> +/**
> + * drm_atomic_pick_worker - helper to get kworker to use for nonblocking commit
> + * @state: the &drm_atomic_state for the commit
> + *
> + * Pick an appropriate worker for a given atomic update.  The first CRTC
> + * invovled in the atomic update is used to pick the worker, to prevent
> + * serializing multiple pageflips / atomic-updates on indenpendent CRTCs.
> + */
> +static inline struct kthread_worker *
> +drm_atomic_pick_worker(const struct drm_atomic_state *state)
> +{
> +	struct drm_crtc_state *crtc_state;
> +	struct drm_crtc *crtc;
> +	unsigned i;
> +
> +	for_each_new_crtc_in_state(state, crtc, crtc_state, i)
> +		return crtc->worker;
> +
> +	return NULL;
> +}
> +
>  /**
>   * drm_atomic_crtc_needs_modeset - compute combined modeset need
>   * @state: &drm_crtc_state for the CRTC
> -- 
> 2.26.2
> 

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

  reply	other threads:[~2020-09-21  9:23 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-19 19:37 [PATCH 0/3] drm: commit_work scheduling Rob Clark
2020-09-19 19:37 ` [PATCH 1/3] drm/crtc: Introduce per-crtc kworker Rob Clark
2020-09-21  9:20   ` Jani Nikula
2020-09-19 19:37 ` [PATCH 2/3] drm/atomic: Use kthread worker for nonblocking commits Rob Clark
2020-09-21  9:23   ` Daniel Vetter [this message]
2020-09-21 14:55     ` Rob Clark
2020-09-22 13:18       ` Daniel Vetter
2020-09-19 19:37 ` [PATCH 3/3] drm: Add a client-cap to set scheduling mode Rob Clark
2020-09-21  9:21 ` [PATCH 0/3] drm: commit_work scheduling Daniel Vetter
2020-09-21 10:49   ` peterz
2020-09-21 14:28   ` Tejun Heo
2020-09-21 15:16   ` Rob Clark
2020-09-21 15:20     ` Rob Clark
2020-09-21 16:19     ` Rob Clark
2020-09-22  6:58     ` Daniel Vetter
2020-09-22 14:48       ` Rob Clark
2020-09-23 15:25         ` Daniel Vetter
2020-09-24  2:33           ` Rob Clark
2020-09-24  8:49             ` Daniel Vetter
2020-09-24 15:24               ` Rob Clark
2020-09-24 16:15               ` Qais Yousef
2020-09-25  8:23                 ` Daniel Vetter
2020-09-21 16:10 ` Qais Yousef
2020-09-21 16:23   ` Rob Clark

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=20200921092322.GK438822@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=peterz@infradead.org \
    --cc=robdclark@chromium.org \
    --cc=robdclark@gmail.com \
    --cc=timmurray@google.com \
    --cc=tj@kernel.org \
    --cc=tzimmermann@suse.de \
    /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