-
Notifications
You must be signed in to change notification settings - Fork 369
[userspace LL] vregion related syscalls #11108
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
base: main
Are you sure you want to change the base?
Changes from all commits
9c04880
3ad3a6a
b07958f
a2eca4e
63cf22a
e7f5d42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,8 @@ | |
| #define __SOF_LIB_VREGION_H__ | ||
|
|
||
| #include <stddef.h> | ||
| #include <stdint.h> | ||
| #include <sof/compiler_attributes.h> | ||
|
|
||
|
lyakh marked this conversation as resolved.
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
|
|
@@ -49,7 +51,7 @@ struct vregion *vregion_create(size_t memsize); | |
| * | ||
| * @param[in] vr Pointer to the virtual region instance. | ||
| */ | ||
| void vregion_set_interim(struct vregion *vr); | ||
| __syscall void vregion_set_interim(struct vregion *vr); | ||
|
|
||
| /** | ||
| * @brief Increment virtual region's user count. | ||
|
|
@@ -60,7 +62,7 @@ void vregion_set_interim(struct vregion *vr); | |
| * @param[in] vr Pointer to the virtual region instance to release. | ||
| * @return struct vregion* Pointer to the virtual region instance. | ||
| */ | ||
| struct vregion *vregion_get(struct vregion *vr); | ||
| __syscall struct vregion *vregion_get(struct vregion *vr); | ||
|
|
||
| /** | ||
| * @brief Decrement virtual region's user count or destroy it. | ||
|
|
@@ -71,7 +73,7 @@ struct vregion *vregion_get(struct vregion *vr); | |
| * @param[in] vr Pointer to the virtual region instance to release. | ||
| * @return struct vregion* Pointer to the virtual region instance or NULL if it has been destroyed. | ||
| */ | ||
| struct vregion *vregion_put(struct vregion *vr); | ||
| __syscall struct vregion *vregion_put(struct vregion *vr); | ||
|
|
||
| /** | ||
| * @brief Allocate memory from the specified virtual region. | ||
|
|
@@ -80,12 +82,16 @@ struct vregion *vregion_put(struct vregion *vr); | |
| * @param[in] size Size of memory to allocate in bytes. | ||
| * @return void* Pointer to the allocated memory, or NULL on failure. | ||
| */ | ||
| void *vregion_alloc(struct vregion *vr, size_t size); | ||
| __syscall void *vregion_alloc(struct vregion *vr, size_t size); | ||
|
|
||
| void *z_impl_vregion_alloc(struct vregion *vr, size_t size); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a cost in adding syscalls? Couldn't we just have one vregion_alloc_align_ext(truct vregion *vr, size_t size, size_t alignment, bool coherent) syscall, and then inline functions calling this single syscall?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jsarha adding syscalls is "free," but calling them from the userspace has a cost. The good news is that calling a syscall from the kernel mode is cheap - it resolves to just a thin wrapper around a function call. ATM I'm trying to make everything work with only a minor optimisation effort. I expect a lot of follow-up improvements and optimisations once the functionality is there.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lyakh Good with both options, feel free to modify the commit directly. |
||
|
|
||
| /** | ||
| * @brief like vregion_alloc() but allocates coherent memory | ||
| */ | ||
| void *vregion_alloc_coherent(struct vregion *vr, size_t size); | ||
| __syscall void *vregion_alloc_coherent(struct vregion *vr, size_t size); | ||
|
|
||
| void *z_impl_vregion_alloc_coherent(struct vregion *vr, size_t size); | ||
|
|
||
| /** | ||
| * @brief Allocate aligned memory from the specified virtual region. | ||
|
|
@@ -98,12 +104,16 @@ void *vregion_alloc_coherent(struct vregion *vr, size_t size); | |
| * @param[in] alignment Alignment of memory to allocate in bytes. | ||
| * @return void* Pointer to the allocated memory, or NULL on failure. | ||
| */ | ||
| void *vregion_alloc_align(struct vregion *vr, size_t size, size_t alignment); | ||
| __syscall void *vregion_alloc_align(struct vregion *vr, size_t size, size_t alignment); | ||
|
|
||
| void *z_impl_vregion_alloc_align(struct vregion *vr, size_t size, size_t alignment); | ||
|
|
||
| /** | ||
| * @brief like vregion_alloc_align() but allocates coherent memory | ||
| */ | ||
| void *vregion_alloc_coherent_align(struct vregion *vr, size_t size, size_t alignment); | ||
| __syscall void *vregion_alloc_coherent_align(struct vregion *vr, size_t size, size_t alignment); | ||
|
|
||
| void *z_impl_vregion_alloc_coherent_align(struct vregion *vr, size_t size, size_t alignment); | ||
|
|
||
| /** | ||
| * @brief Free memory allocated from the specified virtual region. | ||
|
|
@@ -113,7 +123,9 @@ void *vregion_alloc_coherent_align(struct vregion *vr, size_t size, size_t align | |
| * @param[in] vr Pointer to the virtual region instance. | ||
| * @param[in] ptr Pointer to the memory to free. | ||
| */ | ||
| void vregion_free(struct vregion *vr, void *ptr); | ||
| __syscall void vregion_free(struct vregion *vr, void *ptr); | ||
|
|
||
| void z_impl_vregion_free(struct vregion *vr, void *ptr); | ||
|
|
||
| /** | ||
| * @brief Log virtual region memory usage. | ||
|
|
@@ -131,6 +143,12 @@ void vregion_info(struct vregion *vr); | |
| */ | ||
| void vregion_mem_info(struct vregion *vr, size_t *size, uintptr_t *start); | ||
|
|
||
| void vregion_owner_set(struct vregion *vr, void *owner); | ||
| void *vregion_owner_get(struct vregion *vr); | ||
| bool vregion_verify(struct vregion *vr); | ||
|
|
||
| #include <zephyr/syscalls/vregion.h> | ||
|
|
||
| #else /* CONFIG_SOF_VREGIONS */ | ||
|
|
||
| struct vregion { | ||
|
|
@@ -174,6 +192,9 @@ static inline void vregion_mem_info(struct vregion *vr, size_t *size, uintptr_t | |
| if (size) | ||
| *size = 0; | ||
| } | ||
| static inline void vregion_owner_set(struct vregion *vr, void *owner) {} | ||
| static inline void *vregion_owner_get(struct vregion *vr) {return NULL;} | ||
| static inline bool vregion_verify(struct vregion *vr) {return false;} | ||
|
|
||
| #endif /* CONFIG_SOF_VREGIONS */ | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.