2017-07-08 15:50:36

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 1/2] ACPI / boot: Correct address space of __acpi_map_table()

Sparse complains about wrong address space used in __acpi_map_table()
and in __acpi_unmap_table().

arch/x86/kernel/acpi/boot.c:127:29: warning: incorrect type in return expression (different address spaces)
arch/x86/kernel/acpi/boot.c:127:29: expected char *
arch/x86/kernel/acpi/boot.c:127:29: got void [noderef] <asn:2>*
arch/x86/kernel/acpi/boot.c:135:23: warning: incorrect type in argument 1 (different address spaces)
arch/x86/kernel/acpi/boot.c:135:23: expected void [noderef] <asn:2>*addr
arch/x86/kernel/acpi/boot.c:135:23: got char *map

Correct address space to be in align of type of returned and passed
parameter.

Signed-off-by: Andy Shevchenko <[email protected]>
---
arch/x86/kernel/acpi/boot.c | 4 ++--
include/linux/acpi.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 6d534af94761..ac9bb564f004 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -118,7 +118,7 @@ static u32 isa_irq_to_gsi[NR_IRQS_LEGACY] __read_mostly = {
* This is just a simple wrapper around early_ioremap(),
* with sanity checks for phys == 0 and size == 0.
*/
-char *__init __acpi_map_table(unsigned long phys, unsigned long size)
+void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size)
{

if (!phys || !size)
@@ -127,7 +127,7 @@ char *__init __acpi_map_table(unsigned long phys, unsigned long size)
return early_ioremap(phys, size);
}

-void __init __acpi_unmap_table(char *map, unsigned long size)
+void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
{
if (!map || !size)
return;
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 99f96df83dd8..17cb57a533bb 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -224,8 +224,8 @@ struct acpi_subtable_proc {
int count;
};

-char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
-void __acpi_unmap_table(char *map, unsigned long size);
+void __iomem *__acpi_map_table(unsigned long phys_addr, unsigned long size);
+void __acpi_unmap_table(void __iomem *map, unsigned long size);
int early_acpi_boot_init(void);
int acpi_boot_init (void);
void acpi_boot_table_init (void);
--
2.11.0


2017-07-08 15:51:08

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 2/2] ACPI / boot: Don't define unused variables

Some code in acpi_parse_x2apic() conditionally compiled, though parts of
it are being used in any case. This annoys gcc.

arch/x86/kernel/acpi/boot.c: In function ‘acpi_parse_x2apic’:
arch/x86/kernel/acpi/boot.c:203:5: warning: variable ‘enabled’ set but not used [-Wunused-but-set-variable]
u8 enabled;
^~~~~~~
arch/x86/kernel/acpi/boot.c:202:6: warning: variable ‘apic_id’ set but not used [-Wunused-but-set-variable]
int apic_id;
^~~~~~~

Re-arrange the code to avoid compiling unused variables.

Signed-off-by: Andy Shevchenko <[email protected]>
---
arch/x86/kernel/acpi/boot.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index ac9bb564f004..f33eddf4eaa9 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -199,8 +199,10 @@ static int __init
acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
{
struct acpi_madt_local_x2apic *processor = NULL;
+#ifdef CONFIG_X86_X2APIC
int apic_id;
u8 enabled;
+#endif

processor = (struct acpi_madt_local_x2apic *)header;

@@ -209,9 +211,10 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)

acpi_table_print_madt_entry(header);

+#ifdef CONFIG_X86_X2APIC
apic_id = processor->local_apic_id;
enabled = processor->lapic_flags & ACPI_MADT_ENABLED;
-#ifdef CONFIG_X86_X2APIC
+
/*
* We need to register disabled CPU as well to permit
* counting disabled CPUs. This allows us to size
--
2.11.0

2017-07-17 09:51:26

by Hanjun Guo

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] ACPI / boot: Correct address space of __acpi_map_table()

On 2017/7/8 23:50, Andy Shevchenko wrote:
> Sparse complains about wrong address space used in __acpi_map_table()
> and in __acpi_unmap_table().
>
> arch/x86/kernel/acpi/boot.c:127:29: warning: incorrect type in return expression (different address spaces)
> arch/x86/kernel/acpi/boot.c:127:29: expected char *
> arch/x86/kernel/acpi/boot.c:127:29: got void [noderef] <asn:2>*
> arch/x86/kernel/acpi/boot.c:135:23: warning: incorrect type in argument 1 (different address spaces)
> arch/x86/kernel/acpi/boot.c:135:23: expected void [noderef] <asn:2>*addr
> arch/x86/kernel/acpi/boot.c:135:23: got char *map
>
> Correct address space to be in align of type of returned and passed
> parameter.
>
> Signed-off-by: Andy Shevchenko <[email protected]>
> ---
> arch/x86/kernel/acpi/boot.c | 4 ++--
> include/linux/acpi.h | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
> index 6d534af94761..ac9bb564f004 100644
> --- a/arch/x86/kernel/acpi/boot.c
> +++ b/arch/x86/kernel/acpi/boot.c
> @@ -118,7 +118,7 @@ static u32 isa_irq_to_gsi[NR_IRQS_LEGACY] __read_mostly = {
> * This is just a simple wrapper around early_ioremap(),
> * with sanity checks for phys == 0 and size == 0.
> */
> -char *__init __acpi_map_table(unsigned long phys, unsigned long size)
> +void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size)
> {
>
> if (!phys || !size)
> @@ -127,7 +127,7 @@ char *__init __acpi_map_table(unsigned long phys, unsigned long size)
> return early_ioremap(phys, size);
> }
>
> -void __init __acpi_unmap_table(char *map, unsigned long size)
> +void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
> {
> if (!map || !size)
> return;
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 99f96df83dd8..17cb57a533bb 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -224,8 +224,8 @@ struct acpi_subtable_proc {
> int count;
> };
>
> -char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
> -void __acpi_unmap_table(char *map, unsigned long size);
> +void __iomem *__acpi_map_table(unsigned long phys_addr, unsigned long size);
> +void __acpi_unmap_table(void __iomem *map, unsigned long size);

This breaks ACPI compile on ARM64 as ARM64 has its definition for those
two functions, I see patches in linux-next already, should I add a patch on top
to fix it, or this patch should be respined?

Thanks
Hanjun

2017-07-17 09:57:17

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] ACPI / boot: Correct address space of __acpi_map_table()

On Mon, Jul 17, 2017 at 12:49 PM, Hanjun Guo <[email protected]> wrote:
> On 2017/7/8 23:50, Andy Shevchenko wrote:
>> Sparse complains about wrong address space used in __acpi_map_table()
>> and in __acpi_unmap_table().
>>
>> arch/x86/kernel/acpi/boot.c:127:29: warning: incorrect type in return expression (different address spaces)
>> arch/x86/kernel/acpi/boot.c:127:29: expected char *
>> arch/x86/kernel/acpi/boot.c:127:29: got void [noderef] <asn:2>*
>> arch/x86/kernel/acpi/boot.c:135:23: warning: incorrect type in argument 1 (different address spaces)
>> arch/x86/kernel/acpi/boot.c:135:23: expected void [noderef] <asn:2>*addr
>> arch/x86/kernel/acpi/boot.c:135:23: got char *map
>>
>> Correct address space to be in align of type of returned and passed
>> parameter.

>> -char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
>> -void __acpi_unmap_table(char *map, unsigned long size);
>> +void __iomem *__acpi_map_table(unsigned long phys_addr, unsigned long size);
>> +void __acpi_unmap_table(void __iomem *map, unsigned long size);
>
> This breaks ACPI compile on ARM64 as ARM64 has its definition for those
> two functions,

Oops, missed that, sorry.

> I see patches in linux-next already, should I add a patch on top
> to fix it, or this patch should be respined?

Whatever Rafael prefers. I'm fine with either.
I have more patches against that c-file, perhaps better to respin.

--
With Best Regards,
Andy Shevchenko

2017-07-17 10:02:19

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] ACPI / boot: Correct address space of __acpi_map_table()

On Mon, 2017-07-17 at 12:57 +0300, Andy Shevchenko wrote:
> On Mon, Jul 17, 2017 at 12:49 PM, Hanjun Guo <[email protected]>
> wrote:
> > On 2017/7/8 23:50, Andy Shevchenko wrote:
> > > Sparse complains about wrong address space used in
> > > __acpi_map_table()
> > > and in __acpi_unmap_table().
> > >
> > > arch/x86/kernel/acpi/boot.c:127:29: warning: incorrect type in
> > > return expression (different address spaces)
> > > arch/x86/kernel/acpi/boot.c:127:29:    expected char *
> > > arch/x86/kernel/acpi/boot.c:127:29:    got void [noderef] <asn:2>*
> > > arch/x86/kernel/acpi/boot.c:135:23: warning: incorrect type in
> > > argument 1 (different address spaces)
> > > arch/x86/kernel/acpi/boot.c:135:23:    expected void [noderef]
> > > <asn:2>*addr
> > > arch/x86/kernel/acpi/boot.c:135:23:    got char *map
> > >
> > > Correct address space to be in align of type of returned and
> > > passed
> > > parameter.
> > > -char * __acpi_map_table (unsigned long phys_addr, unsigned long
> > > size);
> > > -void __acpi_unmap_table(char *map, unsigned long size);
> > > +void __iomem *__acpi_map_table(unsigned long phys_addr, unsigned
> > > long size);
> > > +void __acpi_unmap_table(void __iomem *map, unsigned long size);
> >
> > This breaks ACPI compile on ARM64 as ARM64 has its definition for
> > those
> > two functions,
>
> Oops, missed that, sorry.
>
> > I see patches in linux-next already, should I add a patch on top
> > to fix it, or this patch should be respined?
>
> Whatever Rafael prefers. I'm fine with either.
> I have more patches against that c-file, perhaps better to respin.

I missed ia64 too :-(

--
Andy Shevchenko <[email protected]>
Intel Finland Oy