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

arch: xtensa: add isync to interrupt vector #69923

Merged
merged 1 commit into from
Mar 16, 2024

Conversation

kv2019i
Copy link
Collaborator

@kv2019i kv2019i commented Mar 7, 2024

On Intel ADSP platforms, additional "isync" is needed in interrupt vector to synchronize icache when core is woken up from deeper sleep state by an interrupt. This is only needed if DSP clock gating is enabled.

@kv2019i kv2019i added the platform: Intel ADSP Intel Audio platforms label Mar 7, 2024
@zephyrbot zephyrbot added the area: Xtensa Xtensa Architecture label Mar 7, 2024
lyakh
lyakh previously approved these changes Mar 7, 2024
dcpleung
dcpleung previously approved these changes Mar 7, 2024
@@ -604,6 +604,11 @@ _Level\LVL\()Vector:
s32i a2, a1, ___xtensa_irq_bsa_t_a2_OFFSET
s32i a3, a1, ___xtensa_irq_bsa_t_a3_OFFSET

#if defined(CONFIG_SOC_FAMILY_INTEL_ADSP) && defined(CONFIG_ADSP_IDLE_CLOCK_GATING)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ADSP_IDLE_CLOCK_GATING depends on SOC_FAMILY_INTEL_ADSP, so there is no need for check on SOC_FAMILY_INTEL_ADSP

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack @nashif , updated in V2

On Intel ADSP platforms, additional "isync" is needed in interrupt
vector to synchronize icache when core is woken up from deeper
sleep state by an interrupt. This is only needed if DSP clock
gating is enabled.

Signed-off-by: Kai Vehmanen <[email protected]>
@kv2019i kv2019i dismissed stale reviews from dcpleung, serhiy-katsyuba-intel, and lyakh via e997e49 March 7, 2024 19:36
@kv2019i kv2019i force-pushed the 202403-isync-fix branch from 476623d to e997e49 Compare March 7, 2024 19:36
#ifdef CONFIG_ADSP_IDLE_CLOCK_GATING
/* Needed when waking from low-power waiti state */
isync
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the right place? At this stage the handler has already significant code, including stores.

Normally you use an isync to prevent any in-flight state changes that might affect instruction fetch (i.e. MMU/MPU changes) from affecting the next instruction in the stream. Which instruction are we trying to protect, and from what? Is this maybe something that only happens if the ISR crosses a page/cacheline/whatever boundary? If so that seems like it could be fixed with alignment instead?

My gut says that if we do need this, you almost certainly want this as the very first instruction in the vector, no? Is there an errata or something that explains what you're trying to fix?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do need this @andyross - pls reach out to @kv2019i for further details.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But right here? It's just a really weird spot.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andyross Following up now to move this to a more maintainable place thesofproject/sof#9031

@andyross
Copy link
Contributor

andyross commented Mar 8, 2024

So, I get that every platform has its weird nonsense to support. But here I'm wearing the hat of an arch maintainer and... this is just really weird to have in the global exception vectors. Maybe a cleaner design would be to swap VECBASE on suspend such that the WAITI returns to SOC-specific code, then do your magic, restore VECBASE, and jump to the regular handler? It would be more code but a lot less confusion in arch/xtensa (and also a lot more safety vs. maintainers coming along later and "fixing" it because they don't understand what can't be documented).

Note FWIW that the call0 stuff is likely to land in the immediate future, and that has a separate interrupt entry path which would need the same treatment.

Copy link
Contributor

@andyross andyross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop a +1 just because there are schedule worries and this is verifiably a noop on other platforms that might include it accidentally.

But let's please remember to move this to the SOC layer over the long term. The global interrupt entry code is a really bad spot for platform support.

@kv2019i
Copy link
Collaborator Author

kv2019i commented Mar 14, 2024

@nashif Please check. This is not pretty, but in practise this is needed for reliable multicore use and not having this can mask other bugs. Should I file a bug to follow-up with the improvements @andyross has asked?

@nashif nashif merged commit be881d4 into zephyrproject-rtos:main Mar 16, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Xtensa Xtensa Architecture platform: Intel ADSP Intel Audio platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants