Message ID | 20241031112030.72647-1-cuiyunhui@bytedance.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | ACPI: fix the warning reported by the sparse | expand |
Hi Yunhui,
kernel test robot noticed the following build warnings:
[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on rafael-pm/bleeding-edge arm64/for-next/core soc/for-next linus/master arm/for-next arm/fixes v6.12-rc5 next-20241101]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Yunhui-Cui/ACPI-fix-the-warning-reported-by-the-sparse/20241031-192215
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link: https://lore.kernel.org/r/20241031112030.72647-1-cuiyunhui%40bytedance.com
patch subject: [PATCH] ACPI: fix the warning reported by the sparse
config: loongarch-randconfig-r112-20241102 (https://download.01.org/0day-ci/archive/20241102/202411020935.IEiVDiTL-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 14.1.0
reproduce: (https://download.01.org/0day-ci/archive/20241102/202411020935.IEiVDiTL-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411020935.IEiVDiTL-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
>> arch/loongarch/kernel/acpi.c:43:30: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void * @@ got void [noderef] __iomem * @@
arch/loongarch/kernel/acpi.c:43:30: sparse: expected void *
arch/loongarch/kernel/acpi.c:43:30: sparse: got void [noderef] __iomem *
arch/loongarch/kernel/acpi.c:206:40: sparse: sparse: undefined identifier '__builtin_loongarch_csrrd_w'
vim +43 arch/loongarch/kernel/acpi.c
628c3bb40e9a8ce Huacai Chen 2022-05-31 21
628c3bb40e9a8ce Huacai Chen 2022-05-31 22 int acpi_disabled;
628c3bb40e9a8ce Huacai Chen 2022-05-31 23 EXPORT_SYMBOL(acpi_disabled);
628c3bb40e9a8ce Huacai Chen 2022-05-31 24 int acpi_noirq;
628c3bb40e9a8ce Huacai Chen 2022-05-31 25 int acpi_pci_disabled;
628c3bb40e9a8ce Huacai Chen 2022-05-31 26 EXPORT_SYMBOL(acpi_pci_disabled);
628c3bb40e9a8ce Huacai Chen 2022-05-31 27 int acpi_strict = 1; /* We have no workarounds on LoongArch */
628c3bb40e9a8ce Huacai Chen 2022-05-31 @28 int num_processors;
628c3bb40e9a8ce Huacai Chen 2022-05-31 29 int disabled_cpus;
628c3bb40e9a8ce Huacai Chen 2022-05-31 30
628c3bb40e9a8ce Huacai Chen 2022-05-31 31 u64 acpi_saved_sp;
628c3bb40e9a8ce Huacai Chen 2022-05-31 32
628c3bb40e9a8ce Huacai Chen 2022-05-31 33 #define PREFIX "ACPI: "
628c3bb40e9a8ce Huacai Chen 2022-05-31 34
4551b30525cf3d2 Huacai Chen 2024-02-06 35 struct acpi_madt_core_pic acpi_core_pic[MAX_CORE_PIC];
f6f0c9a74a48448 Huacai Chen 2023-06-29 36
4802318a3cea8b3 Yunhui Cui 2024-10-31 37 void __init *__acpi_map_table(unsigned long phys, unsigned long size)
628c3bb40e9a8ce Huacai Chen 2022-05-31 38 {
628c3bb40e9a8ce Huacai Chen 2022-05-31 39
628c3bb40e9a8ce Huacai Chen 2022-05-31 40 if (!phys || !size)
628c3bb40e9a8ce Huacai Chen 2022-05-31 41 return NULL;
628c3bb40e9a8ce Huacai Chen 2022-05-31 42
628c3bb40e9a8ce Huacai Chen 2022-05-31 @43 return early_memremap(phys, size);
628c3bb40e9a8ce Huacai Chen 2022-05-31 44 }
628c3bb40e9a8ce Huacai Chen 2022-05-31 45 void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
628c3bb40e9a8ce Huacai Chen 2022-05-31 46 {
628c3bb40e9a8ce Huacai Chen 2022-05-31 47 if (!map || !size)
628c3bb40e9a8ce Huacai Chen 2022-05-31 48 return;
628c3bb40e9a8ce Huacai Chen 2022-05-31 49
628c3bb40e9a8ce Huacai Chen 2022-05-31 50 early_memunmap(map, size);
628c3bb40e9a8ce Huacai Chen 2022-05-31 51 }
628c3bb40e9a8ce Huacai Chen 2022-05-31 52
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index e6f66491fbe9..69017dadb82d 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -88,10 +88,10 @@ static bool __init dt_is_stub(void) } /* - * __acpi_map_table() will be called before page_init(), so early_ioremap() - * or early_memremap() should be called here to for ACPI table mapping. + * __acpi_map_table() will be called before page_init(), so early_memremap() + * should be called here to for ACPI table mapping. */ -void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size) +void __init *__acpi_map_table(unsigned long phys, unsigned long size) { if (!size) return NULL; diff --git a/arch/loongarch/kernel/acpi.c b/arch/loongarch/kernel/acpi.c index f1a74b80f22c..a29c1d86e274 100644 --- a/arch/loongarch/kernel/acpi.c +++ b/arch/loongarch/kernel/acpi.c @@ -34,7 +34,7 @@ u64 acpi_saved_sp; struct acpi_madt_core_pic acpi_core_pic[MAX_CORE_PIC]; -void __init __iomem * __acpi_map_table(unsigned long phys, unsigned long size) +void __init *__acpi_map_table(unsigned long phys, unsigned long size) { if (!phys || !size) diff --git a/arch/riscv/kernel/acpi.c b/arch/riscv/kernel/acpi.c index 2fd29695a788..861ab56962a2 100644 --- a/arch/riscv/kernel/acpi.c +++ b/arch/riscv/kernel/acpi.c @@ -202,10 +202,10 @@ struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu) } /* - * __acpi_map_table() will be called before paging_init(), so early_ioremap() - * or early_memremap() should be called here to for ACPI table mapping. + * __acpi_map_table() will be called before paging_init(), so early_memremap() + * should be called here to for ACPI table mapping. */ -void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size) +void __init *__acpi_map_table(unsigned long phys, unsigned long size) { if (!size) return NULL; diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index 3a44a9dc3fb7..e1ed297552e7 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c @@ -105,7 +105,7 @@ static u32 isa_irq_to_gsi[NR_IRQS_LEGACY] __read_mostly = { * This is just a simple wrapper around early_memremap(), * with sanity checks for phys == 0 and size == 0. */ -void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size) +void __init *__acpi_map_table(unsigned long phys, unsigned long size) { if (!phys || !size) diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 70af3fbbebe5..a36486b59bca 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -334,7 +334,7 @@ void __iomem __ref } if (!acpi_permanent_mmap) - return __acpi_map_table((unsigned long)phys, size); + return (void __iomem __force *)__acpi_map_table((unsigned long)phys, size); mutex_lock(&acpi_ioremap_lock); /* Check if there's a suitable mapping already. */ diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 4d5ee84c468b..d4627d96c13b 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -207,7 +207,7 @@ static inline int acpi_debugger_notify_command_complete(void) (!entry) || (unsigned long)entry + sizeof(*entry) > end || \ ((struct acpi_subtable_header *)entry)->length < sizeof(*entry)) -void __iomem *__acpi_map_table(unsigned long phys, unsigned long size); +void *__acpi_map_table(unsigned long phys, unsigned long size); void __acpi_unmap_table(void __iomem *map, unsigned long size); int early_acpi_boot_init(void); int acpi_boot_init (void);
All architectures use early_memremap() instead of early_ioremap(). Therefore, to solve the warning detected by sparse: ../arch/riscv/kernel/acpi.c:213:30: warning: incorrect type in return expression (different address spaces) ../arch/riscv/kernel/acpi.c:213:30: expected void [noderef] __iomem * ../arch/riscv/kernel/acpi.c:213:30: got void * ../arch/riscv/kernel/acpi.c:221:24: warning: incorrect type in argument 1 (different address spaces) ../arch/riscv/kernel/acpi.c:221:24: expected void *addr ../arch/riscv/kernel/acpi.c:221:24: got void [noderef] __iomem *map The __iomem attribute of __acpi_map_table() is removed. Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com> --- arch/arm64/kernel/acpi.c | 6 +++--- arch/loongarch/kernel/acpi.c | 2 +- arch/riscv/kernel/acpi.c | 6 +++--- arch/x86/kernel/acpi/boot.c | 2 +- drivers/acpi/osl.c | 2 +- include/linux/acpi.h | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-)