-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Rework Xilinx TTC driver #23567
Rework Xilinx TTC driver #23567
Conversation
This commit enables the QEMU icount emulation mode for improved timing stability. In normal emulation mode (without icount), the emulation timing of the TTC system timer is particularly unstable and this results in a high CI failure rate. For more details, refer to the issues zephyrproject-rtos#14173 and zephyrproject-rtos#22904. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
The `tests/kernel/context` test fails for the `qemu_cortex_r5` when the icount emulation mode is used, because the Xilinx QEMU ignores the WFI instruction when the icount parameter is specified. This will be fixed in the Zephyr SDK 0.11.3 and this commit must be reverted once the CI is updated to use this new SDK version. For more details, see zephyrproject-rtos/sdk-ng#191. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
All checks are passing now. Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
417b333
to
c9067fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Some nitpicking but nothing I can see that should block merge.
@@ -9,6 +9,7 @@ set(QEMU_CPU_TYPE_${ARCH} cortex-r5) | |||
set(QEMU_FLAGS_${ARCH} | |||
-nographic | |||
-machine arm-generic-fdt | |||
-icount shift=3,align=off,sleep=off -rtc clock=vm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No complaints here, though IIRC there are still some issues in the main -icount patch. Does this work for everything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is actually from #22904.
There is an issue with the WFI instruction in the Xilinx QEMU when icount mode is used, but this only affects one Zephyr test (tests/kernel/context) and does not really have a real impact in terms of functionality.
@@ -2,3 +2,6 @@ tests: | |||
kernel.common: | |||
tags: kernel | |||
min_ram: 20 | |||
# FIXME: Remove `qemu_cortex_r5` exclusion once Zephyr SDK 0.11.3 is | |||
# mainlined (see #22904). | |||
platform_exclude: qemu_cortex_r5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems cleaner to me to just rush the SDK release than to commit and revert this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be nice; though, @galak seems to be busy working on something else, so I am not sure if that is feasible.
#else | ||
#error ("No timer is specified") | ||
#endif | ||
#define TICKS_PER_SEC CONFIG_SYS_CLOCK_TICKS_PER_SEC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: unless this is needed to keep line lengths under control, I'd prefer to see the existing kconfig used directly instead of a local synonym.
#error ("No timer is specified") | ||
#endif | ||
#define TICKS_PER_SEC CONFIG_SYS_CLOCK_TICKS_PER_SEC | ||
#define CYCLES_PER_SEC TIMER_CLOCK_FREQUECY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto, though I guess DTS constants are really ugly, so I feel less strongly about this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, they get very long and ugly soon after this.
CYCLES_NEXT_MAX : CYCLES_PER_TICK; | ||
sys_write32(reg_val, TIMER_BASE_ADDR + XTTCPS_MATCH_0_OFFSET); | ||
|
||
/* Connect timer interrupt */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: "IRQ_CONNECT(TIMER_IRQ, ..." sufficiently implies that the timer interrupt is connected without the comment. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wanted to provide a logical flow of this function in the comments (i.e. even without reading actual code, you will know what this function does just only reading comments).
Though, I agree that this would often qualify as a "state-the-obvious" kind of comment :p
This commit updates the 'xlnx_psttc_timer' to implement the current system timer API. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
The `xlnx,ttcps` binding, despite having the file name of `xlnx,ttcps.yaml`, had the compatible property of `cdns,ttc`. While it is true that the Xilinx ZynqMP platform embeds the Cadence Triple Timer Counter (TTC) IP core, its TTC differs from the original Cadence core in that it implements 32-bit counters, instead of the 16-bit counters defined in the original; hence, the Xilinx variant is not compatible with the original Cadence version and should be treated as a different device. This commit changes the `xlnx,ttcps.yaml` compatible property to `xlnx,ttcps` for the above reasons. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit reworks the Xilinx TTC timer driver to use the "match" mode instead of the "interval" mode which counts up to the specified value and resets to zero. Using the "match" mode ensures that the timer keeps counting even after an interrupt is triggered, and facilitates the tickless mode support implementation. This also allows `z_timer_cycle_get_32` to return the correct cycle count when interrupt is locked; thereby, fixing the k_busy_wait hang issue. Note that the TTC "match" mode emulation (and tickless timer operation) is only stable when the QEMU icount mode is enabled. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
c9067fe
to
7a17804
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Rework Xilinx TTC driver to support tickless mode and fix the
k_busy_wait
hang issue when calling with interrupts locked.Closes #19869 (tickless support issue)
Fixes #23541