-
Notifications
You must be signed in to change notification settings - Fork 2k
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
sys/ztimer: model ztimer_periph_lptimer for Kconfig #18783
Conversation
Murdock results✔️ PASSED ef3e192 boards/xg23-pk6068a: provide ZTIMER_LPTIMER configuration
ArtifactsThis only reflects a subset of all builds from https://ci-prod.riot-os.org. Please refer to https://ci.riot-os.org for a complete build for now. |
I have always struggled with the ztimer modelling. Maybe it would be nice test with setting |
Yes, this definitely needs an overhaul. One half of the dependency resolution is put in the |
This is very correct Ztimer had this situation before i rearranged (semi-rewrote) Thank you for modeling the lptimer thing in Kconfig. |
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 seem valid from my POV. ✔️
I am not sure if i would default to lptimer or better have rtt as a default. rtt might more often than lptimer have its own power domain in the mcu i think. but on the other hand there are no mcu or boards in riot that have a default lptimer.
Seems goods i think there should be a review from one of our Kconfig experts. (i was not sure about the HAS_
modeling but that seems to be quiet common.
Hmmm, I don't see any related failures in the nightlies. |
Regarding the This is used to match |
Hmm, after reading @MrKevinWeiss comment, I'd like to model this in Makefiles as well. But I don't know how to achieve that. I'm looking for some logic like this: If (Off topic: What's blocking the shift to Kconfig-only dependency resolution?) |
Manpower mostly... All the hard things are left. I would drop the Thus:
Just keep in mind that there are some unsolvable conditions that the makefile resolves that Kconfig cannot (because Kconfig cannot have race conditions). My advice, try to not make the system super smart, put a little burden on the user to select what they want in order to simplify the system UNTIL we are done with the migration. Then there is only one area you need to manage and a clearer set of rules to follow when trying to add the "we know what you want" intelligence of the build system. |
I don't think we should default to lptimer yet - since most boards don't have a lptimer configured. (there for some board would have the rtt avail by default and some not increasing the inconsistency)
I asked a similar question some time ago and got the answer: Make configuration shall always be possible (-I conclude-> everything we model in Kconfig has to be in Make as well (We do not shift); but maybe this is a misinterpretation of the answer i got by me ) |
Oh, I was unaware. I think nobody wants to do that twice... |
I'll try during the next days! At least we could have the backend selection done by Kconfig which is picked up by -- #18780 ist merged! I added the |
Do you mean what Kconfig selects and what If so, you can use #18803 to locally check if they match. My solution for trying to mitigate nightly breaking of kconfig. |
Oh, autocorrect changed "opinion" to "option". My bad - should've noticed :-D But all looks good, I guess ;-) Maybe @kfessel can have a look onto the dependency resolution and defaults I added since the last time he looked at this PR. |
Im curios ... what's the better way to describe dependencies? |
This is the debate @leandrolanzieri and I have often, the "Lazy Developer" problem. Lazy Developers do not want to determine the dependencies themselves each time as this is a lot more effort. The way we do it with |
The complicated part is to inherit all required features of the selected module and modules that might get selected by this module, right? Sorry for getting side-tracked here ... Wouldn't it be nice to model this by |
I 100% agree with this. We come back to this discussion regularly with @MrKevinWeiss. IMO Kconfig models the constraints set by the modules and the system (dependencies, possible values, etc.). That's about it. Another tool (e.g., some solver) would take the modelling + user / app constraints ( |
Just as a pointer, something like this could be already useful https://github.com/oddlama/autokernel |
Ya, we haven't used any tools to successfully get us what we want though... Also what would the app.config look like then, or would we expect the tool to be run as part of the build system? |
But also maybe we should move this to either a separate issue or in the forum somewhere. It is nice to have another voice! |
sys/include/ztimer/config.h
Outdated
/** | ||
* @brief The minimum pm mode required for ZTIMER_LPTIMER to run | ||
*/ | ||
#ifndef CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE | ||
# if defined(CONFIG_ZTIMER_MSEC_REQUIRED_PM_MODE) | ||
# define CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE CONFIG_ZTIMER_MSEC_REQUIRED_PM_MODE | ||
# elif defined(CONFIG_ZTIMER_SEC_REQUIRED_PM_MODE) | ||
# define CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE CONFIG_ZTIMER_SEC_REQUIRED_PM_MODE | ||
# else | ||
# define CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE ZTIMER_CLOCK_NO_REQUIRED_PM_MODE | ||
# endif | ||
#endif | ||
|
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 block should not be added (the other blocks a just there for backward compatibility) translating from x-SEC require PM_MODE-X is not correct since the PM is need by the timer that is doing the backend -> if one writs a configuration for LPTIMER they may also set CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE if they know.
translating from
CONFIG_ZTIMER_MSEC_REQUIRED_PM_MODE
would never be reasonable since there is no old code that knew about LPTIMER before ->
do not add this block for LPTIMER
/** | |
* @brief The minimum pm mode required for ZTIMER_LPTIMER to run | |
*/ | |
#ifndef CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE | |
# if defined(CONFIG_ZTIMER_MSEC_REQUIRED_PM_MODE) | |
# define CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE CONFIG_ZTIMER_MSEC_REQUIRED_PM_MODE | |
# elif defined(CONFIG_ZTIMER_SEC_REQUIRED_PM_MODE) | |
# define CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE CONFIG_ZTIMER_SEC_REQUIRED_PM_MODE | |
# else | |
# define CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE ZTIMER_CLOCK_NO_REQUIRED_PM_MODE | |
# endif | |
#endif |
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.
maybe I should have wite in line 106 and 115 : this is only for backward compatibility and not supposed to be used by new code
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.
What do you think of this default:
#ifndef CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE
# define CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE ZTIMER_CLOCK_NO_REQUIRED_PM_MODE
#endif
No defaults forces every board.h
to pull in ztimer.h
and set the mode to ZTIMER_CLOCK_NO_REQUIRED_PM_MODE
if no power management is required ...
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 you are right there should be a fallback value
/** | |
* @brief The minimum pm mode required for ZTIMER_LPTIMER to run | |
*/ | |
#ifndef CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE | |
# if defined(CONFIG_ZTIMER_MSEC_REQUIRED_PM_MODE) | |
# define CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE CONFIG_ZTIMER_MSEC_REQUIRED_PM_MODE | |
# elif defined(CONFIG_ZTIMER_SEC_REQUIRED_PM_MODE) | |
# define CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE CONFIG_ZTIMER_SEC_REQUIRED_PM_MODE | |
# else | |
# define CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE ZTIMER_CLOCK_NO_REQUIRED_PM_MODE | |
# endif | |
#endif | |
/** | |
* @brief The minimum pm mode required for ZTIMER_LPTIMER to run | |
*/ | |
#ifndef CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE | |
# define CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE ZTIMER_CLOCK_NO_REQUIRED_PM_MODE | |
#endif |
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.
Done. Thank you!
ztimer_periph_lptimer is uses the implementation of ztimer_periph_timer
3662eea
to
da0d37d
Compare
@kfessel @MrKevinWeiss may I ping you? Is this ready to go into master? |
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 from my side. If @kfessel is happy and murdock is happy you have my ACK!
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.
@jue89 @MrKevinWeiss I got just a small question left. other than that the Kconfig things seem correct (from the POV of one who did not use Kconfig very much)
#define CONFIG_ZTIMER_LPTIMER_DEV TIMER_DEV(1) | ||
#define CONFIG_ZTIMER_LPTIMER_FREQ LFXO_FREQ | ||
#define CONFIG_ZTIMER_LPTIMER_WIDTH 24 | ||
/** @} */ |
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.
Why isn't "CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE" defined ?
seems to me that the LETIMER based LPTIMER would at least needs em2 to work
(block the lowest PM_mode em3 (i just saw em4 is pm_off))
i think it this would work out to
#define CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE 1
or
#define CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE EFM32_PM_MODE_EM3
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.
Good catch! You're right - thank you!
Cf. https://www.silabs.com/documents/public/reference-manuals/efr32xg23-rm.pdf page 150: LETIMER0 is clocked by EM23GRPACLK
which is active in EM3. But, this domain is clocked by the LFXO which is active in EM2 ... always confusing ...
I squashed right away. I hope that's okay.
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.
I think p.: 295 provides a good overview over which pm needs to be blocked for which driver to work (hardware is able to wakeup the mcu)
da0d37d
to
ef3e192
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.
I think the CONFIG_*
just means that the values are guarded but the #ifndef CONFIG_*
. AFAIK the equivalent *
from CONFIG_*
does not need to exist in kconfig, but if it is in Kconfig, it will overwrite...
Which makes things like CONFIG_ZTIMER_LPTIMER_DEV
a bit strange if we are wrapping it with a TIMER_DEV
since Kconfig does not have objects...
This would also cause a conflict if a ZTIMER_LPTIMER_DEV
symbol was defined in kconfig somewhere if the xg23-pk6068a
board was selected. That stuff seems closer to the params from periph_conf.h
...
Not going to block though, I don't have time to look to close.
* @brief The minimum pm mode required for ZTIMER_LPTIMER to run | ||
*/ | ||
#ifndef CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE | ||
# define CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE ZTIMER_CLOCK_NO_REQUIRED_PM_MODE |
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.
do we do the spacing with defines?
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.
I just tried to adapt the surrounding indentation.
The naming has been picked by the already merged PR introducing ztimer_periph_lptimer
.
Murdock is green. Is everything addressed, @kfessel? |
I think so
Am 2. November 2022 12:42:03 MEZ schrieb Juergen Fitschen ***@***.***>:
…Murdock is green. Is everything addressed, @kfessel?
--
Reply to this email directly or view it on GitHub:
#18783 (comment)
You are receiving this because you were mentioned.
Message ID: ***@***.***>
|
Thank you for your feedback :-) |
ok das nächstemal werf ich vorher die citation aus der antwort mail |
Contribution description
While working on #18760, I realized that #17654 hasn't modeled the module
ztimer_periph_lptimer
.This PR tries to fix that. For that I added the feature
HAS_ZTIMER_PERIPH_LPTIMER_CONFIG
which should be selected by boards that has the required configuration forztimer_periph_lptimer
.Testing procedure
With Kconfig support
Without Kconfig support
Issues/PRs references