From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759398Ab3JOPqg (ORCPT ); Tue, 15 Oct 2013 11:46:36 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:25155 "EHLO SMTP02.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758875Ab3JOPqf (ORCPT ); Tue, 15 Oct 2013 11:46:35 -0400 X-IronPort-AV: E=Sophos;i="4.93,500,1378857600"; d="scan'208";a="61076373" Date: Tue, 15 Oct 2013 16:45:38 +0100 From: Stefano Stabellini X-X-Sender: sstabellini@kaball.uk.xensource.com To: Will Deacon CC: Stefano Stabellini , "xen-devel@lists.xensource.com" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "konrad.wilk@oracle.com" , "Ian.Campbell@citrix.com" , "linux@arm.linux.org.uk" Subject: Re: [PATCH v8 01/17] arm: make SWIOTLB available In-Reply-To: <20131010094307.GD3817@mudshark.cambridge.arm.com> Message-ID: References: <1381351710-1876-1-git-send-email-stefano.stabellini@eu.citrix.com> <20131010094307.GD3817@mudshark.cambridge.arm.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-DLP: MIA2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 10 Oct 2013, Will Deacon wrote: > On Wed, Oct 09, 2013 at 09:48:14PM +0100, Stefano Stabellini wrote: > > IOMMU_HELPER is needed because SWIOTLB calls iommu_is_span_boundary, > > provided by lib/iommu_helper.c. > > > > Signed-off-by: Stefano Stabellini > > Reviewed-by: Konrad Rzeszutek Wilk > > CC: will.deacon@arm.com > > CC: linux@arm.linux.org.uk > > [...] > > > diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h > > index 5b579b9..9aa5384 100644 > > --- a/arch/arm/include/asm/dma-mapping.h > > +++ b/arch/arm/include/asm/dma-mapping.h > > @@ -10,6 +10,7 @@ > > > > #include > > #include > > +#include > > > > #define DMA_ERROR_CODE (~0) > > extern struct dma_map_ops arm_dma_ops; > > @@ -86,6 +87,42 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) > > } > > #endif > > > > +static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) > > +{ > > + unsigned int offset = paddr & ~PAGE_MASK; > > + return pfn_to_dma(dev, paddr >> PAGE_SHIFT) + offset; > > __phys_to_pfn instead of the explicit shift? > > > +} > > + > > +static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr) > > +{ > > + unsigned int offset = dev_addr & ~PAGE_MASK; > > + return (dma_to_pfn(dev, dev_addr) << PAGE_SHIFT) + offset;i > > then __pfn_to_phys here. good point > > +} > > + > > +static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) > > +{ > > + u64 limit, mask; > > + > > + if (dev->dma_mask) > > + mask = *dev->dma_mask; > > + else > > + mask = dev->coherent_dma_mask; > > + > > + if (mask == 0) > > + return 0; > > + > > + limit = (mask + 1) & ~mask; > > This looks like homebrew alignment to me. Can you use __ALIGN_KERNEL_MASK or > one of thoese guys from kernel.h? It was suggested by Russell here: http://marc.info/?l=linux-arm-kernel&m=137535542901235&w=2 I don't think that __ALIGN_KERNEL_MASK would be useful in this case. I could add a comment to explain the purpose of the check though.