Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

remoteproc: Properly represent the attached state

There is a need to know when a remote processor has been attached
to rather than booted by the remoteproc core. In order to avoid
manipulating two variables, i.e rproc::autonomous and
rproc::state, get rid of the former and simply use the newly
introduced RPROC_ATTACHED state.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Link: https://lore.kernel.org/r/20210312162453.1234145-5-mathieu.poirier@linaro.org
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

authored by

Mathieu Poirier and committed by
Bjorn Andersson
76f4c875 4196d189

+2 -25
+1 -19
drivers/remoteproc/remoteproc_core.c
··· 1450 1450 goto stop_rproc; 1451 1451 } 1452 1452 1453 - rproc->state = RPROC_RUNNING; 1453 + rproc->state = RPROC_ATTACHED; 1454 1454 1455 1455 dev_info(dev, "remote processor %s is now attached\n", rproc->name); 1456 1456 ··· 1664 1664 rproc_unprepare_subdevices(rproc); 1665 1665 1666 1666 rproc->state = RPROC_OFFLINE; 1667 - 1668 - /* 1669 - * The remote processor has been stopped and is now offline, which means 1670 - * that the next time it is brought back online the remoteproc core will 1671 - * be responsible to load its firmware. As such it is no longer 1672 - * autonomous. 1673 - */ 1674 - rproc->autonomous = false; 1675 1667 1676 1668 dev_info(dev, "stopped remote processor %s\n", rproc->name); 1677 1669 ··· 2074 2082 ret = rproc_char_device_add(rproc); 2075 2083 if (ret < 0) 2076 2084 return ret; 2077 - 2078 - /* 2079 - * Remind ourselves the remote processor has been attached to rather 2080 - * than booted by the remoteproc core. This is important because the 2081 - * RPROC_DETACHED state will be lost as soon as the remote processor 2082 - * has been attached to. Used in firmware_show() and reset in 2083 - * rproc_stop(). 2084 - */ 2085 - if (rproc->state == RPROC_DETACHED) 2086 - rproc->autonomous = true; 2087 2085 2088 2086 /* if rproc is marked always-on, request it to boot */ 2089 2087 if (rproc->auto_boot) {
+1 -4
drivers/remoteproc/remoteproc_sysfs.c
··· 138 138 * If the remote processor has been started by an external 139 139 * entity we have no idea of what image it is running. As such 140 140 * simply display a generic string rather then rproc->firmware. 141 - * 142 - * Here we rely on the autonomous flag because a remote processor 143 - * may have been attached to and currently in a running state. 144 141 */ 145 - if (rproc->autonomous) 142 + if (rproc->state == RPROC_ATTACHED) 146 143 firmware = "unknown"; 147 144 148 145 return sprintf(buf, "%s\n", firmware);
-2
include/linux/remoteproc.h
··· 514 514 * @table_sz: size of @cached_table 515 515 * @has_iommu: flag to indicate if remote processor is behind an MMU 516 516 * @auto_boot: flag to indicate if remote processor should be auto-started 517 - * @autonomous: true if an external entity has booted the remote processor 518 517 * @dump_segments: list of segments in the firmware 519 518 * @nb_vdev: number of vdev currently handled by rproc 520 519 * @char_dev: character device of the rproc ··· 550 551 size_t table_sz; 551 552 bool has_iommu; 552 553 bool auto_boot; 553 - bool autonomous; 554 554 struct list_head dump_segments; 555 555 int nb_vdev; 556 556 u8 elf_class;