Marcin Slusarz  committed 5f97ab9

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 <>
Reported-by: Peter Hurley <>
Reported-by: Maarten Lankhorst <>
Reported-by: Daniel J Blueman <>
Signed-off-by: Marcin Slusarz <>
Cc: [3.7, but needs s/const ofuncs/ofuncs/ to build]
Signed-off-by: Ben Skeggs <>

  • Participants
  • Parent commits 526810a

Comments (0)

Files changed (3)

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

 	if (ret)
 		return ret;
-	mutex_init(&subdev->mutex);
+	__mutex_init(&subdev->mutex, subname, &oclass->lock_class_key);
 	subdev->name = subname;
 	if (parent) {

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

 extern struct nouveau_ofuncs nouveau_object_ofuncs;
+/* Don't allocate dynamically, because lockdep needs lock_class_keys to be in
+ * ".data". */
 struct nouveau_oclass {
 	u32 handle;
-	struct nouveau_ofuncs *ofuncs;
-	struct nouveau_omthds *omthds;
+	struct nouveau_ofuncs * const ofuncs;
+	struct nouveau_omthds * const omthds;
+	struct lock_class_key lock_class_key;
 #define nv_oclass(o)    nv_object(o)->oclass

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

 	return 0;
+static struct lock_class_key drm_client_lock_class_key;
 static int
 nouveau_drm_load(struct drm_device *dev, unsigned long flags)
 	ret = nouveau_cli_create(pdev, "DRM", sizeof(*drm), (void**)&drm);
 	if (ret)
 		return ret;
+	lockdep_set_class(&drm->client.mutex, &drm_client_lock_class_key);
 	dev->dev_private = drm;
 	drm->dev = dev;