Skip to content

Commit 0ef48e3

Browse files
committed
fast-get: remove mdom from the entry structure
The mdom member of struct sof_fast_get_entry is redundant, remove it. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 8c6e8d5 commit 0ef48e3

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

zephyr/lib/fast-get.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
struct sof_fast_get_entry {
2929
const void *dram_ptr;
3030
void *sram_ptr;
31-
#if CONFIG_USERSPACE
32-
struct k_mem_domain *mdom;
33-
#endif
3431
size_t size;
3532
unsigned int refcount;
3633
};
@@ -103,10 +100,8 @@ static struct sof_fast_get_entry *fast_get_find_entry(struct sof_fast_get_data *
103100
#endif
104101

105102
#if CONFIG_USERSPACE
106-
static bool fast_get_partition_exists(struct k_thread *thread, void *start, size_t size)
103+
static bool fast_get_partition_exists(struct k_mem_domain *domain, void *start, size_t size)
107104
{
108-
struct k_mem_domain *domain = thread->mem_domain_info.mem_domain;
109-
110105
for (unsigned int i = 0; i < domain->num_partitions; i++) {
111106
struct k_mem_partition *dpart = &domain->partitions[i];
112107

@@ -190,11 +185,9 @@ const void *fast_get(struct k_heap *heap, const void *dram_ptr, size_t size)
190185
* enabled userspace don't create fast-get entries
191186
*/
192187
if (thread_is_userspace(k_current_get())) {
193-
if (mdom != entry->mdom &&
194-
!fast_get_partition_exists(k_current_get(), ret,
188+
if (!fast_get_partition_exists(mdom, ret,
195189
ALIGN_UP(size, CONFIG_MM_DRV_PAGE_SIZE))) {
196-
LOG_DBG("grant access to domain %p first was %p", mdom,
197-
entry->mdom);
190+
LOG_DBG("grant access to domain %p", mdom);
198191

199192
int err = fast_get_access_grant(mdom, ret, size);
200193

@@ -233,10 +226,10 @@ const void *fast_get(struct k_heap *heap, const void *dram_ptr, size_t size)
233226
dcache_writeback_region((__sparse_force void __sparse_cache *)entry->sram_ptr, size);
234227

235228
#if CONFIG_USERSPACE
236-
entry->mdom = k_current_get()->mem_domain_info.mem_domain;
237229
if (size > FAST_GET_MAX_COPY_SIZE) {
238230
/* Otherwise we've allocated on thread's heap, so it already has access */
239-
int err = fast_get_access_grant(entry->mdom, ret, size);
231+
int err = fast_get_access_grant(k_current_get()->mem_domain_info.mem_domain,
232+
ret, size);
240233

241234
if (err < 0) {
242235
LOG_ERR("failed to grant access err=%d", err);
@@ -295,11 +288,8 @@ void fast_put(struct k_heap *heap, struct k_mem_domain *mdom, const void *sram_p
295288
* For large buffers, each thread that called fast_get() has a partition
296289
* in its memory domain. Each thread must remove its own partition here
297290
* to prevent partition leaks.
298-
*
299-
* Order matters: free buffer first (needs partition for cache access),
300-
* then remove partition.
301291
*/
302-
if (entry->size > FAST_GET_MAX_COPY_SIZE && entry->mdom && mdom) {
292+
if (entry->size > FAST_GET_MAX_COPY_SIZE && mdom) {
303293
struct k_mem_partition part = {
304294
.start = (uintptr_t)sram_ptr,
305295
.size = ALIGN_UP(entry->size, CONFIG_MM_DRV_PAGE_SIZE),

0 commit comments

Comments
 (0)