Skip to content

Commit 2a1ec20

Browse files
Apurva Nandangregkh
authored andcommitted
remoteproc: k3-r5: Wait for core0 power-up before powering up core1
commit 61f6f68 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, else the kernel is seen hanging during rproc loading. Make the powering up of cores sequential, by waiting for the current core to power-up before proceeding to the next core, with a timeout of 2sec. Add a wait queue event in k3_r5_cluster_rproc_init call, that will wait for the current core to be released from reset before proceeding with the next core. Fixes: 6dedbd1 ("remoteproc: k3-r5: Add a remoteproc driver for R5F subsystem") Signed-off-by: Apurva Nandan <[email protected]> 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 f6a426a commit 2a1ec20

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

drivers/remoteproc/ti_k3_r5_remoteproc.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,14 @@ struct k3_r5_soc_data {
9898
* @dev: cached device pointer
9999
* @mode: Mode to configure the Cluster - Split or LockStep
100100
* @cores: list of R5 cores within the cluster
101+
* @core_transition: wait queue to sync core state changes
101102
* @soc_data: SoC-specific feature data for a R5FSS
102103
*/
103104
struct k3_r5_cluster {
104105
struct device *dev;
105106
enum cluster_mode mode;
106107
struct list_head cores;
108+
wait_queue_head_t core_transition;
107109
const struct k3_r5_soc_data *soc_data;
108110
};
109111

@@ -123,6 +125,7 @@ struct k3_r5_cluster {
123125
* @atcm_enable: flag to control ATCM enablement
124126
* @btcm_enable: flag to control BTCM enablement
125127
* @loczrama: flag to dictate which TCM is at device address 0x0
128+
* @released_from_reset: flag to signal when core is out of reset
126129
*/
127130
struct k3_r5_core {
128131
struct list_head elem;
@@ -139,6 +142,7 @@ struct k3_r5_core {
139142
u32 atcm_enable;
140143
u32 btcm_enable;
141144
u32 loczrama;
145+
bool released_from_reset;
142146
};
143147

144148
/**
@@ -455,6 +459,8 @@ static int k3_r5_rproc_prepare(struct rproc *rproc)
455459
ret);
456460
return ret;
457461
}
462+
core->released_from_reset = true;
463+
wake_up_interruptible(&cluster->core_transition);
458464

459465
/*
460466
* Newer IP revisions like on J7200 SoCs support h/w auto-initialization
@@ -1137,6 +1143,12 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc)
11371143
return ret;
11381144
}
11391145

1146+
/*
1147+
* Skip the waiting mechanism for sequential power-on of cores if the
1148+
* core has already been booted by another entity.
1149+
*/
1150+
core->released_from_reset = c_state;
1151+
11401152
ret = ti_sci_proc_get_status(core->tsp, &boot_vec, &cfg, &ctrl,
11411153
&stat);
11421154
if (ret < 0) {
@@ -1273,6 +1285,26 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev)
12731285
if (cluster->mode == CLUSTER_MODE_LOCKSTEP ||
12741286
cluster->mode == CLUSTER_MODE_SINGLECPU)
12751287
break;
1288+
1289+
/*
1290+
* R5 cores require to be powered on sequentially, core0
1291+
* should be in higher power state than core1 in a cluster
1292+
* So, wait for current core to power up before proceeding
1293+
* to next core and put timeout of 2sec for each core.
1294+
*
1295+
* This waiting mechanism is necessary because
1296+
* rproc_auto_boot_callback() for core1 can be called before
1297+
* core0 due to thread execution order.
1298+
*/
1299+
ret = wait_event_interruptible_timeout(cluster->core_transition,
1300+
core->released_from_reset,
1301+
msecs_to_jiffies(2000));
1302+
if (ret <= 0) {
1303+
dev_err(dev,
1304+
"Timed out waiting for %s core to power up!\n",
1305+
rproc->name);
1306+
return ret;
1307+
}
12761308
}
12771309

12781310
return 0;
@@ -1708,6 +1740,7 @@ static int k3_r5_probe(struct platform_device *pdev)
17081740
CLUSTER_MODE_SPLIT : CLUSTER_MODE_LOCKSTEP;
17091741
cluster->soc_data = data;
17101742
INIT_LIST_HEAD(&cluster->cores);
1743+
init_waitqueue_head(&cluster->core_transition);
17111744

17121745
ret = of_property_read_u32(np, "ti,cluster-mode", &cluster->mode);
17131746
if (ret < 0 && ret != -EINVAL) {

0 commit comments

Comments
 (0)