aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/core.c1
-rw-r--r--include/linux/lockdep.h8
-rw-r--r--kernel/lockdep.c5
-rwxr-xr-xscripts/checkpatch.pl11
4 files changed, 25 insertions, 0 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index cf507a7d200c..4c5be85016b6 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -559,6 +559,7 @@ void device_initialize(struct device *dev)
559 kobject_init(&dev->kobj, &device_ktype); 559 kobject_init(&dev->kobj, &device_ktype);
560 INIT_LIST_HEAD(&dev->dma_pools); 560 INIT_LIST_HEAD(&dev->dma_pools);
561 mutex_init(&dev->mutex); 561 mutex_init(&dev->mutex);
562 lockdep_set_novalidate_class(&dev->mutex);
562 spin_lock_init(&dev->devres_lock); 563 spin_lock_init(&dev->devres_lock);
563 INIT_LIST_HEAD(&dev->devres_head); 564 INIT_LIST_HEAD(&dev->devres_head);
564 device_pm_init(dev); 565 device_pm_init(dev);
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index a03977a96d7e..06aed8305bf3 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -44,6 +44,8 @@ struct lock_class_key {
44 struct lockdep_subclass_key subkeys[MAX_LOCKDEP_SUBCLASSES]; 44 struct lockdep_subclass_key subkeys[MAX_LOCKDEP_SUBCLASSES];
45}; 45};
46 46
47extern struct lock_class_key __lockdep_no_validate__;
48
47#define LOCKSTAT_POINTS 4 49#define LOCKSTAT_POINTS 4
48 50
49/* 51/*
@@ -270,6 +272,9 @@ extern void lockdep_init_map(struct lockdep_map *lock, const char *name,
270#define lockdep_set_subclass(lock, sub) \ 272#define lockdep_set_subclass(lock, sub) \
271 lockdep_init_map(&(lock)->dep_map, #lock, \ 273 lockdep_init_map(&(lock)->dep_map, #lock, \
272 (lock)->dep_map.key, sub) 274 (lock)->dep_map.key, sub)
275
276#define lockdep_set_novalidate_class(lock) \
277 lockdep_set_class(lock, &__lockdep_no_validate__)
273/* 278/*
274 * Compare locking classes 279 * Compare locking classes
275 */ 280 */
@@ -354,6 +359,9 @@ static inline void lockdep_on(void)
354#define lockdep_set_class_and_subclass(lock, key, sub) \ 359#define lockdep_set_class_and_subclass(lock, key, sub) \
355 do { (void)(key); } while (0) 360 do { (void)(key); } while (0)
356#define lockdep_set_subclass(lock, sub) do { } while (0) 361#define lockdep_set_subclass(lock, sub) do { } while (0)
362
363#define lockdep_set_novalidate_class(lock) do { } while (0)
364
357/* 365/*
358 * We don't define lockdep_match_class() and lockdep_match_key() for !LOCKDEP 366 * We don't define lockdep_match_class() and lockdep_match_key() for !LOCKDEP
359 * case since the result is not well defined and the caller should rather 367 * case since the result is not well defined and the caller should rather
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index ec21304856d1..54286798c37b 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -2711,6 +2711,8 @@ void lockdep_init_map(struct lockdep_map *lock, const char *name,
2711} 2711}
2712EXPORT_SYMBOL_GPL(lockdep_init_map); 2712EXPORT_SYMBOL_GPL(lockdep_init_map);
2713 2713
2714struct lock_class_key __lockdep_no_validate__;
2715
2714/* 2716/*
2715 * This gets called for every mutex_lock*()/spin_lock*() operation. 2717 * This gets called for every mutex_lock*()/spin_lock*() operation.
2716 * We maintain the dependency maps and validate the locking attempt: 2718 * We maintain the dependency maps and validate the locking attempt:
@@ -2745,6 +2747,9 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
2745 return 0; 2747 return 0;
2746 } 2748 }
2747 2749
2750 if (lock->key == &__lockdep_no_validate__)
2751 check = 1;
2752
2748 if (!subclass) 2753 if (!subclass)
2749 class = lock->class_cache; 2754 class = lock->class_cache;
2750 /* 2755 /*
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a4d74344d805..f2bbea900700 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2656,6 +2656,7 @@ sub process {
2656# check for semaphores used as mutexes 2656# check for semaphores used as mutexes
2657 if ($line =~ /^.\s*init_MUTEX_LOCKED\s*\(/) { 2657 if ($line =~ /^.\s*init_MUTEX_LOCKED\s*\(/) {
2658 WARN("consider using a completion\n" . $herecurr); 2658 WARN("consider using a completion\n" . $herecurr);
2659
2659 } 2660 }
2660# recommend strict_strto* over simple_strto* 2661# recommend strict_strto* over simple_strto*
2661 if ($line =~ /\bsimple_(strto.*?)\s*\(/) { 2662 if ($line =~ /\bsimple_(strto.*?)\s*\(/) {
@@ -2740,6 +2741,16 @@ sub process {
2740 WARN("use of in_atomic() is incorrect outside core kernel code\n" . $herecurr); 2741 WARN("use of in_atomic() is incorrect outside core kernel code\n" . $herecurr);
2741 } 2742 }
2742 } 2743 }
2744
2745# check for lockdep_set_novalidate_class
2746 if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ ||
2747 $line =~ /__lockdep_no_validate__\s*\)/ ) {
2748 if ($realfile !~ m@^kernel/lockdep@ &&
2749 $realfile !~ m@^include/linux/lockdep@ &&
2750 $realfile !~ m@^drivers/base/core@) {
2751 ERROR("lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr);
2752 }
2753 }
2743 } 2754 }
2744 2755
2745 # If we have no input at all, then there is nothing to report on 2756 # If we have no input at all, then there is nothing to report on