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
Device-level Cache API #33122
Comments
So I have possibly done something like this for another problem, see #32673, not sure if applicable here. This is how this is working for the
Can something like this work for your cache case? |
I think this can work, yes. Basically, we need a way that the cache API is available in device- and arch-level. In the example you refer to @carlocaione , the API was defined at device-level, and the implementation hooks up arch- functions. |
Isn't exactly the opposite in the |
API meeting 2021.03.16: Proposal:
New API would be in
Use the interrupt controller and the timer ( |
So, back at this again. This is a possible proposal based on the @carlescufi proposal.
tagging some more people for feedbacks: @nashif @npitre @ceolin @andyross @stephanosio |
The problem with weak function is if you end up having two strong definitions (that would cause a build failure) or two weak symbols which the behavior is not defined. Is there a explicit precedence between arch / peripheral ? If yes we could establish that architectures would always implement an weak function and peripherals the strong symbol. The drawback is that all arch have to implement this API.
In this case if |
Build failure is "good" (because you can catch the problem early) and I don't see how you can end up with two weak symbols. The only place where the weak symbol is supposed to be declared is inside
Yes, that should be enforced using Kconfig. For example
Yes, that's why I think my proposal is more complex but less problematic I guess:
Yes, that could be a solution. Just to put down here PROs and CONs:
PROs: slim and elegant
PROs: no weak functions
PROs: fallback weak function Or a mix of course. I don't have a strong preference TBH, so I'm open to whatever implementation the majority thinks is the best. |
Tagging @dcpleung because X86 people can be interested in this. |
Moving into We had this issue with weak functions for timing subsys, as there can be arch-/soc-/board-specific timing routine. We decided to use kconfig to specify which level to use. I think the caching API has similar problem where we can have cache control on different levels, and we cannot use weak functions. Do you think we would need to support all these levels? Or do you prefer to have a 'one or the other |
In
This case is easier though. You do not have levels, you have a choice: either arch-implemented cache operations or driver-implemented cache operations, that's it (or architecture without cache management at all).
Exactly my point. At least for now we do not need to support all the levels, only arch or external / device.
Ok, this is on the same line of what was already proposed. But what about architectures that do not implement neither arch nor device cache drivers? Considering that I'd probably prefer to have a shim as proposed by @ceolin in #33122 (comment) to catch architecture without cache management at all. |
Instead of dealing with weak functions, maybe we can use kconfig choice to choose which to use (including none). Each choice would depend on an |
That's basically solution 2 in #33122 (comment):
Right? |
Oh yeah... forgot I read about it yesterday. (I need more caffeine.) Since we have 3 choices (for now): none, arch and device. Kconfig seems to be a more straightforward approach. |
Introduction
Zephyr has a public API for cache management, and it was greatly enhanced, recently, in this PR: #30398.
There exists an open ticket that reflects an original view of how a “complete” API should look like: #2647.
One limitation of the current API is that it treats cache as, always, arch-specific feature (i.e. a Kernel -> ARCH API). However, there might be SoCs which may implement a cache controller as a peripheral separate from the core.
Problem description
Some SoCs may implement a cache management controller as a separate peripheral that exists outside the core, thus, cache management, becomes, more of a device-management issue, i.e. cache should not be managed at arch level.
The implementation of the current Zephyr Cache API assumes that cache is managed at arch-level only.
Proposed change
Rework implementation of existing Zephyr Cache API so that both arch-level and device-level cache management APIs may be supported.
Detailed RFC
Proposed change (Detailed)
Current implementation of cache API looks like this:
There are two approaches to support both arch & device cache:
arch
directory of affected SoC(analogously to https://github.com/zephyrproject-rtos/zephyr/blob/master/arch/arc/core/cache.c).
This option may sound counter-intuitive (as peripheral is not a part of arch obviously) but I believe it is done in Zephyr already
(example - call to PM subsystem from within
arch
code: https://github.com/zephyrproject-rtos/zephyr/blob/master/arch/arm/core/aarch32/irq_manage.c#L188)Dependencies
As far as I know, cache is not widely used in Zephyr currently.
arc
arch that uses enhanced cache API will be unaffected by proposed changes.Concerns and Unresolved Questions
The text was updated successfully, but these errors were encountered: