aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/init.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c84
1 files changed, 59 insertions, 25 deletions
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index e3d11c41a145..2306f5788675 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -347,7 +347,6 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
347{ 347{
348 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 348 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
349 u8 *ds; 349 u8 *ds;
350 struct ath_buf *bf;
351 int i, bsize, desc_len; 350 int i, bsize, desc_len;
352 351
353 ath_dbg(common, CONFIG, "%s DMA: %u buffers %u desc/buf\n", 352 ath_dbg(common, CONFIG, "%s DMA: %u buffers %u desc/buf\n",
@@ -399,33 +398,68 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
399 ito64(dd->dd_desc_paddr), /*XXX*/(u32) dd->dd_desc_len); 398 ito64(dd->dd_desc_paddr), /*XXX*/(u32) dd->dd_desc_len);
400 399
401 /* allocate buffers */ 400 /* allocate buffers */
402 bsize = sizeof(struct ath_buf) * nbuf; 401 if (is_tx) {
403 bf = devm_kzalloc(sc->dev, bsize, GFP_KERNEL); 402 struct ath_buf *bf;
404 if (!bf) 403
405 return -ENOMEM; 404 bsize = sizeof(struct ath_buf) * nbuf;
405 bf = devm_kzalloc(sc->dev, bsize, GFP_KERNEL);
406 if (!bf)
407 return -ENOMEM;
408
409 for (i = 0; i < nbuf; i++, bf++, ds += (desc_len * ndesc)) {
410 bf->bf_desc = ds;
411 bf->bf_daddr = DS2PHYS(dd, ds);
412
413 if (!(sc->sc_ah->caps.hw_caps &
414 ATH9K_HW_CAP_4KB_SPLITTRANS)) {
415 /*
416 * Skip descriptor addresses which can cause 4KB
417 * boundary crossing (addr + length) with a 32 dword
418 * descriptor fetch.
419 */
420 while (ATH_DESC_4KB_BOUND_CHECK(bf->bf_daddr)) {
421 BUG_ON((caddr_t) bf->bf_desc >=
422 ((caddr_t) dd->dd_desc +
423 dd->dd_desc_len));
424
425 ds += (desc_len * ndesc);
426 bf->bf_desc = ds;
427 bf->bf_daddr = DS2PHYS(dd, ds);
428 }
429 }
430 list_add_tail(&bf->list, head);
431 }
432 } else {
433 struct ath_rxbuf *bf;
434
435 bsize = sizeof(struct ath_rxbuf) * nbuf;
436 bf = devm_kzalloc(sc->dev, bsize, GFP_KERNEL);
437 if (!bf)
438 return -ENOMEM;
406 439
407 for (i = 0; i < nbuf; i++, bf++, ds += (desc_len * ndesc)) { 440 for (i = 0; i < nbuf; i++, bf++, ds += (desc_len * ndesc)) {
408 bf->bf_desc = ds; 441 bf->bf_desc = ds;
409 bf->bf_daddr = DS2PHYS(dd, ds); 442 bf->bf_daddr = DS2PHYS(dd, ds);
410 443
411 if (!(sc->sc_ah->caps.hw_caps & 444 if (!(sc->sc_ah->caps.hw_caps &
412 ATH9K_HW_CAP_4KB_SPLITTRANS)) { 445 ATH9K_HW_CAP_4KB_SPLITTRANS)) {
413 /* 446 /*
414 * Skip descriptor addresses which can cause 4KB 447 * Skip descriptor addresses which can cause 4KB
415 * boundary crossing (addr + length) with a 32 dword 448 * boundary crossing (addr + length) with a 32 dword
416 * descriptor fetch. 449 * descriptor fetch.
417 */ 450 */
418 while (ATH_DESC_4KB_BOUND_CHECK(bf->bf_daddr)) { 451 while (ATH_DESC_4KB_BOUND_CHECK(bf->bf_daddr)) {
419 BUG_ON((caddr_t) bf->bf_desc >= 452 BUG_ON((caddr_t) bf->bf_desc >=
420 ((caddr_t) dd->dd_desc + 453 ((caddr_t) dd->dd_desc +
421 dd->dd_desc_len)); 454 dd->dd_desc_len));
422 455
423 ds += (desc_len * ndesc); 456 ds += (desc_len * ndesc);
424 bf->bf_desc = ds; 457 bf->bf_desc = ds;
425 bf->bf_daddr = DS2PHYS(dd, ds); 458 bf->bf_daddr = DS2PHYS(dd, ds);
459 }
426 } 460 }
461 list_add_tail(&bf->list, head);
427 } 462 }
428 list_add_tail(&bf->list, head);
429 } 463 }
430 return 0; 464 return 0;
431} 465}