Skip to content

Commit dd5042e

Browse files
3V3RYONEgregkh
authored andcommitted
remoteproc: k3-r5: Do not allow core1 to power up before core0 via sysfs
commit 3c8a906 upstream. PSC controller has a limitation that it can only power-up the second core when the first core is in ON state. Power-state for core0 should be equal to or higher than core1. Therefore, prevent core1 from powering up before core0 during the start process from sysfs. Similarly, prevent core0 from shutting down before core1 has been shut down from sysfs. Fixes: 6dedbd1 ("remoteproc: k3-r5: Add a remoteproc driver for R5F subsystem") Signed-off-by: Beleswar Padhi <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mathieu Poirier <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2a1ec20 commit dd5042e

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

drivers/remoteproc/ti_k3_r5_remoteproc.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ static int k3_r5_rproc_start(struct rproc *rproc)
543543
struct k3_r5_rproc *kproc = rproc->priv;
544544
struct k3_r5_cluster *cluster = kproc->cluster;
545545
struct device *dev = kproc->dev;
546-
struct k3_r5_core *core;
546+
struct k3_r5_core *core0, *core;
547547
u32 boot_addr;
548548
int ret;
549549

@@ -569,6 +569,15 @@ static int k3_r5_rproc_start(struct rproc *rproc)
569569
goto unroll_core_run;
570570
}
571571
} else {
572+
/* do not allow core 1 to start before core 0 */
573+
core0 = list_first_entry(&cluster->cores, struct k3_r5_core,
574+
elem);
575+
if (core != core0 && core0->rproc->state == RPROC_OFFLINE) {
576+
dev_err(dev, "%s: can not start core 1 before core 0\n",
577+
__func__);
578+
return -EPERM;
579+
}
580+
572581
ret = k3_r5_core_run(core);
573582
if (ret)
574583
goto put_mbox;
@@ -614,7 +623,8 @@ static int k3_r5_rproc_stop(struct rproc *rproc)
614623
{
615624
struct k3_r5_rproc *kproc = rproc->priv;
616625
struct k3_r5_cluster *cluster = kproc->cluster;
617-
struct k3_r5_core *core = kproc->core;
626+
struct device *dev = kproc->dev;
627+
struct k3_r5_core *core1, *core = kproc->core;
618628
int ret;
619629

620630
/* halt all applicable cores */
@@ -627,6 +637,15 @@ static int k3_r5_rproc_stop(struct rproc *rproc)
627637
}
628638
}
629639
} else {
640+
/* do not allow core 0 to stop before core 1 */
641+
core1 = list_last_entry(&cluster->cores, struct k3_r5_core,
642+
elem);
643+
if (core != core1 && core1->rproc->state != RPROC_OFFLINE) {
644+
dev_err(dev, "%s: can not stop core 0 before core 1\n",
645+
__func__);
646+
return -EPERM;
647+
}
648+
630649
ret = k3_r5_core_halt(core);
631650
if (ret)
632651
goto out;

0 commit comments

Comments
 (0)