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

Export symbols needed for sof probe module llext #81098

Conversation

jsarha
Copy link

@jsarha jsarha commented Nov 7, 2024

My probe llext changes still require some cleaning up, but I'll link the PR here as soon as its ready.

@zephyrbot zephyrbot added area: Xtensa Xtensa Architecture platform: NXP Drivers NXP Semiconductors, drivers area: native port Host native arch port (native_sim) platform: TI SimpleLink Texas Instruments SimpleLink MCU platform: nRF Nordic nRFx platform: ESP32 Espressif ESP32 platform: LiteX platform: X86 x86 and x86-64 area: Timer Timer labels Nov 7, 2024
@zephyrbot zephyrbot requested review from andyross and teburd November 7, 2024 20:08
@jsarha
Copy link
Author

jsarha commented Nov 7, 2024

FYI @lyakh

arch/xtensa/core/xtensa_asm2_export.c Outdated Show resolved Hide resolved
@@ -209,6 +209,7 @@ uint64_t sys_clock_cycle_get_64(void)
{
return rdtsc();
}
EXPORT_SYMBOL(sys_clock_cycle_get_64);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this sort of thing would be better served in drivers/timer/export.c that optionally is built with LLEXT enabled

Since there's a few timer API symbols that we might want to export, in particular cycle_get_32 and cycle_get_64 (should be checked for availability!)

Copy link
Author

Choose a reason for hiding this comment

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

Done.

Copy link
Author

@jsarha jsarha Nov 12, 2024

Choose a reason for hiding this comment

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

Hmm. This is not that simple. All the drivers/timer options do not implement sys_clock_cycle_get_64(), causing undefined symbol error with this approach. I could still add a huge

#if CONFIG_APIC_TIMER || CONFIG_APIC_TSC_DEADLINE_TIMER \
	CONFIG_ARM_ARCH_TIMER || CONFIG_INTEL_ADSP_TIMER \
	CONFIG_CC13XX_CC26XX_RTC_TIMER || CONFIG_CORTEX_M_SYSTICK \
	CONFIG_ESP32_SYS_TIMER || CONFIG_HPET_TIMER \
	CONFIG_LITEX_TIMER || CONFIG_MCUX_OS_TIMER \
...

if condition around EXPORT_SYMBOL(sys_clock_cycle_get_64());, but that is painful to get right, and even more painful to maintain. I suggest I go back to my original solution, and just add the export next to each implementation. @teburd what do you say?

Copy link
Author

Choose a reason for hiding this comment

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

Then there is of course the third option of exporting only the intel adsp implementation, because that is all I need.

Copy link
Collaborator

@lyakh lyakh Nov 13, 2024

Choose a reason for hiding this comment

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

@jsarha you could also add a __weak version of the function, not sure if that would be preferred.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, now there is a new version with a __weak dummy implementation of sys_clock_cycle_get_64().

Copy link
Collaborator

@teburd teburd Nov 13, 2024

Choose a reason for hiding this comment

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

Perhaps using a Kconfig that is selected helps here...

#ifdef CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER
EXPORT_SYMBOL(sys_clock_cycle_get_64());
#endif

Copy link
Author

Choose a reason for hiding this comment

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

Thanks. It was not hard to find, but I did not know what to look for. Hope this is good now.

@jsarha jsarha force-pushed the export_symbols_needed_for_sof_probe_module_llext branch from 762d0bc to e37d327 Compare November 8, 2024 11:43
@jsarha
Copy link
Author

jsarha commented Nov 8, 2024

The SOF side PR requiring this change can be found here: thesofproject/sof#9643

@jsarha jsarha force-pushed the export_symbols_needed_for_sof_probe_module_llext branch 2 times, most recently from 8f36db5 to a32b400 Compare November 13, 2024 16:27
Export sys_clock_cycle_get_64() implementations to enable k_cycle_get_64()
calls from llext libraries.

Signed-off-by: Jyri Sarha <[email protected]>
@jsarha jsarha force-pushed the export_symbols_needed_for_sof_probe_module_llext branch from a32b400 to b32d555 Compare November 14, 2024 10:00
@mmahadevan108
Copy link
Collaborator

cc @dbaluta

@kartben kartben merged commit ff5a458 into zephyrproject-rtos:main Dec 6, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: native port Host native arch port (native_sim) area: Timer Timer area: Xtensa Xtensa Architecture platform: ESP32 Espressif ESP32 platform: LiteX platform: nRF Nordic nRFx platform: NXP Drivers NXP Semiconductors, drivers platform: TI SimpleLink Texas Instruments SimpleLink MCU platform: X86 x86 and x86-64
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants