add Avila/Cambria latch LED support, thanks Chris
[openwrt.git] / target / linux / ar7 / patches-2.6.25 / 140-cpmac_fix.patch
1 Index: linux-2.6.25.4/drivers/net/cpmac.c
2 ===================================================================
3 --- linux-2.6.25.4.orig/drivers/net/cpmac.c
4 +++ linux-2.6.25.4/drivers/net/cpmac.c
5 @@ -38,6 +38,7 @@
6 #include <linux/platform_device.h>
7 #include <linux/dma-mapping.h>
8 #include <asm/gpio.h>
9 +#include <asm/atomic.h>
10
11 MODULE_AUTHOR("Eugene Konev <ejka@imfi.kspu.ru>");
12 MODULE_DESCRIPTION("TI AR7 ethernet driver (CPMAC)");
13 @@ -207,6 +208,7 @@ struct cpmac_priv {
14 struct work_struct reset_work;
15 struct platform_device *pdev;
16 struct napi_struct napi;
17 + atomic_t reset_pending;
18 };
19
20 static irqreturn_t cpmac_irq(int, void *);
21 @@ -455,6 +457,9 @@ static int cpmac_start_xmit(struct sk_bu
22 struct cpmac_desc *desc;
23 struct cpmac_priv *priv = netdev_priv(dev);
24
25 + if (unlikely(atomic_read(&priv->reset_pending)))
26 + return NETDEV_TX_BUSY;
27 +
28 if (unlikely(skb_padto(skb, ETH_ZLEN)))
29 return NETDEV_TX_OK;
30
31 @@ -634,14 +639,14 @@ static void cpmac_clear_tx(struct net_de
32 priv->desc_ring[i].dataflags = 0;
33 if (priv->desc_ring[i].skb) {
34 dev_kfree_skb_any(priv->desc_ring[i].skb);
35 - if (netif_subqueue_stopped(dev, i))
36 - netif_wake_subqueue(dev, i);
37 + priv->desc_ring[i].skb = NULL;
38 }
39 }
40 }
41
42 static void cpmac_hw_error(struct work_struct *work)
43 {
44 + int i;
45 struct cpmac_priv *priv =
46 container_of(work, struct cpmac_priv, reset_work);
47
48 @@ -650,8 +655,47 @@ static void cpmac_hw_error(struct work_s
49 spin_unlock(&priv->rx_lock);
50 cpmac_clear_tx(priv->dev);
51 cpmac_hw_start(priv->dev);
52 - napi_enable(&priv->napi);
53 - netif_start_queue(priv->dev);
54 + barrier();
55 + atomic_dec(&priv->reset_pending);
56 +
57 + for (i = 0; i < CPMAC_QUEUES; i++) {
58 + netif_wake_subqueue(priv->dev, i);
59 + }
60 + netif_wake_queue(priv->dev);
61 + cpmac_write(priv->regs, CPMAC_MAC_INT_ENABLE, 3);
62 +}
63 +
64 +static void cpmac_check_status(struct net_device *dev)
65 +{
66 + struct cpmac_priv *priv = netdev_priv(dev);
67 +
68 + u32 macstatus = cpmac_read(priv->regs, CPMAC_MAC_STATUS);
69 + int rx_channel = (macstatus >> 8) & 7;
70 + int rx_code = (macstatus >> 12) & 15;
71 + int tx_channel = (macstatus >> 16) & 7;
72 + int tx_code = (macstatus >> 20) & 15;
73 +
74 + if (rx_code || tx_code) {
75 + if (netif_msg_drv(priv) && net_ratelimit()) {
76 + /* Can't find any documentation on what these error codes actually are.
77 + * So just log them and hope..
78 + */
79 + if (rx_code)
80 + printk(KERN_WARNING "%s: host error %d on rx channel %d (macstatus %08x), resetting\n",
81 + dev->name, rx_code, rx_channel, macstatus);
82 + if (tx_code)
83 + printk(KERN_WARNING "%s: host error %d on tx channel %d (macstatus %08x), resetting\n",
84 + dev->name, tx_code, tx_channel, macstatus);
85 + }
86 +
87 + netif_stop_queue(dev);
88 + cpmac_hw_stop(dev);
89 + if (schedule_work(&priv->reset_work))
90 + atomic_inc(&priv->reset_pending);
91 + if (unlikely(netif_msg_hw(priv)))
92 + cpmac_dump_regs(dev);
93 + }
94 + cpmac_write(priv->regs, CPMAC_MAC_INT_CLEAR, 0xff);
95 }
96
97 static irqreturn_t cpmac_irq(int irq, void *dev_id)
98 @@ -682,49 +726,33 @@ static irqreturn_t cpmac_irq(int irq, vo
99
100 cpmac_write(priv->regs, CPMAC_MAC_EOI_VECTOR, 0);
101
102 - if (unlikely(status & (MAC_INT_HOST | MAC_INT_STATUS))) {
103 - if (netif_msg_drv(priv) && net_ratelimit())
104 - printk(KERN_ERR "%s: hw error, resetting...\n",
105 - dev->name);
106 - netif_stop_queue(dev);
107 - napi_disable(&priv->napi);
108 - cpmac_hw_stop(dev);
109 - schedule_work(&priv->reset_work);
110 - if (unlikely(netif_msg_hw(priv)))
111 - cpmac_dump_regs(dev);
112 - }
113 + if (unlikely(status & (MAC_INT_HOST | MAC_INT_STATUS)))
114 + cpmac_check_status(dev);
115
116 return IRQ_HANDLED;
117 }
118
119 static void cpmac_tx_timeout(struct net_device *dev)
120 {
121 - struct cpmac_priv *priv = netdev_priv(dev);
122 int i;
123 + struct cpmac_priv *priv = netdev_priv(dev);
124
125 spin_lock(&priv->lock);
126 dev->stats.tx_errors++;
127 spin_unlock(&priv->lock);
128 if (netif_msg_tx_err(priv) && net_ratelimit())
129 printk(KERN_WARNING "%s: transmit timeout\n", dev->name);
130 - /*
131 - * FIXME: waking up random queue is not the best thing to
132 - * do... on the other hand why we got here at all?
133 - */
134 -#ifdef CONFIG_NETDEVICES_MULTIQUEUE
135 - for (i = 0; i < CPMAC_QUEUES; i++)
136 - if (priv->desc_ring[i].skb) {
137 - priv->desc_ring[i].dataflags = 0;
138 - dev_kfree_skb_any(priv->desc_ring[i].skb);
139 - netif_wake_subqueue(dev, i);
140 - break;
141 - }
142 -#else
143 - priv->desc_ring[0].dataflags = 0;
144 - if (priv->desc_ring[0].skb)
145 - dev_kfree_skb_any(priv->desc_ring[0].skb);
146 - netif_wake_queue(dev);
147 -#endif
148 +
149 + atomic_inc(&priv->reset_pending);
150 + barrier();
151 + cpmac_clear_tx(dev);
152 + barrier();
153 + atomic_dec(&priv->reset_pending);
154 +
155 + netif_wake_queue(priv->dev);
156 + for (i = 0; i < CPMAC_QUEUES; i++) {
157 + netif_wake_subqueue(dev, i);
158 + }
159 }
160
161 static int cpmac_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
162 @@ -911,6 +939,7 @@ static int cpmac_open(struct net_device
163 goto fail_irq;
164 }
165
166 + atomic_set(&priv->reset_pending, 0);
167 INIT_WORK(&priv->reset_work, cpmac_hw_error);
168 cpmac_hw_start(dev);
169
This page took 0.066203 seconds and 5 git commands to generate.