huge madwifi update - use a madwifi-ng-refcount snapshot as base, includes lots of...
[openwrt.git] / package / madwifi / patches / 120-soc_fix.patch
1 diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath_ahb.c madwifi-ng-refcount-r2313-20070505.dev/ath/if_ath_ahb.c
2 --- madwifi-ng-refcount-r2313-20070505.old/ath/if_ath_ahb.c     2007-03-08 20:59:06.000000000 +0100
3 +++ madwifi-ng-refcount-r2313-20070505.dev/ath/if_ath_ahb.c     2007-05-13 18:17:56.367999800 +0200
4 @@ -274,12 +274,12 @@
5  }
6  
7  
8 +
9  static int
10 -exit_ath_wmac(u_int16_t wlanNum)
11 +exit_ath_wmac(u_int16_t wlanNum, struct ar531x_config *config)
12  {
13         struct ath_ahb_softc *sc = sclist[wlanNum];
14         struct net_device *dev;
15 -       const char *sysType;
16         u_int16_t devid;        
17  
18         if (sc == NULL)
19 @@ -289,13 +289,17 @@
20         ath_detach(dev);
21         if (dev->irq)
22                 free_irq(dev->irq, dev);
23 -       sysType = get_system_type();
24 -       if (!strcmp(sysType, "Atheros AR5315"))
25 +
26 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
27 +       devid = (u32) config->tag;
28 +#else
29 +       if (!strcmp(get_system_type(), "Atheros AR5315"))
30                 devid = (u_int16_t) (sysRegRead(AR5315_SREV) &
31                         (AR5315_REV_MAJ_M | AR5315_REV_MIN_M));
32         else
33                 devid = (u_int16_t) ((sysRegRead(AR531X_REV) >> 8) & 
34                         (AR531X_REV_MAJ | AR531X_REV_MIN));
35 +#endif
36    
37         ahb_disable_wmac(devid, wlanNum);
38         free_netdev(dev);
39 @@ -401,7 +405,7 @@
40  
41  static int ahb_wmac_remove(struct platform_device *pdev)
42  {
43 -       exit_ath_wmac(pdev->id);
44 +       exit_ath_wmac(pdev->id, (struct ar531x_config *) pdev->dev.platform_data);
45  
46         return 0;
47  }
48 @@ -439,7 +443,7 @@
49                         (AR5315_REV_MAJ_M | AR5315_REV_MIN_M));
50                 if (((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) ||
51                         ((devid & AR5315_REV_MAJ_M) == AR5317_REV_MAJ))
52 -                       return init_ath_wmac(devid, 0, &config);
53 +                       return init_ath_wmac(devid, 0);
54         }
55  
56         devid = (u_int16_t) ((sysRegRead(AR531X_REV) >>8) &
57 @@ -452,11 +456,11 @@
58                 ar5312BspEepromRead(2 * AR531X_RADIO_MASK_OFF, 2,
59                         (char *) &radioMask);
60                 if ((radioMask & AR531X_RADIO0_MASK) != 0)
61 -                       if ((ret = init_ath_wmac(devid, 0, &config)) !=0 )
62 +                       if ((ret = init_ath_wmac(devid, 0)) !=0 )
63                                 return ret;
64                 /* XXX: Fall through?! */
65         case AR5212_AR2313_REV8:
66 -               if ((ret = init_ath_wmac(devid, 1, &config)) != 0)
67 +               if ((ret = init_ath_wmac(devid, 1)) != 0)
68                         return ret;
69                 break;
70         default:
71 diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcount-r2313-20070505.dev/ath/if_ath.c
72 --- madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c 2007-05-13 18:17:56.362000712 +0200
73 +++ madwifi-ng-refcount-r2313-20070505.dev/ath/if_ath.c 2007-05-13 18:17:56.371999192 +0200
74 @@ -2490,6 +2490,7 @@
75                 DPRINTF(sc,ATH_DEBUG_XMIT,                              \
76                         "%s: discard, no xmit buf\n", __func__);        \
77                 sc->sc_stats.ast_tx_nobuf++;                            \
78 +               goto hardstart_fail;                                    \
79         }
80  
81  /*
82 @@ -2676,14 +2677,13 @@
83                 else if (an->an_tx_ffbuf[skb->priority]) {
84                         DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF,
85                                 "%s: Out-Of-Order fast-frame\n", __func__);
86 -                       ATH_TXQ_UNLOCK(txq);
87 +                       ATH_TXQ_UNLOCK_BH(txq);
88                 } else
89 -                       ATH_TXQ_UNLOCK(txq);
90 +                       ATH_TXQ_UNLOCK_BH(txq);
91  
92         ff_flushdone:
93                 ATH_HARDSTART_GET_TX_BUF_WITH_LOCK;
94 -               if (bf == NULL)
95 -                       goto hardstart_fail;
96 +               ATH_HARDSTART_REL_TX_BUF_WITH_TXQLOCK_OFF;
97         }
98  
99  ff_bypass:
100 @@ -5668,6 +5668,7 @@
101                                 sc->sc_stats.ast_rx_phyerr++;
102                                 phyerr = ds->ds_rxstat.rs_phyerr & 0x1f;
103                                 sc->sc_stats.ast_rx_phy[phyerr]++;
104 +                               goto rx_next;
105                         }
106                         if (ds->ds_rxstat.rs_status & HAL_RXERR_DECRYPT) {
107                                 /*
108 @@ -7662,6 +7663,7 @@
109  ath_draintxq(struct ath_softc *sc)
110  {
111         struct ath_hal *ah = sc->sc_ah;
112 +       int npend = 0;
113         unsigned int i;
114  
115         /* XXX return value */
116 @@ -7670,9 +7672,24 @@
117                 DPRINTF(sc, ATH_DEBUG_RESET, "%s: beacon queue 0x%x\n",
118                         __func__, ath_hal_gettxbuf(ah, sc->sc_bhalq));
119                 for (i = 0; i < HAL_NUM_TX_QUEUES; i++)
120 -                       if (ATH_TXQ_SETUP(sc, i))
121 +                       if (ATH_TXQ_SETUP(sc, i)) {
122                                 ath_tx_stopdma(sc, &sc->sc_txq[i]);
123 +
124 +                               /* The TxDMA may not really be stopped.
125 +                                * Double check the hal tx pending count */
126 +                               npend += ath_hal_numtxpending(ah, sc->sc_txq[i].axq_qnum);
127 +                       }
128 +       }
129 +       
130 +       if (npend) {
131 +               HAL_STATUS status;
132 +
133 +               /* TxDMA not stopped, reset the hal */
134 +               DPRINTF(sc, ATH_DEBUG_RESET, "%s: Unable to stop TxDMA. Reset HAL!\n", __func__);
135 +               if (!ath_hal_reset(ah, sc->sc_ic.ic_opmode, &sc->sc_curchan, AH_TRUE, &status))
136 +                       printk("%s: unable to reset hardware; hal status %u\n", __func__, status);
137         }
138 +
139         sc->sc_dev->trans_start = jiffies;
140         netif_start_queue(sc->sc_dev);          /* XXX move to callers */
141         for (i = 0; i < HAL_NUM_TX_QUEUES; i++)