diff mbox series

[net,2/5] ionic: fix up filter locks and debug msgs

Message ID 20200720230017.20419-3-snelson@pensando.io
State Accepted
Delegated to: David Miller
Headers show
Series ionic: locking and filter fixes | expand

Commit Message

Shannon Nelson July 20, 2020, 11 p.m. UTC
Add in a couple of forgotten spinlocks and fix up some of
the debug messages around filter management.

Fixes: c1e329ebec8d ("ionic: Add management of rx filters")
Signed-off-by: Shannon Nelson <snelson@pensando.io>
---
 drivers/net/ethernet/pensando/ionic/ionic_lif.c | 17 +++++++----------
 .../ethernet/pensando/ionic/ionic_rx_filter.c   |  5 +++++
 2 files changed, 12 insertions(+), 10 deletions(-)

Comments

Jakub Kicinski July 21, 2020, 12:03 a.m. UTC | #1
On Mon, 20 Jul 2020 16:00:14 -0700 Shannon Nelson wrote:
> Add in a couple of forgotten spinlocks and fix up some of
> the debug messages around filter management.

Aren't these independent changes?

> Fixes: c1e329ebec8d ("ionic: Add management of rx filters")
> Signed-off-by: Shannon Nelson <snelson@pensando.io>

> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c b/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c
> index 80eeb7696e01..fb9d828812bd 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c
> @@ -69,10 +69,12 @@ int ionic_rx_filters_init(struct ionic_lif *lif)
>  
>  	spin_lock_init(&lif->rx_filters.lock);
>  
> +	spin_lock_bh(&lif->rx_filters.lock);
>  	for (i = 0; i < IONIC_RX_FILTER_HLISTS; i++) {
>  		INIT_HLIST_HEAD(&lif->rx_filters.by_hash[i]);
>  		INIT_HLIST_HEAD(&lif->rx_filters.by_id[i]);
>  	}
> +	spin_unlock_bh(&lif->rx_filters.lock);
>  
>  	return 0;
>  }
> @@ -84,11 +86,13 @@ void ionic_rx_filters_deinit(struct ionic_lif *lif)
>  	struct hlist_node *tmp;
>  	unsigned int i;
>  
> +	spin_lock_bh(&lif->rx_filters.lock);
>  	for (i = 0; i < IONIC_RX_FILTER_HLISTS; i++) {
>  		head = &lif->rx_filters.by_id[i];
>  		hlist_for_each_entry_safe(f, tmp, head, by_id)
>  			ionic_rx_filter_free(lif, f);
>  	}
> +	spin_unlock_bh(&lif->rx_filters.lock);
>  }

Taking a lock around init/deinit is a little strange, is this fixing 
a possible issue or just for "completeness"? If the like head can be
modified before it's initialized or after its flushed - that's a more
serious problem to address..
Shannon Nelson July 21, 2020, 1:05 a.m. UTC | #2
On 7/20/20 5:03 PM, Jakub Kicinski wrote:
> On Mon, 20 Jul 2020 16:00:14 -0700 Shannon Nelson wrote:
>> Add in a couple of forgotten spinlocks and fix up some of
>> the debug messages around filter management.
> Aren't these independent changes?

They can be... they went together in my head as a cleanup that was done 
before the filter_id patch that follows.

>
>> Fixes: c1e329ebec8d ("ionic: Add management of rx filters")
>> Signed-off-by: Shannon Nelson <snelson@pensando.io>
>> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c b/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c
>> index 80eeb7696e01..fb9d828812bd 100644
>> --- a/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c
>> +++ b/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c
>> @@ -69,10 +69,12 @@ int ionic_rx_filters_init(struct ionic_lif *lif)
>>   
>>   	spin_lock_init(&lif->rx_filters.lock);
>>   
>> +	spin_lock_bh(&lif->rx_filters.lock);
>>   	for (i = 0; i < IONIC_RX_FILTER_HLISTS; i++) {
>>   		INIT_HLIST_HEAD(&lif->rx_filters.by_hash[i]);
>>   		INIT_HLIST_HEAD(&lif->rx_filters.by_id[i]);
>>   	}
>> +	spin_unlock_bh(&lif->rx_filters.lock);
>>   
>>   	return 0;
>>   }
>> @@ -84,11 +86,13 @@ void ionic_rx_filters_deinit(struct ionic_lif *lif)
>>   	struct hlist_node *tmp;
>>   	unsigned int i;
>>   
>> +	spin_lock_bh(&lif->rx_filters.lock);
>>   	for (i = 0; i < IONIC_RX_FILTER_HLISTS; i++) {
>>   		head = &lif->rx_filters.by_id[i];
>>   		hlist_for_each_entry_safe(f, tmp, head, by_id)
>>   			ionic_rx_filter_free(lif, f);
>>   	}
>> +	spin_unlock_bh(&lif->rx_filters.lock);
>>   }
> Taking a lock around init/deinit is a little strange, is this fixing
> a possible issue or just for "completeness"? If the like head can be
> modified before it's initialized or after its flushed - that's a more
> serious problem to address..

Yes, this is a completeness thing.

sln
diff mbox series

Patch

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
index f49486b6d04d..41e86d6b76b6 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
@@ -863,8 +863,7 @@  static int ionic_lif_addr_add(struct ionic_lif *lif, const u8 *addr)
 	if (f)
 		return 0;
 
-	netdev_dbg(lif->netdev, "rx_filter add ADDR %pM (id %d)\n", addr,
-		   ctx.comp.rx_filter_add.filter_id);
+	netdev_dbg(lif->netdev, "rx_filter add ADDR %pM\n", addr);
 
 	memcpy(ctx.cmd.rx_filter_add.mac.addr, addr, ETH_ALEN);
 	err = ionic_adminq_post_wait(lif, &ctx);
@@ -893,6 +892,9 @@  static int ionic_lif_addr_del(struct ionic_lif *lif, const u8 *addr)
 		return -ENOENT;
 	}
 
+	netdev_dbg(lif->netdev, "rx_filter del ADDR %pM (id %d)\n",
+		   addr, f->filter_id);
+
 	ctx.cmd.rx_filter_del.filter_id = cpu_to_le32(f->filter_id);
 	ionic_rx_filter_free(lif, f);
 	spin_unlock_bh(&lif->rx_filters.lock);
@@ -901,9 +903,6 @@  static int ionic_lif_addr_del(struct ionic_lif *lif, const u8 *addr)
 	if (err && err != -EEXIST)
 		return err;
 
-	netdev_dbg(lif->netdev, "rx_filter del ADDR %pM (id %d)\n", addr,
-		   ctx.cmd.rx_filter_del.filter_id);
-
 	return 0;
 }
 
@@ -1351,13 +1350,11 @@  static int ionic_vlan_rx_add_vid(struct net_device *netdev, __be16 proto,
 	};
 	int err;
 
+	netdev_dbg(netdev, "rx_filter add VLAN %d\n", vid);
 	err = ionic_adminq_post_wait(lif, &ctx);
 	if (err)
 		return err;
 
-	netdev_dbg(netdev, "rx_filter add VLAN %d (id %d)\n", vid,
-		   ctx.comp.rx_filter_add.filter_id);
-
 	return ionic_rx_filter_save(lif, 0, IONIC_RXQ_INDEX_ANY, 0, &ctx);
 }
 
@@ -1382,8 +1379,8 @@  static int ionic_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto,
 		return -ENOENT;
 	}
 
-	netdev_dbg(netdev, "rx_filter del VLAN %d (id %d)\n", vid,
-		   le32_to_cpu(ctx.cmd.rx_filter_del.filter_id));
+	netdev_dbg(netdev, "rx_filter del VLAN %d (id %d)\n",
+		   vid, f->filter_id);
 
 	ctx.cmd.rx_filter_del.filter_id = cpu_to_le32(f->filter_id);
 	ionic_rx_filter_free(lif, f);
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c b/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c
index 80eeb7696e01..fb9d828812bd 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c
@@ -69,10 +69,12 @@  int ionic_rx_filters_init(struct ionic_lif *lif)
 
 	spin_lock_init(&lif->rx_filters.lock);
 
+	spin_lock_bh(&lif->rx_filters.lock);
 	for (i = 0; i < IONIC_RX_FILTER_HLISTS; i++) {
 		INIT_HLIST_HEAD(&lif->rx_filters.by_hash[i]);
 		INIT_HLIST_HEAD(&lif->rx_filters.by_id[i]);
 	}
+	spin_unlock_bh(&lif->rx_filters.lock);
 
 	return 0;
 }
@@ -84,11 +86,13 @@  void ionic_rx_filters_deinit(struct ionic_lif *lif)
 	struct hlist_node *tmp;
 	unsigned int i;
 
+	spin_lock_bh(&lif->rx_filters.lock);
 	for (i = 0; i < IONIC_RX_FILTER_HLISTS; i++) {
 		head = &lif->rx_filters.by_id[i];
 		hlist_for_each_entry_safe(f, tmp, head, by_id)
 			ionic_rx_filter_free(lif, f);
 	}
+	spin_unlock_bh(&lif->rx_filters.lock);
 }
 
 int ionic_rx_filter_save(struct ionic_lif *lif, u32 flow_id, u16 rxq_index,
@@ -124,6 +128,7 @@  int ionic_rx_filter_save(struct ionic_lif *lif, u32 flow_id, u16 rxq_index,
 	f->filter_id = le32_to_cpu(ctx->comp.rx_filter_add.filter_id);
 	f->rxq_index = rxq_index;
 	memcpy(&f->cmd, ac, sizeof(f->cmd));
+	netdev_dbg(lif->netdev, "rx_filter add filter_id %d\n", f->filter_id);
 
 	INIT_HLIST_NODE(&f->by_hash);
 	INIT_HLIST_NODE(&f->by_id);