diff options
| author | Dan Williams <dan.j.williams@intel.com> | 2019-07-17 21:08:26 -0400 |
|---|---|---|
| committer | Dan Williams <dan.j.williams@intel.com> | 2019-07-18 19:23:27 -0400 |
| commit | 87a30e1f05d73a34e6d1895065541369131aaf1c (patch) | |
| tree | a5582d3cd7723db8b7ad2f4801a5540c36c5266a /include/linux/device.h | |
| parent | ca6bf264f6d856f959c4239cda1047b587745c67 (diff) | |
driver-core, libnvdimm: Let device subsystems add local lockdep coverage
For good reason, the standard device_lock() is marked
lockdep_set_novalidate_class() because there is simply no sane way to
describe the myriad ways the device_lock() ordered with other locks.
However, that leaves subsystems that know their own local device_lock()
ordering rules to find lock ordering mistakes manually. Instead,
introduce an optional / additional lockdep-enabled lock that a subsystem
can acquire in all the same paths that the device_lock() is acquired.
A conversion of the NFIT driver and NVDIMM subsystem to a
lockdep-validate device_lock() scheme is included. The
debug_nvdimm_lock() implementation implements the correct lock-class and
stacking order for the libnvdimm device topology hierarchy.
Yes, this is a hack, but hopefully it is a useful hack for other
subsystems device_lock() debug sessions. Quoting Greg:
"Yeah, it feels a bit hacky but it's really up to a subsystem to mess up
using it as much as anything else, so user beware :)
I don't object to it if it makes things easier for you to debug."
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Keith Busch <keith.busch@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Link: https://lore.kernel.org/r/156341210661.292348.7014034644265455704.stgit@dwillia2-desk3.amr.corp.intel.com
Diffstat (limited to 'include/linux/device.h')
| -rw-r--r-- | include/linux/device.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index 0da5c67f6be1..9237b857b598 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
| @@ -909,6 +909,8 @@ struct dev_links_info { | |||
| 909 | * This identifies the device type and carries type-specific | 909 | * This identifies the device type and carries type-specific |
| 910 | * information. | 910 | * information. |
| 911 | * @mutex: Mutex to synchronize calls to its driver. | 911 | * @mutex: Mutex to synchronize calls to its driver. |
| 912 | * @lockdep_mutex: An optional debug lock that a subsystem can use as a | ||
| 913 | * peer lock to gain localized lockdep coverage of the device_lock. | ||
| 912 | * @bus: Type of bus device is on. | 914 | * @bus: Type of bus device is on. |
| 913 | * @driver: Which driver has allocated this | 915 | * @driver: Which driver has allocated this |
| 914 | * @platform_data: Platform data specific to the device. | 916 | * @platform_data: Platform data specific to the device. |
| @@ -991,6 +993,9 @@ struct device { | |||
| 991 | core doesn't touch it */ | 993 | core doesn't touch it */ |
| 992 | void *driver_data; /* Driver data, set and get with | 994 | void *driver_data; /* Driver data, set and get with |
| 993 | dev_set_drvdata/dev_get_drvdata */ | 995 | dev_set_drvdata/dev_get_drvdata */ |
| 996 | #ifdef CONFIG_PROVE_LOCKING | ||
| 997 | struct mutex lockdep_mutex; | ||
| 998 | #endif | ||
| 994 | struct mutex mutex; /* mutex to synchronize calls to | 999 | struct mutex mutex; /* mutex to synchronize calls to |
| 995 | * its driver. | 1000 | * its driver. |
| 996 | */ | 1001 | */ |
