Re: [PATCH v7 03/13] PCI/P2PDMA: Add PCI p2pmem DMA mappings to adjust the bus offset

From: Bart Van Assche
Date: Tue Sep 25 2018 - 13:33:31 EST


On Tue, 2018-09-25 at 10:22 -0600, Logan Gunthorpe wrote:
+AD4 +-int pci+AF8-p2pdma+AF8-map+AF8-sg(struct device +ACo-dev, struct scatterlist +ACo-sg, int nents,
+AD4 +- enum dma+AF8-data+AF8-direction dir)
+AD4 +-+AHs
+AD4 +- struct dev+AF8-pagemap +ACo-pgmap+ADs
+AD4 +- struct scatterlist +ACo-s+ADs
+AD4 +- phys+AF8-addr+AF8-t paddr+ADs
+AD4 +- int i+ADs
+AD4 +-
+AD4 +- /+ACo
+AD4 +- +ACo p2pdma mappings are not compatible with devices that use
+AD4 +- +ACo dma+AF8-virt+AF8-ops. If the upper layers do the right thing
+AD4 +- +ACo this should never happen because it will be prevented
+AD4 +- +ACo by the check in pci+AF8-p2pdma+AF8-add+AF8-client()
+AD4 +- +ACo-/
+AD4 +- if (WARN+AF8-ON+AF8-ONCE(IS+AF8-ENABLED(CONFIG+AF8-DMA+AF8-VIRT+AF8-OPS) +ACYAJg
+AD4 +- dev-+AD4-dma+AF8-ops +AD0APQ +ACY-dma+AF8-virt+AF8-ops))
+AD4 +- return 0+ADs

Are you assuming that the compiler will optimize out the dev-+AD4-dma+AF8-ops
+AD0APQ +ACY-dma+AF8-virt+AF8-ops test if CONFIG+AF8-DMA+AF8-VIRT+AF8-OPS+AD0-n such that no reference to the
dma+AF8-virt+AF8-ops symbol appears in the object file? Are you sure all compilers
and compiler versions that are used to build the Linux kernel will do that?

Thanks,

Bart.