Skip to contentSkip to conversation

arch, drivers: Add HAVE_IOREMAP_CACHE

PATCH In review Palmer Dabbelt 2 participants 3 messages Oct 7, 2022

Subsystems (18)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arch, drivers: Add HAVE_IOREMAP_CACHE

ioremap_cache() isn't recommended for portable drivers, but there's a handful of uses of it within the kernel. This adds a HAVE_IOREMAP_CACHE Kconfig, which is enabled for the ports that have implemented it and added as a driver dependency when ioremap_cache() is uncoditionally called (a handful of drivers have arch-specific ifdefs already, those I left alone).

---

Not sure what to do about splitting this up, it touches a lot of trees but it seems saner to do this atomicly. I've just included linux-arch for now, just to try and keep from blasting everyone. Another option here would be to add some sort of ioremap_cache() fallback, but I'm assuming that has not been done to discourage more use of ioremap_cache() in drivers.

I'm also not sure all these ports should have ioremap_cache(), but I figured it'd be easier to just enumerate what's there rather than trying to change the ports. Preventing the drivers from compiling also seems like a pretty heavy hammer, as it seems like some of these could have their ioremap_cache() dependency removed pretty easily, but again I figured it'd be better to start small.

This has barely been tested, just a defconfig build on x86. That's very much insufficient, but with this touching so many ports I figure it's better to let the autobuilders have at that.

---
 arch/Kconfig                   | 3 +++
 arch/arm/Kconfig               | 1 +
 arch/arm64/Kconfig             | 1 +
 arch/ia64/Kconfig              | 1 +
 arch/loongarch/Kconfig         | 1 +
 arch/mips/Kconfig              | 1 +
 arch/powerpc/Kconfig           | 1 +
 arch/sh/Kconfig                | 1 +
 arch/x86/Kconfig               | 1 +
 arch/xtensa/Kconfig            | 1 +
 drivers/acpi/apei/Kconfig      | 2 +-
 drivers/firmware/meson/Kconfig | 1 +
 drivers/gpu/drm/Kconfig        | 2 +-
 drivers/mtd/devices/Kconfig    | 2 +-
 drivers/mtd/maps/Kconfig       | 2 +-
 drivers/video/fbdev/Kconfig    | 2 +-
 include/acpi/acpi_io.h         | 2 +-
 17 files changed, 19 insertions(+), 6 deletions(-)
arch/Kconfig +3 -0
index f330410da63a..2b282fabde13 100644
@@ -188,6 +188,9 @@ config USER_RETURN_NOTIFIER
 	  Provide a kernel-internal notification when a cpu is about to
 	  switch to user mode.
 
+config HAVE_IOREMAP_CACHE
+	def_bool n
+
 config HAVE_IOREMAP_PROT
 	bool
 
arch/arm/Kconfig +1 -0
index 87badeae3181..a5e738e0ddd7 100644
@@ -100,6 +100,7 @@ config ARM
 	select HAVE_GCC_PLUGINS
 	select HAVE_HW_BREAKPOINT if PERF_EVENTS && (CPU_V6 || CPU_V6K || CPU_V7)
 	select HAVE_IRQ_TIME_ACCOUNTING
+	select HAVE_IOREMAP_CACHE if MMU
 	select HAVE_KERNEL_GZIP
 	select HAVE_KERNEL_LZ4
 	select HAVE_KERNEL_LZMA
arch/arm64/Kconfig +1 -0
index 571cc234d0b3..e0de7f45fbde 100644
@@ -190,6 +190,7 @@ config ARM64
 	select HAVE_FUNCTION_GRAPH_TRACER
 	select HAVE_GCC_PLUGINS
 	select HAVE_HW_BREAKPOINT if PERF_EVENTS
+	select HAVE_IOREMAP_CACHE
 	select HAVE_IOREMAP_PROT
 	select HAVE_IRQ_TIME_ACCOUNTING
 	select HAVE_KVM
arch/ia64/Kconfig +1 -0
index 26ac8ea15a9e..e51612a94c73 100644
@@ -53,6 +53,7 @@ config IA64
 	select GENERIC_TIME_VSYSCALL
 	select LEGACY_TIMER_TICK
 	select SWIOTLB
+	select HAVE_IOREMAP_CACHE
 	select SYSCTL_ARCH_UNALIGN_NO_WARN
 	select HAVE_MOD_ARCH_SPECIFIC
 	select MODULES_USE_ELF_RELA
arch/loongarch/Kconfig +1 -0
index 4abc9a28aba4..90d9ad188e67 100644
@@ -85,6 +85,7 @@ config LOONGARCH
 	select HAVE_EXIT_THREAD
 	select HAVE_FAST_GUP
 	select HAVE_GENERIC_VDSO
+	select HAVE_IOREMAP_CACHE
 	select HAVE_IOREMAP_PROT
 	select HAVE_IRQ_EXIT_ON_IRQ_STACK
 	select HAVE_IRQ_TIME_ACCOUNTING
arch/mips/Kconfig +1 -0
index ec21f8999249..2900d5c5d5f1 100644
@@ -74,6 +74,7 @@ config MIPS
 	select HAVE_FUNCTION_TRACER
 	select HAVE_GCC_PLUGINS
 	select HAVE_GENERIC_VDSO
+	select HAVE_IOREMAP_CACHE if MMU
 	select HAVE_IOREMAP_PROT
 	select HAVE_IRQ_EXIT_ON_IRQ_STACK
 	select HAVE_IRQ_TIME_ACCOUNTING
arch/powerpc/Kconfig +1 -0
index 4c466acdc70d..c552fc97aad2 100644
@@ -223,6 +223,7 @@ config PPC
 	select HAVE_HARDLOCKUP_DETECTOR_ARCH	if PPC_BOOK3S_64 && SMP
 	select HAVE_HARDLOCKUP_DETECTOR_PERF	if PERF_EVENTS && HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH
 	select HAVE_HW_BREAKPOINT		if PERF_EVENTS && (PPC_BOOK3S || PPC_8xx)
+	select HAVE_IOREMAP_CACHE
 	select HAVE_IOREMAP_PROT
 	select HAVE_IRQ_TIME_ACCOUNTING
 	select HAVE_KERNEL_GZIP
arch/sh/Kconfig +1 -0
index 5f220e903e5a..bd9426cfc13b 100644
@@ -37,6 +37,7 @@ config SUPERH
 	select HAVE_FUNCTION_TRACER
 	select HAVE_FTRACE_MCOUNT_RECORD
 	select HAVE_HW_BREAKPOINT
+	select HAVE_IOREMAP_CACHE if MMU
 	select HAVE_IOREMAP_PROT if MMU && !X2TLB
 	select HAVE_KERNEL_BZIP2
 	select HAVE_KERNEL_GZIP
arch/x86/Kconfig +1 -0
index f9920f1341c8..05fa399fe103 100644
@@ -209,6 +209,7 @@ config X86
 	select HAVE_FUNCTION_TRACER
 	select HAVE_GCC_PLUGINS
 	select HAVE_HW_BREAKPOINT
+	select HAVE_IOREMAP_CACHE
 	select HAVE_IOREMAP_PROT
 	select HAVE_IRQ_EXIT_ON_IRQ_STACK	if X86_64
 	select HAVE_IRQ_TIME_ACCOUNTING
arch/xtensa/Kconfig +1 -0
index 12ac277282ba..edfa5127322c 100644
@@ -42,6 +42,7 @@ config XTENSA
 	select HAVE_FUNCTION_TRACER
 	select HAVE_GCC_PLUGINS if GCC_VERSION >= 120000
 	select HAVE_HW_BREAKPOINT if PERF_EVENTS
+	select HAVE_IOREMAP_CACHE
 	select HAVE_IRQ_TIME_ACCOUNTING
 	select HAVE_PCI
 	select HAVE_PERF_EVENTS
drivers/acpi/apei/Kconfig +1 -1
index 6b18f8bc7be3..56e215641e63 100644
@@ -10,7 +10,7 @@ config ACPI_APEI
 	select MISC_FILESYSTEMS
 	select PSTORE
 	select UEFI_CPER
-	depends on HAVE_ACPI_APEI
+	depends on HAVE_ACPI_APEI && HAVE_IOREMAP_CACHE
 	help
 	  APEI allows to report errors (for example from the chipset)
 	  to the operating system. This improves NMI handling
drivers/firmware/meson/Kconfig +1 -0
index f2fdd3756648..612ca9ad3256 100644
@@ -7,5 +7,6 @@ config MESON_SM
 	depends on ARCH_MESON || COMPILE_TEST
 	default y
 	depends on ARM64_4K_PAGES
+	depends on HAVE_IOREMAP_CACHE
 	help
 	  Say y here to enable the Amlogic secure monitor driver
drivers/gpu/drm/Kconfig +1 -1
index 6c2256e8474b..3c28b3ee1384 100644
@@ -405,7 +405,7 @@ source "drivers/gpu/drm/sprd/Kconfig"
 
 config DRM_HYPERV
 	tristate "DRM Support for Hyper-V synthetic video device"
-	depends on DRM && PCI && MMU && HYPERV
+	depends on DRM && PCI && MMU && HYPERV && HAVE_IOREMAP_CACHE
 	select DRM_KMS_HELPER
 	select DRM_GEM_SHMEM_HELPER
 	help
drivers/mtd/devices/Kconfig +1 -1
index 79cb981ececc..e6b55cab5a4a 100644
@@ -114,7 +114,7 @@ config MTD_SST25L
 
 config MTD_BCM47XXSFLASH
 	tristate "Support for serial flash on BCMA bus"
-	depends on BCMA_SFLASH && (MIPS || ARM)
+	depends on BCMA_SFLASH && (MIPS || ARM) && HAVE_IOREMAP_CACHE
 	help
 	  BCMA bus can have various flash memories attached, they are
 	  registered by bcma as platform devices. This enables driver for
drivers/mtd/maps/Kconfig +1 -1
index e098ae937ce8..e40d3277dcf6 100644
@@ -183,7 +183,7 @@ config MTD_SBC_GXX
 
 config MTD_PXA2XX
 	tristate "CFI Flash device mapped on Intel XScale PXA2xx based boards"
-	depends on (PXA25x || PXA27x) && MTD_CFI_INTELEXT
+	depends on (PXA25x || PXA27x) && MTD_CFI_INTELEXT && HAVE_IOREMAP_CACHE
 	help
 	  This provides a driver for the NOR flash attached to a PXA2xx chip.
 
drivers/video/fbdev/Kconfig +1 -1
index cfc55273dc5d..99f160319b5c 100644
@@ -2181,7 +2181,7 @@ config FB_BROADSHEET
 
 config FB_HYPERV
 	tristate "Microsoft Hyper-V Synthetic Video support"
-	depends on FB && HYPERV
+	depends on FB && HYPERV && HAVE_IOREMAP_CACHE
 	select FB_CFB_FILLRECT
 	select FB_CFB_COPYAREA
 	select FB_CFB_IMAGEBLIT
include/acpi/acpi_io.h +1 -1
index 027faa8883aa..4fb945a449e6 100644
@@ -6,7 +6,7 @@
 
 #include <asm/acpi.h>
 
-#ifndef acpi_os_ioremap
+#if !defined(acpi_os_ioremap) && defined(CONFIG_HAVE_IOREMAP_CACHE)
 static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
 					    acpi_size size)
 {
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 7 lines · Palmer Dabbelt

ioremap_cache() isn't recommended for portable drivers, but there's a handful of uses of it within the kernel. This adds a HAVE_IOREMAP_CACHE Kconfig, which is enabled for the ports that have implemented it and added as a driver dependency when ioremap_cache() is uncoditionally called (a handful of drivers have arch-specific ifdefs already, those I left alone).

Quoted 7 lines

---

Not sure what to do about splitting this up, it touches a lot of trees but it seems saner to do this atomicly. I've just included linux-arch for now, just to try and keep from blasting everyone.

Do you need this in 6.1? If not, I'm happy to just pick it up in the asm-generic tree for 6.2.

Quoted 4 lines

Another option
here would be to add some sort of ioremap_cache() fallback, but I'm assuming that has not been done to discourage more use of ioremap_cache() in drivers.

I think we had a fallback in the past, or at least discussed it, but since it's really incompatible with the uncached map, we probably don't want that.

Quoted 6 lines

I'm also not sure all these ports should have ioremap_cache(), but I figured it'd be easier to just enumerate what's there rather than trying to change the ports. Preventing the drivers from compiling also seems like a pretty heavy hammer, as it seems like some of these could have their ioremap_cache() dependency removed pretty easily, but again I figured it'd be better to start small.

Agreed, makes sense.

Quoted 3 lines

This has barely been tested, just a defconfig build on x86. That's very much insufficient, but with this touching so many ports I figure it's better to let the autobuilders have at that.

Taking a look at the individual instances here, we don't have to address them in the same patch.

arch/Kconfig config USER_RETURN_NOTIFIER · line 193

Quoted 11 lines
arch/Kconfig +3 -0
index f330410da63a..2b282fabde13 100644
@@ -188,6 +188,9 @@ config USER_RETURN_NOTIFIER
 	  Provide a kernel-internal notification when a cpu is about to
 	  switch to user mode.
 
+config HAVE_IOREMAP_CACHE
+	def_bool n
+

This could use a help text that discourages adding it in more places.

arch/powerpc/Kconfig config PPC · line 229

Quoted 13 lines
arch/powerpc/Kconfig +0 -0
index 4c466acdc70d..c552fc97aad2 100644
@@ -223,6 +223,7 @@ config PPC
 	select HAVE_HARDLOCKUP_DETECTOR_ARCH	if PPC_BOOK3S_64 && SMP
 	select HAVE_HARDLOCKUP_DETECTOR_PERF	if PERF_EVENTS && 

HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH

arch/powerpc/Kconfig +1 -0
 	select HAVE_HW_BREAKPOINT		if PERF_EVENTS && (PPC_BOOK3S || PPC_8xx)
+	select HAVE_IOREMAP_CACHE
 	select HAVE_IOREMAP_PROT
 	select HAVE_IRQ_TIME_ACCOUNTING
 	select HAVE_KERNEL_GZIP

ioremap_cache() is used internally in powerpc, but not in any drivers used on this architecture. As expected, all three uses are a bit odd, and they all have missing __iomem annotations and don't use readl() etc for accessing the cached areas. The crashdump code should clearly use memremap(), no idea what the others are doing at all, probably converting to memremap() would make them clearer.

Quoted 17 lines
arch/sh/Kconfig +1 -0
index 5f220e903e5a..bd9426cfc13b 100644
@@ -37,6 +37,7 @@ config SUPERH
 	select HAVE_FUNCTION_TRACER
 	select HAVE_FTRACE_MCOUNT_RECORD
 	select HAVE_HW_BREAKPOINT
+	select HAVE_IOREMAP_CACHE if MMU
 	select HAVE_IOREMAP_PROT if MMU && !X2TLB
 	select HAVE_KERNEL_BZIP2
 	select HAVE_KERNEL_GZIP
arch/xtensa/Kconfig +0 -0
index 12ac277282ba..edfa5127322c 100644

arch/xtensa/Kconfig config XTENSA · line 48

Quoted 7 lines
arch/xtensa/Kconfig +1 -0
@@ -42,6 +42,7 @@ config XTENSA
 	select HAVE_FUNCTION_TRACER
 	select HAVE_GCC_PLUGINS if GCC_VERSION >= 120000
 	select HAVE_HW_BREAKPOINT if PERF_EVENTS
+	select HAVE_IOREMAP_CACHE
 	select HAVE_IRQ_TIME_ACCOUNTING
 	select HAVE_PCI
 	select HAVE_PERF_EVENTS

I don't see any callers, so we could just drop the implementation here entirely.

drivers/firmware/meson/Kconfig config MESON_SM · line 12

Quoted 12 lines
drivers/firmware/meson/Kconfig +1 -0
index f2fdd3756648..612ca9ad3256 100644
@@ -7,5 +7,6 @@ config MESON_SM
 	depends on ARCH_MESON || COMPILE_TEST
 	default y
 	depends on ARM64_4K_PAGES
+	depends on HAVE_IOREMAP_CACHE
 	help
 	  Say y here to enable the Amlogic secure monitor driver

This should use memremap()

drivers/mtd/devices/Kconfig config MTD_SST25L · line 120

Quoted 13 lines
drivers/mtd/devices/Kconfig +1 -1
index 79cb981ececc..e6b55cab5a4a 100644
@@ -114,7 +114,7 @@ config MTD_SST25L
 
 config MTD_BCM47XXSFLASH
 	tristate "Support for serial flash on BCMA bus"
-	depends on BCMA_SFLASH && (MIPS || ARM)
+	depends on BCMA_SFLASH && (MIPS || ARM) && HAVE_IOREMAP_CACHE
 	help
 	  BCMA bus can have various flash memories attached, they are
 	  registered by bcma as platform devices. This enables driver for

From a code comment, I can see that ioremap_cache() is only used on MIPS, and I'm fairly sure it's wrong both in theory and in practice on Arm, so we could put it in an #ifdef. I wonder if on this specifc mips chip, _page_cachable_default does not actually create a cached mapping and that ioremap_cache() just creates a regular uncached mapping. ;-)

drivers/mtd/maps/Kconfig config MTD_SBC_GXX · line 189

Quoted 13 lines
drivers/mtd/maps/Kconfig +1 -1
index e098ae937ce8..e40d3277dcf6 100644
@@ -183,7 +183,7 @@ config MTD_SBC_GXX
 
 config MTD_PXA2XX
 	tristate "CFI Flash device mapped on Intel XScale PXA2xx based boards"
-	depends on (PXA25x || PXA27x) && MTD_CFI_INTELEXT
+	depends on (PXA25x || PXA27x) && MTD_CFI_INTELEXT && HAVE_IOREMAP_CACHE
 	help
 	  This provides a driver for the NOR flash attached to a PXA2xx chip.
 

We only have one machine remaining that uses the cached mtd mapping, and this mainly hangs around for qemu use, so we could decide to just drop all of the related code from drivers/mtd and always use the uncached map, which would probably make all other users a bit faster by getting rid of indirect functions and mutexes in the fast path. Otherwise converting to memremap() would improve the code and avoid some casts.

Arnd

#2 lore raw
Quoted 10 lines · Arnd Bergmann
Quoted 9 lines · Palmer Dabbelt

ioremap_cache() isn't recommended for portable drivers, but there's a handful of uses of it within the kernel. This adds a HAVE_IOREMAP_CACHE Kconfig, which is enabled for the ports that have implemented it and added as a driver dependency when ioremap_cache() is uncoditionally called (a handful of drivers have arch-specific ifdefs already, those I left alone).

Quoted 8 lines
Quoted 5 lines

---

Not sure what to do about splitting this up, it touches a lot of trees but it seems saner to do this atomicly. I've just included linux-arch for now, just to try and keep from blasting everyone.

Do you need this in 6.1? If not, I'm happy to just pick it up in the asm-generic tree for 6.2.

I'm in no rush, 6.2 seems fine to me. There was one patch set for RISC-V that implements ioremap_cache(), but I think we can just toss that implementation and things will still be OK.

Quoted 16 lines
Quoted 4 lines

Another option
here would be to add some sort of ioremap_cache() fallback, but I'm assuming that has not been done to discourage more use of ioremap_cache() in drivers.

I think we had a fallback in the past, or at least discussed it, but since it's really incompatible with the uncached map, we probably don't want that.

Quoted 6 lines

I'm also not sure all these ports should have ioremap_cache(), but I figured it'd be easier to just enumerate what's there rather than trying to change the ports. Preventing the drivers from compiling also seems like a pretty heavy hammer, as it seems like some of these could have their ioremap_cache() dependency removed pretty easily, but again I figured it'd be better to start small.

Quoted 8 lines

Agreed, makes sense.

Quoted 3 lines

This has barely been tested, just a defconfig build on x86. That's very much insufficient, but with this touching so many ports I figure it's better to let the autobuilders have at that.

Taking a look at the individual instances here, we don't have to address them in the same patch.

It definately seems clunky to just touch everything, but there's going to be a bit of work around getting something like this bisection-clean: we need all the arch selects in before we can start adding the driver depends, otherwise we'll lose drivers for a bit. From below it sounds like it's worth just re-spinning this as a more cleanup focused series, I'll go do that and with any luck it'll be sane.

Quoted 8 lines
Quoted 8 lines
arch/Kconfig +0 -0
index f330410da63a..2b282fabde13 100644
@@ -188,6 +188,9 @@ config USER_RETURN_NOTIFIER
 	  Provide a kernel-internal notification when a cpu is about to
 	  switch to user mode.
 
Quoted 6 lines

arch/Kconfig config USER_RETURN_NOTIFIER · line 193

Quoted 3 lines
arch/Kconfig +3 -0
+config HAVE_IOREMAP_CACHE
+	def_bool n
+

This could use a help text that discourages adding it in more places.

OK. This morning when I went back to my work tree I'd also realized I left the doc patch uncommitted.

Documentation/driver-api/device-io.rst +0 -0
index 4d2baac0311c..031263fd3708 100644
@@ -427,7 +427,8 @@ It should also not be used for actual RAM, as the returned pointer is an

``__iomem`` token. memremap() can be used for mapping normal RAM that is outside of the linear kernel memory area to a regular pointer.

-Portable drivers should avoid the use of ioremap_cache(). +Portable drivers should avoid the use of ioremap_cache(). Drivers that use +ioremap_cache() must depend on ``CONFIG_HAVE_IOREMAP_CACHE``.

Architecture example
--------------------

I'll also go ahead and add something like

arch/Kconfig +0 -0
index 2b282fabde13..22ae994e8cd1 100644
@@ -188,6 +188,9 @@ config USER_RETURN_NOTIFIER

Provide a kernel-internal notification when a cpu is about to switch to user mode.

+# Not recommended for new ports, as the semantics of ioremap_cache() differ +# between architectures and thus any portable use of it is likely wrong. +# ioremap_cache() has long been deprecated in favor of memremap(). config HAVE_IOREMAP_CACHE
def_bool n

The changed patches are over at palmer/arch-have_ioremap_cache-v1-fixed.

Quoted 13 lines
Quoted 13 lines
arch/powerpc/Kconfig +0 -0
index 4c466acdc70d..c552fc97aad2 100644
@@ -223,6 +223,7 @@ config PPC
 	select HAVE_HARDLOCKUP_DETECTOR_ARCH	if PPC_BOOK3S_64 && SMP
 	select HAVE_HARDLOCKUP_DETECTOR_PERF	if PERF_EVENTS &&

HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH

arch/powerpc/Kconfig +1 -0
 	select HAVE_HW_BREAKPOINT		if PERF_EVENTS && (PPC_BOOK3S || PPC_8xx)
+	select HAVE_IOREMAP_CACHE
 	select HAVE_IOREMAP_PROT
 	select HAVE_IRQ_TIME_ACCOUNTING
Quoted 8 lines
Quoted 1 line

select HAVE_KERNEL_GZIP

ioremap_cache() is used internally in powerpc, but not in any drivers used on this architecture. As expected, all three uses are a bit odd, and they all have missing __iomem annotations and don't use readl() etc for accessing the cached areas. The crashdump code should clearly use memremap(), no idea what the others are doing at all, probably converting to memremap() would make them clearer.

OK, I was on the fence about cleaning these up.

Quoted 19 lines
Quoted 19 lines
arch/sh/Kconfig +1 -0
index 5f220e903e5a..bd9426cfc13b 100644
@@ -37,6 +37,7 @@ config SUPERH
 	select HAVE_FUNCTION_TRACER
 	select HAVE_FTRACE_MCOUNT_RECORD
 	select HAVE_HW_BREAKPOINT
+	select HAVE_IOREMAP_CACHE if MMU
 	select HAVE_IOREMAP_PROT if MMU && !X2TLB
 	select HAVE_KERNEL_BZIP2
 	select HAVE_KERNEL_GZIP
arch/xtensa/Kconfig +0 -0
index 12ac277282ba..edfa5127322c 100644
@@ -42,6 +42,7 @@ config XTENSA
 	select HAVE_FUNCTION_TRACER
 	select HAVE_GCC_PLUGINS if GCC_VERSION >= 120000
Quoted 8 lines

arch/xtensa/Kconfig config XTENSA · line 48

Quoted 5 lines
arch/xtensa/Kconfig +1 -0
 	select HAVE_HW_BREAKPOINT if PERF_EVENTS
+	select HAVE_IOREMAP_CACHE
 	select HAVE_IRQ_TIME_ACCOUNTING
 	select HAVE_PCI
 	select HAVE_PERF_EVENTS

I don't see any callers, so we could just drop the implementation here entirely.

Makes sense to me.

Quoted 41 lines

drivers/firmware/meson/Kconfig config MESON_SM · line 12

Quoted 12 lines
drivers/firmware/meson/Kconfig +1 -0
index f2fdd3756648..612ca9ad3256 100644
@@ -7,5 +7,6 @@ config MESON_SM
 	depends on ARCH_MESON || COMPILE_TEST
 	default y
 	depends on ARM64_4K_PAGES
+	depends on HAVE_IOREMAP_CACHE
 	help
 	  Say y here to enable the Amlogic secure monitor driver

This should use memremap()

drivers/mtd/devices/Kconfig config MTD_SST25L · line 120

Quoted 13 lines
drivers/mtd/devices/Kconfig +1 -1
index 79cb981ececc..e6b55cab5a4a 100644
@@ -114,7 +114,7 @@ config MTD_SST25L
 
 config MTD_BCM47XXSFLASH
 	tristate "Support for serial flash on BCMA bus"
-	depends on BCMA_SFLASH && (MIPS || ARM)
+	depends on BCMA_SFLASH && (MIPS || ARM) && HAVE_IOREMAP_CACHE
 	help
 	  BCMA bus can have various flash memories attached, they are
 	  registered by bcma as platform devices. This enables driver for

From a code comment, I can see that ioremap_cache() is only used on MIPS, and I'm fairly sure it's wrong both in theory and in practice on Arm, so we could put it in an #ifdef. I wonder if on this specifc mips chip, _page_cachable_default does not actually create a cached mapping and that ioremap_cache() just creates a regular uncached mapping. ;-)

Quoted 6 lines
drivers/mtd/maps/Kconfig +0 -0
index e098ae937ce8..e40d3277dcf6 100644
@@ -183,7 +183,7 @@ config MTD_SBC_GXX
 
Quoted 14 lines

drivers/mtd/maps/Kconfig config MTD_SBC_GXX · line 189

Quoted 7 lines
drivers/mtd/maps/Kconfig +1 -1
 config MTD_PXA2XX
 	tristate "CFI Flash device mapped on Intel XScale PXA2xx based boards"
-	depends on (PXA25x || PXA27x) && MTD_CFI_INTELEXT
+	depends on (PXA25x || PXA27x) && MTD_CFI_INTELEXT && HAVE_IOREMAP_CACHE
 	help
 	  This provides a driver for the NOR flash attached to a PXA2xx chip.
 

We only have one machine remaining that uses the cached mtd mapping, and this mainly hangs around for qemu use, so we could decide to just drop all of the related code from drivers/mtd and always use the uncached map, which would probably make all other users a bit faster by getting rid of indirect functions and mutexes in the fast path. Otherwise converting to memremap() would improve the code and avoid some casts.

OK, so for all these driver bits I'm happy to go sort that out. It might take a bit, but I'm in no particular rush. I can just take a shot at all those? It's early enough in the 6.2 cycle that it seems reasonable to just take a shot at doing this right...