Commit 1ee7fc3f authored by Conor Dooley's avatar Conor Dooley Committed by Palmer Dabbelt

RISC-V: always select RISCV_ALTERNATIVE for non-xip kernels

When moving switch_to's has_fpu() over to using
riscv_has_extension_likely() rather than static branches, the FPU code
gained a dependency on the alternatives framework.
That dependency has now been removed, as riscv_has_extension_ikely() now
contains a fallback path, using __riscv_isa_extension_available(), but
if CONFIG_RISCV_ALTERNATIVE isn't selected when CONFIG_FPU is, has_fpu()
checks will not benefit from the "fast path" that the alternatives
framework provides.

We want to ensure that alternatives are available whenever
riscv_has_extension_[un]likely() is used, rather than silently falling
back to the slow path, but rather than rely on selecting
RISCV_ALTERNATIVE in the myriad of locations that may use
riscv_has_extension_[un]likely(), select it (almost) always instead by
adding it to the main RISCV config entry.
xip kernels cannot make use of the alternatives framework, so it is not
enabled for those configurations, although this is the status quo.

All current sites that select RISCV_ALTERNATIVE are converted to
dependencies on the option instead. The explicit dependencies on
!XIP_KERNEL can be dropped, as RISCV_ALTERNATIVE is not user selectable.

Fixes: 702e6455 ("riscv: fpu: switch has_fpu() to riscv_has_extension_likely()")
Link: https://lore.kernel.org/all/ZBruFRwt3rUVngPu@zx2c4.com/Reported-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: default avatarConor Dooley <conor.dooley@microchip.com>
Reviewed-by: default avatarAndrew Jones <ajones@ventanamicro.com>
Reviewed-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
Link: https://lore.kernel.org/r/20230324100538.3514663-3-conor.dooley@microchip.comSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
parent 1aa86693
...@@ -126,6 +126,7 @@ config RISCV ...@@ -126,6 +126,7 @@ config RISCV
select OF_IRQ select OF_IRQ
select PCI_DOMAINS_GENERIC if PCI select PCI_DOMAINS_GENERIC if PCI
select PCI_MSI if PCI select PCI_MSI if PCI
select RISCV_ALTERNATIVE if !XIP_KERNEL
select RISCV_INTC select RISCV_INTC
select RISCV_TIMER if RISCV_SBI select RISCV_TIMER if RISCV_SBI
select SIFIVE_PLIC select SIFIVE_PLIC
...@@ -401,9 +402,8 @@ config RISCV_ISA_C ...@@ -401,9 +402,8 @@ config RISCV_ISA_C
config RISCV_ISA_SVPBMT config RISCV_ISA_SVPBMT
bool "SVPBMT extension support" bool "SVPBMT extension support"
depends on 64BIT && MMU depends on 64BIT && MMU
depends on !XIP_KERNEL depends on RISCV_ALTERNATIVE
default y default y
select RISCV_ALTERNATIVE
help help
Adds support to dynamically detect the presence of the SVPBMT Adds support to dynamically detect the presence of the SVPBMT
ISA-extension (Supervisor-mode: page-based memory types) and ISA-extension (Supervisor-mode: page-based memory types) and
...@@ -428,8 +428,8 @@ config TOOLCHAIN_HAS_ZBB ...@@ -428,8 +428,8 @@ config TOOLCHAIN_HAS_ZBB
config RISCV_ISA_ZBB config RISCV_ISA_ZBB
bool "Zbb extension support for bit manipulation instructions" bool "Zbb extension support for bit manipulation instructions"
depends on TOOLCHAIN_HAS_ZBB depends on TOOLCHAIN_HAS_ZBB
depends on !XIP_KERNEL && MMU depends on MMU
select RISCV_ALTERNATIVE depends on RISCV_ALTERNATIVE
default y default y
help help
Adds support to dynamically detect the presence of the ZBB Adds support to dynamically detect the presence of the ZBB
...@@ -443,9 +443,9 @@ config RISCV_ISA_ZBB ...@@ -443,9 +443,9 @@ config RISCV_ISA_ZBB
config RISCV_ISA_ZICBOM config RISCV_ISA_ZICBOM
bool "Zicbom extension support for non-coherent DMA operation" bool "Zicbom extension support for non-coherent DMA operation"
depends on !XIP_KERNEL && MMU depends on MMU
depends on RISCV_ALTERNATIVE
default y default y
select RISCV_ALTERNATIVE
select RISCV_DMA_NONCOHERENT select RISCV_DMA_NONCOHERENT
help help
Adds support to dynamically detect the presence of the ZICBOM Adds support to dynamically detect the presence of the ZICBOM
......
...@@ -2,8 +2,7 @@ menu "CPU errata selection" ...@@ -2,8 +2,7 @@ menu "CPU errata selection"
config ERRATA_SIFIVE config ERRATA_SIFIVE
bool "SiFive errata" bool "SiFive errata"
depends on !XIP_KERNEL depends on RISCV_ALTERNATIVE
select RISCV_ALTERNATIVE
help help
All SiFive errata Kconfig depend on this Kconfig. Disabling All SiFive errata Kconfig depend on this Kconfig. Disabling
this Kconfig will disable all SiFive errata. Please say "Y" this Kconfig will disable all SiFive errata. Please say "Y"
...@@ -35,8 +34,7 @@ config ERRATA_SIFIVE_CIP_1200 ...@@ -35,8 +34,7 @@ config ERRATA_SIFIVE_CIP_1200
config ERRATA_THEAD config ERRATA_THEAD
bool "T-HEAD errata" bool "T-HEAD errata"
depends on !XIP_KERNEL depends on RISCV_ALTERNATIVE
select RISCV_ALTERNATIVE
help help
All T-HEAD errata Kconfig depend on this Kconfig. Disabling All T-HEAD errata Kconfig depend on this Kconfig. Disabling
this Kconfig will disable all T-HEAD errata. Please say "Y" this Kconfig will disable all T-HEAD errata. Please say "Y"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment