@@ -194,6 +194,10 @@ static void k3_r5_rproc_mbox_callback(struct mbox_client *client, void *data)
194
194
const char * name = kproc -> rproc -> name ;
195
195
u32 msg = omap_mbox_message (data );
196
196
197
+ /* Do not forward message from a detached core */
198
+ if (kproc -> rproc -> state == RPROC_DETACHED )
199
+ return ;
200
+
197
201
dev_dbg (dev , "mbox msg: 0x%x\n" , msg );
198
202
199
203
switch (msg ) {
@@ -229,6 +233,10 @@ static void k3_r5_rproc_kick(struct rproc *rproc, int vqid)
229
233
mbox_msg_t msg = (mbox_msg_t )vqid ;
230
234
int ret ;
231
235
236
+ /* Do not forward message to a detached core */
237
+ if (kproc -> rproc -> state == RPROC_DETACHED )
238
+ return ;
239
+
232
240
/* send the index of the triggered virtqueue in the mailbox payload */
233
241
ret = mbox_send_message (kproc -> mbox , (void * )msg );
234
242
if (ret < 0 )
@@ -399,12 +407,9 @@ static int k3_r5_rproc_request_mbox(struct rproc *rproc)
399
407
client -> knows_txdone = false;
400
408
401
409
kproc -> mbox = mbox_request_channel (client , 0 );
402
- if (IS_ERR (kproc -> mbox )) {
403
- ret = - EBUSY ;
404
- dev_err (dev , "mbox_request_channel failed: %ld\n" ,
405
- PTR_ERR (kproc -> mbox ));
406
- return ret ;
407
- }
410
+ if (IS_ERR (kproc -> mbox ))
411
+ return dev_err_probe (dev , PTR_ERR (kproc -> mbox ),
412
+ "mbox_request_channel failed\n" );
408
413
409
414
/*
410
415
* Ping the remote processor, this is only for sanity-sake for now;
@@ -552,10 +557,6 @@ static int k3_r5_rproc_start(struct rproc *rproc)
552
557
u32 boot_addr ;
553
558
int ret ;
554
559
555
- ret = k3_r5_rproc_request_mbox (rproc );
556
- if (ret )
557
- return ret ;
558
-
559
560
boot_addr = rproc -> bootaddr ;
560
561
/* TODO: add boot_addr sanity checking */
561
562
dev_dbg (dev , "booting R5F core using boot addr = 0x%x\n" , boot_addr );
@@ -564,7 +565,7 @@ static int k3_r5_rproc_start(struct rproc *rproc)
564
565
core = kproc -> core ;
565
566
ret = ti_sci_proc_set_config (core -> tsp , boot_addr , 0 , 0 );
566
567
if (ret )
567
- goto put_mbox ;
568
+ return ret ;
568
569
569
570
/* unhalt/run all applicable cores */
570
571
if (cluster -> mode == CLUSTER_MODE_LOCKSTEP ) {
@@ -580,13 +581,12 @@ static int k3_r5_rproc_start(struct rproc *rproc)
580
581
if (core != core0 && core0 -> rproc -> state == RPROC_OFFLINE ) {
581
582
dev_err (dev , "%s: can not start core 1 before core 0\n" ,
582
583
__func__ );
583
- ret = - EPERM ;
584
- goto put_mbox ;
584
+ return - EPERM ;
585
585
}
586
586
587
587
ret = k3_r5_core_run (core );
588
588
if (ret )
589
- goto put_mbox ;
589
+ return ret ;
590
590
}
591
591
592
592
return 0 ;
@@ -596,8 +596,6 @@ static int k3_r5_rproc_start(struct rproc *rproc)
596
596
if (k3_r5_core_halt (core ))
597
597
dev_warn (core -> dev , "core halt back failed\n" );
598
598
}
599
- put_mbox :
600
- mbox_free_channel (kproc -> mbox );
601
599
return ret ;
602
600
}
603
601
@@ -658,8 +656,6 @@ static int k3_r5_rproc_stop(struct rproc *rproc)
658
656
goto out ;
659
657
}
660
658
661
- mbox_free_channel (kproc -> mbox );
662
-
663
659
return 0 ;
664
660
665
661
unroll_core_halt :
@@ -674,42 +670,22 @@ static int k3_r5_rproc_stop(struct rproc *rproc)
674
670
/*
675
671
* Attach to a running R5F remote processor (IPC-only mode)
676
672
*
677
- * The R5F attach callback only needs to request the mailbox, the remote
678
- * processor is already booted, so there is no need to issue any TI-SCI
679
- * commands to boot the R5F cores in IPC-only mode. This callback is invoked
680
- * only in IPC-only mode.
673
+ * The R5F attach callback is a NOP. The remote processor is already booted, and
674
+ * all required resources have been acquired during probe routine, so there is
675
+ * no need to issue any TI-SCI commands to boot the R5F cores in IPC-only mode.
676
+ * This callback is invoked only in IPC-only mode and exists because
677
+ * rproc_validate() checks for its existence.
681
678
*/
682
- static int k3_r5_rproc_attach (struct rproc * rproc )
683
- {
684
- struct k3_r5_rproc * kproc = rproc -> priv ;
685
- struct device * dev = kproc -> dev ;
686
- int ret ;
687
-
688
- ret = k3_r5_rproc_request_mbox (rproc );
689
- if (ret )
690
- return ret ;
691
-
692
- dev_info (dev , "R5F core initialized in IPC-only mode\n" );
693
- return 0 ;
694
- }
679
+ static int k3_r5_rproc_attach (struct rproc * rproc ) { return 0 ; }
695
680
696
681
/*
697
682
* Detach from a running R5F remote processor (IPC-only mode)
698
683
*
699
- * The R5F detach callback performs the opposite operation to attach callback
700
- * and only needs to release the mailbox, the R5F cores are not stopped and
701
- * will be left in booted state in IPC-only mode. This callback is invoked
702
- * only in IPC-only mode.
684
+ * The R5F detach callback is a NOP. The R5F cores are not stopped and will be
685
+ * left in booted state in IPC-only mode. This callback is invoked only in
686
+ * IPC-only mode and exists for sanity sake.
703
687
*/
704
- static int k3_r5_rproc_detach (struct rproc * rproc )
705
- {
706
- struct k3_r5_rproc * kproc = rproc -> priv ;
707
- struct device * dev = kproc -> dev ;
708
-
709
- mbox_free_channel (kproc -> mbox );
710
- dev_info (dev , "R5F core deinitialized in IPC-only mode\n" );
711
- return 0 ;
712
- }
688
+ static int k3_r5_rproc_detach (struct rproc * rproc ) { return 0 ; }
713
689
714
690
/*
715
691
* This function implements the .get_loaded_rsc_table() callback and is used
@@ -1278,6 +1254,10 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev)
1278
1254
kproc -> rproc = rproc ;
1279
1255
core -> rproc = rproc ;
1280
1256
1257
+ ret = k3_r5_rproc_request_mbox (rproc );
1258
+ if (ret )
1259
+ return ret ;
1260
+
1281
1261
ret = k3_r5_rproc_configure_mode (kproc );
1282
1262
if (ret < 0 )
1283
1263
goto out ;
@@ -1392,6 +1372,8 @@ static void k3_r5_cluster_rproc_exit(void *data)
1392
1372
}
1393
1373
}
1394
1374
1375
+ mbox_free_channel (kproc -> mbox );
1376
+
1395
1377
rproc_del (rproc );
1396
1378
1397
1379
k3_r5_reserved_mem_exit (kproc );
0 commit comments