intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
	Ben Skeggs <bskeggs@redhat.com>,
	DRI Development <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH] drm/atomic: Introduce drm_atomic_helper_shutdown
Date: Tue, 21 Mar 2017 16:29:06 +0100	[thread overview]
Message-ID: <f0fe47b5-a1a9-8e63-2928-7fff8fb2bd10@linux.intel.com> (raw)
In-Reply-To: <20170321152610.27203-1-daniel.vetter@ffwll.ch>

Op 21-03-17 om 16:26 schreef Daniel Vetter:
> The trouble here is that it does multiple atomic commits under one
> drm_modeset_lock_all, which breaks the behind-the-scenes acquire
> context magic that function pulls off. It's much better to have one
> overall atomic commit. That we still have multiple atomic commits
> prevents us from adding some pretty useful debug checks to the atomic
> machinery.
>
> Hence it is really a bad idea to call the legacy
> drm_crtc_force_disable_all() function. There's 2 atomic drivers using
> this still, nouveau and tinydrm. To fix this, introduce a new
> drm_atomic_helper_shutdown() by extracting the code from i915.
>
> While at it improve kernel-doc and catch future offenders by
> sprinkling a WARN_ON into the legacy function. We should probably move
> those into the legacy modeset helpers, too ...
>
> v2: Make it compile on arm drivers too (Noralf).
>
> Acked-by: Noralf Trønnes <noralf@tronnes.org>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Noralf Trønnes <noralf@tronnes.org>
> Cc: Ben Skeggs <bskeggs@redhat.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/drm_atomic_helper.c         | 42 +++++++++++++++++++++++++++--
>  drivers/gpu/drm/drm_crtc.c                  |  7 +++++
>  drivers/gpu/drm/i915/i915_drv.c             | 20 +-------------
>  drivers/gpu/drm/nouveau/nouveau_display.c   |  8 ++++--
>  drivers/gpu/drm/tinydrm/core/tinydrm-core.c |  4 +--
>  include/drm/drm_atomic_helper.h             |  1 +
>  6 files changed, 57 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index b4dcb2559e09..5f401519d03c 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -2444,7 +2444,8 @@ int __drm_atomic_helper_set_config(struct drm_mode_set *set,
>   * that they are connected to.
>   *
>   * This is used for example in suspend/resume to disable all currently active
> - * functions when suspending.
> + * functions when suspending. If you just want to shut down everything at e.g.
> + * driver unload, look at drm_atomic_helper_shutdown().
>   *
>   * Note that if callers haven't already acquired all modeset locks this might
>   * return -EDEADLK, which must be handled by calling drm_modeset_backoff().
> @@ -2453,7 +2454,8 @@ int __drm_atomic_helper_set_config(struct drm_mode_set *set,
>   * 0 on success or a negative error code on failure.
>   *
>   * See also:
> - * drm_atomic_helper_suspend(), drm_atomic_helper_resume()
> + * drm_atomic_helper_suspend(), drm_atomic_helper_resume() and
> + * drm_atomic_helper_shutdown().
>   */
>  int drm_atomic_helper_disable_all(struct drm_device *dev,
>  				  struct drm_modeset_acquire_ctx *ctx)
> @@ -2518,6 +2520,42 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,
>  EXPORT_SYMBOL(drm_atomic_helper_disable_all);
>  
>  /**
> + * drm_atomic_helper_shutdown - shutdown all CRTC
> + * @dev: DRM device
> + *
> + * This shuts down all CRTC, which is useful for driver unloading. Shutdown on
> + * suspend should instead be handled with drm_atomic_helper_suspend(), since
> + * that also takes a snapshot of the modeset state to be restored on resume.
> + *
> + * This is just a convenience wrapper around drm_atomic_helper_disable_all(),
> + * and it is the atomic version of drm_crtc_force_disable().
> + */
> +void drm_atomic_helper_shutdown(struct drm_device *dev)
> +{
> +	struct drm_modeset_acquire_ctx ctx;
> +	int ret;
> +
> +	drm_modeset_acquire_init(&ctx, 0);
> +	while (1) {
> +		ret = drm_modeset_lock_all_ctx(dev, &ctx);
> +		if (!ret)
> +			ret = drm_atomic_helper_disable_all(dev, &ctx);
> +
> +		if (ret != -EDEADLK)
> +			break;
> +
> +		drm_modeset_backoff(&ctx);
> +	}
> +
> +	if (ret)
> +		DRM_ERROR("Disabling all crtc's during unload failed with %i\n", ret);
> +
> +	drm_modeset_drop_locks(&ctx);
> +	drm_modeset_acquire_fini(&ctx);
> +}
> +EXPORT_SYMBOL(drm_atomic_helper_shutdown);
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2017-03-21 15:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-21 11:22 [PATCH] drm/atomic: Introduce drm_atomic_helper_shutdown Daniel Vetter
2017-03-21 12:43 ` ✗ Fi.CI.BAT: warning for " Patchwork
2017-03-21 13:59 ` [PATCH] " Noralf Trønnes
2017-03-21 15:26 ` Daniel Vetter
2017-03-21 15:29   ` Maarten Lankhorst [this message]
2017-03-21 16:41   ` Daniel Vetter
2017-03-27  7:15     ` Tomi Valkeinen
2017-03-27  7:43       ` Daniel Vetter
2017-03-28 12:18         ` Tomi Valkeinen
2017-03-28 14:22           ` Daniel Vetter
2017-03-29  7:00             ` Tomi Valkeinen
2017-03-21 18:41 ` ✗ Fi.CI.BAT: failure for drm/atomic: Introduce drm_atomic_helper_shutdown (rev3) Patchwork

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=f0fe47b5-a1a9-8e63-2928-7fff8fb2bd10@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=bskeggs@redhat.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /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;
as well as URLs for NNTP newsgroup(s).