Message ID | 1382698313-13161-1-git-send-email-stefano.stabellini@eu.citrix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Russell, this is the only patch that needs an ack at the moment. As you commented on it before and I have already addressed your comments few versions ago, unless you have any complaints I am going to add it to linux-next and I am thinking of merging it during the next merge window. On Fri, 25 Oct 2013, 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 > > > Changes in v8: > - use __phys_to_pfn and __pfn_to_phys. > > Changes in v7: > - dma_mark_clean: empty implementation; > - in dma_capable use coherent_dma_mask if dma_mask hasn't been > allocated. > > Changes in v6: > - check for dev->dma_mask being NULL in dma_capable. > > Changes in v5: > - implement dma_mark_clean using dmac_flush_range. > > Changes in v3: > - dma_capable: do not treat dma_mask as a limit; > - remove SWIOTLB dependency on NEED_SG_DMA_LENGTH. > --- > arch/arm/Kconfig | 6 +++++ > arch/arm/include/asm/dma-mapping.h | 37 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 43 insertions(+), 0 deletions(-) > > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig > index 1ad6fb6..b08374f 100644 > --- a/arch/arm/Kconfig > +++ b/arch/arm/Kconfig > @@ -1872,6 +1872,12 @@ config CC_STACKPROTECTOR > neutralized via a kernel panic. > This feature requires gcc version 4.2 or above. > > +config SWIOTLB > + def_bool y > + > +config IOMMU_HELPER > + def_bool SWIOTLB > + > config XEN_DOM0 > def_bool y > depends on XEN > diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h > index 5b579b9..01b5a3d 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, __phys_to_pfn(paddr)) + offset; > +} > + > +static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr) > +{ > + unsigned int offset = dev_addr & ~PAGE_MASK; > + return __pfn_to_phys(dma_to_pfn(dev, dev_addr)) + offset; > +} > + > +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; > + if (limit && size > limit) > + return 0; > + > + if ((addr | (addr + size - 1)) & ~mask) > + return 0; > + > + return 1; > +} > + > +static inline void dma_mark_clean(void *addr, size_t size) { } > + > /* > * DMA errors are defined by all-bits-set in the DMA address. > */ > -- > 1.7.2.5 >
ping? On Fri, 25 Oct 2013, Stefano Stabellini wrote: > Russell, > this is the only patch that needs an ack at the moment. > As you commented on it before and I have already addressed your comments > few versions ago, unless you have any complaints I am going to add it to > linux-next and I am thinking of merging it during the next merge window. > > On Fri, 25 Oct 2013, 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 > > > > > > Changes in v8: > > - use __phys_to_pfn and __pfn_to_phys. > > > > Changes in v7: > > - dma_mark_clean: empty implementation; > > - in dma_capable use coherent_dma_mask if dma_mask hasn't been > > allocated. > > > > Changes in v6: > > - check for dev->dma_mask being NULL in dma_capable. > > > > Changes in v5: > > - implement dma_mark_clean using dmac_flush_range. > > > > Changes in v3: > > - dma_capable: do not treat dma_mask as a limit; > > - remove SWIOTLB dependency on NEED_SG_DMA_LENGTH. > > --- > > arch/arm/Kconfig | 6 +++++ > > arch/arm/include/asm/dma-mapping.h | 37 ++++++++++++++++++++++++++++++++++++ > > 2 files changed, 43 insertions(+), 0 deletions(-) > > > > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig > > index 1ad6fb6..b08374f 100644 > > --- a/arch/arm/Kconfig > > +++ b/arch/arm/Kconfig > > @@ -1872,6 +1872,12 @@ config CC_STACKPROTECTOR > > neutralized via a kernel panic. > > This feature requires gcc version 4.2 or above. > > > > +config SWIOTLB > > + def_bool y > > + > > +config IOMMU_HELPER > > + def_bool SWIOTLB > > + > > config XEN_DOM0 > > def_bool y > > depends on XEN > > diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h > > index 5b579b9..01b5a3d 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, __phys_to_pfn(paddr)) + offset; > > +} > > + > > +static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr) > > +{ > > + unsigned int offset = dev_addr & ~PAGE_MASK; > > + return __pfn_to_phys(dma_to_pfn(dev, dev_addr)) + offset; > > +} > > + > > +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; > > + if (limit && size > limit) > > + return 0; > > + > > + if ((addr | (addr + size - 1)) & ~mask) > > + return 0; > > + > > + return 1; > > +} > > + > > +static inline void dma_mark_clean(void *addr, size_t size) { } > > + > > /* > > * DMA errors are defined by all-bits-set in the DMA address. > > */ > > -- > > 1.7.2.5 > > >
On Tue, Oct 29, 2013 at 04:41:40AM +0000, Stefano Stabellini wrote: > ping? You know you are pinging yourself, right ? :-) > > On Fri, 25 Oct 2013, Stefano Stabellini wrote: > > Russell, > > this is the only patch that needs an ack at the moment. > > As you commented on it before and I have already addressed your comments > > few versions ago, unless you have any complaints I am going to add it to > > linux-next and I am thinking of merging it during the next merge window. > > > > On Fri, 25 Oct 2013, 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 > > > > > > > > > Changes in v8: > > > - use __phys_to_pfn and __pfn_to_phys. > > > > > > Changes in v7: > > > - dma_mark_clean: empty implementation; > > > - in dma_capable use coherent_dma_mask if dma_mask hasn't been > > > allocated. > > > > > > Changes in v6: > > > - check for dev->dma_mask being NULL in dma_capable. > > > > > > Changes in v5: > > > - implement dma_mark_clean using dmac_flush_range. > > > > > > Changes in v3: > > > - dma_capable: do not treat dma_mask as a limit; > > > - remove SWIOTLB dependency on NEED_SG_DMA_LENGTH. > > > --- > > > arch/arm/Kconfig | 6 +++++ > > > arch/arm/include/asm/dma-mapping.h | 37 ++++++++++++++++++++++++++++++++++++ > > > 2 files changed, 43 insertions(+), 0 deletions(-) > > > > > > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig > > > index 1ad6fb6..b08374f 100644 > > > --- a/arch/arm/Kconfig > > > +++ b/arch/arm/Kconfig > > > @@ -1872,6 +1872,12 @@ config CC_STACKPROTECTOR > > > neutralized via a kernel panic. > > > This feature requires gcc version 4.2 or above. > > > > > > +config SWIOTLB > > > + def_bool y > > > + > > > +config IOMMU_HELPER > > > + def_bool SWIOTLB > > > + > > > config XEN_DOM0 > > > def_bool y > > > depends on XEN > > > diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h > > > index 5b579b9..01b5a3d 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, __phys_to_pfn(paddr)) + offset; > > > +} > > > + > > > +static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr) > > > +{ > > > + unsigned int offset = dev_addr & ~PAGE_MASK; > > > + return __pfn_to_phys(dma_to_pfn(dev, dev_addr)) + offset; > > > +} > > > + > > > +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; > > > + if (limit && size > limit) > > > + return 0; > > > + > > > + if ((addr | (addr + size - 1)) & ~mask) > > > + return 0; > > > + > > > + return 1; > > > +} > > > + > > > +static inline void dma_mark_clean(void *addr, size_t size) { } > > > + > > > /* > > > * DMA errors are defined by all-bits-set in the DMA address. > > > */ > > > -- > > > 1.7.2.5 > > > > >
On Tue, Oct 29, 2013 at 10:20:23AM -0400, Konrad Rzeszutek Wilk wrote: > On Tue, Oct 29, 2013 at 04:41:40AM +0000, Stefano Stabellini wrote: > > ping? > > You know you are pinging yourself, right ? :-) And the patch was only Cc'd. I'm starting to read stuff which isn't flagged as having me in the To: line with less priority in recent times. > > On Fri, 25 Oct 2013, Stefano Stabellini wrote: > > > Russell, > > > this is the only patch that needs an ack at the moment. > > > As you commented on it before and I have already addressed your comments > > > few versions ago, unless you have any complaints I am going to add it to > > > linux-next and I am thinking of merging it during the next merge window. > > > > > > On Fri, 25 Oct 2013, 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 > > > > > > > > > > > > Changes in v8: > > > > - use __phys_to_pfn and __pfn_to_phys. > > > > > > > > Changes in v7: > > > > - dma_mark_clean: empty implementation; > > > > - in dma_capable use coherent_dma_mask if dma_mask hasn't been > > > > allocated. > > > > > > > > Changes in v6: > > > > - check for dev->dma_mask being NULL in dma_capable. > > > > > > > > Changes in v5: > > > > - implement dma_mark_clean using dmac_flush_range. > > > > > > > > Changes in v3: > > > > - dma_capable: do not treat dma_mask as a limit; > > > > - remove SWIOTLB dependency on NEED_SG_DMA_LENGTH. > > > > --- > > > > arch/arm/Kconfig | 6 +++++ > > > > arch/arm/include/asm/dma-mapping.h | 37 ++++++++++++++++++++++++++++++++++++ > > > > 2 files changed, 43 insertions(+), 0 deletions(-) > > > > > > > > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig > > > > index 1ad6fb6..b08374f 100644 > > > > --- a/arch/arm/Kconfig > > > > +++ b/arch/arm/Kconfig > > > > @@ -1872,6 +1872,12 @@ config CC_STACKPROTECTOR > > > > neutralized via a kernel panic. > > > > This feature requires gcc version 4.2 or above. > > > > > > > > +config SWIOTLB > > > > + def_bool y > > > > + > > > > +config IOMMU_HELPER > > > > + def_bool SWIOTLB > > > > + > > > > config XEN_DOM0 > > > > def_bool y > > > > depends on XEN > > > > diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h > > > > index 5b579b9..01b5a3d 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> Why does this need to be here? Your'e not adding anything which needs it. > > > > +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, __phys_to_pfn(paddr)) + offset; > > > > +} > > > > + > > > > +static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr) > > > > +{ > > > > + unsigned int offset = dev_addr & ~PAGE_MASK; > > > > + return __pfn_to_phys(dma_to_pfn(dev, dev_addr)) + offset; > > > > +} These look fine. > > > > +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; This looks like a hack. Either we want to use the streaming mask or the coherent mask as appropriate for the caller. That should be a choice the caller makes, not the implementation of this behind the callers back. > > > > + > > > > + if (mask == 0) > > > > + return 0; > > > > + > > > > + limit = (mask + 1) & ~mask; > > > > + if (limit && size > limit) > > > > + return 0; > > > > + > > > > + if ((addr | (addr + size - 1)) & ~mask) > > > > + return 0; > > > > + > > > > + return 1; > > > > +} The remainder looks fine to me.
On Tue, 29 Oct 2013, Russell King - ARM Linux wrote: > On Tue, Oct 29, 2013 at 10:20:23AM -0400, Konrad Rzeszutek Wilk wrote: > > On Tue, Oct 29, 2013 at 04:41:40AM +0000, Stefano Stabellini wrote: > > > ping? > > > > You know you are pinging yourself, right ? :-) > > And the patch was only Cc'd. I'm starting to read stuff which isn't > flagged as having me in the To: line with less priority in recent times. good to know > > > On Fri, 25 Oct 2013, Stefano Stabellini wrote: > > > > Russell, > > > > this is the only patch that needs an ack at the moment. > > > > As you commented on it before and I have already addressed your comments > > > > few versions ago, unless you have any complaints I am going to add it to > > > > linux-next and I am thinking of merging it during the next merge window. > > > > > > > > On Fri, 25 Oct 2013, 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 > > > > > > > > > > > > > > > Changes in v8: > > > > > - use __phys_to_pfn and __pfn_to_phys. > > > > > > > > > > Changes in v7: > > > > > - dma_mark_clean: empty implementation; > > > > > - in dma_capable use coherent_dma_mask if dma_mask hasn't been > > > > > allocated. > > > > > > > > > > Changes in v6: > > > > > - check for dev->dma_mask being NULL in dma_capable. > > > > > > > > > > Changes in v5: > > > > > - implement dma_mark_clean using dmac_flush_range. > > > > > > > > > > Changes in v3: > > > > > - dma_capable: do not treat dma_mask as a limit; > > > > > - remove SWIOTLB dependency on NEED_SG_DMA_LENGTH. > > > > > --- > > > > > arch/arm/Kconfig | 6 +++++ > > > > > arch/arm/include/asm/dma-mapping.h | 37 ++++++++++++++++++++++++++++++++++++ > > > > > 2 files changed, 43 insertions(+), 0 deletions(-) > > > > > > > > > > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig > > > > > index 1ad6fb6..b08374f 100644 > > > > > --- a/arch/arm/Kconfig > > > > > +++ b/arch/arm/Kconfig > > > > > @@ -1872,6 +1872,12 @@ config CC_STACKPROTECTOR > > > > > neutralized via a kernel panic. > > > > > This feature requires gcc version 4.2 or above. > > > > > > > > > > +config SWIOTLB > > > > > + def_bool y > > > > > + > > > > > +config IOMMU_HELPER > > > > > + def_bool SWIOTLB > > > > > + > > > > > config XEN_DOM0 > > > > > def_bool y > > > > > depends on XEN > > > > > diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h > > > > > index 5b579b9..01b5a3d 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> > > Why does this need to be here? Your'e not adding anything which > needs it. Legacy of a previous iteration of the patch. I'll remove it. > > > > > +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, __phys_to_pfn(paddr)) + offset; > > > > > +} > > > > > + > > > > > +static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr) > > > > > +{ > > > > > + unsigned int offset = dev_addr & ~PAGE_MASK; > > > > > + return __pfn_to_phys(dma_to_pfn(dev, dev_addr)) + offset; > > > > > +} > > These look fine. > > > > > > +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; > > This looks like a hack. Either we want to use the streaming mask or > the coherent mask as appropriate for the caller. That should be a choice > the caller makes, not the implementation of this behind the callers back. How should I choose? Admittedly this is a workaround because some drivers (including Calxeda xgmac) don't set the dma_mask when they should: http://marc.info/?l=linux-arm-kernel&m=138082570519601&w=2 I am happy to reduce this to: if (dev->dma_mask) mask = *dev->dma_mask; even though it means that xgmac & co won't be dma_capable. > > > > > + > > > > > + if (mask == 0) > > > > > + return 0; > > > > > + > > > > > + limit = (mask + 1) & ~mask; > > > > > + if (limit && size > limit) > > > > > + return 0; > > > > > + > > > > > + if ((addr | (addr + size - 1)) & ~mask) > > > > > + return 0; > > > > > + > > > > > + return 1; > > > > > +} > > The remainder looks fine to me. >
On Tue, Oct 29, 2013 at 05:24:50PM +0000, Stefano Stabellini wrote: > On Tue, 29 Oct 2013, Russell King - ARM Linux wrote: > > This looks like a hack. Either we want to use the streaming mask or > > the coherent mask as appropriate for the caller. That should be a choice > > the caller makes, not the implementation of this behind the callers back. > > How should I choose? > Admittedly this is a workaround because some drivers (including Calxeda > xgmac) don't set the dma_mask when they should: > > http://marc.info/?l=linux-arm-kernel&m=138082570519601&w=2 > > I am happy to reduce this to: > > if (dev->dma_mask) > mask = *dev->dma_mask; > > even though it means that xgmac & co won't be dma_capable. Well, if xgmac (there's two in the kernel tree so I'm not sure which you're referring to) is using DMA of any kind, it really ought to be setting a DMA mask via the standard functions - in todays kernel, that is dma_set_mask() for the streaming mask and dma_set_coherent_mask() for the coherent mask. The appropriate mask which the driver is aware of for the hardware should be set here. In the case that a driver needs to call both, and the kernel has my patch set applied, dma_set_mask_and_coherent() can be used to set both at the same time. dma_set_mask() (and dma_set_mask_and_coherent) will fail if storage for the DMA mask has not been allocated previously - iow, if the dev->dma_mask pointer is NULL. The allocation of this storage is the responsibility of the struct device creator, and the struct device creator should initialise the DMA masks to a sensible default for the type of bus. I provide one last call in my patch set - a method that drivers can coerce the DMA mask to whatever they desire irrespective of whether the DMA mask allocation has been setup. This is provided as a way to mark the drivers which are doing this and to ensure that drivers do this in a safe manner - we've had drivers setting it to static storage in module space if it isn't previously set, which is a problem if the module ever gets unloaded. So... what I'm saying is please fix xgmac to use the DMA API properly rather than working around such problems. :)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 1ad6fb6..b08374f 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1872,6 +1872,12 @@ config CC_STACKPROTECTOR neutralized via a kernel panic. This feature requires gcc version 4.2 or above. +config SWIOTLB + def_bool y + +config IOMMU_HELPER + def_bool SWIOTLB + config XEN_DOM0 def_bool y depends on XEN diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index 5b579b9..01b5a3d 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, __phys_to_pfn(paddr)) + offset; +} + +static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr) +{ + unsigned int offset = dev_addr & ~PAGE_MASK; + return __pfn_to_phys(dma_to_pfn(dev, dev_addr)) + offset; +} + +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; + if (limit && size > limit) + return 0; + + if ((addr | (addr + size - 1)) & ~mask) + return 0; + + return 1; +} + +static inline void dma_mark_clean(void *addr, size_t size) { } + /* * DMA errors are defined by all-bits-set in the DMA address. */