提交 4adfcded 编写于 作者: V Vasanthakumar Thiagarajan 提交者: John W. Linville

ath9k: Setup appropriate tx desc for regular dma and edma

Signed-off-by: NVasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 3deb4da5
...@@ -123,7 +123,7 @@ struct ath_descdma { ...@@ -123,7 +123,7 @@ struct ath_descdma {
int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
struct list_head *head, const char *name, struct list_head *head, const char *name,
int nbuf, int ndesc); int nbuf, int ndesc, bool is_tx);
void ath_descdma_cleanup(struct ath_softc *sc, struct ath_descdma *dd, void ath_descdma_cleanup(struct ath_softc *sc, struct ath_descdma *dd,
struct list_head *head); struct list_head *head);
......
...@@ -233,31 +233,37 @@ static int ath9k_reg_notifier(struct wiphy *wiphy, ...@@ -233,31 +233,37 @@ static int ath9k_reg_notifier(struct wiphy *wiphy,
*/ */
int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
struct list_head *head, const char *name, struct list_head *head, const char *name,
int nbuf, int ndesc) int nbuf, int ndesc, bool is_tx)
{ {
#define DS2PHYS(_dd, _ds) \ #define DS2PHYS(_dd, _ds) \
((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc)) ((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc))
#define ATH_DESC_4KB_BOUND_CHECK(_daddr) ((((_daddr) & 0xFFF) > 0xF7F) ? 1 : 0) #define ATH_DESC_4KB_BOUND_CHECK(_daddr) ((((_daddr) & 0xFFF) > 0xF7F) ? 1 : 0)
#define ATH_DESC_4KB_BOUND_NUM_SKIPPED(_len) ((_len) / 4096) #define ATH_DESC_4KB_BOUND_NUM_SKIPPED(_len) ((_len) / 4096)
struct ath_common *common = ath9k_hw_common(sc->sc_ah); struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_desc *ds; u8 *ds;
struct ath_buf *bf; struct ath_buf *bf;
int i, bsize, error; int i, bsize, error, desc_len;
ath_print(common, ATH_DBG_CONFIG, "%s DMA: %u buffers %u desc/buf\n", ath_print(common, ATH_DBG_CONFIG, "%s DMA: %u buffers %u desc/buf\n",
name, nbuf, ndesc); name, nbuf, ndesc);
INIT_LIST_HEAD(head); INIT_LIST_HEAD(head);
if (is_tx)
desc_len = sc->sc_ah->caps.tx_desc_len;
else
desc_len = sizeof(struct ath_desc);
/* ath_desc must be a multiple of DWORDs */ /* ath_desc must be a multiple of DWORDs */
if ((sizeof(struct ath_desc) % 4) != 0) { if ((desc_len % 4) != 0) {
ath_print(common, ATH_DBG_FATAL, ath_print(common, ATH_DBG_FATAL,
"ath_desc not DWORD aligned\n"); "ath_desc not DWORD aligned\n");
BUG_ON((sizeof(struct ath_desc) % 4) != 0); BUG_ON((desc_len % 4) != 0);
error = -ENOMEM; error = -ENOMEM;
goto fail; goto fail;
} }
dd->dd_desc_len = sizeof(struct ath_desc) * nbuf * ndesc; dd->dd_desc_len = desc_len * nbuf * ndesc;
/* /*
* Need additional DMA memory because we can't use * Need additional DMA memory because we can't use
...@@ -270,7 +276,7 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, ...@@ -270,7 +276,7 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
u32 dma_len; u32 dma_len;
while (ndesc_skipped) { while (ndesc_skipped) {
dma_len = ndesc_skipped * sizeof(struct ath_desc); dma_len = ndesc_skipped * desc_len;
dd->dd_desc_len += dma_len; dd->dd_desc_len += dma_len;
ndesc_skipped = ATH_DESC_4KB_BOUND_NUM_SKIPPED(dma_len); ndesc_skipped = ATH_DESC_4KB_BOUND_NUM_SKIPPED(dma_len);
...@@ -284,7 +290,7 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, ...@@ -284,7 +290,7 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
error = -ENOMEM; error = -ENOMEM;
goto fail; goto fail;
} }
ds = dd->dd_desc; ds = (u8 *) dd->dd_desc;
ath_print(common, ATH_DBG_CONFIG, "%s DMA map: %p (%u) -> %llx (%u)\n", ath_print(common, ATH_DBG_CONFIG, "%s DMA map: %p (%u) -> %llx (%u)\n",
name, ds, (u32) dd->dd_desc_len, name, ds, (u32) dd->dd_desc_len,
ito64(dd->dd_desc_paddr), /*XXX*/(u32) dd->dd_desc_len); ito64(dd->dd_desc_paddr), /*XXX*/(u32) dd->dd_desc_len);
...@@ -298,7 +304,7 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, ...@@ -298,7 +304,7 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
} }
dd->dd_bufptr = bf; dd->dd_bufptr = bf;
for (i = 0; i < nbuf; i++, bf++, ds += ndesc) { for (i = 0; i < nbuf; i++, bf++, ds += (desc_len * ndesc)) {
bf->bf_desc = ds; bf->bf_desc = ds;
bf->bf_daddr = DS2PHYS(dd, ds); bf->bf_daddr = DS2PHYS(dd, ds);
...@@ -314,7 +320,7 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, ...@@ -314,7 +320,7 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
((caddr_t) dd->dd_desc + ((caddr_t) dd->dd_desc +
dd->dd_desc_len)); dd->dd_desc_len));
ds += ndesc; ds += (desc_len * ndesc);
bf->bf_desc = ds; bf->bf_desc = ds;
bf->bf_daddr = DS2PHYS(dd, ds); bf->bf_daddr = DS2PHYS(dd, ds);
} }
......
...@@ -325,7 +325,7 @@ int ath_rx_init(struct ath_softc *sc, int nbufs) ...@@ -325,7 +325,7 @@ int ath_rx_init(struct ath_softc *sc, int nbufs)
/* Initialize rx descriptors */ /* Initialize rx descriptors */
error = ath_descdma_setup(sc, &sc->rx.rxdma, &sc->rx.rxbuf, error = ath_descdma_setup(sc, &sc->rx.rxdma, &sc->rx.rxbuf,
"rx", nbufs, 1); "rx", nbufs, 1, 0);
if (error != 0) { if (error != 0) {
ath_print(common, ATH_DBG_FATAL, ath_print(common, ATH_DBG_FATAL,
"failed to allocate rx descriptors: %d\n", "failed to allocate rx descriptors: %d\n",
......
...@@ -2152,7 +2152,7 @@ int ath_tx_init(struct ath_softc *sc, int nbufs) ...@@ -2152,7 +2152,7 @@ int ath_tx_init(struct ath_softc *sc, int nbufs)
spin_lock_init(&sc->tx.txbuflock); spin_lock_init(&sc->tx.txbuflock);
error = ath_descdma_setup(sc, &sc->tx.txdma, &sc->tx.txbuf, error = ath_descdma_setup(sc, &sc->tx.txdma, &sc->tx.txbuf,
"tx", nbufs, 1); "tx", nbufs, 1, 1);
if (error != 0) { if (error != 0) {
ath_print(common, ATH_DBG_FATAL, ath_print(common, ATH_DBG_FATAL,
"Failed to allocate tx descriptors: %d\n", error); "Failed to allocate tx descriptors: %d\n", error);
...@@ -2160,7 +2160,7 @@ int ath_tx_init(struct ath_softc *sc, int nbufs) ...@@ -2160,7 +2160,7 @@ int ath_tx_init(struct ath_softc *sc, int nbufs)
} }
error = ath_descdma_setup(sc, &sc->beacon.bdma, &sc->beacon.bbuf, error = ath_descdma_setup(sc, &sc->beacon.bdma, &sc->beacon.bbuf,
"beacon", ATH_BCBUF, 1); "beacon", ATH_BCBUF, 1, 0);
if (error != 0) { if (error != 0) {
ath_print(common, ATH_DBG_FATAL, ath_print(common, ATH_DBG_FATAL,
"Failed to allocate beacon descriptors: %d\n", error); "Failed to allocate beacon descriptors: %d\n", error);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册