@@ -115,6 +115,10 @@ static void k3_dsp_rproc_mbox_callback(struct mbox_client *client, void *data)
115115 const char * name = kproc -> rproc -> name ;
116116 u32 msg = omap_mbox_message (data );
117117
118+ /* Do not forward messages from a detached core */
119+ if (kproc -> rproc -> state == RPROC_DETACHED )
120+ return ;
121+
118122 dev_dbg (dev , "mbox msg: 0x%x\n" , msg );
119123
120124 switch (msg ) {
@@ -155,6 +159,10 @@ static void k3_dsp_rproc_kick(struct rproc *rproc, int vqid)
155159 mbox_msg_t msg = (mbox_msg_t )vqid ;
156160 int ret ;
157161
162+ /* Do not forward messages to a detached core */
163+ if (kproc -> rproc -> state == RPROC_DETACHED )
164+ return ;
165+
158166 /* send the index of the triggered virtqueue in the mailbox payload */
159167 ret = mbox_send_message (kproc -> mbox , (void * )msg );
160168 if (ret < 0 )
@@ -230,12 +238,9 @@ static int k3_dsp_rproc_request_mbox(struct rproc *rproc)
230238 client -> knows_txdone = false;
231239
232240 kproc -> mbox = mbox_request_channel (client , 0 );
233- if (IS_ERR (kproc -> mbox )) {
234- ret = - EBUSY ;
235- dev_err (dev , "mbox_request_channel failed: %ld\n" ,
236- PTR_ERR (kproc -> mbox ));
237- return ret ;
238- }
241+ if (IS_ERR (kproc -> mbox ))
242+ return dev_err_probe (dev , PTR_ERR (kproc -> mbox ),
243+ "mbox_request_channel failed\n" );
239244
240245 /*
241246 * Ping the remote processor, this is only for sanity-sake for now;
@@ -315,32 +320,23 @@ static int k3_dsp_rproc_start(struct rproc *rproc)
315320 u32 boot_addr ;
316321 int ret ;
317322
318- ret = k3_dsp_rproc_request_mbox (rproc );
319- if (ret )
320- return ret ;
321-
322323 boot_addr = rproc -> bootaddr ;
323324 if (boot_addr & (kproc -> data -> boot_align_addr - 1 )) {
324325 dev_err (dev , "invalid boot address 0x%x, must be aligned on a 0x%x boundary\n" ,
325326 boot_addr , kproc -> data -> boot_align_addr );
326- ret = - EINVAL ;
327- goto put_mbox ;
327+ return - EINVAL ;
328328 }
329329
330330 dev_dbg (dev , "booting DSP core using boot addr = 0x%x\n" , boot_addr );
331331 ret = ti_sci_proc_set_config (kproc -> tsp , boot_addr , 0 , 0 );
332332 if (ret )
333- goto put_mbox ;
333+ return ret ;
334334
335335 ret = k3_dsp_rproc_release (kproc );
336336 if (ret )
337- goto put_mbox ;
337+ return ret ;
338338
339339 return 0 ;
340-
341- put_mbox :
342- mbox_free_channel (kproc -> mbox );
343- return ret ;
344340}
345341
346342/*
@@ -353,8 +349,6 @@ static int k3_dsp_rproc_stop(struct rproc *rproc)
353349{
354350 struct k3_dsp_rproc * kproc = rproc -> priv ;
355351
356- mbox_free_channel (kproc -> mbox );
357-
358352 k3_dsp_rproc_reset (kproc );
359353
360354 return 0 ;
@@ -363,42 +357,22 @@ static int k3_dsp_rproc_stop(struct rproc *rproc)
363357/*
364358 * Attach to a running DSP remote processor (IPC-only mode)
365359 *
366- * This rproc attach callback only needs to request the mailbox, the remote
367- * processor is already booted, so there is no need to issue any TI-SCI
368- * commands to boot the DSP core. This callback is invoked only in IPC-only
369- * mode.
360+ * This rproc attach callback is a NOP. The remote processor is already booted,
361+ * and all required resources have been acquired during probe routine, so there
362+ * is no need to issue any TI-SCI commands to boot the DSP core. This callback
363+ * is invoked only in IPC-only mode and exists because rproc_validate() checks
364+ * for its existence.
370365 */
371- static int k3_dsp_rproc_attach (struct rproc * rproc )
372- {
373- struct k3_dsp_rproc * kproc = rproc -> priv ;
374- struct device * dev = kproc -> dev ;
375- int ret ;
376-
377- ret = k3_dsp_rproc_request_mbox (rproc );
378- if (ret )
379- return ret ;
380-
381- dev_info (dev , "DSP initialized in IPC-only mode\n" );
382- return 0 ;
383- }
366+ static int k3_dsp_rproc_attach (struct rproc * rproc ) { return 0 ; }
384367
385368/*
386369 * Detach from a running DSP remote processor (IPC-only mode)
387370 *
388- * This rproc detach callback performs the opposite operation to attach callback
389- * and only needs to release the mailbox, the DSP core is not stopped and will
390- * be left to continue to run its booted firmware. This callback is invoked only
391- * in IPC-only mode.
371+ * This rproc detach callback is a NOP. The DSP core is not stopped and will be
372+ * left to continue to run its booted firmware. This callback is invoked only in
373+ * IPC-only mode and exists for sanity sake.
392374 */
393- static int k3_dsp_rproc_detach (struct rproc * rproc )
394- {
395- struct k3_dsp_rproc * kproc = rproc -> priv ;
396- struct device * dev = kproc -> dev ;
397-
398- mbox_free_channel (kproc -> mbox );
399- dev_info (dev , "DSP deinitialized in IPC-only mode\n" );
400- return 0 ;
401- }
375+ static int k3_dsp_rproc_detach (struct rproc * rproc ) { return 0 ; }
402376
403377/*
404378 * This function implements the .get_loaded_rsc_table() callback and is used
@@ -697,6 +671,10 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)
697671 kproc -> dev = dev ;
698672 kproc -> data = data ;
699673
674+ ret = k3_dsp_rproc_request_mbox (rproc );
675+ if (ret )
676+ return ret ;
677+
700678 kproc -> ti_sci = devm_ti_sci_get_by_phandle (dev , "ti,sci" );
701679 if (IS_ERR (kproc -> ti_sci ))
702680 return dev_err_probe (dev , PTR_ERR (kproc -> ti_sci ),
@@ -789,6 +767,8 @@ static void k3_dsp_rproc_remove(struct platform_device *pdev)
789767 if (ret )
790768 dev_err (dev , "failed to detach proc (%pe)\n" , ERR_PTR (ret ));
791769 }
770+
771+ mbox_free_channel (kproc -> mbox );
792772}
793773
794774static const struct k3_dsp_mem_data c66_mems [] = {
0 commit comments