Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
To: Matthew Auld <matthew.auld@intel.com>
Cc: Jocelyn Falempe <jfalempe@redhat.com>,
	Sarah Walker <sarah.walker@imgtec.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	dri-devel@lists.freedesktop.org,
	Boris Brezillon <boris.brezillon@collabora.com>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	intel-xe@lists.freedesktop.org
Subject: Re: [Intel-xe] [PATCH v2] drm: fix drmm_mutex_init()
Date: Fri, 19 May 2023 11:40:56 +0200	[thread overview]
Message-ID: <20230519094056.GB650806@linux.intel.com> (raw)
In-Reply-To: <20230519090733.489019-1-matthew.auld@intel.com>

On Fri, May 19, 2023 at 10:07:33AM +0100, Matthew Auld wrote:
> In mutex_init() lockdep identifies a lock by defining a special static
> key for each lock class. However if we wrap the macro in a function,
> like in drmm_mutex_init(), we end up generating:
> 
> int drmm_mutex_init(struct drm_device *dev, struct mutex *lock)
> {
>       static struct lock_class_key __key;
> 
>       __mutex_init((lock), "lock", &__key);
>       ....
> }
> 
> The static __key here is what lockdep uses to identify the lock class,
> however since this is just a normal function the key here will be
> created once, where all callers then use the same key. In effect the
> mutex->depmap.key will be the same pointer for different
> drmm_mutex_init() callers. This then results in impossible lockdep
> splats since lockdep thinks completely unrelated locks are the same lock
> class.
> 
> To fix this turn drmm_mutex_init() into a macro such that it generates a
> different "static struct lock_class_key __key" for each invocation,
> which looks to be inline with what mutex_init() wants.
> 
> v2:
>   - Revamp the commit message with clearer explanation of the issue.
>   - Rather export __drmm_mutex_release() than static inline.
> 
> Reported-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Reported-by: Sarah Walker <sarah.walker@imgtec.com>
> Fixes: e13f13e039dc ("drm: Add DRM-managed mutex_init()")
> Cc: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
> Cc: Boris Brezillon <boris.brezillon@collabora.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Jocelyn Falempe <jfalempe@redhat.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>

Regards
Stanislaw

  parent reply	other threads:[~2023-05-19  9:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-19  9:07 [Intel-xe] [PATCH v2] drm: fix drmm_mutex_init() Matthew Auld
2023-05-19  9:09 ` [Intel-xe] ✓ CI.Patch_applied: success for " Patchwork
2023-05-19  9:11 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-05-19  9:14 ` [Intel-xe] [PATCH v2] " Boris Brezillon
2023-05-19  9:15 ` [Intel-xe] ✓ CI.Build: success for " Patchwork
2023-05-19  9:40 ` Stanislaw Gruszka [this message]
2023-05-19  9:42 ` [Intel-xe] ○ CI.BAT: info " Patchwork
2023-05-19 15:20 ` [Intel-xe] [PATCH v2] " Lucas De Marchi
2023-05-22  9:43 ` Thomas Zimmermann
2023-05-22  9:50   ` Matthew Auld
2023-05-22 11:12     ` Thomas Zimmermann

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=20230519094056.GB650806@linux.intel.com \
    --to=stanislaw.gruszka@linux.intel.com \
    --cc=boris.brezillon@collabora.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jfalempe@redhat.com \
    --cc=matthew.auld@intel.com \
    --cc=sarah.walker@imgtec.com \
    --cc=tzimmermann@suse.de \
    /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