All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Dave Airlie <airlied@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: DPCD/AUX locking
Date: Wed, 7 May 2014 10:26:52 +0200	[thread overview]
Message-ID: <20140507082652.GS5730@phenom.ffwll.local> (raw)
In-Reply-To: <CAPM=9twQLROceO1sSoLHODmiwLNx+O0EnXYcuKxEzAzXxJi=kg@mail.gmail.com>

On Wed, May 07, 2014 at 09:20:41AM +1000, Dave Airlie wrote:
> So now I've been playing with MST I think get the feeling I might need
> some explicit locking on the AUX channel, I think at the moment the
> mode_config mutex implicitly defends the aux channel as the only real
> paths into it are
> 
> a) from userspace connector probing,
> b) from HPD irqs,

c) Directly through the i2c-over-dp_aux /dev nodes with e.g. ddc tools.

> currently both of these on i915 at least take mode config,
> 
> however with MST I can't use mode_config for this, so I'm wondering if
> I should be adding some explicit locking in the helpers or make it the
> drivers problem to lock around helper access?
> 
> Any ideas, it would most likely have to be a mutex since DPCD can in
> theory sleep.

Definitely needs to be a mutex since at leas i915 does sleep doing dp_aux
transactions.

With gmbus we've had a similar issue since that one's shared and there's
the direct i2c access path from userspace (or other kernel drivers, e.g.
google's pixie has a touchpad connected to the i915 gmbus controller
iirc).

Like Ben says that kind of locking must be done in the driver since. But
on hw which doesn't have shared dp aux pads I think the locking for
concurrent access from a)-c) should be done in the helper. I think we
actually need 2 locks:

1. Low-level hardware lock which is just held around calls to the drivers
aux.transfer callback. This avoids races between a) and b). I guess we
could debate whether this should be in drivers or not, but doing it in the
helper should restrict us and prevents stupid bugs. Drivers should have a
locking assert in their low-level dp aux functions to make sure other
(driver-internal callers) also obey this rule.

2. High-level dp aux interface lock. We need this to prevent races between
a) and c), which is currently completely broken. And maybe we'll add a raw
dp aux interface eventually too. All dp aux helpers which are exposed to
drivers and the i2c transfer functions should grab this except the single
entry point used to handle dp hpd events. Otherwise b) will deadlock
against a)&c).

Cheers, Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

      parent reply	other threads:[~2014-05-07  8:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-06 23:20 DPCD/AUX locking Dave Airlie
2014-05-07  5:26 ` Ben Skeggs
2014-05-07  7:12   ` Dave Airlie
2014-05-07  8:01     ` Thierry Reding
2014-05-07  8:26 ` Daniel Vetter [this message]

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=20140507082652.GS5730@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@gmail.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.