|
28 | 28 | struct sof_fast_get_entry { |
29 | 29 | const void *dram_ptr; |
30 | 30 | void *sram_ptr; |
31 | | -#if CONFIG_USERSPACE |
32 | | - struct k_mem_domain *mdom; |
33 | | -#endif |
34 | 31 | size_t size; |
35 | 32 | unsigned int refcount; |
36 | 33 | }; |
@@ -103,10 +100,8 @@ static struct sof_fast_get_entry *fast_get_find_entry(struct sof_fast_get_data * |
103 | 100 | #endif |
104 | 101 |
|
105 | 102 | #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) |
107 | 104 | { |
108 | | - struct k_mem_domain *domain = thread->mem_domain_info.mem_domain; |
109 | | - |
110 | 105 | for (unsigned int i = 0; i < domain->num_partitions; i++) { |
111 | 106 | struct k_mem_partition *dpart = &domain->partitions[i]; |
112 | 107 |
|
@@ -190,11 +185,9 @@ const void *fast_get(struct k_heap *heap, const void *dram_ptr, size_t size) |
190 | 185 | * enabled userspace don't create fast-get entries |
191 | 186 | */ |
192 | 187 | 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, |
195 | 189 | 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); |
198 | 191 |
|
199 | 192 | int err = fast_get_access_grant(mdom, ret, size); |
200 | 193 |
|
@@ -233,10 +226,10 @@ const void *fast_get(struct k_heap *heap, const void *dram_ptr, size_t size) |
233 | 226 | dcache_writeback_region((__sparse_force void __sparse_cache *)entry->sram_ptr, size); |
234 | 227 |
|
235 | 228 | #if CONFIG_USERSPACE |
236 | | - entry->mdom = k_current_get()->mem_domain_info.mem_domain; |
237 | 229 | if (size > FAST_GET_MAX_COPY_SIZE) { |
238 | 230 | /* 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); |
240 | 233 |
|
241 | 234 | if (err < 0) { |
242 | 235 | 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 |
295 | 288 | * For large buffers, each thread that called fast_get() has a partition |
296 | 289 | * in its memory domain. Each thread must remove its own partition here |
297 | 290 | * to prevent partition leaks. |
298 | | - * |
299 | | - * Order matters: free buffer first (needs partition for cache access), |
300 | | - * then remove partition. |
301 | 291 | */ |
302 | | - if (entry->size > FAST_GET_MAX_COPY_SIZE && entry->mdom && mdom) { |
| 292 | + if (entry->size > FAST_GET_MAX_COPY_SIZE && mdom) { |
303 | 293 | struct k_mem_partition part = { |
304 | 294 | .start = (uintptr_t)sram_ptr, |
305 | 295 | .size = ALIGN_UP(entry->size, CONFIG_MM_DRV_PAGE_SIZE), |
|
0 commit comments