Since rmtfs typically provides resources for wireless and modem-related
processors, it's important to ensure that this service starts before
and stops after NetworkManager.
On platforms like QCOM RB1, this sequencing prevents the Wi-Fi interface(s)
from being left in a dangling state while NetworkManager attempts to tear
down the interface(s):
https://github.com/qualcomm-linux/qcom-deb-images/issues/40#issuecomment-2944265370
The 'Before' dependency directive is ignored if NetworkManager is disabled or absent.
Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
The QRTR nameserver has been built into the kernel for years now, drop
the dependency since qrtr-ns.service won't do anything anyways.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
The EFS data can either be in a partition or a filesystem path. The rmtfs
allows both, but there is only a systemd service to use the former.
Add another systemd service that does the latter. By default, the EFS path
is /var/lib/rmtfs (which is the directory used by msm-cros-efs-loader.sh
and other tools that extract the EFS data) but this can be changed during
build by setting the RMTFS_EFS_PATH environment variable.
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
GCC version 13.2.1 20231205 complains about the following:
cc -Wall -g -O2 -c -o storage.o storage.c
In function ‘rmtfs_iovec’,
inlined from ‘handle_rmtfs’ at rmtfs.c:403:4:
rmtfs.c:224:12: warning: ‘is_write’ may be used uninitialized [-Wmaybe-uninitialized]
224 | if (is_write)
| ^
rmtfs.c: In function ‘handle_rmtfs’:
rmtfs.c:158:17: note: ‘is_write’ was declared here
158 | uint8_t is_write;
| ^
In function ‘rmtfs_iovec’,
inlined from ‘handle_rmtfs’ at rmtfs.c:403:4:
rmtfs.c:225:17: warning: ‘rmtfd’ may be used uninitialized [-Wmaybe-uninitialized]
225 | storage_sync(rmtfd);
| ^~~~~~~~~~~~~~~~~~~
rmtfs.c: In function ‘handle_rmtfs’:
rmtfs.c:154:23: note: ‘rmtfd’ was declared here
154 | struct rmtfd *rmtfd;
| ^~~~~
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Given that shadow_len is size_t (unsigned integer), subtracting a number
from it will make it wrap around < 0 and become positive again so the
subsequent "if (n > 0)" check will be mostly useless. On AOSP this makes
rmtfs segfault, on Linux distributions rmtfs happily reads beyond the
end of the buf.
Fix this by casting both parameters to ssize_t (which is signed) to
correctly use the if and not read beyond the end of shadow_buf.
Relevant trace using extra debug statements:
storage_populate_shadow_buf: file=/dev/disk/by-partlabel/fsg shadow_buf=0xffffa5217060 shadow_len=0x280000
<snip>
storage_pread: memcpy shadow_buf=0xffffa5217060 offset=0x27fc00 n=0x200
storage_pread: memcpy shadow_buf=0xffffa5217060 offset=0x27fe00 n=0x200
storage_pread: memcpy shadow_buf=0xffffa5217060 offset=0x280000 n=0x0 - don't read!
storage_pread: memcpy shadow_buf=0xffffa5217060 offset=0x280200 n=0x200
storage_pread: memcpy shadow_buf=0xffffa5217060 offset=0x280400 n=0x200
storage_pread: memcpy shadow_buf=0xffffa5217060 offset=0x280600 n=0x200
storage_pread: memcpy shadow_buf=0xffffa5217060 offset=0x280800 n=0x200
<snip>
Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
Opening the backing files with O_SYNC makes things really slow. So slow
in fact that the modem times out after 10 seconds waiting for the last
EFS sync to go through. I think this takes forever because rmtfs is
doing 512-byte reads and writes.
One option would be to make this bigger. But a better option is to not
use O_SYNC, but explicitly do an fdatasync() after the iovec operation
is complete. This is better because 1) it's way faster, we no longer see
10-12 second delays at rebooto time, and 2) partial syncs of the EFS
file aren't useful anyway.
Use fdatasync() as opposed to fsync() since it's not important for the
metadata to be synced, just the file contents.
Signed-off-by: Evan Green <evangreen86@gmail.com>
Open the storage devices as O_SYNC, to make sure modem writes aren't
lingering in the event of power loss or sudden reboot.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Use storage_close() to free up the shadow buffers as well, to avoid any
lingering allocations.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
We're not joining the start and stop threads, so create them in detached
state to avoid having their resources lingering.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
According to valgrind the modalias read from the remoteproc device is
not NUL-terminated, so do this to avoid reading in the weeds.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Include the reason for the failure to update the "state" sysfs
attribtue in the error message.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
The old mechanism searched for remoteproc instances from the
qcom_q6v5_mss driver, but in modern platforms the MSA based remoteproc
model has been replaced by the PAS based one. As such we use the common
qcom_q6v5_pas driver - as with other subsystems.
Use the modalias to find remoteproc drivers with the mpss-pas or mss-pil
compatible to find these, and fall back to the old heuristics if this
fails.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Attempting to shut down a system with rmtfs running without an
associated remoteproc results in systemd waiting forever for the
remoteproc code to never signal that it's done.
Instead exit immediately when signalled, when there's no associated
remoteproc.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Building rmtfs on AOSP, we see a lot of the following:
warning: arithmetic on a pointer to void is a GNU extension
Fix this by casting the void* ptrs to char* when doing pointer
arithmatic.
Signed-off-by: John Stultz <john.stultz@linaro.org>
[AmitP: Fixed cherry-pick conflicts and updated commit log]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Instead of hardcoding BY_PARTLABEL_PATH for AOSP,
reuse -o option as suggested by Bjorn to expand John's
patch to find correct partition by-name on newer
kernels (which is /dev/block/platform/soc*/*.*/by-name).
For example: On db845c running v5.4+ kernel we run:
rmtfs -o /dev/block/platform/soc@0/1d84000.ufshc/by-name -P -r -s
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>