public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Florian Fainelli <florian@openwrt•org>
To: David Miller <davem@davemloft•net>,
	jeff@garzik•org, netdev@vger•kernel.org,
	Joe Chou <Joe.Chou@rdc•com.tw>
Subject: [PATCH 1/4] r6040: fix ifconfig down and freeing of tx/rx descriptors
Date: Fri, 9 Jan 2009 02:04:39 +0100	[thread overview]
Message-ID: <200901090204.39930.florian@openwrt.org> (raw)

From: Florian Fainelli <florian@openwrt•org>
Subject: [PATCH 1/4] r6040: fix ifconfig down and freeing of tx/rx descriptors

This patch fixes warnings and such traces that appear when doing
an ifconfig down on the interface:

WARNING: at arch/x86/kernel/pci-dma.c:376 dma_free_coherent+0x40/0x7d()
Modules linked in:

Signed-off-by: Joe Chou <joe.chou@rdc•com.tw>
Signed-off-by: Florian Fainelli <florian@openwrt•org>
---
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c
index 706a0af..6b8bc6d 100644
--- a/drivers/net/r6040.c
+++ b/drivers/net/r6040.c
@@ -457,17 +457,6 @@ static void r6040_down(struct net_device *dev)
 	iowrite16(adrp[0], ioaddr + MID_0L);
 	iowrite16(adrp[1], ioaddr + MID_0M);
 	iowrite16(adrp[2], ioaddr + MID_0H);
-	free_irq(dev->irq, dev);
-
-	/* Free RX buffer */
-	r6040_free_rxbufs(dev);
-
-	/* Free TX buffer */
-	r6040_free_txbufs(dev);
-
-	/* Free Descriptor memory */
-	pci_free_consistent(pdev, RX_DESC_SIZE, lp->rx_ring, lp->rx_ring_dma);
-	pci_free_consistent(pdev, TX_DESC_SIZE, lp->tx_ring, lp->tx_ring_dma);
 }
 
 static int r6040_close(struct net_device *dev)
@@ -481,8 +470,28 @@ static int r6040_close(struct net_device *dev)
 	napi_disable(&lp->napi);
 	netif_stop_queue(dev);
 	r6040_down(dev);
+	
+	free_irq(dev->irq, dev);
+
+	/* Free RX buffer */
+	r6040_free_rxbufs(dev);
+
+	/* Free TX buffer */
+	r6040_free_txbufs(dev);
+	
 	spin_unlock_irq(&lp->lock);
 
+	/* Free Descriptor memory */
+	if (lp->rx_ring) {
+		pci_free_consistent(pdev, RX_DESC_SIZE, lp->rx_ring, lp->rx_ring_dma);
+		lp->rx_ring = 0;
+	}
+
+	if (lp->tx_ring) {
+		pci_free_consistent(pdev, TX_DESC_SIZE, lp->tx_ring, lp->tx_ring_dma);
+		lp->tx_ring = 0;
+	}
+
 	return 0;
 }
 

             reply	other threads:[~2009-01-09  1:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-09  1:04 Florian Fainelli [this message]
2009-01-10  7:07 ` [PATCH 1/4] r6040: fix ifconfig down and freeing of tx/rx descriptors David Miller
2009-01-10  7:16   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200901090204.39930.florian@openwrt.org \
    --to=florian@openwrt$(echo .)org \
    --cc=Joe.Chou@rdc$(echo .)com.tw \
    --cc=davem@davemloft$(echo .)net \
    --cc=jeff@garzik$(echo .)org \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox