Skip to content

Commit ea510e4

Browse files
Sujith Manoharanlinvjw
Sujith Manoharan
authored andcommitted
ath9k: Cleanup MCI init/deinit routines
This patch simplifies the buffer allocation functions for MCI and removes unneeded memset calls. Also, a couple of unused variables are removed and a memory leak in DMA allocation is fixed. [ 1263.788267] WARNING: at /home/sujith/dev/wireless-testing/lib/dma-debug.c:875 check_unmap+0x173/0x7e0() [ 1263.788273] ath9k 0000:06:00.0: DMA-API: device driver frees DMA memory with different size [device address=0x0000000071908000] [map size=512 bytes] [unmap size=256 bytes] [ 1263.788345] Pid: 774, comm: rmmod Tainted: G W O 3.3.0-rc3-wl #18 [ 1263.788348] Call Trace: [ 1263.788355] [<ffffffff8105110f>] warn_slowpath_common+0x7f/0xc0 [ 1263.788359] [<ffffffff81051206>] warn_slowpath_fmt+0x46/0x50 [ 1263.788363] [<ffffffff8125a713>] check_unmap+0x173/0x7e0 [ 1263.788368] [<ffffffff8123fc22>] ? prio_tree_left+0x32/0xc0 [ 1263.788373] [<ffffffff8125aded>] debug_dma_free_coherent+0x6d/0x80 [ 1263.788381] [<ffffffffa0701c3c>] ath_mci_cleanup+0x7c/0x110 [ath9k] [ 1263.788387] [<ffffffffa06f4033>] ath9k_deinit_softc+0x113/0x120 [ath9k] [ 1263.788392] [<ffffffffa06f55cc>] ath9k_deinit_device+0x5c/0x70 [ath9k] [ 1263.788397] [<ffffffffa0704934>] ath_pci_remove+0x54/0xa0 [ath9k] [ 1263.788401] [<ffffffff81267d06>] pci_device_remove+0x46/0x110 [ 1263.788406] [<ffffffff813102bc>] __device_release_driver+0x7c/0xe0 [ 1263.788410] [<ffffffff81310a00>] driver_detach+0xd0/0xe0 [ 1263.788414] [<ffffffff81310118>] bus_remove_driver+0x88/0xe0 [ 1263.788418] [<ffffffff813111c2>] driver_unregister+0x62/0xa0 [ 1263.788421] [<ffffffff812680c4>] pci_unregister_driver+0x44/0xc0 [ 1263.788427] [<ffffffffa0705015>] ath_pci_exit+0x15/0x20 [ath9k] [ 1263.788432] [<ffffffffa070a92d>] ath9k_exit+0x15/0x31 [ath9k] [ 1263.788436] [<ffffffff810b971c>] sys_delete_module+0x18c/0x270 [ 1263.788441] [<ffffffff81436edd>] ? retint_swapgs+0x13/0x1b [ 1263.788446] [<ffffffff812483be>] ? trace_hardirqs_on_thunk+0x3a/0x3f [ 1263.788450] [<ffffffff814378e9>] system_call_fastpath+0x16/0x1b [ 1263.788453] ---[ end trace 3ab4d030ffde40d4 ]--- Signed-off-by: Sujith Manoharan <[email protected]> Signed-off-by: John W. Linville <[email protected]>
1 parent c91ec46 commit ea510e4

File tree

4 files changed

+23
-56
lines changed

4 files changed

+23
-56
lines changed

drivers/net/wireless/ath/ath9k/ar9003_mci.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,6 @@ void ar9003_mci_setup(struct ath_hw *ah, u32 gpm_addr, void *gpm_buf,
973973
u16 len, u32 sched_addr)
974974
{
975975
struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
976-
void *sched_buf = (void *)((char *) gpm_buf + (sched_addr - gpm_addr));
977976

978977
if (!ATH9K_HW_CAP_MCI)
979978
return;
@@ -982,22 +981,18 @@ void ar9003_mci_setup(struct ath_hw *ah, u32 gpm_addr, void *gpm_buf,
982981
mci->gpm_buf = gpm_buf;
983982
mci->gpm_len = len;
984983
mci->sched_addr = sched_addr;
985-
mci->sched_buf = sched_buf;
986984

987985
ar9003_mci_reset(ah, true, true, true);
988986
}
989987
EXPORT_SYMBOL(ar9003_mci_setup);
990988

991989
void ar9003_mci_cleanup(struct ath_hw *ah)
992990
{
993-
struct ath_common *common = ath9k_hw_common(ah);
994-
995991
if (!ATH9K_HW_CAP_MCI)
996992
return;
997993

998994
/* Turn off MCI and Jupiter mode. */
999995
REG_WRITE(ah, AR_BTCOEX_CTRL, 0x00);
1000-
ath_dbg(common, MCI, "MCI ar9003_mci_cleanup\n");
1001996
ar9003_mci_disable_interrupt(ah);
1002997
}
1003998
EXPORT_SYMBOL(ar9003_mci_cleanup);

drivers/net/wireless/ath/ath9k/btcoex.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ struct ath9k_hw_mci {
6767
u32 wlan_cal_done;
6868
u32 config;
6969
u8 *gpm_buf;
70-
u8 *sched_buf;
7170
bool ready;
7271
bool update_2g5g;
7372
bool is_2g;

drivers/net/wireless/ath/ath9k/mci.c

Lines changed: 23 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -383,84 +383,60 @@ static void ath_mci_msg(struct ath_softc *sc, u8 opcode, u8 *rx_payload)
383383
}
384384
}
385385

386-
static int ath_mci_buf_alloc(struct ath_softc *sc, struct ath_mci_buf *buf)
387-
{
388-
int error = 0;
389-
390-
buf->bf_addr = dma_alloc_coherent(sc->dev, buf->bf_len,
391-
&buf->bf_paddr, GFP_KERNEL);
392-
393-
if (buf->bf_addr == NULL) {
394-
error = -ENOMEM;
395-
goto fail;
396-
}
397-
398-
return 0;
399-
400-
fail:
401-
memset(buf, 0, sizeof(*buf));
402-
return error;
403-
}
404-
405-
static void ath_mci_buf_free(struct ath_softc *sc, struct ath_mci_buf *buf)
406-
{
407-
if (buf->bf_addr) {
408-
dma_free_coherent(sc->dev, buf->bf_len, buf->bf_addr,
409-
buf->bf_paddr);
410-
memset(buf, 0, sizeof(*buf));
411-
}
412-
}
413-
414386
int ath_mci_setup(struct ath_softc *sc)
415387
{
416388
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
417389
struct ath_mci_coex *mci = &sc->mci_coex;
418-
int error = 0;
390+
struct ath_mci_buf *buf = &mci->sched_buf;
419391

420392
if (!ATH9K_HW_CAP_MCI)
421393
return 0;
422394

423-
mci->sched_buf.bf_len = ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE;
395+
buf->bf_addr = dma_alloc_coherent(sc->dev,
396+
ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE,
397+
&buf->bf_paddr, GFP_KERNEL);
424398

425-
if (ath_mci_buf_alloc(sc, &mci->sched_buf)) {
399+
if (buf->bf_addr == NULL) {
426400
ath_dbg(common, FATAL, "MCI buffer alloc failed\n");
427-
error = -ENOMEM;
428-
goto fail;
401+
return -ENOMEM;
429402
}
430403

431-
mci->sched_buf.bf_len = ATH_MCI_SCHED_BUF_SIZE;
404+
memset(buf->bf_addr, MCI_GPM_RSVD_PATTERN,
405+
ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE);
432406

433-
memset(mci->sched_buf.bf_addr, MCI_GPM_RSVD_PATTERN,
434-
mci->sched_buf.bf_len);
407+
mci->sched_buf.bf_len = ATH_MCI_SCHED_BUF_SIZE;
435408

436409
mci->gpm_buf.bf_len = ATH_MCI_GPM_BUF_SIZE;
437-
mci->gpm_buf.bf_addr = (u8 *)mci->sched_buf.bf_addr +
438-
mci->sched_buf.bf_len;
410+
mci->gpm_buf.bf_addr = (u8 *)mci->sched_buf.bf_addr + mci->sched_buf.bf_len;
439411
mci->gpm_buf.bf_paddr = mci->sched_buf.bf_paddr + mci->sched_buf.bf_len;
440412

441-
/* initialize the buffer */
442-
memset(mci->gpm_buf.bf_addr, MCI_GPM_RSVD_PATTERN, mci->gpm_buf.bf_len);
443-
444413
ar9003_mci_setup(sc->sc_ah, mci->gpm_buf.bf_paddr,
445414
mci->gpm_buf.bf_addr, (mci->gpm_buf.bf_len >> 4),
446415
mci->sched_buf.bf_paddr);
447-
fail:
448-
return error;
416+
417+
ath_dbg(common, MCI, "MCI Initialized\n");
418+
419+
return 0;
449420
}
450421

451422
void ath_mci_cleanup(struct ath_softc *sc)
452423
{
424+
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
453425
struct ath_hw *ah = sc->sc_ah;
454426
struct ath_mci_coex *mci = &sc->mci_coex;
427+
struct ath_mci_buf *buf = &mci->sched_buf;
455428

456429
if (!ATH9K_HW_CAP_MCI)
457430
return;
458431

459-
/*
460-
* both schedule and gpm buffers will be released
461-
*/
462-
ath_mci_buf_free(sc, &mci->sched_buf);
432+
if (buf->bf_addr)
433+
dma_free_coherent(sc->dev,
434+
ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE,
435+
buf->bf_addr, buf->bf_paddr);
436+
463437
ar9003_mci_cleanup(ah);
438+
439+
ath_dbg(common, MCI, "MCI De-Initialized\n");
464440
}
465441

466442
void ath_mci_intr(struct ath_softc *sc)

drivers/net/wireless/ath/ath9k/mci.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,15 @@ struct ath_mci_profile {
113113
u8 num_bdr;
114114
};
115115

116-
117116
struct ath_mci_buf {
118117
void *bf_addr; /* virtual addr of desc */
119118
dma_addr_t bf_paddr; /* physical addr of buffer */
120119
u32 bf_len; /* len of data */
121120
};
122121

123122
struct ath_mci_coex {
124-
atomic_t mci_cal_flag;
125123
struct ath_mci_buf sched_buf;
126124
struct ath_mci_buf gpm_buf;
127-
u32 bt_cal_start;
128125
};
129126

130127
void ath_mci_flush_profile(struct ath_mci_profile *mci);

0 commit comments

Comments
 (0)