procd: emit tty events for ttyUSB* even when they come from the usb-serial subsystem
[openwrt.git] / target / linux / mpc85xx / patches-3.10 / 200-gianfar_napi_poll_revert.patch
1 --- a/drivers/net/ethernet/freescale/gianfar.c
2 +++ b/drivers/net/ethernet/freescale/gianfar.c
3 @@ -132,7 +132,7 @@ static int gfar_poll(struct napi_struct
4  static void gfar_netpoll(struct net_device *dev);
5  #endif
6  int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit);
7 -static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue);
8 +static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue);
9  static void gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
10                                int amount_pull, struct napi_struct *napi);
11  void gfar_halt(struct net_device *dev);
12 @@ -2475,7 +2475,7 @@ static void gfar_align_skb(struct sk_buf
13  }
14  
15  /* Interrupt Handler for Transmit complete */
16 -static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
17 +static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
18  {
19         struct net_device *dev = tx_queue->dev;
20         struct netdev_queue *txq;
21 @@ -2575,6 +2575,8 @@ static void gfar_clean_tx_ring(struct gf
22         tx_queue->dirty_tx = bdp;
23  
24         netdev_tx_completed_queue(txq, howmany, bytes_sent);
25 +
26 +       return howmany;
27  }
28  
29  static void gfar_schedule_cleanup(struct gfar_priv_grp *gfargrp)
30 @@ -2833,82 +2835,62 @@ static int gfar_poll(struct napi_struct
31         struct gfar __iomem *regs = gfargrp->regs;
32         struct gfar_priv_tx_q *tx_queue = NULL;
33         struct gfar_priv_rx_q *rx_queue = NULL;
34 -       int work_done = 0, work_done_per_q = 0;
35 -       int i, budget_per_q = 0;
36 -       int has_tx_work;
37 -       unsigned long rstat_rxf;
38 -       int num_act_queues;
39 +       int rx_cleaned = 0, budget_per_queue = 0, rx_cleaned_per_queue = 0;
40 +       int tx_cleaned = 0, i, left_over_budget = budget;
41 +       unsigned long serviced_queues = 0;
42 +       int num_queues = 0;
43 +
44 +       num_queues = gfargrp->num_rx_queues;
45 +       budget_per_queue = budget/num_queues;
46  
47         /* Clear IEVENT, so interrupts aren't called again
48          * because of the packets that have already arrived
49          */
50         gfar_write(&regs->ievent, IEVENT_RTX_MASK);
51  
52 -       rstat_rxf = gfar_read(&regs->rstat) & RSTAT_RXF_MASK;
53 -
54 -       num_act_queues = bitmap_weight(&rstat_rxf, MAX_RX_QS);
55 -       if (num_act_queues)
56 -               budget_per_q = budget/num_act_queues;
57 -
58 -       while (1) {
59 -               has_tx_work = 0;
60 -               for_each_set_bit(i, &gfargrp->tx_bit_map, priv->num_tx_queues) {
61 -                       tx_queue = priv->tx_queue[i];
62 -                       /* run Tx cleanup to completion */
63 -                       if (tx_queue->tx_skbuff[tx_queue->skb_dirtytx]) {
64 -                               gfar_clean_tx_ring(tx_queue);
65 -                               has_tx_work = 1;
66 -                       }
67 -               }
68 +       while (num_queues && left_over_budget) {
69 +               budget_per_queue = left_over_budget/num_queues;
70 +               left_over_budget = 0;
71  
72                 for_each_set_bit(i, &gfargrp->rx_bit_map, priv->num_rx_queues) {
73 -                       /* skip queue if not active */
74 -                       if (!(rstat_rxf & (RSTAT_CLEAR_RXF0 >> i)))
75 +                       if (test_bit(i, &serviced_queues))
76                                 continue;
77 -
78                         rx_queue = priv->rx_queue[i];
79 -                       work_done_per_q =
80 -                               gfar_clean_rx_ring(rx_queue, budget_per_q);
81 -                       work_done += work_done_per_q;
82 -
83 -                       /* finished processing this queue */
84 -                       if (work_done_per_q < budget_per_q) {
85 -                               /* clear active queue hw indication */
86 -                               gfar_write(&regs->rstat,
87 -                                          RSTAT_CLEAR_RXF0 >> i);
88 -                               rstat_rxf &= ~(RSTAT_CLEAR_RXF0 >> i);
89 -                               num_act_queues--;
90 -
91 -                               if (!num_act_queues)
92 -                                       break;
93 -                               /* recompute budget per Rx queue */
94 -                               budget_per_q =
95 -                                       (budget - work_done) / num_act_queues;
96 +                       tx_queue = priv->tx_queue[rx_queue->qindex];
97 +
98 +                       tx_cleaned += gfar_clean_tx_ring(tx_queue);
99 +                       rx_cleaned_per_queue =
100 +                               gfar_clean_rx_ring(rx_queue, budget_per_queue);
101 +                       rx_cleaned += rx_cleaned_per_queue;
102 +                       if (rx_cleaned_per_queue < budget_per_queue) {
103 +                               left_over_budget = left_over_budget +
104 +                                       (budget_per_queue -
105 +                                        rx_cleaned_per_queue);
106 +                               set_bit(i, &serviced_queues);
107 +                               num_queues--;
108                         }
109                 }
110 +       }
111  
112 -               if (work_done >= budget)
113 -                       break;
114 -
115 -               if (!num_act_queues && !has_tx_work) {
116 +       if (tx_cleaned)
117 +               return budget;
118  
119 -                       napi_complete(napi);
120 +       if (rx_cleaned < budget) {
121 +               napi_complete(napi);
122  
123 -                       /* Clear the halt bit in RSTAT */
124 -                       gfar_write(&regs->rstat, gfargrp->rstat);
125 +               /* Clear the halt bit in RSTAT */
126 +               gfar_write(&regs->rstat, gfargrp->rstat);
127  
128 -                       gfar_write(&regs->imask, IMASK_DEFAULT);
129 +               gfar_write(&regs->imask, IMASK_DEFAULT);
130  
131 -                       /* If we are coalescing interrupts, update the timer
132 -                        * Otherwise, clear it
133 -                        */
134 -                       gfar_configure_coalescing(priv, gfargrp->rx_bit_map,
135 -                                                 gfargrp->tx_bit_map);
136 -                       break;
137 -               }
138 +               /* If we are coalescing interrupts, update the timer
139 +                * Otherwise, clear it
140 +                */
141 +               gfar_configure_coalescing(priv, gfargrp->rx_bit_map,
142 +                                         gfargrp->tx_bit_map);
143         }
144  
145 -       return work_done;
146 +       return rx_cleaned;
147  }
148  
149  #ifdef CONFIG_NET_POLL_CONTROLLER
150 --- a/drivers/net/ethernet/freescale/gianfar.h
151 +++ b/drivers/net/ethernet/freescale/gianfar.h
152 @@ -291,9 +291,7 @@ extern const char gfar_driver_version[];
153  #define RCTRL_PADDING(x)       ((x << 16) & RCTRL_PAL_MASK)
154  
155  
156 -#define RSTAT_CLEAR_RHALT      0x00800000
157 -#define RSTAT_CLEAR_RXF0       0x00000080
158 -#define RSTAT_RXF_MASK         0x000000ff
159 +#define RSTAT_CLEAR_RHALT       0x00800000
160  
161  #define TCTRL_IPCSEN           0x00004000
162  #define TCTRL_TUCSEN           0x00002000