DMA map error validation issue in dma_alloc_noncoherent()

Praneesh P praneesh.p at oss.qualcomm.com
Thu Jan 30 02:24:27 PST 2025


Hi,

There is an issue with the dma_alloc_noncoherent() function when it 
allocates
buffers. This function internally calls debug_dma_map_page(), which 
allocates
a new struct dma_debug_entry for tracking each buffer. After 
initialization, this
new entry is added through add_dma_entry(). Initially, 
entry->map_err_type is
set to MAP_ERR_NOT_CHECKED. It should change to MAP_ERR_CHECKED during
error validation in debug_dma_mapping_error(). However, because
debug_dma_mapping_error() is called before the new entry allocation,
entry->map_err_type doesn't change to MAP_ERR_CHECKED. This causes the
warning "device driver failed to check map error" during 
dma_free_noncoherent().
This issue is specific to dma_alloc_noncoherent().

The flow is as follows:

-> dma_alloc_noncoherent()
     ->  dma_alloc_pages()
         -> debug_dma_map_page()
             ->  dma_mapping_error() -> debug_dma_mapping_error() 
(update dma debug data structure)
                 -> add_dma_entry()

Possible solution:

-> dma_alloc_noncoherent()
     ->  dma_alloc_pages()
         -> debug_dma_map_page()
             ->  if (dma_addr == DMA_MAPPING_ERROR)
                     return
             -> add_dma_entry()
             -> debug_dma_mapping_error()

To resolve this issue, call debug_dma_mapping_error() after 
add_dma_entry(). If this solution is not suitable, please suggest any 
other potential fixes ?.

---
Praneesh.




More information about the ath11k mailing list