Commit c1d55d50139b ("asm-generic/io.h: Fix sparse warnings on
big-endian architectures") missed fixing the 64-bit accessors.
Arnd explains in the attached link why the casts are necessary, even if
__raw_readq() and __raw_writeq() do not take endian-specific types.
Link: https://lore.kernel.org/lkml/[email protected]/
Suggested-by: Arnd Bergmann <[email protected]>
Signed-off-by: Vladimir Oltean <[email protected]>
---
include/asm-generic/io.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 4c44a29b5e8e..d78c3056c98f 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -236,7 +236,7 @@ static inline u64 readq(const volatile void __iomem *addr)
log_read_mmio(64, addr, _THIS_IP_, _RET_IP_);
__io_br();
- val = __le64_to_cpu(__raw_readq(addr));
+ val = __le64_to_cpu((__le64 __force)__raw_readq(addr));
__io_ar(val);
log_post_read_mmio(val, 64, addr, _THIS_IP_, _RET_IP_);
return val;
@@ -287,7 +287,7 @@ static inline void writeq(u64 value, volatile void __iomem *addr)
{
log_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
__io_bw();
- __raw_writeq(__cpu_to_le64(value), addr);
+ __raw_writeq((u64 __force)__cpu_to_le64(value), addr);
__io_aw();
log_post_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
}
--
2.34.1
Copy the forced type casts from the normal MMIO accessors to suppress
the sparse warnings that point out __raw_readl() returns a native endian
word (just like readl()).
Signed-off-by: Vladimir Oltean <[email protected]>
---
include/asm-generic/io.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index d78c3056c98f..587e7e9b9a37 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -319,7 +319,7 @@ static inline u16 readw_relaxed(const volatile void __iomem *addr)
u16 val;
log_read_mmio(16, addr, _THIS_IP_, _RET_IP_);
- val = __le16_to_cpu(__raw_readw(addr));
+ val = __le16_to_cpu((__le16 __force)__raw_readw(addr));
log_post_read_mmio(val, 16, addr, _THIS_IP_, _RET_IP_);
return val;
}
@@ -332,7 +332,7 @@ static inline u32 readl_relaxed(const volatile void __iomem *addr)
u32 val;
log_read_mmio(32, addr, _THIS_IP_, _RET_IP_);
- val = __le32_to_cpu(__raw_readl(addr));
+ val = __le32_to_cpu((__le32 __force)__raw_readl(addr));
log_post_read_mmio(val, 32, addr, _THIS_IP_, _RET_IP_);
return val;
}
@@ -345,7 +345,7 @@ static inline u64 readq_relaxed(const volatile void __iomem *addr)
u64 val;
log_read_mmio(64, addr, _THIS_IP_, _RET_IP_);
- val = __le64_to_cpu(__raw_readq(addr));
+ val = __le64_to_cpu((__le64 __force)__raw_readq(addr));
log_post_read_mmio(val, 64, addr, _THIS_IP_, _RET_IP_);
return val;
}
@@ -366,7 +366,7 @@ static inline void writeb_relaxed(u8 value, volatile void __iomem *addr)
static inline void writew_relaxed(u16 value, volatile void __iomem *addr)
{
log_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_);
- __raw_writew(cpu_to_le16(value), addr);
+ __raw_writew((u16 __force)cpu_to_le16(value), addr);
log_post_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_);
}
#endif
@@ -376,7 +376,7 @@ static inline void writew_relaxed(u16 value, volatile void __iomem *addr)
static inline void writel_relaxed(u32 value, volatile void __iomem *addr)
{
log_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_);
- __raw_writel(__cpu_to_le32(value), addr);
+ __raw_writel((u32 __force)__cpu_to_le32(value), addr);
log_post_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_);
}
#endif
@@ -386,7 +386,7 @@ static inline void writel_relaxed(u32 value, volatile void __iomem *addr)
static inline void writeq_relaxed(u64 value, volatile void __iomem *addr)
{
log_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
- __raw_writeq(__cpu_to_le64(value), addr);
+ __raw_writeq((u64 __force)__cpu_to_le64(value), addr);
log_post_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
}
#endif
--
2.34.1
Hi Arnd,
On Mon, Jan 09, 2023 at 03:11:52PM +0200, Vladimir Oltean wrote:
> Commit c1d55d50139b ("asm-generic/io.h: Fix sparse warnings on
> big-endian architectures") missed fixing the 64-bit accessors.
>
> Arnd explains in the attached link why the casts are necessary, even if
> __raw_readq() and __raw_writeq() do not take endian-specific types.
>
> Link: https://lore.kernel.org/lkml/[email protected]/
> Suggested-by: Arnd Bergmann <[email protected]>
> Signed-off-by: Vladimir Oltean <[email protected]>
> ---
> include/asm-generic/io.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
> index 4c44a29b5e8e..d78c3056c98f 100644
> --- a/include/asm-generic/io.h
> +++ b/include/asm-generic/io.h
> @@ -236,7 +236,7 @@ static inline u64 readq(const volatile void __iomem *addr)
>
> log_read_mmio(64, addr, _THIS_IP_, _RET_IP_);
> __io_br();
> - val = __le64_to_cpu(__raw_readq(addr));
> + val = __le64_to_cpu((__le64 __force)__raw_readq(addr));
> __io_ar(val);
> log_post_read_mmio(val, 64, addr, _THIS_IP_, _RET_IP_);
> return val;
> @@ -287,7 +287,7 @@ static inline void writeq(u64 value, volatile void __iomem *addr)
> {
> log_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
> __io_bw();
> - __raw_writeq(__cpu_to_le64(value), addr);
> + __raw_writeq((u64 __force)__cpu_to_le64(value), addr);
> __io_aw();
> log_post_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
> }
> --
> 2.34.1
>
Did these patches get lost?
On Mon, 9 Jan 2023 15:11:52 +0200
Vladimir Oltean <[email protected]> wrote:
> Commit c1d55d50139b ("asm-generic/io.h: Fix sparse warnings on
> big-endian architectures") missed fixing the 64-bit accessors.
>
> Arnd explains in the attached link why the casts are necessary, even if
> __raw_readq() and __raw_writeq() do not take endian-specific types.
>
> Link: https://lore.kernel.org/lkml/[email protected]/
> Suggested-by: Arnd Bergmann <[email protected]>
> Signed-off-by: Vladimir Oltean <[email protected]>
Found this when about to send an equivalent patch. Not seeing this in linux-next yet
and would be good to clean the resulting warnings up.
Reviewed-by: Jonathan Cameron <[email protected]>
> ---
> include/asm-generic/io.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
> index 4c44a29b5e8e..d78c3056c98f 100644
> --- a/include/asm-generic/io.h
> +++ b/include/asm-generic/io.h
> @@ -236,7 +236,7 @@ static inline u64 readq(const volatile void __iomem *addr)
>
> log_read_mmio(64, addr, _THIS_IP_, _RET_IP_);
> __io_br();
> - val = __le64_to_cpu(__raw_readq(addr));
> + val = __le64_to_cpu((__le64 __force)__raw_readq(addr));
> __io_ar(val);
> log_post_read_mmio(val, 64, addr, _THIS_IP_, _RET_IP_);
> return val;
> @@ -287,7 +287,7 @@ static inline void writeq(u64 value, volatile void __iomem *addr)
> {
> log_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
> __io_bw();
> - __raw_writeq(__cpu_to_le64(value), addr);
> + __raw_writeq((u64 __force)__cpu_to_le64(value), addr);
> __io_aw();
> log_post_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
> }
On Fri, Mar 10, 2023, at 10:30, Vladimir Oltean wrote:
> Hi Arnd,
>
> On Mon, Jan 09, 2023 at 03:11:52PM +0200, Vladimir Oltean wrote:
>> Commit c1d55d50139b ("asm-generic/io.h: Fix sparse warnings on
>> big-endian architectures") missed fixing the 64-bit accessors.
>>
>> Arnd explains in the attached link why the casts are necessary, even if
>> __raw_readq() and __raw_writeq() do not take endian-specific types.
>>
>> Link: https://lore.kernel.org/lkml/[email protected]/
>> Suggested-by: Arnd Bergmann <[email protected]>
>> Signed-off-by: Vladimir Oltean <[email protected]>
>>
>
> Did these patches get lost?
Yes, sorry about that. I picked them up for 6.3 now, along with another
one that I just remembered.
Arnd