lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1418135842-21389-10-git-send-email-sd@queasysnail.net>
Date:	Tue,  9 Dec 2014 15:37:20 +0100
From:	Sabrina Dubroca <sd@...asysnail.net>
To:	davem@...emloft.net
Cc:	netdev@...r.kernel.org, Sabrina Dubroca <sd@...asysnail.net>,
	Anirudha Sarangi <anirudh@...inx.com>,
	John Linn <John.Linn@...inx.com>,
	Michal Simek <michal.simek@...inx.com>,
	Sören Brinkmann <soren.brinkmann@...inx.com>
Subject: [RFC PATCH net-next 09/11] xilinx/axienet: remove disable_irq from netpoll controller, use netpoll_irq_lock

disable_irq() may sleep, replace it with a spin_lock in the interrupt
handler and netpoll controller.

No actual testing done, only compiled.

Signed-off-by: Sabrina Dubroca <sd@...asysnail.net>
Cc: Anirudha Sarangi <anirudh@...inx.com>
Cc: John Linn <John.Linn@...inx.com>
Cc: Michal Simek <michal.simek@...inx.com>
Cc: "Sören Brinkmann" <soren.brinkmann@...inx.com>
---
 drivers/net/ethernet/xilinx/xilinx_axienet.h      |  3 +++
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 15 +++++++++------
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h
index 44b8d2bad8c3..b871857cb258 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet.h
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h
@@ -9,6 +9,7 @@
 #define XILINX_AXIENET_H
 
 #include <linux/netdevice.h>
+#include <linux/netpoll.h>
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
 
@@ -455,6 +456,8 @@ struct axienet_local {
 
 	u32 coalesce_count_rx;
 	u32 coalesce_count_tx;
+
+	struct netpoll_irq_lock netpoll_lock;
 };
 
 /**
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 4ea2d4e6f1d1..ff6be3d82618 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -806,6 +806,7 @@ static irqreturn_t axienet_tx_irq(int irq, void *_ndev)
 	struct net_device *ndev = _ndev;
 	struct axienet_local *lp = netdev_priv(ndev);
 
+	netpoll_irq_lock(&lp->netpoll_lock);
 	status = axienet_dma_in32(lp, XAXIDMA_TX_SR_OFFSET);
 	if (status & (XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK)) {
 		axienet_start_xmit_done(lp->ndev);
@@ -834,6 +835,7 @@ static irqreturn_t axienet_tx_irq(int irq, void *_ndev)
 	}
 out:
 	axienet_dma_out32(lp, XAXIDMA_TX_SR_OFFSET, status);
+	netpoll_irq_unlock(&lp->netpoll_lock);
 	return IRQ_HANDLED;
 }
 
@@ -854,6 +856,7 @@ static irqreturn_t axienet_rx_irq(int irq, void *_ndev)
 	struct net_device *ndev = _ndev;
 	struct axienet_local *lp = netdev_priv(ndev);
 
+	netpoll_irq_lock(&lp->netpoll_lock);
 	status = axienet_dma_in32(lp, XAXIDMA_RX_SR_OFFSET);
 	if (status & (XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK)) {
 		axienet_recv(lp->ndev);
@@ -882,6 +885,7 @@ static irqreturn_t axienet_rx_irq(int irq, void *_ndev)
 	}
 out:
 	axienet_dma_out32(lp, XAXIDMA_RX_SR_OFFSET, status);
+	netpoll_irq_unlock(&lp->netpoll_lock);
 	return IRQ_HANDLED;
 }
 
@@ -1035,18 +1039,15 @@ static int axienet_change_mtu(struct net_device *ndev, int new_mtu)
  * axienet_poll_controller - Axi Ethernet poll mechanism.
  * @ndev:	Pointer to net_device structure
  *
- * This implements Rx/Tx ISR poll mechanisms. The interrupts are disabled prior
- * to polling the ISRs and are enabled back after the polling is done.
+ * This implements Rx/Tx ISR poll mechanisms. The ISRs use a spinlock to
+ * protect against reentrancy when polling.
  */
 static void axienet_poll_controller(struct net_device *ndev)
 {
 	struct axienet_local *lp = netdev_priv(ndev);
-	disable_irq(lp->tx_irq);
-	disable_irq(lp->rx_irq);
+
 	axienet_rx_irq(lp->tx_irq, ndev);
 	axienet_tx_irq(lp->rx_irq, ndev);
-	enable_irq(lp->tx_irq);
-	enable_irq(lp->rx_irq);
 }
 #endif
 
@@ -1602,6 +1603,8 @@ static int axienet_of_probe(struct platform_device *op)
 	if (ret)
 		dev_warn(&op->dev, "error registering MDIO bus\n");
 
+	netpoll_irq_lock_init(&lp->netpoll_lock);
+
 	ret = register_netdev(lp->ndev);
 	if (ret) {
 		dev_err(lp->dev, "register_netdev() error (%i)\n", ret);
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ