From: Lyude Paul <lyude@redhat.com>
To: Lukas Wunner <lukas@wunner.de>
Cc: Pierre Moreau <pierre.morrow@free.fr>,
Archit Taneja <architt@codeaurora.org>,
Ismo Toijala <ismo.toijala@gmail.com>,
nouveau@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
dri-devel@lists.freedesktop.org,
Hans de Goede <hdegoede@redhat.com>,
Ben Skeggs <bskeggs@redhat.com>,
Alex Deucher <alexander.deucher@amd.com>,
Dave Airlie <airlied@redhat.com>, Peter Wu <peter@lekensteyn.nl>
Subject: Re: [PATCH v2] drm: Allow determining if current task is output poll worker
Date: Wed, 14 Feb 2018 14:07:52 -0500 [thread overview]
Message-ID: <1518635272.3674.0.camel@redhat.com> (raw)
In-Reply-To: <3549ce32e7f1467102e70d3e9cbf70c46bfe108e.1518593424.git.lukas@wunner.de>
I think your idea of having the extra kerneldoc as a seperate patch to make
this easier to backport should work fine :). Thanks for the good work!
Reviewed-by: Lyude Paul <lyude@redhat.com>
On Wed, 2018-02-14 at 08:41 +0100, Lukas Wunner wrote:
> Introduce a helper to determine if the current task is an output poll
> worker.
>
> This allows us to fix a long-standing deadlock in several DRM drivers
> wherein the ->runtime_suspend callback waits for the output poll worker
> to finish and the worker in turn calls a ->detect callback which waits
> for runtime suspend to finish. The ->detect callback is invoked from
> multiple call sites and waiting for runtime suspend to finish is the
> correct thing to do except if it's executing in the context of the
> worker.
>
> v2: Expand kerneldoc to specifically mention deadlock between
> output poll worker and autosuspend worker as use case. (Lyude)
>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Ben Skeggs <bskeggs@redhat.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Reviewed-by: Lyude Paul <lyude@redhat.com>
> Signed-off-by: Lukas Wunner <lukas@wunner.de>
> ---
> drivers/gpu/drm/drm_probe_helper.c | 20 ++++++++++++++++++++
> include/drm/drm_crtc_helper.h | 1 +
> 2 files changed, 21 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_probe_helper.c
> b/drivers/gpu/drm/drm_probe_helper.c
> index 6dc2dde5b672..7a6b2dc08913 100644
> --- a/drivers/gpu/drm/drm_probe_helper.c
> +++ b/drivers/gpu/drm/drm_probe_helper.c
> @@ -654,6 +654,26 @@ static void output_poll_execute(struct work_struct
> *work)
> schedule_delayed_work(delayed_work,
> DRM_OUTPUT_POLL_PERIOD);
> }
>
> +/**
> + * drm_kms_helper_is_poll_worker - is %current task an output poll worker?
> + *
> + * Determine if %current task is an output poll worker. This can be used
> + * to select distinct code paths for output polling versus other contexts.
> + *
> + * One use case is to avoid a deadlock between the output poll worker and
> + * the autosuspend worker wherein the latter waits for polling to finish
> + * upon calling drm_kms_helper_poll_disable(), while the former waits for
> + * runtime suspend to finish upon calling pm_runtime_get_sync() in a
> + * connector ->detect hook.
> + */
> +bool drm_kms_helper_is_poll_worker(void)
> +{
> + struct work_struct *work = current_work();
> +
> + return work && work->func == output_poll_execute;
> +}
> +EXPORT_SYMBOL(drm_kms_helper_is_poll_worker);
> +
> /**
> * drm_kms_helper_poll_disable - disable output polling
> * @dev: drm_device
> diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
> index 76e237bd989b..6914633037a5 100644
> --- a/include/drm/drm_crtc_helper.h
> +++ b/include/drm/drm_crtc_helper.h
> @@ -77,5 +77,6 @@ void drm_kms_helper_hotplug_event(struct drm_device *dev);
>
> void drm_kms_helper_poll_disable(struct drm_device *dev);
> void drm_kms_helper_poll_enable(struct drm_device *dev);
> +bool drm_kms_helper_is_poll_worker(void);
>
> #endif
--
Cheers,
Lyude Paul
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2018-02-14 19:07 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-11 9:38 [PATCH 0/5] Fix deadlock on runtime suspend in DRM drivers Lukas Wunner
2018-02-11 9:38 ` [PATCH 5/5] drm/amdgpu: Fix deadlock on runtime suspend Lukas Wunner
2018-02-11 9:38 ` [PATCH 2/5] drm: Allow determining if current task is output poll worker Lukas Wunner
2018-02-12 17:46 ` Lyude Paul
2018-02-12 17:50 ` [Intel-gfx] " Chris Wilson
2018-02-12 18:40 ` Lukas Wunner
2018-02-14 8:19 ` Lukas Wunner
2018-02-14 7:41 ` [PATCH v2] " Lukas Wunner
2018-02-14 19:07 ` Lyude Paul [this message]
2018-02-11 9:38 ` [PATCH 4/5] drm/radeon: Fix deadlock on runtime suspend Lukas Wunner
2018-02-11 9:38 ` [PATCH 1/5] workqueue: Allow retrieval of current task's work struct Lukas Wunner
2018-02-12 17:07 ` Tejun Heo
2018-02-11 9:38 ` [PATCH 3/5] drm/nouveau: Fix deadlock on runtime suspend Lukas Wunner
2018-02-11 18:58 ` [PATCH 0/5] Fix deadlock on runtime suspend in DRM drivers Mike Lothian
2018-02-11 19:23 ` Lukas Wunner
2018-02-11 19:41 ` Lukas Wunner
2018-02-12 0:35 ` Mike Lothian
2018-02-12 3:39 ` Lukas Wunner
2018-02-12 9:03 ` Mike Lothian
2018-02-12 9:45 ` Lukas Wunner
2018-02-12 18:58 ` Alex Deucher
2018-02-13 8:17 ` Lukas Wunner
2018-02-13 15:19 ` Alex Deucher
2018-02-12 13:04 ` Imre Deak
2018-02-16 8:49 ` i915 runtime PM (was: Re: [PATCH 0/5] Fix deadlock on runtime suspend in DRM drivers) Lukas Wunner
2018-02-16 12:33 ` Imre Deak
2018-02-12 17:43 ` [PATCH 0/5] Fix deadlock on runtime suspend in DRM drivers Lyude Paul
[not found] ` <cover.1518338788.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2018-02-13 10:55 ` Liviu Dudau
2018-02-13 11:52 ` Lukas Wunner
2018-02-13 15:46 ` Liviu Dudau
[not found] ` <20180213154608.GI9111-A/Nd4k6kWRHZROr8t4l/smS4ubULX0JqMm0uRHvK7Nw@public.gmane.org>
2018-02-14 13:57 ` Lukas Wunner
2018-02-14 8:46 ` Lukas Wunner
2018-02-14 9:26 ` Maarten Lankhorst
[not found] ` <1ab1ea48-125c-a104-c11d-16d1e9d94b98-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2018-02-14 14:08 ` Sean Paul
2018-02-14 14:43 ` Michel Dänzer
2018-02-14 14:58 ` Sean Paul
2018-02-15 5:38 ` Lukas Wunner
2018-02-19 11:48 ` [Intel-gfx] " Daniel Vetter
2018-02-19 12:22 ` Lukas Wunner
2018-02-17 10:38 ` Lukas Wunner
2018-02-19 11:34 ` [Nouveau] " Daniel Vetter
2018-02-19 11:58 ` Lukas Wunner
2018-02-19 14:05 ` [Intel-gfx] " Daniel Vetter
2018-02-19 14:47 ` Lukas Wunner
2018-02-19 14:54 ` Daniel Vetter
2018-02-19 15:50 ` [Intel-gfx] " Alex Deucher
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=1518635272.3674.0.camel@redhat.com \
--to=lyude@redhat.com \
--cc=airlied@redhat.com \
--cc=alexander.deucher@amd.com \
--cc=architt@codeaurora.org \
--cc=bskeggs@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hdegoede@redhat.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=ismo.toijala@gmail.com \
--cc=lukas@wunner.de \
--cc=nouveau@lists.freedesktop.org \
--cc=peter@lekensteyn.nl \
--cc=pierre.morrow@free.fr \
/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