Skip to contentSkip to conversation

RISC-V: ACPI: Fix acpi_os_ioremap to return iomem address

PATCH Superseded Sunil V L 2 participants 3 messages Jul 23, 2023 – Jul 24, 2023 RISC-V

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Sunil V L

author
#0 lore raw

PATCH v2 1/1 RISC-V: ACPI: Fix acpi_os_ioremap to return iomem address

acpi_os_ioremap() currently is a wrapper to memremap() on RISC-V. But the callers of acpi_os_ioremap() expect it to return __iomem address and hence sparse tool reports a new warning. Fix this issue by type casting to __iomem type.

Fixes a91a9ffbd3a5 ("RISC-V: Add support to build the ACPI core")

---
Changes since v1:
1) Removed enhancements from the fix patch.

 arch/riscv/include/asm/acpi.h | 2 +-
 arch/riscv/kernel/acpi.c      | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/riscv/include/asm/acpi.h +1 -1
index f71ce21ff684..d5604d2073bc 100644
@@ -19,7 +19,7 @@ typedef u64 phys_cpuid_t;
 #define PHYS_CPUID_INVALID INVALID_HARTID
 
 /* ACPI table mapping after acpi_permanent_mmap is set */
-void *acpi_os_ioremap(acpi_physical_address phys, acpi_size size);
+void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size);
 #define acpi_os_ioremap acpi_os_ioremap
 
 #define acpi_strict 1	/* No out-of-spec workarounds on RISC-V */
arch/riscv/kernel/acpi.c +2 -2
index 5ee03ebab80e..e6fdb9edcdd9 100644
@@ -215,9 +215,9 @@ void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
 	early_iounmap(map, size);
 }
 
-void *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
+void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
 {
-	return memremap(phys, size, MEMREMAP_WB);
+	return (__force void __iomem *) memremap(phys, size, MEMREMAP_WB);
 }
 
 #ifdef CONFIG_PCI
Signature · 1 line
2.39.2
#1 lore raw
Quoted 35 lines · Sunil V L

acpi_os_ioremap() currently is a wrapper to memremap() on RISC-V. But the callers of acpi_os_ioremap() expect it to return __iomem address and hence sparse tool reports a new warning. Fix this issue by type casting to __iomem type.

Fixes a91a9ffbd3a5 ("RISC-V: Add support to build the ACPI core")

---
Changes since v1:
1) Removed enhancements from the fix patch.

 arch/riscv/include/asm/acpi.h | 2 +-
 arch/riscv/kernel/acpi.c      | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/riscv/include/asm/acpi.h +1 -1
index f71ce21ff684..d5604d2073bc 100644
@@ -19,7 +19,7 @@ typedef u64 phys_cpuid_t;
 #define PHYS_CPUID_INVALID INVALID_HARTID
 
 /* ACPI table mapping after acpi_permanent_mmap is set */
-void *acpi_os_ioremap(acpi_physical_address phys, acpi_size size);
+void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size);
 #define acpi_os_ioremap acpi_os_ioremap
 
 #define acpi_strict 1	/* No out-of-spec workarounds on RISC-V */
arch/riscv/kernel/acpi.c +0 -0
index 5ee03ebab80e..e6fdb9edcdd9 100644

arch/riscv/kernel/acpi.c void __init __acpi_unmap_table(void __iomem *map, unsigned long size) · line 220

Quoted 8 lines
arch/riscv/kernel/acpi.c +2 -2
@@ -215,9 +215,9 @@ void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
 	early_iounmap(map, size);
 }
 
-void *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
+void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
 {
-	return memremap(phys, size, MEMREMAP_WB);
+	return (__force void __iomem *) memremap(phys, size, MEMREMAP_WB);

Why's the __force needed? Does sparse complain about the cast too?

author
#2 lore raw
Quoted 39 lines · Conor Dooley
Quoted 38 lines · Sunil V L

acpi_os_ioremap() currently is a wrapper to memremap() on RISC-V. But the callers of acpi_os_ioremap() expect it to return __iomem address and hence sparse tool reports a new warning. Fix this issue by type casting to __iomem type.

Fixes a91a9ffbd3a5 ("RISC-V: Add support to build the ACPI core")

---
Changes since v1:
1) Removed enhancements from the fix patch.

 arch/riscv/include/asm/acpi.h | 2 +-
 arch/riscv/kernel/acpi.c      | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/riscv/include/asm/acpi.h +1 -1
index f71ce21ff684..d5604d2073bc 100644
@@ -19,7 +19,7 @@ typedef u64 phys_cpuid_t;
 #define PHYS_CPUID_INVALID INVALID_HARTID
 
 /* ACPI table mapping after acpi_permanent_mmap is set */
-void *acpi_os_ioremap(acpi_physical_address phys, acpi_size size);
+void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size);
 #define acpi_os_ioremap acpi_os_ioremap
 
 #define acpi_strict 1	/* No out-of-spec workarounds on RISC-V */
arch/riscv/kernel/acpi.c +0 -0
index 5ee03ebab80e..e6fdb9edcdd9 100644
@@ -215,9 +215,9 @@ void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
 	early_iounmap(map, size);
 }
 
Quoted 7 lines

arch/riscv/kernel/acpi.c void __init __acpi_unmap_table(void __iomem *map, unsigned long size) · line 220

Quoted 5 lines
arch/riscv/kernel/acpi.c +2 -2
-void *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
+void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
 {
-	return memremap(phys, size, MEMREMAP_WB);
+	return (__force void __iomem *) memremap(phys, size, MEMREMAP_WB);

Why's the __force needed? Does sparse complain about the cast too?

Nope, I think it is required only if the cast is other way. Let me remove this in v3.

Thanks,
Sunil

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv