|
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 |
|
@@ -193,11 +188,9 @@ const void *fast_get(struct k_heap *heap, const void *dram_ptr, size_t size) |
193 | 188 | * enabled userspace don't create fast-get entries |
194 | 189 | */ |
195 | 190 | if (current_is_userspace) { |
196 | | - if (mdom != entry->mdom && |
197 | | - !fast_get_partition_exists(k_current_get(), ret, |
| 191 | + if (!fast_get_partition_exists(mdom, ret, |
198 | 192 | ALIGN_UP(size, CONFIG_MM_DRV_PAGE_SIZE))) { |
199 | | - LOG_DBG("grant access to domain %p first was %p", mdom, |
200 | | - entry->mdom); |
| 193 | + LOG_DBG("grant access to domain %p", mdom); |
201 | 194 |
|
202 | 195 | int err = fast_get_access_grant(mdom, ret, size); |
203 | 196 |
|
@@ -236,10 +229,10 @@ const void *fast_get(struct k_heap *heap, const void *dram_ptr, size_t size) |
236 | 229 | dcache_writeback_region((__sparse_force void __sparse_cache *)entry->sram_ptr, size); |
237 | 230 |
|
238 | 231 | #if CONFIG_USERSPACE |
239 | | - entry->mdom = k_current_get()->mem_domain_info.mem_domain; |
240 | 232 | if (size > FAST_GET_MAX_COPY_SIZE && current_is_userspace) { |
241 | 233 | /* Otherwise we've allocated on thread's heap, so it already has access */ |
242 | | - int err = fast_get_access_grant(entry->mdom, ret, size); |
| 234 | + int err = fast_get_access_grant(k_current_get()->mem_domain_info.mem_domain, |
| 235 | + ret, size); |
243 | 236 |
|
244 | 237 | if (err < 0) { |
245 | 238 | LOG_ERR("failed to grant access err=%d", err); |
@@ -298,11 +291,8 @@ void fast_put(struct k_heap *heap, struct k_mem_domain *mdom, const void *sram_p |
298 | 291 | * For large buffers, each thread that called fast_get() has a partition |
299 | 292 | * in its memory domain. Each thread must remove its own partition here |
300 | 293 | * to prevent partition leaks. |
301 | | - * |
302 | | - * Order matters: free buffer first (needs partition for cache access), |
303 | | - * then remove partition. |
304 | 294 | */ |
305 | | - if (entry->size > FAST_GET_MAX_COPY_SIZE && entry->mdom && mdom) { |
| 295 | + if (entry->size > FAST_GET_MAX_COPY_SIZE && mdom) { |
306 | 296 | struct k_mem_partition part = { |
307 | 297 | .start = (uintptr_t)sram_ptr, |
308 | 298 | .size = ALIGN_UP(entry->size, CONFIG_MM_DRV_PAGE_SIZE), |
|
0 commit comments