diff mbox

[v1,1/4] ASoC: Intel: common: Replace custom implementation of readq / writeq

Message ID 20170131141425.35482-1-andriy.shevchenko@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andy Shevchenko Jan. 31, 2017, 2:14 p.m. UTC
The readq() and writeq() helpers are available in the
linux/io-64-nonatomic-hi-lo.h and linux/io-64-nonatomic-lo-hi.h headers.

Replace custom implementation by the generic helpers.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 sound/soc/intel/common/sst-dsp.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Liam Girdwood Feb. 3, 2017, 2:12 p.m. UTC | #1
On Tue, 2017-01-31 at 16:14 +0200, Andy Shevchenko wrote:
> The readq() and writeq() helpers are available in the
> linux/io-64-nonatomic-hi-lo.h and linux/io-64-nonatomic-lo-hi.h headers.
> 
> Replace custom implementation by the generic helpers.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

All

Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Vinod Koul Feb. 6, 2017, 5:03 p.m. UTC | #2
On Tue, Jan 31, 2017 at 04:14:22PM +0200, Andy Shevchenko wrote:
> The readq() and writeq() helpers are available in the
> linux/io-64-nonatomic-hi-lo.h and linux/io-64-nonatomic-lo-hi.h headers.
> 
> Replace custom implementation by the generic helpers.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  sound/soc/intel/common/sst-dsp.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/sound/soc/intel/common/sst-dsp.c b/sound/soc/intel/common/sst-dsp.c
> index 11c0805393ff..748f1f5c02df 100644
> --- a/sound/soc/intel/common/sst-dsp.c
> +++ b/sound/soc/intel/common/sst-dsp.c
> @@ -22,6 +22,8 @@
>  #include <linux/io.h>
>  #include <linux/delay.h>
>  
> +#include <linux/io-64-nonatomic-lo-hi.h>
> +
>  #include "sst-dsp.h"
>  #include "sst-dsp-priv.h"
>  
> @@ -43,16 +45,13 @@ EXPORT_SYMBOL_GPL(sst_shim32_read);
>  
>  void sst_shim32_write64(void __iomem *addr, u32 offset, u64 value)
>  {
> -	memcpy_toio(addr + offset, &value, sizeof(value));
> +	lo_hi_writeq(value, addr + offset);

why not use writeq here and for 32bit this becomes lo_hi_writeq(), or did I
miss something here..

>  }
>  EXPORT_SYMBOL_GPL(sst_shim32_write64);
>  
>  u64 sst_shim32_read64(void __iomem *addr, u32 offset)
>  {
> -	u64 val;
> -
> -	memcpy_fromio(&val, addr + offset, sizeof(val));
> -	return val;
> +	return lo_hi_readq(addr + offset);
>  }
>  EXPORT_SYMBOL_GPL(sst_shim32_read64);
>  
> -- 
> 2.11.0
>
Andy Shevchenko Feb. 8, 2017, 11:59 a.m. UTC | #3
On Mon, 2017-02-06 at 22:33 +0530, Vinod Koul wrote:
> On Tue, Jan 31, 2017 at 04:14:22PM +0200, Andy Shevchenko wrote:
> > The readq() and writeq() helpers are available in the
> > linux/io-64-nonatomic-hi-lo.h and linux/io-64-nonatomic-lo-hi.h
> > headers.
> > 
> > Replace custom implementation by the generic helpers.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> >  sound/soc/intel/common/sst-dsp.c | 9 ++++-----
> >  1 file changed, 4 insertions(+), 5 deletions(-)
> > 
> > diff --git a/sound/soc/intel/common/sst-dsp.c
> > b/sound/soc/intel/common/sst-dsp.c
> > index 11c0805393ff..748f1f5c02df 100644
> > --- a/sound/soc/intel/common/sst-dsp.c
> > +++ b/sound/soc/intel/common/sst-dsp.c
> > @@ -22,6 +22,8 @@
> >  #include <linux/io.h>
> >  #include <linux/delay.h>
> >  
> > +#include <linux/io-64-nonatomic-lo-hi.h>
> > +
> >  #include "sst-dsp.h"
> >  #include "sst-dsp-priv.h"
> >  
> > @@ -43,16 +45,13 @@ EXPORT_SYMBOL_GPL(sst_shim32_read);
> >  
> >  void sst_shim32_write64(void __iomem *addr, u32 offset, u64 value)
> >  {
> > -	memcpy_toio(addr + offset, &value, sizeof(value));
> > +	lo_hi_writeq(value, addr + offset);
> 
> why not use writeq here and for 32bit this becomes lo_hi_writeq(), or
> did I
> miss something here..

I'm not sure our hardware will correctly handle writeq()/readq().
OCP bus which is quite likely used internally is 32-bit bus.



> 
> >  }
> >  EXPORT_SYMBOL_GPL(sst_shim32_write64);
> >  
> >  u64 sst_shim32_read64(void __iomem *addr, u32 offset)
> >  {
> > -	u64 val;
> > -
> > -	memcpy_fromio(&val, addr + offset, sizeof(val));
> > -	return val;
> > +	return lo_hi_readq(addr + offset);
> >  }
> >  EXPORT_SYMBOL_GPL(sst_shim32_read64);
> >  
> > -- 
> > 2.11.0
> > 
> 
>
Vinod Koul Feb. 9, 2017, 3:56 a.m. UTC | #4
On Wed, Feb 08, 2017 at 01:59:35PM +0200, Andy Shevchenko wrote:
> On Mon, 2017-02-06 at 22:33 +0530, Vinod Koul wrote:
> > On Tue, Jan 31, 2017 at 04:14:22PM +0200, Andy Shevchenko wrote:
> > > The readq() and writeq() helpers are available in the
> > > linux/io-64-nonatomic-hi-lo.h and linux/io-64-nonatomic-lo-hi.h
> > > headers.
> > > 
> > > Replace custom implementation by the generic helpers.
> > > 
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > > ---
> > >  sound/soc/intel/common/sst-dsp.c | 9 ++++-----
> > >  1 file changed, 4 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/sound/soc/intel/common/sst-dsp.c
> > > b/sound/soc/intel/common/sst-dsp.c
> > > index 11c0805393ff..748f1f5c02df 100644
> > > --- a/sound/soc/intel/common/sst-dsp.c
> > > +++ b/sound/soc/intel/common/sst-dsp.c
> > > @@ -22,6 +22,8 @@
> > >  #include <linux/io.h>
> > >  #include <linux/delay.h>
> > >  
> > > +#include <linux/io-64-nonatomic-lo-hi.h>
> > > +
> > >  #include "sst-dsp.h"
> > >  #include "sst-dsp-priv.h"
> > >  
> > > @@ -43,16 +45,13 @@ EXPORT_SYMBOL_GPL(sst_shim32_read);
> > >  
> > >  void sst_shim32_write64(void __iomem *addr, u32 offset, u64 value)
> > >  {
> > > -	memcpy_toio(addr + offset, &value, sizeof(value));
> > > +	lo_hi_writeq(value, addr + offset);
> > 
> > why not use writeq here and for 32bit this becomes lo_hi_writeq(), or
> > did I
> > miss something here..
> 
> I'm not sure our hardware will correctly handle writeq()/readq().
> OCP bus which is quite likely used internally is 32-bit bus.

Yes it is a 32 bit bus, but then we have a bridge which splilts it up. So it
should work, would be worth to test this and update.
diff mbox

Patch

diff --git a/sound/soc/intel/common/sst-dsp.c b/sound/soc/intel/common/sst-dsp.c
index 11c0805393ff..748f1f5c02df 100644
--- a/sound/soc/intel/common/sst-dsp.c
+++ b/sound/soc/intel/common/sst-dsp.c
@@ -22,6 +22,8 @@ 
 #include <linux/io.h>
 #include <linux/delay.h>
 
+#include <linux/io-64-nonatomic-lo-hi.h>
+
 #include "sst-dsp.h"
 #include "sst-dsp-priv.h"
 
@@ -43,16 +45,13 @@  EXPORT_SYMBOL_GPL(sst_shim32_read);
 
 void sst_shim32_write64(void __iomem *addr, u32 offset, u64 value)
 {
-	memcpy_toio(addr + offset, &value, sizeof(value));
+	lo_hi_writeq(value, addr + offset);
 }
 EXPORT_SYMBOL_GPL(sst_shim32_write64);
 
 u64 sst_shim32_read64(void __iomem *addr, u32 offset)
 {
-	u64 val;
-
-	memcpy_fromio(&val, addr + offset, sizeof(val));
-	return val;
+	return lo_hi_readq(addr + offset);
 }
 EXPORT_SYMBOL_GPL(sst_shim32_read64);