offest calculation from the dma_address
Hello,
In pci.c, in nvme_setup_prps() offset is calculated from the dma address:
int offset = dma_addr & (page_size - 1);
Why not to use sg->offset?
I mean, what if hypothetical dma allocator returns non-page aligned addresses? In such case offset would be wrong.
Thanks,
Alex
Quoted 4 lines · alexnln
In
pci.c, innvme_setup_prps()offset is calculated from the dma address:
int offset =dma_addr& (page_size- 1);Why not to use
sg->offset?
PRP lists are constructed from DMA addresses, so the DMA address offset is the one to use. Kernel virtual addresses don't necessarilly have the same page offset as DMA addresses.
Quoted 2 lines
I mean, what if hypothetical dma allocator returns non-page aligned addresses? In such case offset would be wrong.
I don't follow. If the DMA address isn't page aligned, we need to account for that when constructing the PRP.