Re: helping with remapping vmem for dma

From: Robin Murphy
Date: Wed Jun 15 2022 - 09:15:50 EST


On 2022-06-15 13:11, Frank Wunderlich wrote:
Hi,

i have upported a wifi-driver (mt6625l for armhf) for some time and fall now (at least 5.18) in the
"rejecting DMA map of vmalloc memory" error [1].

maybe anybody here can guide me on how to nail it down and maybe fix it.

as far as i have debugged it, it uses dma_map_single [2] to get dma memory from a previous
allocated memory region.

this function "kalDevPortRead" in [2] is used via macro HAL_PORT_RD [3] (used in HAL_READ_RX_PORT
and HAL_READ_INTR_STATUS in same hal.h file)

HAL_READ_INTR_STATUS is always called with an empty int array as buf which i guess is not the problem.
I think the issue is using the use with an preallocated prSDIOCtrl struct (have not completely traced
it back where it is allocated).

Put simply, if you want to call dma_map_single() on a buffer, then that buffer needs to be allocated with kmalloc() (or technically alloc_pages(), but then dma_map_page() would make more sense when dealing with entire pages.

Robin.

calls of HAL_PORT_RD/HAL_READ_RX_PORT are in nic{,_rx}.c (with sdio-struct) ([4] as example)

maybe there is a simple way to get an address in preallocated memory as replacement for the dma_map_simple call (and the unmap of course).

regards Frank

[1] https://elixir.bootlin.com/linux/latest/source/include/linux/dma-mapping.h#L327
[2] https://github.com/frank-w/BPI-R2-4.14/blob/5.18-main/drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/hif/ahb/ahb.c#L940
[3] https://github.com/frank-w/BPI-R2-4.14/blob/5.18-main/drivers/misc/mediatek/connectivity/wlan/gen2/include/nic/hal.h#L176
[4] https://github.com/frank-w/BPI-R2-4.14/blob/5.18-main/drivers/misc/mediatek/connectivity/wlan/gen2/nic/nic_rx.c#L3604