Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion soc/nordic/common/dmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
struct dmm_heap {
struct sys_heap heap;
const struct dmm_region *region;
struct k_spinlock lock;
};

static const struct dmm_region dmm_regions[] = {
Expand All @@ -54,6 +55,7 @@
struct dmm_heap dmm_heaps[ARRAY_SIZE(dmm_regions)];
} dmm_heaps_data;


Check notice on line 58 in soc/nordic/common/dmm.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

soc/nordic/common/dmm.c:58 -
static struct dmm_heap *dmm_heap_find(void *region)
{
struct dmm_heap *dh;
Expand Down Expand Up @@ -113,13 +115,25 @@

static void *dmm_buffer_alloc(struct dmm_heap *dh, size_t length)
{
void *ret;
k_spinlock_key_t key;

length = ROUND_UP(length, dh->region->dt_align);
return sys_heap_aligned_alloc(&dh->heap, dh->region->dt_align, length);

key = k_spin_lock(&dh->lock);
ret = sys_heap_aligned_alloc(&dh->heap, dh->region->dt_align, length);
k_spin_unlock(&dh->lock, key);

return ret;
}

static void dmm_buffer_free(struct dmm_heap *dh, void *buffer)
{
k_spinlock_key_t key;

key = k_spin_lock(&dh->lock);
sys_heap_free(&dh->heap, buffer);
k_spin_unlock(&dh->lock, key);
}

int dmm_buffer_out_prepare(void *region, void const *user_buffer, size_t user_length,
Expand Down
Loading