lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.02.1410251424350.22875@kaball.uk.xensource.com>
Date:	Sat, 25 Oct 2014 14:29:07 +0100
From:	Stefano Stabellini <stefano.stabellini@...citrix.com>
To:	Stefano Stabellini <stefano.stabellini@...citrix.com>
CC:	Catalin Marinas <catalin.marinas@....com>,
	Will Deacon <Will.Deacon@....com>,
	"xen-devel@...ts.xensource.com" <xen-devel@...ts.xensource.com>,
	"konrad.wilk@...cle.com" <konrad.wilk@...cle.com>,
	"Ian.Campbell@...rix.com" <Ian.Campbell@...rix.com>,
	"david.vrabel@...rix.com" <david.vrabel@...rix.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linux-arm-kernel@...ts.infradead.org" 
	<linux-arm-kernel@...ts.infradead.org>,
	"linux@....linux.org.uk" <linux@....linux.org.uk>
Subject: Re: [PATCH v4 3/7] [RFC] arm/arm64: introduce is_dma_coherent

On Fri, 24 Oct 2014, Stefano Stabellini wrote:
> On Fri, 24 Oct 2014, Stefano Stabellini wrote:
> > On Fri, 24 Oct 2014, Catalin Marinas wrote:
> > > > However given the timing constraints I hope you would be OK with the
> > > > suboptimal solution for now and create a common is_dma_coherent function
> > > > in 3.19?
> > > 
> > > If you want to push something for 3.18, you could have a temporary
> > > solution but I would prefer a bool or something in the dev_archdata
> > > structure. Another untested patch:
> > > 
> > > diff --git a/arch/arm64/include/asm/device.h b/arch/arm64/include/asm/device.h
> > > index cf98b362094b..243ef256b8c9 100644
> > > --- a/arch/arm64/include/asm/device.h
> > > +++ b/arch/arm64/include/asm/device.h
> > > @@ -21,6 +21,7 @@ struct dev_archdata {
> > >  #ifdef CONFIG_IOMMU_API
> > >  	void *iommu;			/* private IOMMU data */
> > >  #endif
> > > +	bool dma_coherent;
> > >  };
> > >  
> > >  struct pdev_archdata {
> > > diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h
> > > index adeae3f6f0fc..b6bc4c268878 100644
> > > --- a/arch/arm64/include/asm/dma-mapping.h
> > > +++ b/arch/arm64/include/asm/dma-mapping.h
> > > @@ -54,11 +54,17 @@ static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops)
> > >  
> > >  static inline int set_arch_dma_coherent_ops(struct device *dev)
> > >  {
> > > +	dev->dev_archdata.dma_coherent = true;
> > >  	set_dma_ops(dev, &coherent_swiotlb_dma_ops);
> > >  	return 0;
> > >  }
> > >  #define set_arch_dma_coherent_ops	set_arch_dma_coherent_ops
> > >  
> > > +static inline int is_device_dma_coherent(struct device *dev)
> > > +{
> > > +	return dev->dev_archdata.dma_coherent;
> > > +}
> > > +
> > >  #include <asm-generic/dma-mapping-common.h>
> > >  
> > >  static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
> > > 
> > > 
> > > This way you don't have to test for swiotlb vs iommu ops (we don't have
> > > the latter yet on arm64 but they are coming).
 
Your suggestions and looking more at the code gave me another idea, that
I think is clean and at the same time suitable for 3.18.
What do you think of the following? It is simple, self-contained and
doesn't need a new flag in struct device.


diff --git a/arch/arm/xen/mm32.c b/arch/arm/xen/mm32.c
index 6153d61..2b259f1 100644
--- a/arch/arm/xen/mm32.c
+++ b/arch/arm/xen/mm32.c
@@ -2,10 +2,16 @@
 #include <linux/dma-mapping.h>
 #include <linux/gfp.h>
 #include <linux/highmem.h>
+#include <linux/of_address.h>
 
 #include <xen/features.h>
 
 
+static inline bool is_dma_coherent(struct device *dev)
+{
+	return of_dma_is_coherent(dev->of_node);
+}
+
 /* functions called by SWIOTLB */
 
 static void dma_cache_maint(dma_addr_t handle, unsigned long offset,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ