aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/r6040.c
diff options
context:
space:
mode:
authorFlorian Fainelli <florian.fainelli@telecomint.eu>2008-07-13 08:28:27 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-07-22 19:56:29 -0400
commit3d25434816356e8d1e3167c5f7a56d3d81aeb239 (patch)
tree5a0f658324549defcaf2090141276996a2065df1 /drivers/net/r6040.c
parentc6e69bb92ed6e22a0931e29daff6539f2bac29b9 (diff)
r6040: fix null pointer access and tx timeouts
This patch fixes a null pointer access in r6040_rx due to lp->dev not being initialized. Fix the TX timeouts, TX irq was not re-enabled on RX irq Signed-Off-By: Joerg Albert <jal2@gmx.de> Signed-off-by: Florian Fainelli <florian.fainelli@telecomint.eu> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/r6040.c')
-rw-r--r--drivers/net/r6040.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c
index 4e67884bdc9e..d277deb872e0 100644
--- a/drivers/net/r6040.c
+++ b/drivers/net/r6040.c
@@ -91,6 +91,14 @@
91#define MISR 0x3C /* Status register */ 91#define MISR 0x3C /* Status register */
92#define MIER 0x40 /* INT enable register */ 92#define MIER 0x40 /* INT enable register */
93#define MSK_INT 0x0000 /* Mask off interrupts */ 93#define MSK_INT 0x0000 /* Mask off interrupts */
94#define RX_FINISH 0x0001 /* RX finished */
95#define RX_NO_DESC 0x0002 /* No RX descriptor available */
96#define RX_FIFO_FULL 0x0004 /* RX FIFO full */
97#define RX_EARLY 0x0008 /* RX early */
98#define TX_FINISH 0x0010 /* TX finished */
99#define TX_EARLY 0x0080 /* TX early */
100#define EVENT_OVRFL 0x0100 /* Event counter overflow */
101#define LINK_CHANGED 0x0200 /* PHY link changed */
94#define ME_CISR 0x44 /* Event counter INT status */ 102#define ME_CISR 0x44 /* Event counter INT status */
95#define ME_CIER 0x48 /* Event counter INT enable */ 103#define ME_CIER 0x48 /* Event counter INT enable */
96#define MR_CNT 0x50 /* Successfully received packet counter */ 104#define MR_CNT 0x50 /* Successfully received packet counter */
@@ -139,10 +147,10 @@ MODULE_AUTHOR("Sten Wang <sten.wang@rdc.com.tw>,"
139MODULE_LICENSE("GPL"); 147MODULE_LICENSE("GPL");
140MODULE_DESCRIPTION("RDC R6040 NAPI PCI FastEthernet driver"); 148MODULE_DESCRIPTION("RDC R6040 NAPI PCI FastEthernet driver");
141 149
142#define RX_INT 0x0001 150/* RX and TX interrupts that we handle */
143#define TX_INT 0x0010 151#define RX_INT (RX_FINISH)
144#define RX_NO_DESC_INT 0x0002 152#define TX_INT (TX_FINISH)
145#define INT_MASK (RX_INT | TX_INT) 153#define INT_MASK (RX_INT | TX_INT)
146 154
147struct r6040_descriptor { 155struct r6040_descriptor {
148 u16 status, len; /* 0-3 */ 156 u16 status, len; /* 0-3 */
@@ -502,8 +510,6 @@ static int r6040_rx(struct net_device *dev, int limit)
502 struct r6040_descriptor *descptr = priv->rx_remove_ptr; 510 struct r6040_descriptor *descptr = priv->rx_remove_ptr;
503 struct sk_buff *skb_ptr; 511 struct sk_buff *skb_ptr;
504 512
505 /* Disable RX interrupt */
506 iowrite16(ioread16(ioaddr + MIER) & (~RX_INT), ioaddr + MIER);
507 descptr = priv->rx_remove_ptr; 513 descptr = priv->rx_remove_ptr;
508 514
509 /* Check for errors */ 515 /* Check for errors */
@@ -639,8 +645,9 @@ static irqreturn_t r6040_interrupt(int irq, void *dev_id)
639 645
640 /* RX interrupt request */ 646 /* RX interrupt request */
641 if (status & 0x01) { 647 if (status & 0x01) {
648 /* Mask off RX interrupt */
649 iowrite16(ioread16(ioaddr + MIER) & ~RX_INT, ioaddr + MIER);
642 netif_rx_schedule(dev, &lp->napi); 650 netif_rx_schedule(dev, &lp->napi);
643 iowrite16(TX_INT, ioaddr + MIER);
644 } 651 }
645 652
646 /* TX interrupt request */ 653 /* TX interrupt request */
@@ -687,7 +694,11 @@ static void r6040_up(struct net_device *dev)
687 else 694 else
688 lp->phy_mode = (PHY_MODE & 0x0100) ? 0x8000:0x0; 695 lp->phy_mode = (PHY_MODE & 0x0100) ? 0x8000:0x0;
689 } 696 }
690 /* MAC Bus Control Register */ 697 /* MAC Bus Control Register :
698 * - wait 1 host clock SDRAM bus request
699 * - RX FIFO : 32 bytes
700 * - TX FIFO : 64 bytes
701 * - FIFO transfer lenght : 16 bytes */
691 iowrite16(MBCR_DEFAULT, ioaddr + MBCR); 702 iowrite16(MBCR_DEFAULT, ioaddr + MBCR);
692 703
693 /* MAC TX/RX Enable */ 704 /* MAC TX/RX Enable */
@@ -1018,6 +1029,7 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
1018 SET_NETDEV_DEV(dev, &pdev->dev); 1029 SET_NETDEV_DEV(dev, &pdev->dev);
1019 lp = netdev_priv(dev); 1030 lp = netdev_priv(dev);
1020 lp->pdev = pdev; 1031 lp->pdev = pdev;
1032 lp->dev = dev;
1021 1033
1022 if (pci_request_regions(pdev, DRV_NAME)) { 1034 if (pci_request_regions(pdev, DRV_NAME)) {
1023 printk(KERN_ERR DRV_NAME ": Failed to request PCI regions\n"); 1035 printk(KERN_ERR DRV_NAME ": Failed to request PCI regions\n");