From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: Will Deacon <will.deacon@arm.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"konrad.wilk@oracle.com" <konrad.wilk@oracle.com>,
"Ian.Campbell@citrix.com" <Ian.Campbell@citrix.com>,
"linux@arm.linux.org.uk" <linux@arm.linux.org.uk>
Subject: Re: [PATCH v8 01/17] arm: make SWIOTLB available
Date: Tue, 15 Oct 2013 16:45:38 +0100 [thread overview]
Message-ID: <alpine.DEB.2.02.1310151643230.26077@kaball.uk.xensource.com> (raw)
In-Reply-To: <20131010094307.GD3817@mudshark.cambridge.arm.com>
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 <stefano.stabellini@eu.citrix.com>
> > Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > 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 <asm-generic/dma-coherent.h>
> > #include <asm/memory.h>
> > +#include <asm/cacheflush.h>
> >
> > #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.
next prev parent reply other threads:[~2013-10-15 15:46 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-09 20:47 [PATCH v7 0/17] enable swiotlb-xen on arm and arm64 Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 01/17] arm: make SWIOTLB available Stefano Stabellini
2013-10-10 9:43 ` Will Deacon
2013-10-15 15:45 ` Stefano Stabellini [this message]
2013-10-09 20:48 ` [PATCH v8 02/17] arm64: define DMA_ERROR_CODE Stefano Stabellini
2013-10-10 9:44 ` Will Deacon
2013-10-15 15:46 ` Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 03/17] arm/xen,arm64/xen: introduce p2m Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 04/17] xen/x86: allow __set_phys_to_machine for autotranslate guests Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 05/17] xen: make xen_create_contiguous_region return the dma address Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 06/17] xen/arm,arm64: enable SWIOTLB_XEN Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 07/17] swiotlb-xen: introduce xen_swiotlb_set_dma_mask Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 08/17] arm/xen: get_dma_ops: return xen_dma_ops if we are running as xen_initial_domain Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 09/17] arm64/xen: " Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 10/17] xen: introduce xen_alloc/free_coherent_pages Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 11/17] swiotlb-xen: use xen_alloc/free_coherent_pages Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 12/17] xen: introduce xen_dma_map/unmap_page and xen_dma_sync_single_for_cpu/device Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 13/17] swiotlb-xen: use xen_dma_map/unmap_page, xen_dma_sync_single_for_cpu/device Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 14/17] ASoC: Samsung: Rename dma_ops by samsung_dma_ops Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 15/17] swiotlb: print a warning when the swiotlb is full Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 16/17] arm,arm64: do not always merge biovec if we are running on Xen Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 17/17] grant-table: call set_phys_to_machine after mapping grant refs Stefano Stabellini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.02.1310151643230.26077@kaball.uk.xensource.com \
--to=stefano.stabellini@eu.citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=will.deacon@arm.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®