-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
mem_attr: Introduce library to query memory attributes #60916
Conversation
Add a dt-bindings header file to be able to easily match in C code the YAML / DT enum. Signed-off-by: Carlo Caione <[email protected]>
Instead of relying on numerical values only. Signed-off-by: Carlo Caione <[email protected]>
…_NODE Introduce a new DT_MEMORY_ATTR_FOREACH_STATUS_OKAY_NODE() macro and make the DT_MEMORY_ATTR_FOREACH_NODE() macro visiting disabled nodes as well. Signed-off-by: Carlo Caione <[email protected]>
The introduction on the `zephyr,memory-attr` property for memory nodes has been very useful to mark attributes and capabilities of the memory regions defined into the DT. What's still missing is an abstracted and unified way to deal and manage this kind of information. In this PR we introduce a small and extensible library / subsystem that can be used by application, drivers or other subsystems to query this kind of information. One very common use-case of this library is for example to check whether a buffer has certain kind of capabilities (i.e. it is cacheable / non-cacheable). Signed-off-by: Carlo Caione <[email protected]>
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 mostly looks great.
I do think a few of the names are a bit misleading though.
mem_mgmt makes me think oh, this thing will have something like allocation and other such things to manage memory. But its more like memory introspection abilities to query what some memory is capable. mem_caps, mem_info, mem_introspect, etc seem more apt than mem_mgmt to me.
The other oddity is the memory attributes themselves. I had, wrongly, assumed there could be more than one attribute applied to a memory region. E.g. this memory is uncached and has buswide access, such that it's useful to dma and not just tcm attached to core(s). Maybe that means RAM_NOCACHE | BUS_ACCESSIBLE for example. Point being there are multiple attributes associated.
It seems like instead each region more or less gets a type tag enum and calls that mem_attr which is a bit misleading.
The actual API seems plenty fine to me and does as advertised I believe.
Aaargh, this is in draft, I feel violated now 😄 (joking, I'm just waiting for the other PRs this is depending on to be merged before marking this as ready)
Yes, you actually got the point here. But this PR is part of a long game that will add a couple of more memory management bits and the biggest player will be indeed a memory allocator based on memory properties (think about a
Fully agree here and you are spot on. I thought hard about that but this is extremely hard to achieve if we want to achieve everything only using the zephyr/include/zephyr/devicetree/memory-attr.h Lines 64 to 157 in 3191d08
Used for example in:
So we have two ways forward here:
I was going with (1) because is objectively easier but if we want to steer towards (2) this is something that I need to know ASAP because that will be quite a bit of work :) |
@teburd I actually got an idea, let me prepare an RFC. |
The introduction on the
zephyr,memory-attr
property for memory nodes in #60049 has been very useful to mark attributes and capabilities of the memory regions defined in the DT. What's still missing is an abstracted and unified way to deal and manage this kind of information.In this PR we introduce a small and extensible library / subsystem that can be used by application, drivers or other subsystems to query this kind of information.
One very common use-case of this library is for example to check whether a buffer has certain kind of capabilities (i.e. it is cacheable / non-cacheable). Right now there is no common and generalized why to achieve that, so each platform has to resort to custom platform-specific code, like in #57786