2024-02-26 11:38:48

by Serge Semin

[permalink] [raw]
Subject: [PATCH v2 0/2] MIPS: Fix missing proto and passing arg warnings

After getting my local tree rebased onto the kernel 6.8-rc3 the MIPS32
kernel build procedure produced a couple of warnings which I suggest to
fix in the framework of this series.

A first warning is of the "no previous prototype for `<func>`" type. In
particular my arch-specific code has the mips_cm_l2sync_phys_base() method
re-defined, but even though the function is global it' prototype isn't
declared anywhere. Fix that by moving the __mips_cm_l2sync_phys_base()
body to a weak implementation of mips_cm_l2sync_phys_base() and adding the
method prototype declaration to the mips/include/asm/mips-cm.h header
file. For the sake of unification a similar solution was provided for the
mips_cm_phys_base()/__mips_cm_phys_base() couple.

The following text describes the patches which have already merged in at
v1 stage of the patchset (see changelog v2).

One more case of the denoted earlier warning I spotted in the
self-extracting kernel (so called zboot) with the debug printouts enabled.
In particular there are several putc() method re-definitions available in:
arch/mips/boot/compressed/uart-prom.c
arch/mips/boot/compressed/uart-16550.c
arch/mips/boot/compressed/uart-alchemy.c
All of these files lacked the prototype declaration what caused having the
"no previous prototype for ‘putc’" printed on my build with the next
configs enabled:
CONFIG_SYS_SUPPORTS_ZBOOT=y
CONFIG_SYS_SUPPORTS_ZBOOT_UART_PROM=y
CONFIG_ZBOOT_LOAD_ADDRESS=0x85100000
CONFIG_DEBUG_ZBOOT=y

The second warning is of the "passing argument <x> of ‘<func>’ from
incompatible pointer type" type which I discovered in the
drivers/tty/mips_ejtag_fdc.c driver. The problem most likely happened due
to the commit ce7cbd9a6c81 ("tty: mips_ejtag_fdc: use u8 for character
pointers").

That's it for today.) Thanks for review in advance. Any tests are very
welcome.

Link: https://lore.kernel.org/linux-mips/[email protected]
Changelog v2:
- Drop aleady applied pateches:
[PATCH 3/4] mips: zboot: Fix "no previous prototype" build warning
[PATCH 4/4] tty: mips_ejtag_fdc: Fix passing incompatible pointer type warning
- Drop Linux serial mailing list and the respective maintainers from the
Cc-list.
- Covert the underscored versions of the CM2/L2-sync base address
getters to being the body of the weakly defined original methods.

Cc: Alexey Malahov <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: [email protected]
Cc: [email protected]

Serge Semin (2):
mips: cm: Convert __mips_cm_l2sync_phys_base() to weak function
mips: cm: Convert __mips_cm_phys_base() to weak function

arch/mips/include/asm/mips-cm.h | 20 ++++++++++++++++----
arch/mips/kernel/mips-cm.c | 10 ++--------
2 files changed, 18 insertions(+), 12 deletions(-)

--
2.43.0



2024-02-26 11:40:36

by Serge Semin

[permalink] [raw]
Subject: [PATCH v2 2/2] mips: cm: Convert __mips_cm_phys_base() to weak function

Based on the design pattern utilized in the CM GCR base address getter
implementation, the platform-specific code is capable to re-define the
getter and re-use the weakly defined initial version. But since the
pattern hasn't been used for over 10 years and another similar case (CM
L2-sync only base address getter) has just been fixed, let's unify the
interface and convert it to a more traditional single weakly defined
method: mips_cm_phys_base() (see the link below for the discussion around
this).

Link: https://lore.kernel.org/linux-mips/[email protected]
Signed-off-by: Serge Semin <[email protected]>

---

Changelog v2:
- Convert the underscored method to a single weakly defined function.
---
arch/mips/include/asm/mips-cm.h | 7 +++----
arch/mips/kernel/mips-cm.c | 5 +----
2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/arch/mips/include/asm/mips-cm.h b/arch/mips/include/asm/mips-cm.h
index 6cc79296c8ef..c4e27970d88f 100644
--- a/arch/mips/include/asm/mips-cm.h
+++ b/arch/mips/include/asm/mips-cm.h
@@ -22,16 +22,15 @@ extern void __iomem *mips_gcr_base;
extern void __iomem *mips_cm_l2sync_base;

/**
- * __mips_cm_phys_base - retrieve the physical base address of the CM
+ * mips_cm_phys_base - retrieve the physical base address of the CM
*
* This function returns the physical base address of the Coherence Manager
* global control block, or 0 if no Coherence Manager is present. It provides
* a default implementation which reads the CMGCRBase register where available,
* and may be overridden by platforms which determine this address in a
- * different way by defining a function with the same prototype except for the
- * name mips_cm_phys_base (without underscores).
+ * different way by defining a function with the same prototype.
*/
-extern phys_addr_t __mips_cm_phys_base(void);
+extern phys_addr_t mips_cm_phys_base(void);

/**
* mips_cm_l2sync_phys_base - retrieve the physical base address of the CM
diff --git a/arch/mips/kernel/mips-cm.c b/arch/mips/kernel/mips-cm.c
index 268ac0b811e3..3a115fab5573 100644
--- a/arch/mips/kernel/mips-cm.c
+++ b/arch/mips/kernel/mips-cm.c
@@ -179,7 +179,7 @@ static char *cm3_causes[32] = {
static DEFINE_PER_CPU_ALIGNED(spinlock_t, cm_core_lock);
static DEFINE_PER_CPU_ALIGNED(unsigned long, cm_core_lock_flags);

-phys_addr_t __mips_cm_phys_base(void)
+phys_addr_t __weak mips_cm_phys_base(void)
{
unsigned long cmgcr;

@@ -198,9 +198,6 @@ phys_addr_t __mips_cm_phys_base(void)
return (cmgcr & MIPS_CMGCRF_BASE) << (36 - 32);
}

-phys_addr_t mips_cm_phys_base(void)
- __attribute__((weak, alias("__mips_cm_phys_base")));
-
phys_addr_t __weak mips_cm_l2sync_phys_base(void)
{
u32 base_reg;
--
2.43.0


2024-03-11 13:34:43

by Thomas Bogendoerfer

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] MIPS: Fix missing proto and passing arg warnings

On Mon, Feb 26, 2024 at 01:54:20PM +0300, Serge Semin wrote:
> After getting my local tree rebased onto the kernel 6.8-rc3 the MIPS32
> kernel build procedure produced a couple of warnings which I suggest to
> fix in the framework of this series.
>
> A first warning is of the "no previous prototype for `<func>`" type. In
> particular my arch-specific code has the mips_cm_l2sync_phys_base() method
> re-defined, but even though the function is global it' prototype isn't
> declared anywhere. Fix that by moving the __mips_cm_l2sync_phys_base()
> body to a weak implementation of mips_cm_l2sync_phys_base() and adding the
> method prototype declaration to the mips/include/asm/mips-cm.h header
> file. For the sake of unification a similar solution was provided for the
> mips_cm_phys_base()/__mips_cm_phys_base() couple.
>
> The following text describes the patches which have already merged in at
> v1 stage of the patchset (see changelog v2).
>
> One more case of the denoted earlier warning I spotted in the
> self-extracting kernel (so called zboot) with the debug printouts enabled.
> In particular there are several putc() method re-definitions available in:
> arch/mips/boot/compressed/uart-prom.c
> arch/mips/boot/compressed/uart-16550.c
> arch/mips/boot/compressed/uart-alchemy.c
> All of these files lacked the prototype declaration what caused having the
> "no previous prototype for ‘putc’" printed on my build with the next
> configs enabled:
> CONFIG_SYS_SUPPORTS_ZBOOT=y
> CONFIG_SYS_SUPPORTS_ZBOOT_UART_PROM=y
> CONFIG_ZBOOT_LOAD_ADDRESS=0x85100000
> CONFIG_DEBUG_ZBOOT=y
>
> The second warning is of the "passing argument <x> of ‘<func>’ from
> incompatible pointer type" type which I discovered in the
> drivers/tty/mips_ejtag_fdc.c driver. The problem most likely happened due
> to the commit ce7cbd9a6c81 ("tty: mips_ejtag_fdc: use u8 for character
> pointers").
>
> That's it for today.) Thanks for review in advance. Any tests are very
> welcome.
>
> Link: https://lore.kernel.org/linux-mips/[email protected]
> Changelog v2:
> - Drop aleady applied pateches:
> [PATCH 3/4] mips: zboot: Fix "no previous prototype" build warning
> [PATCH 4/4] tty: mips_ejtag_fdc: Fix passing incompatible pointer type warning
> - Drop Linux serial mailing list and the respective maintainers from the
> Cc-list.
> - Covert the underscored versions of the CM2/L2-sync base address
> getters to being the body of the weakly defined original methods.
>
> Cc: Alexey Malahov <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
>
> Serge Semin (2):
> mips: cm: Convert __mips_cm_l2sync_phys_base() to weak function
> mips: cm: Convert __mips_cm_phys_base() to weak function
>
> arch/mips/include/asm/mips-cm.h | 20 ++++++++++++++++----
> arch/mips/kernel/mips-cm.c | 10 ++--------
> 2 files changed, 18 insertions(+), 12 deletions(-)
>
> --
> 2.43.0

series applied to mips-next.

Thomas.

--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]