offest calculation from the dma_address

Keith Busch keith.busch at intel.com
Fri Apr 14 07:00:40 PDT 2017


On Fri, Apr 14, 2017 at 01:54:51PM +0300, alexnln wrote:
> 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?

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.
 
> 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.



More information about the Linux-nvme mailing list