Skip to contentSkip to conversation

sst: replace custom implementation of readq / writeq

PATCH In review Andy Shevchenko 4 participants 6 messages Aug 27, 2015 – Nov 24, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sst: replace custom implementation of readq / writeq

The readq() and writeq() helpers are available in the asm-generic/io-64-nonatomic-hi-lo.h and asm-generic/io-64-nonatomic-lo-hi.h headers. Replace custom implementation by the generic helpers.

---
 sound/soc/intel/atom/sst/sst_pvt.c | 16 ++++++----------
 sound/soc/intel/common/sst-dsp.c   |  9 ++++-----
 2 files changed, 10 insertions(+), 15 deletions(-)
sound/soc/intel/atom/sst/sst_pvt.c +6 -10
index adb32fe..6cc222d 100644
@@ -31,7 +31,10 @@
 #include <sound/pcm.h>
 #include <sound/soc.h>
 #include <sound/compress_driver.h>
+
+#include <asm-generic/io-64-nonatomic-lo-hi.h>
 #include <asm/platform_sst_audio.h>
+
 #include "../sst-mfld-platform.h"
 #include "sst.h"
 #include "../../common/sst-dsp.h"
@@ -49,25 +52,18 @@ u32 sst_shim_read(void __iomem *addr, int offset)
 
 u64 sst_reg_read64(void __iomem *addr, int offset)
 {
-	u64 val = 0;
-
-	memcpy_fromio(&val, addr + offset, sizeof(val));
-
-	return val;
+	return readq(addr + offset);
 }
 
 int sst_shim_write64(void __iomem *addr, int offset, u64 value)
 {
-	memcpy_toio(addr + offset, &value, sizeof(value));
+	writeq(value, addr + offset);
 	return 0;
 }
 
 u64 sst_shim_read64(void __iomem *addr, int offset)
 {
-	u64 val = 0;
-
-	memcpy_fromio(&val, addr + offset, sizeof(val));
-	return val;
+	return readq(addr + offset);
 }
 
 void sst_set_fw_state_locked(
sound/soc/intel/common/sst-dsp.c +4 -5
index a627236..5274482 100644
@@ -22,6 +22,8 @@
 #include <linux/io.h>
 #include <linux/delay.h>
 
+#include <asm-generic/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));
+	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 readq(addr + offset);
 }
 EXPORT_SYMBOL_GPL(sst_shim32_read64);
 
Signature · 1 line
2.5.0
#1 lore raw
Quoted 5 lines · Andy Shevchenko

The readq() and writeq() helpers are available in the asm-generic/io-64-nonatomic-hi-lo.h and asm-generic/io-64-nonatomic -lo-hi.h
headers. Replace custom implementation by the generic helpers.

Liam, any comments on this?

Quoted 84 lines
---
 sound/soc/intel/atom/sst/sst_pvt.c | 16 ++++++----------
 sound/soc/intel/common/sst-dsp.c   |  9 ++++-----
 2 files changed, 10 insertions(+), 15 deletions(-)
sound/soc/intel/atom/sst/sst_pvt.c +6 -10
index adb32fe..6cc222d 100644
@@ -31,7 +31,10 @@
 #include <sound/pcm.h>
 #include <sound/soc.h>
 #include <sound/compress_driver.h>
+
+#include <asm-generic/io-64-nonatomic-lo-hi.h>
 #include <asm/platform_sst_audio.h>
+
 #include "../sst-mfld-platform.h"
 #include "sst.h"
 #include "../../common/sst-dsp.h"
@@ -49,25 +52,18 @@ u32 sst_shim_read(void __iomem *addr, int offset)
 
 u64 sst_reg_read64(void __iomem *addr, int offset)
 {
-	u64 val = 0;
-
-	memcpy_fromio(&val, addr + offset, sizeof(val));
-
-	return val;
+	return readq(addr + offset);
 }
 
 int sst_shim_write64(void __iomem *addr, int offset, u64 value)
 {
-	memcpy_toio(addr + offset, &value, sizeof(value));
+	writeq(value, addr + offset);
 	return 0;
 }
 
 u64 sst_shim_read64(void __iomem *addr, int offset)
 {
-	u64 val = 0;
-
-	memcpy_fromio(&val, addr + offset, sizeof(val));
-	return val;
+	return readq(addr + offset);
 }
 
 void sst_set_fw_state_locked(
sound/soc/intel/common/sst-dsp.c +4 -5
index a627236..5274482 100644
@@ -22,6 +22,8 @@
 #include <linux/io.h>
 #include <linux/delay.h>
 
+#include <asm-generic/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));
+	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 readq(addr + offset);
 }
 EXPORT_SYMBOL_GPL(sst_shim32_read64);
 
Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
maintainer
#2 lore raw
Quoted 8 lines · Andy Shevchenko
Quoted 5 lines · Andy Shevchenko

The readq() and writeq() helpers are available in the asm-generic/io-64-nonatomic-hi-lo.h and asm-generic/io-64-nonatomic -lo-hi.h
headers. Replace custom implementation by the generic helpers.

Liam, any comments on this?

Looks good from me, but it's one of Vinod's drivers (now added to CC).

Liam

Quoted 86 lines
Quoted 85 lines
---
 sound/soc/intel/atom/sst/sst_pvt.c | 16 ++++++----------
 sound/soc/intel/common/sst-dsp.c   |  9 ++++-----
 2 files changed, 10 insertions(+), 15 deletions(-)
sound/soc/intel/atom/sst/sst_pvt.c +6 -10
index adb32fe..6cc222d 100644
@@ -31,7 +31,10 @@
 #include <sound/pcm.h>
 #include <sound/soc.h>
 #include <sound/compress_driver.h>
+
+#include <asm-generic/io-64-nonatomic-lo-hi.h>
 #include <asm/platform_sst_audio.h>
+
 #include "../sst-mfld-platform.h"
 #include "sst.h"
 #include "../../common/sst-dsp.h"
@@ -49,25 +52,18 @@ u32 sst_shim_read(void __iomem *addr, int offset)
 
 u64 sst_reg_read64(void __iomem *addr, int offset)
 {
-	u64 val = 0;
-
-	memcpy_fromio(&val, addr + offset, sizeof(val));
-
-	return val;
+	return readq(addr + offset);
 }
 
 int sst_shim_write64(void __iomem *addr, int offset, u64 value)
 {
-	memcpy_toio(addr + offset, &value, sizeof(value));
+	writeq(value, addr + offset);
 	return 0;
 }
 
 u64 sst_shim_read64(void __iomem *addr, int offset)
 {
-	u64 val = 0;
-
-	memcpy_fromio(&val, addr + offset, sizeof(val));
-	return val;
+	return readq(addr + offset);
 }
 
 void sst_set_fw_state_locked(
sound/soc/intel/common/sst-dsp.c +4 -5
index a627236..5274482 100644
@@ -22,6 +22,8 @@
 #include <linux/io.h>
 #include <linux/delay.h>
 
+#include <asm-generic/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));
+	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 readq(addr + offset);
 }
 EXPORT_SYMBOL_GPL(sst_shim32_read64);
 
Acked-by
#3 lore raw
Quoted 11 lines · Liam Girdwood
Quoted 8 lines · Andy Shevchenko
Quoted 5 lines · Andy Shevchenko

The readq() and writeq() helpers are available in the asm-generic/io-64-nonatomic-hi-lo.h and asm-generic/io-64-nonatomic -lo-hi.h
headers. Replace custom implementation by the generic helpers.

Liam, any comments on this?

Looks good from me, but it's one of Vinod's drivers (now added to CC).

Please do test this on BYT/BSW as well, otherwise looks good

Signature · 1 line
~Vinod
Quoted 90 lines

Liam

Quoted 86 lines
Quoted 85 lines
---
 sound/soc/intel/atom/sst/sst_pvt.c | 16 ++++++----------
 sound/soc/intel/common/sst-dsp.c   |  9 ++++-----
 2 files changed, 10 insertions(+), 15 deletions(-)
sound/soc/intel/atom/sst/sst_pvt.c +6 -10
index adb32fe..6cc222d 100644
@@ -31,7 +31,10 @@
 #include <sound/pcm.h>
 #include <sound/soc.h>
 #include <sound/compress_driver.h>
+
+#include <asm-generic/io-64-nonatomic-lo-hi.h>
 #include <asm/platform_sst_audio.h>
+
 #include "../sst-mfld-platform.h"
 #include "sst.h"
 #include "../../common/sst-dsp.h"
@@ -49,25 +52,18 @@ u32 sst_shim_read(void __iomem *addr, int offset)
 
 u64 sst_reg_read64(void __iomem *addr, int offset)
 {
-	u64 val = 0;
-
-	memcpy_fromio(&val, addr + offset, sizeof(val));
-
-	return val;
+	return readq(addr + offset);
 }
 
 int sst_shim_write64(void __iomem *addr, int offset, u64 value)
 {
-	memcpy_toio(addr + offset, &value, sizeof(value));
+	writeq(value, addr + offset);
 	return 0;
 }
 
 u64 sst_shim_read64(void __iomem *addr, int offset)
 {
-	u64 val = 0;
-
-	memcpy_fromio(&val, addr + offset, sizeof(val));
-	return val;
+	return readq(addr + offset);
 }
 
 void sst_set_fw_state_locked(
sound/soc/intel/common/sst-dsp.c +4 -5
index a627236..5274482 100644
@@ -22,6 +22,8 @@
 #include <linux/io.h>
 #include <linux/delay.h>
 
+#include <asm-generic/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));
+	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 readq(addr + offset);
 }
 EXPORT_SYMBOL_GPL(sst_shim32_read64);
 
#4 lore raw
Quoted 12 lines · Vinod Koul
Quoted 11 lines · Liam Girdwood
Quoted 9 lines · Andy Shevchenko
Quoted 6 lines · Andy Shevchenko

The readq() and writeq() helpers are available in the asm-generic/io-64-nonatomic-hi-lo.h and asm-generic/io-64

(quoted diff) +0 -2
-nonatomic
-lo-hi.h

headers. Replace custom implementation by the generic helpers.

Liam, any comments on this?

Quoted 4 lines
Quoted 2 lines

Looks good from me, but it's one of Vinod's drivers (now added to CC).

Please do test this on BYT/BSW as well, otherwise looks good

Tested both patches (another one just recently sent) on ASuS T100TA.

Quoted 3 lines
Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#5 lore raw
Quoted 14 lines · Andy Shevchenko
Quoted 13 lines · Vinod Koul
Quoted 12 lines · Liam Girdwood
Quoted 10 lines · Andy Shevchenko
Quoted 7 lines · Andy Shevchenko

The readq() and writeq() helpers are available in the asm-generic/io-64-nonatomic-hi-lo.h and asm-generic/io-64

(quoted diff) +0 -2
-nonatomic
-lo-hi.h

headers. Replace custom implementation by the generic helpers.

Liam, any comments on this?

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Looks good from me, but it's one of Vinod's drivers (now added to CC).

Please do test this on BYT/BSW as well, otherwise looks good

Tested both patches (another one just recently sent) on ASuS T100TA.

Do I understand correctly I have to resend with Mark in Cc?

Quoted 5 lines
Quoted 4 lines
Signature · 12 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.