All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Hellstrom <thellstrom@vmware.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: DRI Development <dri-devel@lists.freedesktop.org>,
	Rob Clark <robdclark@gmail.com>,
	maarten.lankhorst@canonical.com, stable@vger.kernel.org,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [PATCH] drm: Drop modeset locking from crtc init function
Date: Mon, 8 Sep 2014 14:57:23 +0200	[thread overview]
Message-ID: <540DA7B3.2080601@vmware.com> (raw)
In-Reply-To: <1410159801-28400-1-git-send-email-daniel.vetter@ffwll.ch>

On 09/08/2014 09:03 AM, Daniel Vetter wrote:
> At driver init no one can access modeset objects and we're
> single-threaded. So locking is just cargo-culting here. Worse, with
> the new ww mutexes and ww mutex slowpath debugging the mutex_lock
> might actually fail, and we don't have the full-blown ww recovery
> dance.
>
> Which then leads to fireworks when we try to unlock the not-locked
> crtc lock.
>
> An audit of all the functions called from here shows that none of them
> contain locking checks, so there's also no reason to keep the locking
> around just for consistency of caller contexts. Besides that I have
> the rule (at least in i915) that such places where we take locks just
> to simplify locking checks and not for correctness always require a
> comment.

I'm not really opposed to any of the patches. It's clear that trylock
will work, and it's also clear that locking is not strictly needed, at
least not of a lock that has not been published yet.

However, I tend to go for the  "lock even if it's unnecessary" version
for a couple of reasons:

a) If that turns out to be impossible or very hard, then something is
probably wrong with the design.
b) It's good to think of locks where possible as "protecting data"
rather than serializing something. With that in mind, and if we in the
future were to have tools to automatically check that relevant locks are
held while accessing lock-protected stuff, we're in trouble.
c) Even if there aren't any functions now that check for relevant locks
held, there might be in the future.
d) People will probably spend time wondering why locking is done
elsewhere but not here.

So at least considering d) and b) I'd like to see documentation the
other way around:
If we avoid taking locks around data accesses that are supposed to be
protected by the lock for whatever reason, the reason should be documented.

Thanks,
Thomas

  reply	other threads:[~2014-09-08 12:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-05 11:59 [PATCH] drm: use trylock to avoid fault injection antics Rob Clark
2014-09-05 12:25 ` Daniel Vetter
2014-09-07 15:02   ` Rob Clark
2014-09-08  6:57     ` Thomas Hellstrom
2014-09-05 12:34 ` [PATCH] drm: Drop modeset locking from crtc init function Daniel Vetter
2014-09-08  7:03   ` Daniel Vetter
2014-09-08 12:57     ` Thomas Hellstrom [this message]
2014-09-08 13:41       ` Daniel Vetter

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=540DA7B3.2080601@vmware.com \
    --to=thellstrom@vmware.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=maarten.lankhorst@canonical.com \
    --cc=robdclark@gmail.com \
    --cc=stable@vger.kernel.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.