Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xtensa: allow arch-specific arch_spin_relax() with more NOPs #60601

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions arch/xtensa/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ config XTENSA_CCOUNT_HZ
Rate in HZ of the Xtensa core as measured by the value of
the CCOUNT register.

config XTENSA_MORE_SPIN_RELAX_NOPS
bool "Use Xtensa specific arch_spin_relax() with more NOPs"
help
Some Xtensa SoCs, especially under SMP, may need extra
NOPs after failure to lock a spinlock. This gives
the bus extra time to synchronize the RCW transaction
among CPUs.

config XTENSA_NUM_SPIN_RELAX_NOPS
int "Number of NOPs to be used in arch_spin_relax()"
default 1
depends on XTENSA_MORE_SPIN_RELAX_NOPS
help
Specify the number of NOPs in Xtensa specific
arch_spin_relax().

if CPU_HAS_MMU

config XTENSA_MMU
Expand Down
13 changes: 13 additions & 0 deletions arch/xtensa/core/xtensa-asm2.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,16 @@ int z_xtensa_irq_is_enabled(unsigned int irq)

return (ie & (1 << irq)) != 0U;
}

#ifdef CONFIG_XTENSA_MORE_SPIN_RELAX_NOPS
/* Some compilers might "optimize out" (i.e. remove) continuous NOPs.
* So force no optimization to avoid that.
*/
__no_optimization
void arch_spin_relax(void)
{
#define NOP1(_, __) __asm__ volatile("nop.n;");
LISTIFY(CONFIG_XTENSA_NUM_SPIN_RELAX_NOPS, NOP1, (;))
#undef NOP1
}
#endif /* CONFIG_XTENSA_MORE_SPIN_RELAX_NOPS */
Loading