Linux Kernel Mentees Archive on lore.kernel.org
 help / color / Atom feed
* [Linux-kernel-mentees] [PATCH] drivers: firewire: core-transaction: Pass lockdep condition to address_handler_list iterator
@ 2020-01-04 14:42 madhuparnabhowmik04
  2020-01-04 21:21 ` Joel Fernandes
  0 siblings, 1 reply; 2+ messages in thread
From: madhuparnabhowmik04 @ 2020-01-04 14:42 UTC (permalink / raw)
  To: stefanr, paulmck, joel
  Cc: linux-kernel, rcu, linux1394-devel, linux-kernel-mentees

From: Madhuparna Bhowmik <madhuparnabhowmik04@gmail.com>

The address_handler_list is traversed with list_for_each_entry_rcu
with address_handler_list_lock held.
list_for_each_entry_rcu has built-in RCU and lock checking.
Use it for address_handler_list traversal.

Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik04@gmail.com>
---
 drivers/firewire/core-transaction.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
index 404a035f104d..a15e70027932 100644
--- a/drivers/firewire/core-transaction.c
+++ b/drivers/firewire/core-transaction.c
@@ -61,6 +61,11 @@
 #define PHY_CONFIG_ROOT_ID(node_id)	((((node_id) & 0x3f) << 24) | (1 << 23))
 #define PHY_IDENTIFIER(id)		((id) << 30)
 
+static DEFINE_SPINLOCK(address_handler_list_lock);
+static LIST_HEAD(address_handler_list);
+
+#define address_handler_list_lock_held() lock_is_held(&(address_handler_list_lock).dep_map)
+
 /* returns 0 if the split timeout handler is already running */
 static int try_cancel_split_timeout(struct fw_transaction *t)
 {
@@ -485,7 +490,7 @@ static struct fw_address_handler *lookup_overlapping_address_handler(
 {
 	struct fw_address_handler *handler;
 
-	list_for_each_entry_rcu(handler, list, link) {
+	list_for_each_entry_rcu(handler, list, link, address_handler_list_lock_held()) {
 		if (handler->offset < offset + length &&
 		    offset < handler->offset + handler->length)
 			return handler;
@@ -514,8 +519,6 @@ static struct fw_address_handler *lookup_enclosing_address_handler(
 	return NULL;
 }
 
-static DEFINE_SPINLOCK(address_handler_list_lock);
-static LIST_HEAD(address_handler_list);
 
 const struct fw_address_region fw_high_memory_region =
 	{ .start = FW_MAX_PHYSICAL_RANGE, .end = 0xffffe0000000ULL, };
-- 
2.17.1

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH] drivers: firewire: core-transaction: Pass lockdep condition to address_handler_list iterator
  2020-01-04 14:42 [Linux-kernel-mentees] [PATCH] drivers: firewire: core-transaction: Pass lockdep condition to address_handler_list iterator madhuparnabhowmik04
@ 2020-01-04 21:21 ` Joel Fernandes
  0 siblings, 0 replies; 2+ messages in thread
From: Joel Fernandes @ 2020-01-04 21:21 UTC (permalink / raw)
  To: madhuparnabhowmik04
  Cc: paulmck, linux-kernel, rcu, stefanr, linux1394-devel,
	linux-kernel-mentees

On Sat, Jan 04, 2020 at 08:12:15PM +0530, madhuparnabhowmik04@gmail.com wrote:
> From: Madhuparna Bhowmik <madhuparnabhowmik04@gmail.com>
> 
> The address_handler_list is traversed with list_for_each_entry_rcu
> with address_handler_list_lock held.
> list_for_each_entry_rcu has built-in RCU and lock checking.
> Use it for address_handler_list traversal.
> 
> Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik04@gmail.com>

Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>

thanks,

 - Joel

> ---
>  drivers/firewire/core-transaction.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
> index 404a035f104d..a15e70027932 100644
> --- a/drivers/firewire/core-transaction.c
> +++ b/drivers/firewire/core-transaction.c
> @@ -61,6 +61,11 @@
>  #define PHY_CONFIG_ROOT_ID(node_id)	((((node_id) & 0x3f) << 24) | (1 << 23))
>  #define PHY_IDENTIFIER(id)		((id) << 30)
>  
> +static DEFINE_SPINLOCK(address_handler_list_lock);
> +static LIST_HEAD(address_handler_list);
> +
> +#define address_handler_list_lock_held() lock_is_held(&(address_handler_list_lock).dep_map)
> +
>  /* returns 0 if the split timeout handler is already running */
>  static int try_cancel_split_timeout(struct fw_transaction *t)
>  {
> @@ -485,7 +490,7 @@ static struct fw_address_handler *lookup_overlapping_address_handler(
>  {
>  	struct fw_address_handler *handler;
>  
> -	list_for_each_entry_rcu(handler, list, link) {
> +	list_for_each_entry_rcu(handler, list, link, address_handler_list_lock_held()) {
>  		if (handler->offset < offset + length &&
>  		    offset < handler->offset + handler->length)
>  			return handler;
> @@ -514,8 +519,6 @@ static struct fw_address_handler *lookup_enclosing_address_handler(
>  	return NULL;
>  }
>  
> -static DEFINE_SPINLOCK(address_handler_list_lock);
> -static LIST_HEAD(address_handler_list);
>  
>  const struct fw_address_region fw_high_memory_region =
>  	{ .start = FW_MAX_PHYSICAL_RANGE, .end = 0xffffe0000000ULL, };
> -- 
> 2.17.1
> 
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-04 14:42 [Linux-kernel-mentees] [PATCH] drivers: firewire: core-transaction: Pass lockdep condition to address_handler_list iterator madhuparnabhowmik04
2020-01-04 21:21 ` Joel Fernandes

Linux Kernel Mentees Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-kernel-mentees/0 linux-kernel-mentees/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-kernel-mentees linux-kernel-mentees/ https://lore.kernel.org/linux-kernel-mentees \
		linux-kernel-mentees@lists.linuxfoundation.org
	public-inbox-index linux-kernel-mentees

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.linuxfoundation.lists.linux-kernel-mentees


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git