@@ -57,8 +57,8 @@ struct comp_dev *module_adapter_new(const struct comp_driver *drv,
5757#define PAGE_SZ HOST_PAGE_SIZE
5858#endif
5959
60- static struct dp_heap_user * module_adapter_dp_heap_new (const struct comp_ipc_config * config ,
61- size_t * heap_size )
60+ static struct k_heap * module_adapter_dp_heap_new (const struct comp_ipc_config * config ,
61+ size_t * heap_size )
6262{
6363 /* src-lite with 8 channels has been seen allocating 14k in one go */
6464 /* FIXME: the size will be derived from configuration */
@@ -71,9 +71,8 @@ static struct dp_heap_user *module_adapter_dp_heap_new(const struct comp_ipc_con
7171 if (!mod_heap_mem )
7272 return NULL ;
7373
74- struct dp_heap_user * mod_heap_user = (struct dp_heap_user * )mod_heap_mem ;
75- struct k_heap * mod_heap = & mod_heap_user -> heap ;
76- const size_t heap_prefix_size = ALIGN_UP (sizeof (* mod_heap_user ), 4 );
74+ struct k_heap * mod_heap = (struct k_heap * )mod_heap_mem ;
75+ const size_t heap_prefix_size = ALIGN_UP (sizeof (* mod_heap ), 4 );
7776 void * mod_heap_buf = mod_heap_mem + heap_prefix_size ;
7877
7978 * heap_size = buf_size - heap_prefix_size ;
@@ -83,7 +82,7 @@ static struct dp_heap_user *module_adapter_dp_heap_new(const struct comp_ipc_con
8382 mod_heap -> heap .init_bytes = * heap_size ;
8483#endif
8584
86- return mod_heap_user ;
85+ return mod_heap ;
8786}
8887
8988static struct processing_module * module_adapter_mem_alloc (const struct comp_driver * drv ,
@@ -99,20 +98,17 @@ static struct processing_module *module_adapter_mem_alloc(const struct comp_driv
9998 */
10099 uint32_t flags = config -> proc_domain == COMP_PROCESSING_DOMAIN_DP ?
101100 SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT : SOF_MEM_FLAG_USER ;
102- struct dp_heap_user * mod_heap_user ;
103101 size_t heap_size ;
104102
105103 if (config -> proc_domain == COMP_PROCESSING_DOMAIN_DP && IS_ENABLED (CONFIG_USERSPACE ) &&
106104 !IS_ENABLED (CONFIG_SOF_USERSPACE_USE_DRIVER_HEAP )) {
107- mod_heap_user = module_adapter_dp_heap_new (config , & heap_size );
108- if (!mod_heap_user ) {
105+ mod_heap = module_adapter_dp_heap_new (config , & heap_size );
106+ if (!mod_heap ) {
109107 comp_cl_err (drv , "Failed to allocate DP module heap" );
110108 return NULL ;
111109 }
112- mod_heap = & mod_heap_user -> heap ;
113110 } else {
114111 mod_heap = drv -> user_heap ;
115- mod_heap_user = NULL ;
116112 heap_size = 0 ;
117113 }
118114
@@ -123,9 +119,10 @@ static struct processing_module *module_adapter_mem_alloc(const struct comp_driv
123119 goto emod ;
124120 }
125121
122+ struct sof_alloc_api * alloc = & mod -> priv .resources .alloc ;
123+
126124 memset (mod , 0 , sizeof (* mod ));
127- mod -> priv .resources .alloc .heap = mod_heap ;
128- mod -> priv .resources .alloc .client = mod_heap_user ;
125+ alloc -> heap = mod_heap ;
129126 mod_resource_init (mod );
130127
131128 /*
@@ -147,22 +144,23 @@ static struct processing_module *module_adapter_mem_alloc(const struct comp_driv
147144 mod -> dev = dev ;
148145 dev -> mod = mod ;
149146
150- if (mod_heap_user )
151- mod_heap_user -> client_count ++ ;
147+ if (config -> proc_domain == COMP_PROCESSING_DOMAIN_DP )
148+ alloc -> client_count ++ ;
152149
153150 return mod ;
154151
155152err :
156153 sof_heap_free (mod_heap , mod );
157154emod :
158- rfree (mod_heap_user );
155+ rfree (mod_heap );
159156
160157 return NULL ;
161158}
162159
163160static void module_adapter_mem_free (struct processing_module * mod )
164161{
165- struct k_heap * mod_heap = mod -> priv .resources .alloc .heap ;
162+ struct sof_alloc_api * alloc = & mod -> priv .resources .alloc ;
163+ struct k_heap * mod_heap = alloc -> heap ;
166164 unsigned int domain = mod -> dev -> ipc_config .proc_domain ;
167165
168166 /*
@@ -174,13 +172,8 @@ static void module_adapter_mem_free(struct processing_module *mod)
174172#endif
175173 sof_heap_free (mod_heap , mod -> dev );
176174 sof_heap_free (mod_heap , mod );
177- if (domain == COMP_PROCESSING_DOMAIN_DP ) {
178- struct dp_heap_user * mod_heap_user = container_of (mod_heap , struct dp_heap_user ,
179- heap );
180-
181- if (mod_heap && !-- mod_heap_user -> client_count )
182- rfree (mod_heap_user );
183- }
175+ if (domain == COMP_PROCESSING_DOMAIN_DP && mod_heap && !-- alloc -> client_count )
176+ rfree (mod_heap );
184177}
185178
186179/*
@@ -626,7 +619,7 @@ int module_adapter_prepare(struct comp_dev *dev)
626619
627620 if (md -> resources .alloc .heap &&
628621 md -> resources .alloc .heap != dev -> drv -> user_heap )
629- md -> resources .alloc .client -> client_count ++ ;
622+ md -> resources .alloc .client_count ++ ;
630623
631624 irq_local_disable (flags );
632625 list_item_prepend (& buffer -> buffers_list , & mod -> raw_data_buffers_list );
0 commit comments