@@ -58,12 +58,36 @@ struct comp_dev *module_adapter_new(const struct comp_driver *drv,
5858#endif
5959
6060static struct dp_heap_user * module_adapter_dp_heap_new (const struct comp_ipc_config * config ,
61+ const struct module_ext_init_data * ext_init ,
6162 size_t * heap_size )
6263{
6364 /* src-lite with 8 channels has been seen allocating 14k in one go */
6465 /* FIXME: the size will be derived from configuration */
65- const size_t buf_size = 20 * 1024 ;
66+ size_t buf_size = 20 * 1024 ;
6667
68+ #if CONFIG_IPC_MAJOR_4
69+ if (config -> ipc_extended_init && ext_init && ext_init -> dp_data &&
70+ (ext_init -> dp_data -> lifetime_heap_bytes > 0 ||
71+ ext_init -> dp_data -> interim_heap_bytes > 0 )) {
72+ if (ext_init -> dp_data -> lifetime_heap_bytes > 64 * 1024 * 1024 ||
73+ ext_init -> dp_data -> interim_heap_bytes > 64 * 1024 * 1024 ) {
74+ comp_cl_err (drv , "Insanely large lifetime %u or interim %u heap size" ,
75+ ext_init -> dp_data -> lifetime_heap_bytes ,
76+ ext_init -> dp_data -> interim_heap_bytes );
77+ return NULL ;
78+ }
79+
80+ /*
81+ * For the moment there is only one heap so sum up
82+ * lifetime and interim values. It is also a conscious
83+ * decision here to count the size of struct
84+ * dp_heap_user to be included into required heap
85+ * size.
86+ */
87+ buf_size = ext_init -> dp_data -> lifetime_heap_bytes +
88+ ext_init -> dp_data -> interim_heap_bytes ;
89+ }
90+ #endif
6791 /* Keep uncached to match the default SOF heap! */
6892 uint8_t * mod_heap_mem = rballoc_align (SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT ,
6993 buf_size , PAGE_SZ );
@@ -86,8 +110,10 @@ static struct dp_heap_user *module_adapter_dp_heap_new(const struct comp_ipc_con
86110 return mod_heap_user ;
87111}
88112
89- static struct processing_module * module_adapter_mem_alloc (const struct comp_driver * drv ,
90- const struct comp_ipc_config * config )
113+ static
114+ struct processing_module * module_adapter_mem_alloc (const struct comp_driver * drv ,
115+ const struct comp_ipc_config * config ,
116+ const struct module_ext_init_data * ext_init )
91117{
92118 struct k_heap * mod_heap ;
93119 /*
@@ -104,7 +130,7 @@ static struct processing_module *module_adapter_mem_alloc(const struct comp_driv
104130
105131 if (config -> proc_domain == COMP_PROCESSING_DOMAIN_DP && IS_ENABLED (CONFIG_USERSPACE ) &&
106132 !IS_ENABLED (CONFIG_SOF_USERSPACE_USE_DRIVER_HEAP )) {
107- mod_heap_user = module_adapter_dp_heap_new (config , & heap_size );
133+ mod_heap_user = module_adapter_dp_heap_new (config , ext_init , & heap_size );
108134 if (!mod_heap_user ) {
109135 comp_cl_err (drv , "Failed to allocate DP module heap" );
110136 return NULL ;
@@ -220,8 +246,14 @@ struct comp_dev *module_adapter_new_ext(const struct comp_driver *drv,
220246 return NULL ;
221247 }
222248#endif
249+ const struct module_ext_init_data * ext_init =
250+ #if CONFIG_IPC_MAJOR_4
251+ & ext_data ;
252+ #else
253+ NULL ;
254+ #endif
223255
224- struct processing_module * mod = module_adapter_mem_alloc (drv , config );
256+ struct processing_module * mod = module_adapter_mem_alloc (drv , config , ext_init );
225257
226258 if (!mod )
227259 return NULL ;
0 commit comments