All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ethernet: mvneta: Support netpoll
@ 2016-03-28 20:41 Ezequiel Garcia
  2016-03-30  3:09 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Ezequiel Garcia @ 2016-03-28 20:41 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: netdev, Ezequiel Garcia

This commit adds the support for netpoll, which is used
to implement netconsole.

Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
---
Tested on Armada 370 Mirabox and Armada XP Openblocks AX3-4
with netconsole.

 drivers/net/ethernet/marvell/mvneta.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 577f7ca7deba..dd114303c98f 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -3813,6 +3813,24 @@ static int mvneta_ethtool_get_rxfh(struct net_device *dev, u32 *indir, u8 *key,
 	return 0;
 }
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void mvneta_percpu_poll_controller(void *arg)
+{
+	struct mvneta_port *pp = arg;
+	struct mvneta_pcpu_port *pcpu_port =
+		this_cpu_ptr(pp->ports);
+	mvneta_isr(pp->dev->irq, pcpu_port);
+}
+
+/* Polled functionality used by netconsole and others in non interrupt mode */
+static void mvneta_poll_controller(struct net_device *dev)
+{
+	struct mvneta_port *pp = netdev_priv(dev);
+
+	on_each_cpu(mvneta_percpu_poll_controller, pp, false);
+}
+#endif
+
 static const struct net_device_ops mvneta_netdev_ops = {
 	.ndo_open            = mvneta_open,
 	.ndo_stop            = mvneta_stop,
@@ -3823,6 +3841,9 @@ static const struct net_device_ops mvneta_netdev_ops = {
 	.ndo_fix_features    = mvneta_fix_features,
 	.ndo_get_stats64     = mvneta_get_stats64,
 	.ndo_do_ioctl        = mvneta_ioctl,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	.ndo_poll_controller = mvneta_poll_controller,
+#endif
 };
 
 const struct ethtool_ops mvneta_eth_tool_ops = {
-- 
2.7.0

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

* Re: [PATCH] ethernet: mvneta: Support netpoll
  2016-03-28 20:41 [PATCH] ethernet: mvneta: Support netpoll Ezequiel Garcia
@ 2016-03-30  3:09 ` David Miller
  2016-03-30  4:59   ` Ezequiel Garcia
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2016-03-30  3:09 UTC (permalink / raw)
  To: ezequiel; +Cc: thomas.petazzoni, netdev

From: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Date: Mon, 28 Mar 2016 17:41:18 -0300

> +/* Polled functionality used by netconsole and others in non interrupt mode */
> +static void mvneta_poll_controller(struct net_device *dev)
> +{
> +	struct mvneta_port *pp = netdev_priv(dev);
> +
> +	on_each_cpu(mvneta_percpu_poll_controller, pp, false);
> +}

This doesn't work.

netpoll may be invoked from any context whatsoever, even hardware
interrupt handlers or contexts where cpu interrupts are disabled.

smp_call_function() and thus on_each_cpu() may not be called with
disabled interrupts or from a hardware interrupt handler or from
a bottom half handler, all of which are valid situations where
netpoll may occur since printk's can occur anywhere.

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

* Re: [PATCH] ethernet: mvneta: Support netpoll
  2016-03-30  3:09 ` David Miller
@ 2016-03-30  4:59   ` Ezequiel Garcia
  0 siblings, 0 replies; 3+ messages in thread
From: Ezequiel Garcia @ 2016-03-30  4:59 UTC (permalink / raw)
  To: David Miller; +Cc: Thomas Petazzoni, netdev

Hi David,

On 30 March 2016 at 00:09, David Miller <davem@davemloft.net> wrote:
> From: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
> Date: Mon, 28 Mar 2016 17:41:18 -0300
>
>> +/* Polled functionality used by netconsole and others in non interrupt mode */
>> +static void mvneta_poll_controller(struct net_device *dev)
>> +{
>> +     struct mvneta_port *pp = netdev_priv(dev);
>> +
>> +     on_each_cpu(mvneta_percpu_poll_controller, pp, false);
>> +}
>
> This doesn't work.
>
> netpoll may be invoked from any context whatsoever, even hardware
> interrupt handlers or contexts where cpu interrupts are disabled.
>
> smp_call_function() and thus on_each_cpu() may not be called with
> disabled interrupts or from a hardware interrupt handler or from
> a bottom half handler, all of which are valid situations where
> netpoll may occur since printk's can occur anywhere.

Well, I hated the idea of using on_each_cpu here, but wasn't sure
if there was a real reason that forbid it.

Thanks a lot for the feedback.
-- 
Ezequiel García, VanguardiaSur
www.vanguardiasur.com.ar

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

end of thread, other threads:[~2016-03-30  4:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-28 20:41 [PATCH] ethernet: mvneta: Support netpoll Ezequiel Garcia
2016-03-30  3:09 ` David Miller
2016-03-30  4:59   ` Ezequiel Garcia

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.