Skip to contentSkip to conversation

net: macb: change GFP_KERNEL to GFP_ATOMIC

PATCH Applied Julia Lawall 4 participants 13 messages Dec 2, 2017 – Dec 6, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: macb: change GFP_KERNEL to GFP_ATOMIC

Function gem_add_flow_filter called on line 2958 inside lock on line 2949 but uses GFP_KERNEL

Generated by: scripts/coccinelle/locks/call_kern.cocci

Fixes ae8223de3df5 ("net: macb: Added support for RX filtering")
CC Rafal Ozieblo <[email protected]>

---

v2: Fix some broken email addresses. No change to the patch.

tree:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
master

head:   fb20eb9d798d2f4c1a75b7fe981d72dfa8d7270d
commit: ae8223de3df5a0ce651d14a50dad31b9cae029f2 [2033/2251] net: macb:

Added support for RX filtering

 macb_main.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/cadence/macb_main.c +1 -1
@@ -2799,7 +2799,7 @@ static int gem_add_flow_filter(struct ne
 	int ret = -EINVAL;
 	bool added = false;
 
-	newfs = kmalloc(sizeof(*newfs), GFP_KERNEL);
+	newfs = kmalloc(sizeof(*newfs), GFP_ATOMIC);
 	if (newfs == NULL)
 		return -ENOMEM;
 	memcpy(&newfs->fs, fs, sizeof(newfs->fs));
maintainer Applied
#1 lore raw

From: Julia Lawall <[email protected]>
Date: Sat, 2 Dec 2017 08:01:21 +0100 (CET)

Quoted 9 lines

Function gem_add_flow_filter called on line 2958 inside lock on line 2949 but uses GFP_KERNEL

Generated by: scripts/coccinelle/locks/call_kern.cocci

Fixes ae8223de3df5 ("net: macb: Added support for RX filtering")
CC Rafal Ozieblo <[email protected]>

Applied to net-next.

#2 lore raw

PATCH 1/2 net: macb: reduce scope of rx_fs_lock-protected regions

In reply to Julia Lawall

Commit ae8223de3df5 ("net: macb: Added support for RX filtering") introduces a lock, rx_fs_lock which is intended to protect the list of rx_flow items and synchronize access to the hardware rx filtering registers.

However, the region protected by this lock is overscoped, unnecessarily including things like slab allocation. Reduce this lock scope to only include operations which must be performed atomically: list traversal, addition, and removal, and hitting the macb filtering registers.

This fixes the use of kmalloc w/ GFP_KERNEL in atomic context.

Fixes ae8223de3df5 ("net: macb: Added support for RX filtering")
Cc Rafal Ozieblo <[email protected]>
Cc Julia Lawall <[email protected]>

---
While Julia Lawall's cocci-generated patch fixes the problem, the right solution is to obviate the problem altogether.

Thanks,
The Other Julia

 drivers/net/ethernet/cadence/macb_main.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +14 -6
index c5fa87cdc6c4..e7ef104a077d 100644
@@ -2796,6 +2796,7 @@ static int gem_add_flow_filter(struct net_device *netdev,
 	struct macb *bp = netdev_priv(netdev);
 	struct ethtool_rx_flow_spec *fs = &cmd->fs;
 	struct ethtool_rx_fs_item *item, *newfs;
+	unsigned long flags;
 	int ret = -EINVAL;
 	bool added = false;
 
@@ -2811,6 +2812,8 @@ static int gem_add_flow_filter(struct net_device *netdev,
 			htonl(fs->h_u.tcp_ip4_spec.ip4dst),
 			htons(fs->h_u.tcp_ip4_spec.psrc), htons(fs->h_u.tcp_ip4_spec.pdst));
 
+	spin_lock_irqsave(&bp->rx_fs_lock, flags);
+
 	/* find correct place to add in list */
 	if (list_empty(&bp->rx_fs_list.list))
 		list_add(&newfs->list, &bp->rx_fs_list.list);
@@ -2837,9 +2840,11 @@ static int gem_add_flow_filter(struct net_device *netdev,
 	if (netdev->features & NETIF_F_NTUPLE)
 		gem_enable_flow_filters(bp, 1);
 
+	spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
 	return 0;
 
 err:
+	spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
 	kfree(newfs);
 	return ret;
 }
@@ -2850,9 +2855,14 @@ static int gem_del_flow_filter(struct net_device *netdev,
 	struct macb *bp = netdev_priv(netdev);
 	struct ethtool_rx_fs_item *item;
 	struct ethtool_rx_flow_spec *fs;
+	unsigned long flags;
 
-	if (list_empty(&bp->rx_fs_list.list))
+	spin_lock_irqsave(&bp->rx_fs_lock, flags);
+
+	if (list_empty(&bp->rx_fs_list.list)) {
+		spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
 		return -EINVAL;
+	}
 
 	list_for_each_entry(item, &bp->rx_fs_list.list, list) {
 		if (item->fs.location == cmd->fs.location) {
@@ -2869,12 +2879,14 @@ static int gem_del_flow_filter(struct net_device *netdev,
 			gem_writel_n(bp, SCRT2, fs->location, 0);
 
 			list_del(&item->list);
-			kfree(item);
 			bp->rx_fs_list.count--;
+			spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
+			kfree(item);
 			return 0;
 		}
 	}
 
+	spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
 	return -EINVAL;
 }
 
@@ -2943,11 +2955,8 @@ static int gem_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
 static int gem_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
 {
 	struct macb *bp = netdev_priv(netdev);
-	unsigned long flags;
 	int ret;
 
-	spin_lock_irqsave(&bp->rx_fs_lock, flags);
-
 	switch (cmd->cmd) {
 	case ETHTOOL_SRXCLSRLINS:
 		if ((cmd->fs.location >= bp->max_tuples)
@@ -2966,7 +2975,6 @@ static int gem_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
 		ret = -EOPNOTSUPP;
 	}
 
-	spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
 	return ret;
 }
 
Signature · 1 line
2.14.2
#3 lore raw

PATCH 2/2 net: macb: kill useless use of list_empty()

The list_for_each_entry() macro already handles the case where the list is empty (by not executing the loop body). It's not necessary to handle this case specially, so stop doing so.

---
This is an additional cleanup patch found when looking at this code.

Julia

 drivers/net/ethernet/cadence/macb_main.c | 34 ++++++++++++--------------------
 1 file changed, 13 insertions(+), 21 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +13 -21
index e7ef104a077d..3643c6ad2322 100644
@@ -2815,25 +2815,22 @@ static int gem_add_flow_filter(struct net_device *netdev,
 	spin_lock_irqsave(&bp->rx_fs_lock, flags);
 
 	/* find correct place to add in list */
-	if (list_empty(&bp->rx_fs_list.list))
-		list_add(&newfs->list, &bp->rx_fs_list.list);
-	else {
-		list_for_each_entry(item, &bp->rx_fs_list.list, list) {
-			if (item->fs.location > newfs->fs.location) {
-				list_add_tail(&newfs->list, &item->list);
-				added = true;
-				break;
-			} else if (item->fs.location == fs->location) {
-				netdev_err(netdev, "Rule not added: location %d not free!\n",
-						fs->location);
-				ret = -EBUSY;
-				goto err;
-			}
+	list_for_each_entry(item, &bp->rx_fs_list.list, list) {
+		if (item->fs.location > newfs->fs.location) {
+			list_add_tail(&newfs->list, &item->list);
+			added = true;
+			break;
+		} else if (item->fs.location == fs->location) {
+			netdev_err(netdev, "Rule not added: location %d not free!\n",
+					fs->location);
+			ret = -EBUSY;
+			goto err;
 		}
-		if (!added)
-			list_add_tail(&newfs->list, &bp->rx_fs_list.list);
 	}
 
+	if (!added)
+		list_add_tail(&newfs->list, &bp->rx_fs_list.list);
+
 	gem_prog_cmp_regs(bp, fs);
 	bp->rx_fs_list.count++;
 	/* enable filtering if NTUPLE on */
@@ -2859,11 +2856,6 @@ static int gem_del_flow_filter(struct net_device *netdev,
 
 	spin_lock_irqsave(&bp->rx_fs_lock, flags);
 
-	if (list_empty(&bp->rx_fs_list.list)) {
-		spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
-		return -EINVAL;
-	}
-
 	list_for_each_entry(item, &bp->rx_fs_list.list, list) {
 		if (item->fs.location == cmd->fs.location) {
 			/* disable screener regs for the flow entry */
Signature · 1 line
2.14.2
Acked-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] net: macb: kill useless use of list_empty()

Quoted 10 lines · Julia Cartwright

The list_for_each_entry() macro already handles the case where the list is empty (by not executing the loop body). It's not necessary to handle this case specially, so stop doing so.

---
This is an additional cleanup patch found when looking at this code.

Julia

Thanks

Quoted 60 lines
 drivers/net/ethernet/cadence/macb_main.c | 34 ++++++++++++--------------------
 1 file changed, 13 insertions(+), 21 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +13 -21
index e7ef104a077d..3643c6ad2322 100644
@@ -2815,25 +2815,22 @@ static int gem_add_flow_filter(struct net_device *netdev,
 	spin_lock_irqsave(&bp->rx_fs_lock, flags);
 
 	/* find correct place to add in list */
-	if (list_empty(&bp->rx_fs_list.list))
-		list_add(&newfs->list, &bp->rx_fs_list.list);
-	else {
-		list_for_each_entry(item, &bp->rx_fs_list.list, list) {
-			if (item->fs.location > newfs->fs.location) {
-				list_add_tail(&newfs->list, &item->list);
-				added = true;
-				break;
-			} else if (item->fs.location == fs->location) {
-				netdev_err(netdev, "Rule not added: location %d not free!\n",
-						fs->location);
-				ret = -EBUSY;
-				goto err;
-			}
+	list_for_each_entry(item, &bp->rx_fs_list.list, list) {
+		if (item->fs.location > newfs->fs.location) {
+			list_add_tail(&newfs->list, &item->list);
+			added = true;
+			break;
+		} else if (item->fs.location == fs->location) {
+			netdev_err(netdev, "Rule not added: location %d not free!\n",
+					fs->location);
+			ret = -EBUSY;
+			goto err;
 		}
-		if (!added)
-			list_add_tail(&newfs->list, &bp->rx_fs_list.list);
 	}
 
+	if (!added)
+		list_add_tail(&newfs->list, &bp->rx_fs_list.list);
+
 	gem_prog_cmp_regs(bp, fs);
 	bp->rx_fs_list.count++;
 	/* enable filtering if NTUPLE on */
@@ -2859,11 +2856,6 @@ static int gem_del_flow_filter(struct net_device *netdev,
 
 	spin_lock_irqsave(&bp->rx_fs_lock, flags);
 
-	if (list_empty(&bp->rx_fs_list.list)) {
-		spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
-		return -EINVAL;
-	}
-
 	list_for_each_entry(item, &bp->rx_fs_list.list, list) {
 		if (item->fs.location == cmd->fs.location) {
 			/* disable screener regs for the flow entry */
Signature · 1 line
Nicolas Ferre
Acked-by on v1 1/2
#5 lore raw

Re: [PATCH 1/2] net: macb: reduce scope of rx_fs_lock-protected regions

In reply to Julia Cartwright
Quoted 16 lines · Julia Cartwright

Commit ae8223de3df5 ("net: macb: Added support for RX filtering") introduces a lock, rx_fs_lock which is intended to protect the list of rx_flow items and synchronize access to the hardware rx filtering registers.

However, the region protected by this lock is overscoped, unnecessarily including things like slab allocation. Reduce this lock scope to only include operations which must be performed atomically: list traversal, addition, and removal, and hitting the macb filtering registers.

This fixes the use of kmalloc w/ GFP_KERNEL in atomic context.

Fixes ae8223de3df5 ("net: macb: Added support for RX filtering")
Cc Rafal Ozieblo <[email protected]>
Cc Julia Lawall <[email protected]>
Quoted 6 lines

---
While Julia Lawall's cocci-generated patch fixes the problem, the right solution is to obviate the problem altogether.

Thanks,
The Other Julia

Julia,

Thanks for your patch, it seems good indeed. Here is my:

As the patch by Julia L. is already in net-next, I suspect that you would need to add a kind of revert patch if we want to come back to a more usual GFP_KERNEL for the kmalloc.

Best regards,
Nicolas

Quoted 89 lines
 drivers/net/ethernet/cadence/macb_main.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +14 -6
index c5fa87cdc6c4..e7ef104a077d 100644
@@ -2796,6 +2796,7 @@ static int gem_add_flow_filter(struct net_device *netdev,
 	struct macb *bp = netdev_priv(netdev);
 	struct ethtool_rx_flow_spec *fs = &cmd->fs;
 	struct ethtool_rx_fs_item *item, *newfs;
+	unsigned long flags;
 	int ret = -EINVAL;
 	bool added = false;
 
@@ -2811,6 +2812,8 @@ static int gem_add_flow_filter(struct net_device *netdev,
 			htonl(fs->h_u.tcp_ip4_spec.ip4dst),
 			htons(fs->h_u.tcp_ip4_spec.psrc), htons(fs->h_u.tcp_ip4_spec.pdst));
 
+	spin_lock_irqsave(&bp->rx_fs_lock, flags);
+
 	/* find correct place to add in list */
 	if (list_empty(&bp->rx_fs_list.list))
 		list_add(&newfs->list, &bp->rx_fs_list.list);
@@ -2837,9 +2840,11 @@ static int gem_add_flow_filter(struct net_device *netdev,
 	if (netdev->features & NETIF_F_NTUPLE)
 		gem_enable_flow_filters(bp, 1);
 
+	spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
 	return 0;
 
 err:
+	spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
 	kfree(newfs);
 	return ret;
 }
@@ -2850,9 +2855,14 @@ static int gem_del_flow_filter(struct net_device *netdev,
 	struct macb *bp = netdev_priv(netdev);
 	struct ethtool_rx_fs_item *item;
 	struct ethtool_rx_flow_spec *fs;
+	unsigned long flags;
 
-	if (list_empty(&bp->rx_fs_list.list))
+	spin_lock_irqsave(&bp->rx_fs_lock, flags);
+
+	if (list_empty(&bp->rx_fs_list.list)) {
+		spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
 		return -EINVAL;
+	}
 
 	list_for_each_entry(item, &bp->rx_fs_list.list, list) {
 		if (item->fs.location == cmd->fs.location) {
@@ -2869,12 +2879,14 @@ static int gem_del_flow_filter(struct net_device *netdev,
 			gem_writel_n(bp, SCRT2, fs->location, 0);
 
 			list_del(&item->list);
-			kfree(item);
 			bp->rx_fs_list.count--;
+			spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
+			kfree(item);
 			return 0;
 		}
 	}
 
+	spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
 	return -EINVAL;
 }
 
@@ -2943,11 +2955,8 @@ static int gem_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
 static int gem_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
 {
 	struct macb *bp = netdev_priv(netdev);
-	unsigned long flags;
 	int ret;
 
-	spin_lock_irqsave(&bp->rx_fs_lock, flags);
-
 	switch (cmd->cmd) {
 	case ETHTOOL_SRXCLSRLINS:
 		if ((cmd->fs.location >= bp->max_tuples)
@@ -2966,7 +2975,6 @@ static int gem_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
 		ret = -EOPNOTSUPP;
 	}
 
-	spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
 	return ret;
 }
 
Signature · 1 line
Nicolas Ferre
maintainer
#6 lore raw

Re: [PATCH 1/2] net: macb: reduce scope of rx_fs_lock-protected regions

In reply to Julia Cartwright

From: Julia Cartwright <[email protected]>
Date: Tue, 5 Dec 2017 14:17:11 -0600

Quoted 2 lines

While Julia Lawall's cocci-generated patch fixes the problem, the right solution is to obviate the problem altogether.

I already applied Julia's patch. And I hope that if you generated this against current net-next you would have seen that.

So you'll need to redo this series and put the GFP_KERNEL back.

#7 lore raw

v2 cover macb rx filter cleanups

Here's a proper patchset based on net-next.

v1 -> v2:
- Rebased on net-next
- Add Nicolas's Acks
- Reorder commits, putting the list_empty() cleanups prior to the others.
- Added commit reverting the GFP_ATOMIC change.

Julia Cartwright (3):
net: macb: kill useless use of list_empty()
net: macb: reduce scope of rx_fs_lock-protected regions
net: macb: change GFP_ATOMIC to GFP_KERNEL

 drivers/net/ethernet/cadence/macb_main.c | 47 ++++++++++++++++----------------
 1 file changed, 23 insertions(+), 24 deletions(-)
Signature · 1 line
2.14.2
#8 lore raw

PATCH v2 1/3 net: macb: kill useless use of list_empty()

The list_for_each_entry() macro already handles the case where the list is empty (by not executing the loop body). It's not necessary to handle this case specially, so stop doing so.

---
 drivers/net/ethernet/cadence/macb_main.c | 31 ++++++++++++-------------------
 1 file changed, 12 insertions(+), 19 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +12 -19
index ebfeab853bf4..b7644836aba1 100644
@@ -2812,24 +2812,20 @@ static int gem_add_flow_filter(struct net_device *netdev,
 			htons(fs->h_u.tcp_ip4_spec.psrc), htons(fs->h_u.tcp_ip4_spec.pdst));
 
 	/* find correct place to add in list */
-	if (list_empty(&bp->rx_fs_list.list))
-		list_add(&newfs->list, &bp->rx_fs_list.list);
-	else {
-		list_for_each_entry(item, &bp->rx_fs_list.list, list) {
-			if (item->fs.location > newfs->fs.location) {
-				list_add_tail(&newfs->list, &item->list);
-				added = true;
-				break;
-			} else if (item->fs.location == fs->location) {
-				netdev_err(netdev, "Rule not added: location %d not free!\n",
-						fs->location);
-				ret = -EBUSY;
-				goto err;
-			}
+	list_for_each_entry(item, &bp->rx_fs_list.list, list) {
+		if (item->fs.location > newfs->fs.location) {
+			list_add_tail(&newfs->list, &item->list);
+			added = true;
+			break;
+		} else if (item->fs.location == fs->location) {
+			netdev_err(netdev, "Rule not added: location %d not free!\n",
+					fs->location);
+			ret = -EBUSY;
+			goto err;
 		}
-		if (!added)
-			list_add_tail(&newfs->list, &bp->rx_fs_list.list);
 	}
+	if (!added)
+		list_add_tail(&newfs->list, &bp->rx_fs_list.list);
 
 	gem_prog_cmp_regs(bp, fs);
 	bp->rx_fs_list.count++;
@@ -2851,9 +2847,6 @@ static int gem_del_flow_filter(struct net_device *netdev,
 	struct ethtool_rx_fs_item *item;
 	struct ethtool_rx_flow_spec *fs;
 
-	if (list_empty(&bp->rx_fs_list.list))
-		return -EINVAL;
-
 	list_for_each_entry(item, &bp->rx_fs_list.list, list) {
 		if (item->fs.location == cmd->fs.location) {
 			/* disable screener regs for the flow entry */
Signature · 1 line
2.14.2
#9 lore raw

PATCH v2 2/3 net: macb: reduce scope of rx_fs_lock-protected regions

In reply to Julia Cartwright

Commit ae8223de3df5 ("net: macb: Added support for RX filtering") introduces a lock, rx_fs_lock which is intended to protect the list of rx_flow items and synchronize access to the hardware rx filtering registers.

However, the region protected by this lock is overscoped, unnecessarily including things like slab allocation. Reduce this lock scope to only include operations which must be performed atomically: list traversal, addition, and removal, and hitting the macb filtering registers.

This fixes the use of kmalloc w/ GFP_KERNEL in atomic context.

Fixes ae8223de3df5 ("net: macb: Added support for RX filtering")
Cc Rafal Ozieblo <[email protected]>
Cc Julia Lawall <[email protected]>
---
 drivers/net/ethernet/cadence/macb_main.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +11 -5
index b7644836aba1..758e8b3042b2 100644
@@ -2796,6 +2796,7 @@ static int gem_add_flow_filter(struct net_device *netdev,
 	struct macb *bp = netdev_priv(netdev);
 	struct ethtool_rx_flow_spec *fs = &cmd->fs;
 	struct ethtool_rx_fs_item *item, *newfs;
+	unsigned long flags;
 	int ret = -EINVAL;
 	bool added = false;
 
@@ -2811,6 +2812,8 @@ static int gem_add_flow_filter(struct net_device *netdev,
 			htonl(fs->h_u.tcp_ip4_spec.ip4dst),
 			htons(fs->h_u.tcp_ip4_spec.psrc), htons(fs->h_u.tcp_ip4_spec.pdst));
 
+	spin_lock_irqsave(&bp->rx_fs_lock, flags);
+
 	/* find correct place to add in list */
 	list_for_each_entry(item, &bp->rx_fs_list.list, list) {
 		if (item->fs.location > newfs->fs.location) {
@@ -2833,9 +2836,11 @@ static int gem_add_flow_filter(struct net_device *netdev,
 	if (netdev->features & NETIF_F_NTUPLE)
 		gem_enable_flow_filters(bp, 1);
 
+	spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
 	return 0;
 
 err:
+	spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
 	kfree(newfs);
 	return ret;
 }
@@ -2846,6 +2851,9 @@ static int gem_del_flow_filter(struct net_device *netdev,
 	struct macb *bp = netdev_priv(netdev);
 	struct ethtool_rx_fs_item *item;
 	struct ethtool_rx_flow_spec *fs;
+	unsigned long flags;
+
+	spin_lock_irqsave(&bp->rx_fs_lock, flags);
 
 	list_for_each_entry(item, &bp->rx_fs_list.list, list) {
 		if (item->fs.location == cmd->fs.location) {
@@ -2862,12 +2870,14 @@ static int gem_del_flow_filter(struct net_device *netdev,
 			gem_writel_n(bp, SCRT2, fs->location, 0);
 
 			list_del(&item->list);
-			kfree(item);
 			bp->rx_fs_list.count--;
+			spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
+			kfree(item);
 			return 0;
 		}
 	}
 
+	spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
 	return -EINVAL;
 }
 
@@ -2936,11 +2946,8 @@ static int gem_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
 static int gem_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
 {
 	struct macb *bp = netdev_priv(netdev);
-	unsigned long flags;
 	int ret;
 
-	spin_lock_irqsave(&bp->rx_fs_lock, flags);
-
 	switch (cmd->cmd) {
 	case ETHTOOL_SRXCLSRLINS:
 		if ((cmd->fs.location >= bp->max_tuples)
@@ -2959,7 +2966,6 @@ static int gem_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
 		ret = -EOPNOTSUPP;
 	}
 
-	spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
 	return ret;
 }
 
Signature · 1 line
2.14.2
#10 lore raw

PATCH v2 3/3 net: macb: change GFP_ATOMIC to GFP_KERNEL

In reply to Julia Cartwright

Now that the rx_fs_lock is no longer held across allocation, it's safe to use GFP_KERNEL for allocating new entries.

This reverts commit 81da3bf6e3f88 ("net: macb: change GFP_KERNEL to GFP_ATOMIC").

---
 drivers/net/ethernet/cadence/macb_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/cadence/macb_main.c +1 -1
index 758e8b3042b2..234667eaaa92 100644
@@ -2800,7 +2800,7 @@ static int gem_add_flow_filter(struct net_device *netdev,
 	int ret = -EINVAL;
 	bool added = false;
 
-	newfs = kmalloc(sizeof(*newfs), GFP_ATOMIC);
+	newfs = kmalloc(sizeof(*newfs), GFP_KERNEL);
 	if (newfs == NULL)
 		return -ENOMEM;
 	memcpy(&newfs->fs, fs, sizeof(newfs->fs));
Signature · 1 line
2.14.2
author Acked-by on v2 3/3
#11 lore raw

Re: [PATCH v2 3/3] net: macb: change GFP_ATOMIC to GFP_KERNEL

Quoted 8 lines · Julia Cartwright

Now that the rx_fs_lock is no longer held across allocation, it's safe to use GFP_KERNEL for allocating new entries.

This reverts commit 81da3bf6e3f88 ("net: macb: change GFP_KERNEL to GFP_ATOMIC").

Quoted 21 lines
---
 drivers/net/ethernet/cadence/macb_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/cadence/macb_main.c +1 -2
index 758e8b3042b2..234667eaaa92 100644
@@ -2800,7 +2800,7 @@ static int gem_add_flow_filter(struct net_device *netdev,
 	int ret = -EINVAL;
 	bool added = false;
 
-	newfs = kmalloc(sizeof(*newfs), GFP_ATOMIC);
+	newfs = kmalloc(sizeof(*newfs), GFP_KERNEL);
 	if (newfs == NULL)
 		return -ENOMEM;
 	memcpy(&newfs->fs, fs, sizeof(newfs->fs));
--

2.14.2

maintainer
#12 lore raw

Re: [PATCH v2 0/3] macb rx filter cleanups

In reply to Julia Cartwright

From: Julia Cartwright <[email protected]>
Date: Tue, 5 Dec 2017 18:02:47 -0600

Quoted 8 lines

Here's a proper patchset based on net-next.

v1 -> v2:
- Rebased on net-next
- Add Nicolas's Acks
- Reorder commits, putting the list_empty() cleanups prior to the others.
- Added commit reverting the GFP_ATOMIC change.

Thanks for following up so quickly.

Series applied to net-next, thanks.