diff mbox series

[v2] drivers: soc: ti: knav_qmss_queue: Pass lockdep expression to RCU lists

Message ID 20200118042433.4968-1-frextrite@gmail.com (mailing list archive)
State Mainlined
Commit feec214afb53f17554c9c0c85f72de709b7ba3e4
Headers show
Series [v2] drivers: soc: ti: knav_qmss_queue: Pass lockdep expression to RCU lists | expand

Commit Message

Amol Grover Jan. 18, 2020, 4:24 a.m. UTC
inst->handles is traversed using list_for_each_entry_rcu
outside an RCU read-side critical section but under the protection
of knav_dev_lock.

Hence, add corresponding lockdep expression to silence false-positive
lockdep warnings, and harden RCU lists.

Add macro for the corresponding lockdep expression.

Signed-off-by: Amol Grover <frextrite@gmail.com>
---
v2:
- Remove rcu_read_lock_held() from lockdep expression since it is
  implicitly checked for.

 drivers/soc/ti/knav_qmss_queue.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Santosh Shilimkar Jan. 18, 2020, 6:06 p.m. UTC | #1
On 1/17/20 8:24 PM, Amol Grover wrote:
> inst->handles is traversed using list_for_each_entry_rcu
> outside an RCU read-side critical section but under the protection
> of knav_dev_lock.
> 
> Hence, add corresponding lockdep expression to silence false-positive
> lockdep warnings, and harden RCU lists.
> 
> Add macro for the corresponding lockdep expression.
> 
> Signed-off-by: Amol Grover <frextrite@gmail.com>
> ---
> v2:
> - Remove rcu_read_lock_held() from lockdep expression since it is
>    implicitly checked for.
>
Thanks.
Acked-by: Santosh Shilimkar <ssantosh@kernel.org>

>   drivers/soc/ti/knav_qmss_queue.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
> index 1ccc9064e1eb..37f3db6c041c 100644
> --- a/drivers/soc/ti/knav_qmss_queue.c
> +++ b/drivers/soc/ti/knav_qmss_queue.c
> @@ -25,6 +25,8 @@
>   
>   static struct knav_device *kdev;
>   static DEFINE_MUTEX(knav_dev_lock);
> +#define knav_dev_lock_held() \
> +	lockdep_is_held(&knav_dev_lock)
>   
>   /* Queue manager register indices in DTS */
>   #define KNAV_QUEUE_PEEK_REG_INDEX	0
> @@ -52,8 +54,9 @@ static DEFINE_MUTEX(knav_dev_lock);
>   #define knav_queue_idx_to_inst(kdev, idx)			\
>   	(kdev->instances + (idx << kdev->inst_shift))
>   
> -#define for_each_handle_rcu(qh, inst)			\
> -	list_for_each_entry_rcu(qh, &inst->handles, list)
> +#define for_each_handle_rcu(qh, inst)				\
> +	list_for_each_entry_rcu(qh, &inst->handles, list,	\
> +				knav_dev_lock_held())
>   
>   #define for_each_instance(idx, inst, kdev)		\
>   	for (idx = 0, inst = kdev->instances;		\
> 

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#1271): https://linux.kernel.org/g/patchwork-soc/message/1271
Mute This Topic: https://linux.kernel.org/mt/69875375/1554929
Group Owner: patchwork-soc+owner@linux.kernel.org
Unsubscribe: https://linux.kernel.org/g/patchwork-soc/unsub  [patchwork-linux-kernel-org@patchwork.kernel.org]
-=-=-=-=-=-=-=-=-=-=-=-
patchwork-bot+linux-soc@kernel.org Jan. 20, 2020, 7:02 a.m. UTC | #2
Hello:

This patch was applied to soc/soc.git (refs/heads/for-next).

On Sat, 18 Jan 2020 09:54:34 +0530 you wrote:
> inst->handles is traversed using list_for_each_entry_rcu
> outside an RCU read-side critical section but under the protection
> of knav_dev_lock.
> 
> Hence, add corresponding lockdep expression to silence false-positive
> lockdep warnings, and harden RCU lists.
> 
> [...]


Here is a summary with links:
  - [v2] drivers: soc: ti: knav_qmss_queue: Pass lockdep expression to RCU lists
    https://git.kernel.org/soc/soc/c/b285d6aabffba2c9107aad14454eda84409ffef0

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
index 1ccc9064e1eb..37f3db6c041c 100644
--- a/drivers/soc/ti/knav_qmss_queue.c
+++ b/drivers/soc/ti/knav_qmss_queue.c
@@ -25,6 +25,8 @@ 
 
 static struct knav_device *kdev;
 static DEFINE_MUTEX(knav_dev_lock);
+#define knav_dev_lock_held() \
+	lockdep_is_held(&knav_dev_lock)
 
 /* Queue manager register indices in DTS */
 #define KNAV_QUEUE_PEEK_REG_INDEX	0
@@ -52,8 +54,9 @@  static DEFINE_MUTEX(knav_dev_lock);
 #define knav_queue_idx_to_inst(kdev, idx)			\
 	(kdev->instances + (idx << kdev->inst_shift))
 
-#define for_each_handle_rcu(qh, inst)			\
-	list_for_each_entry_rcu(qh, &inst->handles, list)
+#define for_each_handle_rcu(qh, inst)				\
+	list_for_each_entry_rcu(qh, &inst->handles, list,	\
+				knav_dev_lock_held())
 
 #define for_each_instance(idx, inst, kdev)		\
 	for (idx = 0, inst = kdev->instances;		\