dma-proxy: SG list needs to be mapped before use with DMA driver#17
dma-proxy: SG list needs to be mapped before use with DMA driver#17jh-hsd wants to merge 1 commit intoXilinx-Wiki-Projects:masterfrom
Conversation
At least sg_dma_len(), in case that IOMMU is enabled, will fail getting the correct length in case of no mapping. Signed-off-by: Jochen Henneberg <henneberg@innolintec.eu>
| pchannel_p->buffer_table_p[bdindex].length | ||
| ); | ||
| sg_init_one(&pchannel_p->bdtable[bdindex].sglist, | ||
| (void*)pchannel_p->bdtable[baindex].dma_handle, |
There was a problem hiding this comment.
sg_init_one() according to scatterlist.c takes in a virtual address to the memory to write to.
| (void*)pchannel_p->bdtable[baindex].dma_handle, | |
| (void*)pchannel_p->buffer_table_p[bdindex].buffer, |
There was a problem hiding this comment.
Hmm, yes. Not sure why dma_handle has been introduced here. In that case it's probably better to drop the dma_handle completely instead of just ignoring it.
| (void*)pchannel_p->bdtable[baindex].dma_handle, | ||
| pchannel_p->buffer_table_p[bdindex].length); | ||
|
|
||
| n = dma_map_sg(dma_device->dev, &pchannel_p->bdtable[bdindex].sglist, |
There was a problem hiding this comment.
Since we allocated in create_channel() with dmam_alloc_coherent() we probably don't need to map anymore.
There was a problem hiding this comment.
The problem that I addressed here was not the mapping of the memory pointers. It was about the length. In scatterlist.h there is
#ifdef CONFIG_NEED_SG_DMA_LENGTH
#define sg_dma_len(sg) ((sg)->dma_length)
#else
#define sg_dma_len(sg) ((sg)->length)
#endif
so with IOMMU a different length field is accessed. Those field values are harmonized with dma_map_sg() and that makes the transfer work, otherwise the length field will be read with 0.
At least sg_dma_len(), in case that IOMMU is enabled, will fail getting the correct length in case of no mapping.
In general the SG list should always be mapped before transferred to DMA driver.