Skip to content

Commit 59b3204

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 5b4aaa4 commit 59b3204

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

@@ -193,11 +188,9 @@ const void *fast_get(struct k_heap *heap, const void *dram_ptr, size_t size)
193188
* enabled userspace don't create fast-get entries
194189
*/
195190
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,
198192
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);
201194

202195
int err = fast_get_access_grant(mdom, ret, size);
203196

@@ -236,10 +229,10 @@ const void *fast_get(struct k_heap *heap, const void *dram_ptr, size_t size)
236229
dcache_writeback_region((__sparse_force void __sparse_cache *)entry->sram_ptr, size);
237230

238231
#if CONFIG_USERSPACE
239-
entry->mdom = k_current_get()->mem_domain_info.mem_domain;
240232
if (size > FAST_GET_MAX_COPY_SIZE && current_is_userspace) {
241233
/* 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);
243236

244237
if (err < 0) {
245238
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
298291
* For large buffers, each thread that called fast_get() has a partition
299292
* in its memory domain. Each thread must remove its own partition here
300293
* to prevent partition leaks.
301-
*
302-
* Order matters: free buffer first (needs partition for cache access),
303-
* then remove partition.
304294
*/
305-
if (entry->size > FAST_GET_MAX_COPY_SIZE && entry->mdom && mdom) {
295+
if (entry->size > FAST_GET_MAX_COPY_SIZE && mdom) {
306296
struct k_mem_partition part = {
307297
.start = (uintptr_t)sram_ptr,
308298
.size = ALIGN_UP(entry->size, CONFIG_MM_DRV_PAGE_SIZE),

0 commit comments

Comments
 (0)