mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
To: Daniel Stone <daniel@fooishbar.org>
Cc: "Simona Vetter" <simona@ffwll.ch>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"David Airlie" <airlied@gmail.com>,
	"Stanislav Lisovskiy" <stanislav.lisovskiy@intel.com>,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	"Louis Chauvet" <louis.chauvet@bootlin.com>,
	"Haneen Mohammed" <hamohammed.sa@gmail.com>,
	"Melissa Wen" <melissa.srw@gmail.com>,
	"Daniel Stone" <daniel.stone@collabora.com>,
	"Ian Forbes" <ian.forbes@broadcom.com>,
	"Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	kernel@collabora.com, wayland-devel@lists.freedesktop.org,
	"Marius Vlad" <marius.vlad@collabora.com>
Subject: Re: [PATCH v9 2/2] drm: Send per-connector hotplug events
Date: Fri, 22 May 2026 21:28:27 +0200	[thread overview]
Message-ID: <nHIzMkkRSw6xN8LBsR66Zg@collabora.com> (raw)
In-Reply-To: <CAPj87rOiq1i6ZFaeYoeu3jhCRdZPiwdfffHBJ97ihTxmgMJ_VA@mail.gmail.com>

On Friday, 22 May 2026 19:58:26 Central European Summer Time Daniel Stone wrote:
> On Fri, 22 May 2026 at 14:06, Nicolas Frattaroli
> <nicolas.frattaroli@collabora.com> wrote:
> > On Thursday, 21 May 2026 17:00:17 Central European Summer Time Daniel Stone wrote:
> > > On Wed, 22 Apr 2026 at 19:24, Nicolas Frattaroli
> > > <nicolas.frattaroli@collabora.com> wrote:
> > > > +       /* Pick up any changes detected by the probe functions. */
> > > > +       if (dev->mode_config.delayed_event) {
> > >
> > > Not your doing, as it was just the same before, but doesn't this read
> > > need to be protected by the mode_config mutex?
> >
> > It looks like the fuzzy meaning of the mode_config.mutex came to
> > bite here. It is set to true with the lock held in
> > drm_helper_probe_single_connector_modes(), but set to false in this
> > function without the lock, and always read without the lock
> > (drm_kms_helper_poll_enable(), reschedule_output_poll_work()). Some
> > of these calls happen in paths where it might be inconvenient to take
> > a lock this coarse.
> >
> > Specifically, drm_helper_probe_single_connector_modes() has this
> > comment right before setting delayed_event to true:
> >
> >         /*
> >          * The hotplug event code might call into the fb
> >          * helpers, and so expects that we do not hold any
> >          * locks. Fire up the poll struct instead, it will
> >          * disable itself again.
> >          */
> >
> > So there was a problem with accessing parts under a lock before,
> > so if we're reintroducing the coarse lock wherever the boolean is
> > accessed we might be going backwards here.
> 
> Yeah, that makes sense - those are definitely called from an IRQ
> context so it wouldn't be safe to take the mode_config mutex.
> 
> I wonder if the safest path which guarantees eventual consistency is
> to change the !trylock(mode_config) { goto out } path in
> output_poll_execute() to jump directly to the schedule_delayed_work()?
> That way we could read and modify delayed_event under the mode_config
> mutex; the if (changed) path will not be taken if it wasn't possible
> to take the mode_config mutex.

If the drm_kms_helper_poll module parameter is set to false (i.e. the
non-default setting), with my patch we'd then also need to think about
the behavior if delayed_event == true in that case, since it also goes
to `out` without taking the lock.

I think I need to ponder this particular orb some more. I suspect it'd
be fine to move the delayed_event clearing + sending to before the
mutex unlock, since failing to lock the mutex will just make it repoll
and try again in 0.1 seconds. The event would only be lost if the
another delayed_event arrives before it's processed.

I think Ville's on the money here in that the users of delayed_event
might want to call a drm_client_dev_hotplug that does the work
scheduling instead, but that might be a bigger thing to work towards.

Kind regards,
Nicolas Frattaroli

> 
> Cheers,
> Daniel
> 





  parent reply	other threads:[~2026-05-22 19:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-22 18:24 [PATCH v9 0/2] Pass down hot-plug CONNECTOR ID to user-space Nicolas Frattaroli
2026-04-22 18:24 ` [PATCH v9 1/2] drm/connector: Fix epoch_counter docs to reflect reality Nicolas Frattaroli
2026-04-22 18:24 ` [PATCH v9 2/2] drm: Send per-connector hotplug events Nicolas Frattaroli
2026-05-21 15:00   ` Daniel Stone
2026-05-22 13:05     ` Nicolas Frattaroli
2026-05-22 17:58       ` Daniel Stone
2026-05-22 18:10         ` Ville Syrjälä
2026-05-22 19:28         ` Nicolas Frattaroli [this message]
2026-05-22 19:47           ` Daniel Stone

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=nHIzMkkRSw6xN8LBsR66Zg@collabora.com \
    --to=nicolas.frattaroli@collabora.com \
    --cc=airlied@gmail.com \
    --cc=daniel.stone@collabora.com \
    --cc=daniel@fooishbar.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hamohammed.sa@gmail.com \
    --cc=ian.forbes@broadcom.com \
    --cc=kernel@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=louis.chauvet@bootlin.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=marius.vlad@collabora.com \
    --cc=melissa.srw@gmail.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=stanislav.lisovskiy@intel.com \
    --cc=tzimmermann@suse.de \
    --cc=ville.syrjala@linux.intel.com \
    --cc=wayland-devel@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

all inboxes | Powered by JetHome®