Hi,
I think there may be a bug in the ARMv7-M-ALT core (and, it seems in ARMv8-M-ML-ALT, too) in the __port_schedule_next(void) function (both in 21.11.x and trunk). Although it now calls __trace_switch(ntp, otp) and __stats_ctxswc(ntp, otp), the call to the CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) is ommitted (in contrast to what happens in the chSysSwitch(ntp, otp) macro). This breaks my thread-local support (which uses this hook to update the current thread pointer) as soon as any context switching happens via this function. Once I add the hook call, everything works as expected (like in the regular ARMv7-M port). Am I overlooking a reason why this hook is not called in the __port_schedule_next(void) function, or is this a bug?
Thanks for looking into this!
ARMv7-M-ALT port missing CH_CFG_CONTEXT_SWITCH_HOOK Topic is solved
- Giovanni
- Site Admin
- Posts: 14658
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1135 times
- Been thanked: 947 times
Re: ARMv7-M-ALT port missing CH_CFG_CONTEXT_SWITCH_HOOK
Hi,
Please post your change so I can review it, probably it is just missing because it is a new port.
Giovanni
Please post your change so I can review it, probably it is just missing because it is a new port.
Giovanni
Re: ARMv7-M-ALT port missing CH_CFG_CONTEXT_SWITCH_HOOK
It's really just the already mentioned one-liner 

Code: Select all
diff --git a/lib/ChibiOS/os/common/ports/ARMv7-M-ALT/chcore.c b/lib/ChibiOS/os/common/ports/ARMv7-M-ALT/chcore.c
index 03d8817eb..6c95d7fca 100644
--- a/lib/ChibiOS/os/common/ports/ARMv7-M-ALT/chcore.c
+++ b/lib/ChibiOS/os/common/ports/ARMv7-M-ALT/chcore.c
@@ -141,6 +141,7 @@ uint64_t __port_schedule_next(void) {
__trace_switch(ntp, otp);
__stats_ctxswc(ntp, otp);
+ CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp);
return ((uint64_t)(uint32_t)otp << 32) | ((uint64_t)(uint32_t)ntp << 0);
}
- Giovanni
- Site Admin
- Posts: 14658
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1135 times
- Been thanked: 947 times
Re: ARMv7-M-ALT port missing CH_CFG_CONTEXT_SWITCH_HOOK
Hi,
Change committed, while looking at that code I also found a nice improvement to IRQ servicing, committed that too.
Giovanni
Change committed, while looking at that code I also found a nice improvement to IRQ servicing, committed that too.
Giovanni
Who is online
Users browsing this forum: No registered users and 62 guests