netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 1/2] ocelot: Don't sleep in atomic context (irqs_disabled())
@ 2019-04-16 14:51 Claudiu Manoil
  2019-04-16 14:51 ` [PATCH net 2/2] ocelot: Clean up stats update deferred work Claudiu Manoil
  2019-04-17  4:44 ` [PATCH net 1/2] ocelot: Don't sleep in atomic context (irqs_disabled()) David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Claudiu Manoil @ 2019-04-16 14:51 UTC (permalink / raw)
  To: netdev; +Cc: Alexandre Belloni, David S . Miller

 Preemption disabled at:
 [<ffff000008cabd54>] dev_set_rx_mode+0x1c/0x38
 Call trace:
 [<ffff00000808a5c0>] dump_backtrace+0x0/0x3d0
 [<ffff00000808a9a4>] show_stack+0x14/0x20
 [<ffff000008e6c0c0>] dump_stack+0xac/0xe4
 [<ffff0000080fe76c>] ___might_sleep+0x164/0x238
 [<ffff0000080fe890>] __might_sleep+0x50/0x88
 [<ffff0000082261e4>] kmem_cache_alloc+0x17c/0x1d0
 [<ffff000000ea0ae8>] ocelot_set_rx_mode+0x108/0x188 [mscc_ocelot_common]
 [<ffff000008cabcf0>] __dev_set_rx_mode+0x58/0xa0
 [<ffff000008cabd5c>] dev_set_rx_mode+0x24/0x38

Fixes: a556c76adc05 ("net: mscc: Add initial Ocelot switch support")

Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
---
 drivers/net/ethernet/mscc/ocelot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
index a1d0d6e42533..6cb2f03b67e6 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -613,7 +613,7 @@ static int ocelot_mact_mc_add(struct ocelot_port *port,
 			      struct netdev_hw_addr *hw_addr)
 {
 	struct ocelot *ocelot = port->ocelot;
-	struct netdev_hw_addr *ha = kzalloc(sizeof(*ha), GFP_KERNEL);
+	struct netdev_hw_addr *ha = kzalloc(sizeof(*ha), GFP_ATOMIC);
 
 	if (!ha)
 		return -ENOMEM;
-- 
2.17.1


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

* [PATCH net 2/2] ocelot: Clean up stats update deferred work
  2019-04-16 14:51 [PATCH net 1/2] ocelot: Don't sleep in atomic context (irqs_disabled()) Claudiu Manoil
@ 2019-04-16 14:51 ` Claudiu Manoil
  2019-04-17  4:44   ` David Miller
  2019-04-17  4:44 ` [PATCH net 1/2] ocelot: Don't sleep in atomic context (irqs_disabled()) David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Claudiu Manoil @ 2019-04-16 14:51 UTC (permalink / raw)
  To: netdev; +Cc: Alexandre Belloni, David S . Miller

This is preventive cleanup that may save troubles later.
No need to cancel repeateadly queued work if code is properly
refactored.
Don't let the ethtool -s process interfere with the stat workqueue
scheduling.

Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
---
 drivers/net/ethernet/mscc/ocelot.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
index 6cb2f03b67e6..d715ef4fc92f 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -959,10 +959,8 @@ static void ocelot_get_strings(struct net_device *netdev, u32 sset, u8 *data)
 		       ETH_GSTRING_LEN);
 }
 
-static void ocelot_check_stats(struct work_struct *work)
+static void ocelot_update_stats(struct ocelot *ocelot)
 {
-	struct delayed_work *del_work = to_delayed_work(work);
-	struct ocelot *ocelot = container_of(del_work, struct ocelot, stats_work);
 	int i, j;
 
 	mutex_lock(&ocelot->stats_lock);
@@ -986,11 +984,19 @@ static void ocelot_check_stats(struct work_struct *work)
 		}
 	}
 
-	cancel_delayed_work(&ocelot->stats_work);
+	mutex_unlock(&ocelot->stats_lock);
+}
+
+static void ocelot_check_stats_work(struct work_struct *work)
+{
+	struct delayed_work *del_work = to_delayed_work(work);
+	struct ocelot *ocelot = container_of(del_work, struct ocelot,
+					     stats_work);
+
+	ocelot_update_stats(ocelot);
+
 	queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work,
 			   OCELOT_STATS_CHECK_DELAY);
-
-	mutex_unlock(&ocelot->stats_lock);
 }
 
 static void ocelot_get_ethtool_stats(struct net_device *dev,
@@ -1001,7 +1007,7 @@ static void ocelot_get_ethtool_stats(struct net_device *dev,
 	int i;
 
 	/* check and update now */
-	ocelot_check_stats(&ocelot->stats_work.work);
+	ocelot_update_stats(ocelot);
 
 	/* Copy all counters */
 	for (i = 0; i < ocelot->num_stats; i++)
@@ -1809,7 +1815,7 @@ int ocelot_init(struct ocelot *ocelot)
 				 ANA_CPUQ_8021_CFG_CPUQ_BPDU_VAL(6),
 				 ANA_CPUQ_8021_CFG, i);
 
-	INIT_DELAYED_WORK(&ocelot->stats_work, ocelot_check_stats);
+	INIT_DELAYED_WORK(&ocelot->stats_work, ocelot_check_stats_work);
 	queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work,
 			   OCELOT_STATS_CHECK_DELAY);
 	return 0;
-- 
2.17.1


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

* Re: [PATCH net 1/2] ocelot: Don't sleep in atomic context (irqs_disabled())
  2019-04-16 14:51 [PATCH net 1/2] ocelot: Don't sleep in atomic context (irqs_disabled()) Claudiu Manoil
  2019-04-16 14:51 ` [PATCH net 2/2] ocelot: Clean up stats update deferred work Claudiu Manoil
@ 2019-04-17  4:44 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2019-04-17  4:44 UTC (permalink / raw)
  To: claudiu.manoil; +Cc: netdev, alexandre.belloni

From: Claudiu Manoil <claudiu.manoil@nxp.com>
Date: Tue, 16 Apr 2019 17:51:58 +0300

>  Preemption disabled at:
>  [<ffff000008cabd54>] dev_set_rx_mode+0x1c/0x38
>  Call trace:
>  [<ffff00000808a5c0>] dump_backtrace+0x0/0x3d0
>  [<ffff00000808a9a4>] show_stack+0x14/0x20
>  [<ffff000008e6c0c0>] dump_stack+0xac/0xe4
>  [<ffff0000080fe76c>] ___might_sleep+0x164/0x238
>  [<ffff0000080fe890>] __might_sleep+0x50/0x88
>  [<ffff0000082261e4>] kmem_cache_alloc+0x17c/0x1d0
>  [<ffff000000ea0ae8>] ocelot_set_rx_mode+0x108/0x188 [mscc_ocelot_common]
>  [<ffff000008cabcf0>] __dev_set_rx_mode+0x58/0xa0
>  [<ffff000008cabd5c>] dev_set_rx_mode+0x24/0x38
> 
> Fixes: a556c76adc05 ("net: mscc: Add initial Ocelot switch support")
> 
> Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>

Applied.

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

* Re: [PATCH net 2/2] ocelot: Clean up stats update deferred work
  2019-04-16 14:51 ` [PATCH net 2/2] ocelot: Clean up stats update deferred work Claudiu Manoil
@ 2019-04-17  4:44   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-04-17  4:44 UTC (permalink / raw)
  To: claudiu.manoil; +Cc: netdev, alexandre.belloni

From: Claudiu Manoil <claudiu.manoil@nxp.com>
Date: Tue, 16 Apr 2019 17:51:59 +0300

> This is preventive cleanup that may save troubles later.
> No need to cancel repeateadly queued work if code is properly
> refactored.
> Don't let the ethtool -s process interfere with the stat workqueue
> scheduling.
> 
> Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>

Applied.

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

end of thread, other threads:[~2019-04-17  4:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-16 14:51 [PATCH net 1/2] ocelot: Don't sleep in atomic context (irqs_disabled()) Claudiu Manoil
2019-04-16 14:51 ` [PATCH net 2/2] ocelot: Clean up stats update deferred work Claudiu Manoil
2019-04-17  4:44   ` David Miller
2019-04-17  4:44 ` [PATCH net 1/2] ocelot: Don't sleep in atomic context (irqs_disabled()) David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).