2023-04-27 17:42:29

by Stanislav Kinsburskii

[permalink] [raw]
Subject: [PATCH 0/7] Expect immutable pointer in virt_to_phys/isa_virt_to_bus prototypes

This series is aimed to address compilation warnings when a constant pointer
is passed to virt_to_phys and isa_virt_to_bus functions:

warning: passing argument 1 of ‘virt_to_phys’ discards ‘const’ qualifier from pointer target type
warning: passing argument 1 of ‘isa_virt_to_bus’ discards ‘const’ qualifier from pointer target type

The change(s) is the same for all architectures, but it's split into a series on
per-arch basis to simplify applying and testing on the maintainers side.

The following series implements...

---

Stanislav Kinsburskii (7):
x86: asm/io.h: Expect immutable pointer in virt_to_phys/isa_virt_to_bus prototypes
alpha: asm/io.h: Expect immutable pointer in virt_to_phys/isa_virt_to_bus prototypes
mips: asm/io.h: Expect immutable pointer in isa_virt_to_bus prototype
hexagon: asm/io.h: Expect immutable pointer in virt_to_phys prototype
ia64: asm/io.h: Expect immutable pointer in virt_to_phys prototype
powerpc: asm/io.h: Expect immutable pointer in virt_to_phys prototype
asm-generic/io.h: Expect immutable pointer in virt_to_phys


arch/alpha/include/asm/io.h | 6 +++---
arch/hexagon/include/asm/io.h | 2 +-
arch/ia64/include/asm/io.h | 2 +-
arch/mips/include/asm/io.h | 2 +-
arch/powerpc/include/asm/io.h | 2 +-
arch/x86/include/asm/io.h | 4 ++--
include/asm-generic/io.h | 2 +-
7 files changed, 10 insertions(+), 10 deletions(-)



2023-04-27 17:42:49

by Stanislav Kinsburskii

[permalink] [raw]
Subject: [PATCH 1/7] x86: asm/io.h: Expect immutable pointer in virt_to_phys/isa_virt_to_bus prototypes

From: Stanislav Kinsburskii <[email protected]>

These two helper functions - virt_to_phys and isa_virt_to_bus - don't need the
address pointer to be mutable.

In the same time expecting it to be mutable leads to the following build
warning for constant pointers:

warning: passing argument 1 of ‘virt_to_phys’ discards ‘const’ qualifier from pointer target type

Signed-off-by: Stanislav Kinsburskii <[email protected]>
CC: Thomas Gleixner <[email protected]>
CC: Ingo Molnar <[email protected]>
CC: Borislav Petkov <[email protected]>
CC: Dave Hansen <[email protected]>
CC: [email protected]
CC: "H. Peter Anvin" <[email protected]>
CC: Geert Uytterhoeven <[email protected]>
CC: Arnd Bergmann <[email protected]>
CC: Chris Down <[email protected]>
CC: Helge Deller <[email protected]>
CC: Omar Sandoval <[email protected]>
CC: [email protected]
---
arch/x86/include/asm/io.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index e9025640f634..0e6f5b48f517 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -128,7 +128,7 @@ extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
* this function
*/

-static inline phys_addr_t virt_to_phys(volatile void *address)
+static inline phys_addr_t virt_to_phys(const volatile void *address)
{
return __pa(address);
}
@@ -163,7 +163,7 @@ static inline void *phys_to_virt(phys_addr_t address)
* However, we truncate the address to unsigned int to avoid undesirable
* promotions in legacy drivers.
*/
-static inline unsigned int isa_virt_to_bus(volatile void *address)
+static inline unsigned int isa_virt_to_bus(const volatile void *address)
{
return (unsigned int)virt_to_phys(address);
}


2023-04-27 17:42:54

by Stanislav Kinsburskii

[permalink] [raw]
Subject: [PATCH 2/7] alpha: asm/io.h: Expect immutable pointer in virt_to_phys/isa_virt_to_bus prototypes

From: Stanislav Kinsburskii <[email protected]>

These two helper functions - virt_to_phys and isa_virt_to_bus - don't need the
address pointer to be mutable.

In the same time expecting it to be mutable leads to the following build
warning for constant pointers:

warning: passing argument 1 of ‘virt_to_phys’ discards ‘const’ qualifier from pointer target type

Signed-off-by: Stanislav Kinsburskii <[email protected]>
CC: Richard Henderson <[email protected]>
CC: Ivan Kokshaysky <[email protected]>
CC: Matt Turner <[email protected]>
CC: Arnd Bergmann <[email protected]>
CC: Geert Uytterhoeven <[email protected]>
CC: Linus Walleij <[email protected]>
CC: Stanislav Kinsburskii <[email protected]>
CC: Michael Ellerman <[email protected]>
CC: Bjorn Helgaas <[email protected]>
CC: [email protected]
CC: [email protected]
---
arch/alpha/include/asm/io.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/alpha/include/asm/io.h b/arch/alpha/include/asm/io.h
index 7aeaf7c30a6f..0e2016537bd3 100644
--- a/arch/alpha/include/asm/io.h
+++ b/arch/alpha/include/asm/io.h
@@ -56,7 +56,7 @@ extern inline void set_hae(unsigned long new_hae)
* Change virtual addresses to physical addresses and vv.
*/
#ifdef USE_48_BIT_KSEG
-static inline unsigned long virt_to_phys(volatile void *address)
+static inline unsigned long virt_to_phys(const volatile void *address)
{
return (unsigned long)address - IDENT_ADDR;
}
@@ -66,7 +66,7 @@ static inline void * phys_to_virt(unsigned long address)
return (void *) (address + IDENT_ADDR);
}
#else
-static inline unsigned long virt_to_phys(volatile void *address)
+static inline unsigned long virt_to_phys(const volatile void *address)
{
unsigned long phys = (unsigned long)address;

@@ -104,7 +104,7 @@ static inline void * phys_to_virt(unsigned long address)
extern unsigned long __direct_map_base;
extern unsigned long __direct_map_size;

-static inline unsigned long __deprecated isa_virt_to_bus(volatile void *address)
+static inline unsigned long __deprecated isa_virt_to_bus(const volatile void *address)
{
unsigned long phys = virt_to_phys(address);
unsigned long bus = phys + __direct_map_base;


2023-04-27 17:43:01

by Stanislav Kinsburskii

[permalink] [raw]
Subject: [PATCH 3/7] mips: asm/io.h: Expect immutable pointer in isa_virt_to_bus prototype

From: Stanislav Kinsburskii <[email protected]>

These helper function - isa_virt_to_bus - doesn't need the address pointer to
be mutable.

In the same time expecting it to be mutable leads to the following build
warning for constant pointers:

warning: passing argument 1 of ‘isa_virt_to_bus’ discards ‘const’ qualifier from pointer target type

Signed-off-by: Stanislav Kinsburskii <[email protected]>
CC: Thomas Bogendoerfer <[email protected]>
CC: Geert Uytterhoeven <[email protected]>
CC: Michael Ellerman <[email protected]>
CC: Florian Fainelli <[email protected]>
CC: Arnd Bergmann <[email protected]>
CC: Stanislav Kinsburskii <[email protected]>
CC: Jiaxun Yang <[email protected]>
CC: [email protected]
CC: [email protected]
---
arch/mips/include/asm/io.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index cc28d207a061..d78ca2e71f8c 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -137,7 +137,7 @@ static inline void * phys_to_virt(unsigned long address)
/*
* ISA I/O bus memory addresses are 1:1 with the physical address.
*/
-static inline unsigned long isa_virt_to_bus(volatile void *address)
+static inline unsigned long isa_virt_to_bus(const volatile void *address)
{
return virt_to_phys(address);
}


2023-04-27 17:43:05

by Stanislav Kinsburskii

[permalink] [raw]
Subject: [PATCH 4/7] hexagon: asm/io.h: Expect immutable pointer in virt_to_phys prototype

From: Stanislav Kinsburskii <[email protected]>

These helper function - virt_to_phys - doesn't need the address pointer to
be mutable.

In the same time expecting it to be mutable leads to the following build
warning for constant pointers:

warning: passing argument 1 of ‘virt_to_phys’ discards ‘const’ qualifier from pointer target type

Signed-off-by: Stanislav Kinsburskii <[email protected]>
CC: Brian Cain <[email protected]>
CC: Linus Walleij <[email protected]>
CC: Mark Brown <[email protected]>
CC: [email protected]
CC: [email protected]
---
arch/hexagon/include/asm/io.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/hexagon/include/asm/io.h b/arch/hexagon/include/asm/io.h
index 46a099de85b7..facbd7467dd3 100644
--- a/arch/hexagon/include/asm/io.h
+++ b/arch/hexagon/include/asm/io.h
@@ -46,7 +46,7 @@ extern void __raw_writesl(void __iomem *addr, const void *data, int wordlen);
* virt_to_phys - map virtual address to physical
* @address: address to map
*/
-static inline unsigned long virt_to_phys(volatile void *address)
+static inline unsigned long virt_to_phys(const volatile void *address)
{
return __pa(address);
}


2023-04-27 17:43:35

by Stanislav Kinsburskii

[permalink] [raw]
Subject: [PATCH 5/7] ia64: asm/io.h: Expect immutable pointer in virt_to_phys prototype

From: Stanislav Kinsburskii <[email protected]>

These helper function - virt_to_phys - doesn't need the address pointer to
be mutable.

In the same time expecting it to be mutable leads to the following build
warning for constant pointers:

warning: passing argument 1 of ‘virt_to_phys’ discards ‘const’ qualifier from pointer target type

Signed-off-by: Stanislav Kinsburskii <[email protected]>
CC: Geert Uytterhoeven <[email protected]>
CC: Helge Deller <[email protected]>
CC: Arnd Bergmann <[email protected]>
CC: Andrew Morton <[email protected]>
CC: Bjorn Helgaas <[email protected]>
CC: Stanislav Kinsburskii <[email protected]>
CC: [email protected]
CC: [email protected]
---
arch/ia64/include/asm/io.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/ia64/include/asm/io.h b/arch/ia64/include/asm/io.h
index 83a492c8d298..c56ad21ba1e9 100644
--- a/arch/ia64/include/asm/io.h
+++ b/arch/ia64/include/asm/io.h
@@ -74,7 +74,7 @@ extern unsigned int num_io_spaces;
* Change virtual addresses to physical addresses and vv.
*/
static inline unsigned long
-virt_to_phys (volatile void *address)
+virt_to_phys (const volatile void *address)
{
return (unsigned long) address - PAGE_OFFSET;
}


2023-04-27 17:43:36

by Stanislav Kinsburskii

[permalink] [raw]
Subject: [PATCH 6/7] powerpc: asm/io.h: Expect immutable pointer in virt_to_phys prototype

From: Stanislav Kinsburskii <[email protected]>

These helper function - virt_to_phys - doesn't need the address pointer to
be mutable.

In the same time expecting it to be mutable leads to the following build
warning for constant pointers:

warning: passing argument 1 of ‘virt_to_phys’ discards ‘const’ qualifier from pointer target type

Signed-off-by: Stanislav Kinsburskii <[email protected]>
CC: Michael Ellerman <[email protected]>
CC: Nicholas Piggin <[email protected]>
CC: Christophe Leroy <[email protected]>
CC: Geert Uytterhoeven <[email protected]>
CC: Bjorn Helgaas <[email protected]>
CC: Stanislav Kinsburskii <[email protected]>
CC: Arnd Bergmann <[email protected]>
CC: [email protected]
CC: [email protected]
---
arch/powerpc/include/asm/io.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index f1e657c9bbe8..c287eeb9536f 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -959,7 +959,7 @@ extern void __iomem *__ioremap_caller(phys_addr_t, unsigned long size,
* almost all conceivable cases a device driver should not be using
* this function
*/
-static inline unsigned long virt_to_phys(volatile void * address)
+static inline unsigned long virt_to_phys(const volatile void * address)
{
WARN_ON(IS_ENABLED(CONFIG_DEBUG_VIRTUAL) && !virt_addr_valid(address));



2023-04-27 17:43:38

by Stanislav Kinsburskii

[permalink] [raw]
Subject: [PATCH 7/7] asm-generic/io.h: Expect immutable pointer in virt_to_phys

From: Stanislav Kinsburskii <[email protected]>

These helper function - virt_to_phys - doesn't need the address pointer to be
mutable.

In the same time expecting it to be mutable leads to the following build
warning for constant pointers:

warning: passing argument 1 of ‘virt_to_phys’ discards ‘const’ qualifier from pointer target type

Signed-off-by: Stanislav Kinsburskii <[email protected]>
CC: Arnd Bergmann <[email protected]>
CC: [email protected]
CC: [email protected]
---
include/asm-generic/io.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 587e7e9b9a37..ee9d9584e05b 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -1000,7 +1000,7 @@ static inline void iowrite64_rep(volatile void __iomem *addr,
*/
#ifndef virt_to_phys
#define virt_to_phys virt_to_phys
-static inline unsigned long virt_to_phys(volatile void *address)
+static inline unsigned long virt_to_phys(const volatile void *address)
{
return __pa((unsigned long)address);
}


2023-04-28 07:44:52

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH 0/7] Expect immutable pointer in virt_to_phys/isa_virt_to_bus prototypes

On Sat, Apr 15, 2023, at 12:17, Stanislav Kinsburskii wrote:
> This series is aimed to address compilation warnings when a constant pointer
> is passed to virt_to_phys and isa_virt_to_bus functions:
>
> warning: passing argument 1 of ‘virt_to_phys’ discards ‘const’
> qualifier from pointer target type
> warning: passing argument 1 of ‘isa_virt_to_bus’ discards ‘const’
> qualifier from pointer target type
>
> The change(s) is the same for all architectures, but it's split into a series on
> per-arch basis to simplify applying and testing on the maintainers side.
>

Looks all good to me. If everyone is happy with it, I'll queue it up
after in the asm-generic tree for 6.5, once rc1 is out.

Arnd

2023-05-03 07:34:01

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 0/7] Expect immutable pointer in virt_to_phys/isa_virt_to_bus prototypes

On Thu, Apr 27, 2023 at 7:41 PM Stanislav Kinsburskii
<[email protected]> wrote:

> This series is aimed to address compilation warnings when a constant pointer
> is passed to virt_to_phys and isa_virt_to_bus functions:
>
> warning: passing argument 1 of ‘virt_to_phys’ discards ‘const’ qualifier from pointer target type
> warning: passing argument 1 of ‘isa_virt_to_bus’ discards ‘const’ qualifier from pointer target type
>
> The change(s) is the same for all architectures, but it's split into a series on
> per-arch basis to simplify applying and testing on the maintainers side.
>
> The following series implements...

This is nice.
Reviewed-by: Linus Walleij <[email protected]>

I am working with an adjacent task, which is to make virt_to_pfn() and
pfn_to_virt() into static inlines. I might need to rebase my work on top
of this but it should be doable, I am currently stressing the buildbots
with this with the idea to propose it to Arnd once v6.4-rc1 is out:
https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-integrator.git/log/?h=b4/virt-to-pfn-v6-4-rc1

Yours,
Linus Walleij