Skip to content

Commit a8631f6

Browse files
richard-bootlinmathieupoirier
authored andcommitted
remoteproc: k3-r5: Fix IPC-only mode detection
ret variable was used to test reset status, get from reset_control_status() call. But this variable was overwritten by ti_sci_proc_get_status() a few lines bellow. And as ti_sci_proc_get_status() returns 0 or a negative value (in this latter case, followed by a return), the expression !ret was always true, Clearly, this was not what was intended: In the comment above it's said that "requires both local and module resets to be deasserted"; if reset_control_status() returns 0 it means that the reset line is deasserted. So, it's pretty clear that the return value of reset_control_status() was intended to be used instead of ti_sci_proc_get_status() return value. This could lead in an incorrect IPC-only mode detection if reset line is asserted (so reset_control_status() return > 0) and c_state != 0 and halted == 0. In this case, the old code would have detected an IPC-only mode instead of a mismatched mode. Fixes: 1168af4 ("remoteproc: k3-r5: Add support for IPC-only mode for all R5Fs") Signed-off-by: Richard Genoud <richard.genoud@bootlin.com> Reviewed-by: Hari Nagalla <hnagalla@ti.com> Link: https://lore.kernel.org/r/20240621150058.319524-2-richard.genoud@bootlin.com Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
1 parent 67ca3f9 commit a8631f6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

drivers/remoteproc/ti_k3_r5_remoteproc.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,7 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc)
11441144
u32 atcm_enable, btcm_enable, loczrama;
11451145
struct k3_r5_core *core0;
11461146
enum cluster_mode mode = cluster->mode;
1147+
int reset_ctrl_status;
11471148
int ret;
11481149

11491150
core0 = list_first_entry(&cluster->cores, struct k3_r5_core, elem);
@@ -1160,11 +1161,11 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc)
11601161
r_state, c_state);
11611162
}
11621163

1163-
ret = reset_control_status(core->reset);
1164-
if (ret < 0) {
1164+
reset_ctrl_status = reset_control_status(core->reset);
1165+
if (reset_ctrl_status < 0) {
11651166
dev_err(cdev, "failed to get initial local reset status, ret = %d\n",
1166-
ret);
1167-
return ret;
1167+
reset_ctrl_status);
1168+
return reset_ctrl_status;
11681169
}
11691170

11701171
/*
@@ -1199,7 +1200,7 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc)
11991200
* irrelevant if module reset is asserted (POR value has local reset
12001201
* deasserted), and is deemed as remoteproc mode
12011202
*/
1202-
if (c_state && !ret && !halted) {
1203+
if (c_state && !reset_ctrl_status && !halted) {
12031204
dev_info(cdev, "configured R5F for IPC-only mode\n");
12041205
kproc->rproc->state = RPROC_DETACHED;
12051206
ret = 1;
@@ -1217,7 +1218,7 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc)
12171218
ret = 0;
12181219
} else {
12191220
dev_err(cdev, "mismatched mode: local_reset = %s, module_reset = %s, core_state = %s\n",
1220-
!ret ? "deasserted" : "asserted",
1221+
!reset_ctrl_status ? "deasserted" : "asserted",
12211222
c_state ? "deasserted" : "asserted",
12221223
halted ? "halted" : "unhalted");
12231224
ret = -EINVAL;

0 commit comments

Comments
 (0)