Skip to content

Commit 5f97ab9

Browse files
mslusarzBen Skeggs
authored andcommitted
drm/nouveau: add lockdep annotations
1) Lockdep thinks all nouveau subdevs belong to the same class and can be locked in arbitrary order, which is not true (at least in general case). Tell it to distinguish subdevs by (o)class type. 2) DRM client can be locked under user client lock - tell lockdep to put DRM client lock in a separate class. Reported-by: Arend van Spriel <arend@broadcom.com> Reported-by: Peter Hurley <peter@hurleysoftware.com> Reported-by: Maarten Lankhorst <maarten.lankhorst@canonical.com> Reported-by: Daniel J Blueman <daniel@quora.org> Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com> Cc: stable@vger.kernel.org [3.7, but needs s/const ofuncs/ofuncs/ to build] Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
1 parent 526810a commit 5f97ab9

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎drivers/gpu/drm/nouveau/core/core/subdev.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ nouveau_subdev_create_(struct nouveau_object *parent,
9999
if (ret)
100100
return ret;
101101

102-
mutex_init(&subdev->mutex);
102+
__mutex_init(&subdev->mutex, subname, &oclass->lock_class_key);
103103
subdev->name = subname;
104104

105105
if (parent) {

‎drivers/gpu/drm/nouveau/core/include/core/object.h‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,13 @@ int nouveau_object_fini(struct nouveau_object *, bool suspend);
5050

5151
extern struct nouveau_ofuncs nouveau_object_ofuncs;
5252

53+
/* Don't allocate dynamically, because lockdep needs lock_class_keys to be in
54+
* ".data". */
5355
struct nouveau_oclass {
5456
u32 handle;
55-
struct nouveau_ofuncs *ofuncs;
56-
struct nouveau_omthds *omthds;
57+
struct nouveau_ofuncs * const ofuncs;
58+
struct nouveau_omthds * const omthds;
59+
struct lock_class_key lock_class_key;
5760
};
5861

5962
#define nv_oclass(o) nv_object(o)->oclass

‎drivers/gpu/drm/nouveau/nouveau_drm.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ nouveau_drm_probe(struct pci_dev *pdev, const struct pci_device_id *pent)
245245
return 0;
246246
}
247247

248+
static struct lock_class_key drm_client_lock_class_key;
249+
248250
static int
249251
nouveau_drm_load(struct drm_device *dev, unsigned long flags)
250252
{
@@ -256,6 +258,7 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
256258
ret = nouveau_cli_create(pdev, "DRM", sizeof(*drm), (void**)&drm);
257259
if (ret)
258260
return ret;
261+
lockdep_set_class(&drm->client.mutex, &drm_client_lock_class_key);
259262

260263
dev->dev_private = drm;
261264
drm->dev = dev;

0 commit comments

Comments
 (0)