Commit 60a0d23386eab0559ad32ae50b200cc58545f327

Authored by Johannes Berg
Committed by Linus Torvalds
1 parent c642b8391c

hibernate: fix lockdep report

Lockdep reports a circular locking dependency in the hibernate code
because
 - during system boot hibernate code (from an initcall) locks pm_mutex
   and then a sysfs buffer mutex via name_to_dev_t
 - during regular operation hibernate code locks pm_mutex under a
   sysfs buffer mutex because it's called from sysfs methods.

The deadlock can never happen because during initcall invocation nothing
can write to sysfs yet. This removes the lockdep report by marking the
initcall locking as being in a different class.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 11 additions and 1 deletions Side-by-side Diff

... ... @@ -456,7 +456,17 @@
456 456 int error;
457 457 unsigned int flags;
458 458  
459   - mutex_lock(&pm_mutex);
  459 + /*
  460 + * name_to_dev_t() below takes a sysfs buffer mutex when sysfs
  461 + * is configured into the kernel. Since the regular hibernate
  462 + * trigger path is via sysfs which takes a buffer mutex before
  463 + * calling hibernate functions (which take pm_mutex) this can
  464 + * cause lockdep to complain about a possible ABBA deadlock
  465 + * which cannot happen since we're in the boot code here and
  466 + * sysfs can't be invoked yet. Therefore, we use a subclass
  467 + * here to avoid lockdep complaining.
  468 + */
  469 + mutex_lock_nested(&pm_mutex, SINGLE_DEPTH_NESTING);
460 470 if (!swsusp_resume_device) {
461 471 if (!strlen(resume_file)) {
462 472 mutex_unlock(&pm_mutex);