Skip to content

Commit ba65768

Browse files
lyakhkv2019i
authored andcommitted
vregion: make two functions inline
Make vregion_alloc() and vregion_alloc_coherent() static inlines, calling their respective aligned versions with zero alignment. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent c6080f4 commit ba65768

3 files changed

Lines changed: 18 additions & 57 deletions

File tree

‎src/include/sof/lib/vregion.h‎

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,36 +83,42 @@ __syscall struct vregion *vregion_get(struct vregion *vr);
8383
__syscall struct vregion *vregion_put(struct vregion *vr);
8484

8585
/**
86-
* @brief Allocate memory from the specified virtual region.
86+
* @brief Allocate aligned memory from the specified virtual region.
87+
*
88+
* Allocate aligned memory from the specified virtual region using the
89+
* current allocation mode (lifetime or interim).
8790
*
8891
* @param[in] vr Pointer to the virtual region instance.
8992
* @param[in] size Size of memory to allocate in bytes.
93+
* @param[in] alignment Alignment of memory to allocate in bytes.
9094
* @return void* Pointer to the allocated memory, or NULL on failure.
9195
*/
92-
__syscall void *vregion_alloc(struct vregion *vr, size_t size);
96+
__syscall void *vregion_alloc_align(struct vregion *vr, size_t size, size_t alignment);
9397

9498
/**
95-
* @brief like vregion_alloc() but allocates coherent memory
99+
* @brief like vregion_alloc_align() but allocates coherent memory
96100
*/
97-
__syscall void *vregion_alloc_coherent(struct vregion *vr, size_t size);
101+
__syscall void *vregion_alloc_coherent_align(struct vregion *vr, size_t size, size_t alignment);
98102

99103
/**
100-
* @brief Allocate aligned memory from the specified virtual region.
101-
*
102-
* Allocate aligned memory from the specified virtual region using the
103-
* current allocation mode (lifetime or interim).
104+
* @brief Allocate memory from the specified virtual region.
104105
*
105106
* @param[in] vr Pointer to the virtual region instance.
106107
* @param[in] size Size of memory to allocate in bytes.
107-
* @param[in] alignment Alignment of memory to allocate in bytes.
108108
* @return void* Pointer to the allocated memory, or NULL on failure.
109109
*/
110-
__syscall void *vregion_alloc_align(struct vregion *vr, size_t size, size_t alignment);
110+
static inline void *vregion_alloc(struct vregion *vr, size_t size)
111+
{
112+
return vregion_alloc_align(vr, size, 0);
113+
}
111114

112115
/**
113-
* @brief like vregion_alloc_align() but allocates coherent memory
116+
* @brief like vregion_alloc() but allocates coherent memory
114117
*/
115-
__syscall void *vregion_alloc_coherent_align(struct vregion *vr, size_t size, size_t alignment);
118+
static inline void *vregion_alloc_coherent(struct vregion *vr, size_t size)
119+
{
120+
return vregion_alloc_coherent_align(vr, size, 0);
121+
}
116122

117123
/**
118124
* @brief Free memory allocated from the specified virtual region.

‎zephyr/lib/vregion.c‎

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -504,33 +504,6 @@ void *z_impl_vregion_alloc_align(struct vregion *vr,
504504
}
505505
EXPORT_SYMBOL(z_impl_vregion_alloc_align);
506506

507-
/**
508-
* @brief Allocate memory from the virtual region.
509-
* @param[in] vr Pointer to the virtual region instance.
510-
* @param[in] size Size of the allocation.
511-
* @return void* Pointer to the allocated memory, or NULL on failure.
512-
*/
513-
void *z_impl_vregion_alloc(struct vregion *vr, size_t size)
514-
{
515-
return z_impl_vregion_alloc_align(vr, size, 0);
516-
}
517-
EXPORT_SYMBOL(z_impl_vregion_alloc);
518-
519-
void *z_impl_vregion_alloc_coherent(struct vregion *vr, size_t size)
520-
{
521-
size = ALIGN_UP(size, CONFIG_DCACHE_LINE_SIZE);
522-
523-
void *p = z_impl_vregion_alloc_align(vr, size, CONFIG_DCACHE_LINE_SIZE);
524-
525-
if (!p)
526-
return NULL;
527-
528-
sys_cache_data_invd_range(p, size);
529-
530-
return sys_cache_uncached_ptr_get(p);
531-
}
532-
EXPORT_SYMBOL(z_impl_vregion_alloc_coherent);
533-
534507
void *z_impl_vregion_alloc_coherent_align(struct vregion *vr, size_t size, size_t alignment)
535508
{
536509
if (alignment < CONFIG_DCACHE_LINE_SIZE)

‎zephyr/syscall/vregion.c‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,6 @@
66
#include <zephyr/kernel.h>
77
#include <zephyr/internal/syscall_handler.h>
88

9-
static inline void *z_vrfy_vregion_alloc(struct vregion *vr, size_t size)
10-
{
11-
if (vregion_verify(vr))
12-
return z_impl_vregion_alloc(vr, size);
13-
14-
return NULL;
15-
}
16-
#include <zephyr/syscalls/vregion_alloc_mrsh.c>
17-
18-
static inline void *z_vrfy_vregion_alloc_coherent(struct vregion *vr, size_t size)
19-
{
20-
if (vregion_verify(vr))
21-
return z_impl_vregion_alloc_coherent(vr, size);
22-
23-
return NULL;
24-
}
25-
#include <zephyr/syscalls/vregion_alloc_coherent_mrsh.c>
26-
279
static inline void *z_vrfy_vregion_alloc_align(struct vregion *vr, size_t size, size_t alignment)
2810
{
2911
if (vregion_verify(vr))

0 commit comments

Comments
 (0)