From mboxrd@z Thu Jan 1 00:00:00 1970 From: josephl@nvidia.com (Joseph Lo) Date: Mon, 26 Jan 2015 17:10:22 +0800 Subject: [RFC PATCH 4/5] arm64: add IOMMU dma_ops In-Reply-To: References: Message-ID: <54C6047E.6070005@nvidia.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On 01/13/2015 04:48 AM, Robin Murphy wrote: > Taking some inspiration from the arch/arm code, implement the > arch-specific side of the DMA mapping ops using the new IOMMU-DMA layer. > > Signed-off-by: Robin Murphy > --- [snip] > static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr) > { > +#ifdef CONFIG_IOMMU_DMA > + if (dev->archdata.mapping) Hi Robin, Report one more issue, it would be safer like this. if (dev && dev->archdata.mapping) I do some more tests with a generic buffer allocator (ION). Allocate buffer from ION and then import by Tegra/DRM. I saw a crash in ION. Please reference and follow the call stack below. You could find out it could pass NULL of the dev pointer (ion_page_pool_alloc_pages). [ 83.836688] Call trace: [ 83.836694] [] swiotlb_sync_single+0xc/0xa4 [ 83.836707] [] swiotlb_sync_sg_for_device+0x44/0x70 [ 83.836713] [] __swiotlb_sync_sg_for_device+0x28/0xac [ 83.836720] [] ion_pages_sync_for_device+0xfc/0x10c [ 83.836724] [] ion_page_pool_alloc+0xc8/0xe0 [ 83.836729] [] ion_system_heap_allocate+0xfc/0x324 [ 83.836732] [] ion_alloc+0xf0/0x480 [ 83.836736] [] ion_ioctl+0x194/0x608 [ 83.836741] [] compat_ion_ioctl+0x300/0x6e0 [ 83.836747] [] compat_sys_ioctl+0x108/0x139c Thanks -Joseph > + return iova_to_phys(dev, dev_addr); > +#endif > return (phys_addr_t)dev_addr; > }