diff mbox series

mvebu: fix __iomem on mvebu_pm_store_armadaxp_bootinfo()

Message ID 20191009153342.23789-1-ben.dooks@codethink.co.uk (mailing list archive)
State New, archived
Headers show
Series mvebu: fix __iomem on mvebu_pm_store_armadaxp_bootinfo() | expand

Commit Message

Ben Dooks Oct. 9, 2019, 3:33 p.m. UTC
The mvebu_pm_store_armadaxp_bootinfo() uses writel to
store data, so the pointer into it should be __iomem
annotated. Fixes the following sparse warnings:

arch/arm/mach-mvebu/pm.c:124:9: warning: incorrect type in argument 2 (different address spaces)
arch/arm/mach-mvebu/pm.c:124:9:    expected void volatile [noderef] <asn:2> *addr
arch/arm/mach-mvebu/pm.c:124:9:    got unsigned int [usertype] *
arch/arm/mach-mvebu/pm.c:125:9: warning: incorrect type in argument 2 (different address spaces)
arch/arm/mach-mvebu/pm.c:125:9:    expected void volatile [noderef] <asn:2> *addr
arch/arm/mach-mvebu/pm.c:125:9:    got unsigned int [usertype] *
arch/arm/mach-mvebu/pm.c:133:9: warning: incorrect type in argument 2 (different address spaces)
arch/arm/mach-mvebu/pm.c:133:9:    expected void volatile [noderef] <asn:2> *addr
arch/arm/mach-mvebu/pm.c:133:9:    got unsigned int [usertype] *
arch/arm/mach-mvebu/pm.c:134:9: warning: incorrect type in argument 2 (different address spaces)
arch/arm/mach-mvebu/pm.c:134:9:    expected void volatile [noderef] <asn:2> *addr
arch/arm/mach-mvebu/pm.c:134:9:    got unsigned int [usertype] *
arch/arm/mach-mvebu/pm.c:140:9: warning: incorrect type in argument 2 (different address spaces)
arch/arm/mach-mvebu/pm.c:140:9:    expected void volatile [noderef] <asn:2> *addr
arch/arm/mach-mvebu/pm.c:140:9:    got unsigned int [usertype] *
arch/arm/mach-mvebu/pm.c:141:9: warning: incorrect type in argument 2 (different address spaces)
arch/arm/mach-mvebu/pm.c:141:9:    expected void volatile [noderef] <asn:2> *addr
arch/arm/mach-mvebu/pm.c:141:9:    got unsigned int [usertype] *
arch/arm/mach-mvebu/pm.c:148:50: warning: incorrect type in argument 1 (different address spaces)
arch/arm/mach-mvebu/pm.c:148:50:    expected unsigned int [noderef] [usertype] <asn:2> *store_addr
arch/arm/mach-mvebu/pm.c:148:50:    got unsigned int [usertype] *[assigned] store_addr
arch/arm/mach-mvebu/pm.c:150:9: warning: incorrect type in argument 2 (different address spaces)
arch/arm/mach-mvebu/pm.c:150:9:    expected void volatile [noderef] <asn:2> *addr
arch/arm/mach-mvebu/pm.c:150:9:    got unsigned int [usertype] *[assigned] store_addr

Note, this doesn't take into account writel() is probably heavy
handed here and just writing the data and then flushing all the
caches etc would be good enough.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Gregory Clement <gregory.clement@bootlin.com>
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
---
 arch/arm/mach-mvebu/pm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Christoph Hellwig Oct. 9, 2019, 3:35 p.m. UTC | #1
On Wed, Oct 09, 2019 at 04:33:42PM +0100, Ben Dooks wrote:
> The mvebu_pm_store_armadaxp_bootinfo() uses writel to
> store data, so the pointer into it should be __iomem
> annotated. Fixes the following sparse warnings:

Shouldn't this use something like early_ioremap instead of blind casts?
Russell King (Oracle) Oct. 9, 2019, 4 p.m. UTC | #2
On Wed, Oct 09, 2019 at 04:33:42PM +0100, Ben Dooks wrote:
> The mvebu_pm_store_armadaxp_bootinfo() uses writel to
> store data, so the pointer into it should be __iomem
> annotated. Fixes the following sparse warnings:
> 
> arch/arm/mach-mvebu/pm.c:124:9: warning: incorrect type in argument 2 (different address spaces)
> arch/arm/mach-mvebu/pm.c:124:9:    expected void volatile [noderef] <asn:2> *addr
> arch/arm/mach-mvebu/pm.c:124:9:    got unsigned int [usertype] *
> arch/arm/mach-mvebu/pm.c:125:9: warning: incorrect type in argument 2 (different address spaces)
> arch/arm/mach-mvebu/pm.c:125:9:    expected void volatile [noderef] <asn:2> *addr
> arch/arm/mach-mvebu/pm.c:125:9:    got unsigned int [usertype] *
> arch/arm/mach-mvebu/pm.c:133:9: warning: incorrect type in argument 2 (different address spaces)
> arch/arm/mach-mvebu/pm.c:133:9:    expected void volatile [noderef] <asn:2> *addr
> arch/arm/mach-mvebu/pm.c:133:9:    got unsigned int [usertype] *
> arch/arm/mach-mvebu/pm.c:134:9: warning: incorrect type in argument 2 (different address spaces)
> arch/arm/mach-mvebu/pm.c:134:9:    expected void volatile [noderef] <asn:2> *addr
> arch/arm/mach-mvebu/pm.c:134:9:    got unsigned int [usertype] *
> arch/arm/mach-mvebu/pm.c:140:9: warning: incorrect type in argument 2 (different address spaces)
> arch/arm/mach-mvebu/pm.c:140:9:    expected void volatile [noderef] <asn:2> *addr
> arch/arm/mach-mvebu/pm.c:140:9:    got unsigned int [usertype] *
> arch/arm/mach-mvebu/pm.c:141:9: warning: incorrect type in argument 2 (different address spaces)
> arch/arm/mach-mvebu/pm.c:141:9:    expected void volatile [noderef] <asn:2> *addr
> arch/arm/mach-mvebu/pm.c:141:9:    got unsigned int [usertype] *
> arch/arm/mach-mvebu/pm.c:148:50: warning: incorrect type in argument 1 (different address spaces)
> arch/arm/mach-mvebu/pm.c:148:50:    expected unsigned int [noderef] [usertype] <asn:2> *store_addr
> arch/arm/mach-mvebu/pm.c:148:50:    got unsigned int [usertype] *[assigned] store_addr
> arch/arm/mach-mvebu/pm.c:150:9: warning: incorrect type in argument 2 (different address spaces)
> arch/arm/mach-mvebu/pm.c:150:9:    expected void volatile [noderef] <asn:2> *addr
> arch/arm/mach-mvebu/pm.c:150:9:    got unsigned int [usertype] *[assigned] store_addr
> 
> Note, this doesn't take into account writel() is probably heavy
> handed here and just writing the data and then flushing all the
> caches etc would be good enough.

This is definitely wrong.

> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
> Cc: Jason Cooper <jason@lakedaemon.net>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Gregory Clement <gregory.clement@bootlin.com>
> Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: linux-arm-kernel@lists.infradead.org
> ---
>  arch/arm/mach-mvebu/pm.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/mach-mvebu/pm.c b/arch/arm/mach-mvebu/pm.c
> index c487be61d6d8..c223f87ed338 100644
> --- a/arch/arm/mach-mvebu/pm.c
> +++ b/arch/arm/mach-mvebu/pm.c
> @@ -106,7 +106,7 @@ static phys_addr_t mvebu_internal_reg_base(void)
>  	return of_translate_address(np, in_addr);
>  }
>  
> -static void mvebu_pm_store_armadaxp_bootinfo(u32 *store_addr)
> +static void mvebu_pm_store_armadaxp_bootinfo(u32 __iomem *store_addr)
>  {
>  	phys_addr_t resume_pc;
>  
> @@ -152,9 +152,9 @@ static void mvebu_pm_store_armadaxp_bootinfo(u32 *store_addr)
>  
>  static int mvebu_pm_store_bootinfo(void)
>  {
> -	u32 *store_addr;
> +	u32 __iomem *store_addr;
>  
> -	store_addr = phys_to_virt(BOOT_INFO_ADDR);
> +	store_addr = (__force __iomem u32*)phys_to_virt(BOOT_INFO_ADDR);

phys_to_virt() does not return an iomem pointer, so the memory pointed
to here is _not_ iomem.  Thus, iomem accessors should not be used - and
that's where the problem actually lies.

>  
>  	if (of_machine_is_compatible("marvell,armadaxp"))
>  		mvebu_pm_store_armadaxp_bootinfo(store_addr);
> -- 
> 2.23.0
> 
>
diff mbox series

Patch

diff --git a/arch/arm/mach-mvebu/pm.c b/arch/arm/mach-mvebu/pm.c
index c487be61d6d8..c223f87ed338 100644
--- a/arch/arm/mach-mvebu/pm.c
+++ b/arch/arm/mach-mvebu/pm.c
@@ -106,7 +106,7 @@  static phys_addr_t mvebu_internal_reg_base(void)
 	return of_translate_address(np, in_addr);
 }
 
-static void mvebu_pm_store_armadaxp_bootinfo(u32 *store_addr)
+static void mvebu_pm_store_armadaxp_bootinfo(u32 __iomem *store_addr)
 {
 	phys_addr_t resume_pc;
 
@@ -152,9 +152,9 @@  static void mvebu_pm_store_armadaxp_bootinfo(u32 *store_addr)
 
 static int mvebu_pm_store_bootinfo(void)
 {
-	u32 *store_addr;
+	u32 __iomem *store_addr;
 
-	store_addr = phys_to_virt(BOOT_INFO_ADDR);
+	store_addr = (__force __iomem u32*)phys_to_virt(BOOT_INFO_ADDR);
 
 	if (of_machine_is_compatible("marvell,armadaxp"))
 		mvebu_pm_store_armadaxp_bootinfo(store_addr);