Skip to contentSkip to conversation

Netpoll support for Sibyte MAC

PATCH Applied Deepak Saxena 5 participants 6 messages Mar 19, 2007 – Mar 23, 2007

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

PATCH 1/1 Netpoll support for Sibyte MAC

NETPOLL support for Sibyte MAC

---

Applies cleanly to 2.6.21-rc4

 drivers/net/sb1250-mac.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+)
drivers/net/sb1250-mac.c +23 -0
Index: linux-2.6.18/drivers/net/sb1250-mac.c
===================================================================
@@ -1128,6 +1128,26 @@ static void sbdma_fillring(sbmacdma_t *d
 	}
 }
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void sbmac_netpoll(struct net_device *netdev)
+{
+	struct sbmac_softc *sc = netdev_priv(netdev);
+	int irq = sc->sbm_dev->irq;
+
+	__raw_writeq(0, sc->sbm_imr);
+
+	sbmac_intr(irq, netdev, NULL);
+
+#ifdef CONFIG_SBMAC_COALESCE
+	__raw_writeq(((M_MAC_INT_EOP_COUNT | M_MAC_INT_EOP_TIMER) << S_MAC_TX_CH0) |
+	((M_MAC_INT_EOP_COUNT | M_MAC_INT_EOP_TIMER) << S_MAC_RX_CH0),
+	sc->sbm_imr);
+#else
+	__raw_writeq((M_MAC_INT_CHANNEL << S_MAC_TX_CH0) | 
+	(M_MAC_INT_CHANNEL << S_MAC_RX_CH0), sc->sbm_imr);
+#endif
+}
+#endif
 
 /**********************************************************************
  *  SBDMA_RX_PROCESS(sc,d)
@@ -2402,6 +2422,9 @@ static int sbmac_init(struct net_device 
 	dev->watchdog_timeo     = TX_TIMEOUT;
 
 	dev->change_mtu         = sb1250_change_mtu;
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	dev->poll_controller = sbmac_netpoll;
+#endif
 
 	/* This is needed for PASS2 for Rx H/W checksum feature */
 	sbmac_set_iphdr_offset(sc);
Signature · 4 lines
Deepak Saxena - [email protected] - http://www.plexity.net

In the end, they will not say, "those were dark times,"  they will ask
"why were their poets silent?" - Bertolt Brecht
#2 lore raw

Hello.

Quoted 8 lines · Atsushi Nemoto
Quoted 4 lines

NETPOLL support for Sibyte MAC

If you added NETPOLL support, do not forget to ensure hard_start_xmit routine callable from interrupt context (or irq disabled). See commit bce305f4fe779f29d99d414685243f5da0803254 for example.

You're absolutely right: this driver is very likely to blow up the caller
when called with interrupts disabled -- it uses spin_unlock_irq() there! This *must* be fixed.

Quoted 2 lines

---
Atsushi Nemoto

WBR, Sergei

#3 lore raw
In reply to Deepak Saxena

Hello.

Quoted 8 lines · Deepak Saxena

NETPOLL support for Sibyte MAC

Index: linux-2.6.18/drivers/net/sb1250-mac.c
===================================================================

drivers/net/sb1250-mac.c +0 -0
@@ -1128,6 +1128,26 @@ static void sbdma_fillring(sbmacdma_t *d
 	}

drivers/net/sb1250-mac.c static void sbdma_fillring(sbmacdma_t *d · line 1138

Quoted 10 lines
drivers/net/sb1250-mac.c +8 -0
 }
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void sbmac_netpoll(struct net_device *netdev)
+{
+	struct sbmac_softc *sc = netdev_priv(netdev);
+	int irq = sc->sbm_dev->irq;
+
+	__raw_writeq(0, sc->sbm_imr);
+

Thinking about it again, I'm not sure that blindly writing to the chip
reg. to mask interrupts is SMP-safe enough (versus disable_irq()). I know why it was done this way -- to quell the BUG emitted in the realtime mode on SMP -- because of scheduling with disabled interrupts in synchoronize_irq(), but after having spent much time on netpoll, I'm no longer sure that anything but disable_irq() is safe enough for SMP since -- otherwise there's no warranty that sbmac_intr() is not running on another CPU...

drivers/net/sb1250-mac.c static void sbdma_fillring(sbmacdma_t *d · line 1150

Quoted 12 lines
drivers/net/sb1250-mac.c +12 -0
+	sbmac_intr(irq, netdev, NULL);
+
+#ifdef CONFIG_SBMAC_COALESCE
+	__raw_writeq(((M_MAC_INT_EOP_COUNT | M_MAC_INT_EOP_TIMER) << S_MAC_TX_CH0) |
+	((M_MAC_INT_EOP_COUNT | M_MAC_INT_EOP_TIMER) << S_MAC_RX_CH0),
+	sc->sbm_imr);
+#else
+	__raw_writeq((M_MAC_INT_CHANNEL << S_MAC_TX_CH0) | 
+	(M_MAC_INT_CHANNEL << S_MAC_RX_CH0), sc->sbm_imr);
+#endif
+}
+#endif

WBR, Sergei

#4 lore raw
In reply to Deepak Saxena
Quoted 1 line · Deepak Saxena

+#ifdef CONFIG_SBMAC_COALESCE

Not your patch's fault but ... CONFIG_SBMAC_COALESCE is being defined in sb1250-mac.c but the CONFIG_* namespace is reserved for kconfig.

Ralf