Commit Graph

44 Commits

Author SHA1 Message Date
Aníbal Limón
dfb8f3ed1c rmtfs.service.in: Add RestartSec to 1 sec intervals
Systemd has a default restart policy of 5 retries so wait
1 second in each retry because if is too fast will fail to
start properly.

Signed-off-by: Aníbal Limón <anibal.limon@linaro.org>
2020-01-30 22:09:44 -08:00
Aníbal Limón
29eb4a5b06 rmtfs.c: Exit when fail to get rprocfd
When -s option is specified rmtfs handled the start of rproc
but at init may be the /sys entries are not fully populated yet
due to module load/setup so exit with 1 and let systemd restart
the service.

Signed-off-by: Aníbal Limón <anibal.limon@linaro.org>
2020-01-30 11:16:22 -08:00
Bjorn Andersson
df6c19d033 storage: Track opened files without backing storage
Upon populating the shadow_buf the no fd is associated with the rmtfd.
Therefor the next open request will conclude that the rmtfd is available
and use the same entry. Fix this by checking for both associated fd and
shadow_buf in the open call.

Fixes: c35633ab23 ("storage: Allow read only backing storage")
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2019-07-28 13:11:53 -07:00
Bjorn Andersson
6d2cfcddfc rmtfs.service: Add systemd service
Add rmtfs.service and install this.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2019-07-25 11:18:58 -07:00
Sibi Sankar
976aa0ddbe rmtfs: Sync rmtfs server with rproc instance
Add sigterm/sigint handlers to enable graceful rmtfs server
bringdown on first instance of SIGINT/SIGTERM. Start/Stop the
remoteproc instance on RMTFS service up and SIGINT/SIGTERM
respectively. Force quit on second instance of SIGINT/SIGTERM.

Signed-off-by: Sibi Sankar <sibis@codeaurora.org>
[bjorn: Pipe for event loop signaling, reworked /sys traversal]
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2019-07-19 00:24:35 -07:00
Bjorn Andersson
42edb9c07a storage: Support operating on raw partitions
Most devices has partitions named modemst1, modemst2, fsg and fsc
backing the rmtfs. Add a new argument '-P' to get the storage
implementation to use these partitions directly instead of files.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2019-07-17 12:23:19 -07:00
Bjorn Andersson
c35633ab23 storage: Allow read only backing storage
Add a new argument '-r' to prevent writes back to the backing storage.
This is useful for experimenting with the remote storage, without having
the files overwritten.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2019-07-17 12:23:02 -07:00
Bjorn Andersson
e6d703b3c8 storage: Revise API
Pass "struct rmtfd" instead of file descriptors in the interface. This
cleans up the api a little bit, but more importantly allow us to
associate additional things with the remote file descriptors.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2019-07-17 12:22:26 -07:00
Bjorn Andersson
152b96981e storage: Rename caller to "remote fd"
The caller (and caller_id) are really "remote file descriptors", so
rename them based on this.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2019-07-17 12:22:26 -07:00
Bjorn Andersson
886608484b rmtfs: Use pread/pwrite for storage
Instead of relying on an initial lseek, use pread/pwrite. This creates a
cleaner interface towards the storage.c implementation, allowing us to
provide a memory-only implementation of the backing storage.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2019-07-17 12:22:26 -07:00
Evan Green
cfb76ff6ee storage: Allow specifying the storage directory
Enable the specification of storage paths other than /boot, using
a new -o command line argument. Getoptify the command line arguments
for better processing.
2018-12-19 09:21:06 -08:00
Evan Green
08d20f1646 rmtfs: Better support for EFS backed by files
Currently, in order to back the EFS storage with a regular file,
those files have to be pre-allocated, and with their correct size.
This is especially problematic when preparing a minimal FSG, since
we do not know ahead of time what size to pre-allocate.

Allow reads that go beyond the end of the backing storage to simply
read zeroes. When a write comes in, the file will be automatically
expanded to the correct size. (And should really only be written
if a full sector was pulled out of the modem). For solutions
that use partitions instead of files, this change should be a no-op.
2018-12-19 09:21:06 -08:00
Ben Chan
0d3c49ec5a rmtfs: remove unused cpu_to_le32 and le32_to_cpu functions
This patch addresses the following compiler warnings on unused function:

  rmtfs.c:24:22: warning: unused function 'cpu_to_le32' [-Wunused-function]
  static inline __le32 cpu_to_le32(uint32_t x) { return htole32(x); }
                       ^
  rmtfs.c:25:24: warning: unused function 'le32_to_cpu' [-Wunused-function]
  static inline uint32_t le32_to_cpu(__le32 x) { return le32toh(x); }
                       ^
2018-07-26 06:34:05 -07:00
Ben Chan
b3ea7fdf7b rmtfs: fix the type of the phys_address argument of rmtfs_mem_ptr()
The 'phys_address' argument of rmtfs_mem_read() and rmtfs_mem_write() is
an 'unsigned long' type value, which is then passed to the
'phys_address' argument of rmtfs_mem_ptr(), which is an 'unsigned int'
type value. This patch fixes the mismatch.

Signed-off-by: Ben Chan <benchan@chromium.org>
2018-07-05 07:10:30 -07:00
Brian Norris
577aedad06 sharedmem: use 'unsigned long long' for memory region parsing
I see warnings like this:

sharedmem.c:89:44: warning: incompatible pointer types passing 'uint64_t *' (aka 'unsigned long long *') to parameter of type 'unsigned long *' [-Wincompatible-pointer-types]

Since 'unsigned long' might actually be smaller than 'uint64_t', we
should really upgrade to 'unsigned long long' parsing.

At the same time, the existing error handling was wrong: it should have
been looking for ULONG_MAX (per the man page). Convert that to
ULLONG_MAX to fix that bug while we're at it.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2018-07-05 07:01:36 -07:00
Brian Norris
5eb67a1fb5 Makefile: allow $(CFLAGS), $(LDFLAGS) override
The caller might have specified CFLAGS or LDFLAGS. Let's respect those.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2018-07-05 07:01:36 -07:00
Joey Hewitt
a75ad5dc2a sharedmem: support uio device
Also a fix to error-reporting for opening the storage.
2018-05-21 17:05:29 -07:00
Bjorn Andersson
0f800fa433 rmtfs: Don't include ../qrtr
While convenient it's easy to mess things up with the qrtr project in
the include and library path. Drop these and rely on the installed
version of the include and library files.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-02-01 05:04:50 +00:00
Bjorn Andersson
96a272bccb qmic: Use kernel-style qmic output
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-31 20:56:57 -08:00
Bjorn Andersson
cff3f619d5 qmi_rmtfs: Update definition file to match the generated files
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-02-01 04:39:46 +00:00
Bjorn Andersson
42ed7b4e4c rmtfs: Rework message pump
The message pump is cleaned up from cruft that was added to deal with
multiple services (rmtfs and rfsa) as well as ENETRESET handling.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-02-01 02:28:17 +00:00
Bjorn Andersson
db86a3b1a5 rmtfs: Migrate to new QMI encoder/decoder library
Utilize the QMI encoder/decoder functions being part of libqrtr instead
of rolling our own.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-02-01 02:09:35 +00:00
Bjorn Andersson
343817e402 rmtfs: Drop the rfsa service
The rfsa service is not used on any supported targets and should most
likely be implemented in the kernel driver directly, so remove any
traces of it from rmtfs.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-09-06 23:15:48 -07:00
Bjorn Andersson
91f765efa8 rmtfs: Update dev node of rmtfs_mem
The kernel driver exposing the shared memory was renamed, update the
path in rmtfs as well.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-09-06 23:15:48 -07:00
Bjorn Andersson
93f9564224 rmtfs: Interface qcom_rfsa device for mem access
Attempt to open /dev/qcom_rfsa1 and use this instead of memory mapping
/dev/mem, while falling back to the old behavior. This allow us to drop
the dependency on /dev/mem access and will aid supporting multiple
memory regions.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-07-28 16:30:05 -07:00
Bjorn Andersson
c7822e84b1 rmtfs: Extract rmtfs mem IO operations
Rather than exposing a pointer to the mmapped memory and performing IO
directly on this address pass the data through a local buffer and move
the reading and writing of memory into the sharedmem module.

This allows us to support shared memory that is not memory mapped in the
future.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-07-28 16:26:09 -07:00
Bjorn Andersson
6b7646c45f rmtfs: Move rmtfs_mem data to struct
Introduce a struct to pass around the parameters related to the rmtfs
memory, in preparation for supporting multiple memory regions.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-07-28 16:21:15 -07:00
Bjorn Andersson
9fb35632fc rmtfs: Newline error prints in rmtfs
As a leftover from previous usage of err(3) the error prints did not end
with a newline.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-07-28 16:21:15 -07:00
Bjorn Andersson
2d0be77c2e rmtfs: Re-register services as the nameserver restarts
When the nameserver restarts we need to re-register the services.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-06-07 10:54:42 -07:00
Bjorn Andersson
0579b3b33c rfsa: Silence informational messages related to rfsa service
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-06-07 10:53:26 -07:00
Bjorn Andersson
02efe22a55 rmtfs: Handle qrtr control messages
The nameserver notifies all registered servers about leaving clients.
Stub the handling of these messages, so they are not confused with the
qmi messages.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-06-07 09:53:25 -07:00
Bjorn Andersson
4a6bc382b7 rmtfs: Bind sockets to privileged ports
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-06-07 09:52:33 -07:00
Bjorn Andersson
8c79959935 storage: Reuse already open caller objects
In the event that the remote crashes, or for other reasons try to open a
partition that we already have open we should reuse the caller objects,
so that we don't run out of them. This should likely be replaced by a
working mechanism for notifications when the remote is going away.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2016-11-29 09:09:04 -08:00
Bjorn Andersson
d28f52c246 rmtfs: Build with optimization
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2016-07-01 17:34:41 -07:00
Bjorn Andersson
7a0bd0f561 rmtfs: Don't mark memory busy
We don't have a way to notice if the remote crashes and free the memory,
so for now don't mark it as busy and just hand out the same memory the
next time.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2016-07-01 17:34:12 -07:00
Bjorn Andersson
dc7de6ef56 Merge pull request #1 from ndechesne/gnu
Makefile: implement GNU Coding Standard for Makefiles
2016-06-06 08:39:42 -07:00
Nicolas Dechesne
bf673a675d Makefile: implement GNU Coding Standard for Makefiles
GNU coding standards notably specifies:
 * install files with the $(DESTDIR) to the target system image
 * install files with the $(prefix), not $(PREFIX)
 * the default value of $(prefix) should be /usr/local

as per
https://www.gnu.org/prep/standards/html_node/Directory-Variables.html.

Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
2016-06-05 22:07:46 +02:00
Bjorn Andersson
dcdc8e8603 rmtfs: Add .gitignore
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2016-06-02 10:30:22 -07:00
Bjorn Andersson
dce9fcf267 rmtfs: Add missing LICENSE file
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2016-06-02 10:29:40 -07:00
Bjorn Andersson
2150e2ae74 rmtfs: Fetch rmtfs address from device-tree
The rmtfs address differes from platform to platform, so fetch these
from the device-tree node in /proc instead of hard coding them.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2016-02-08 16:30:25 -08:00
Bjorn Andersson
6e467200c5 rmtfs: Include fsc partition in white list
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2016-02-08 16:29:51 -08:00
Bjorn Andersson
d5e516a6c6 rmtfs: Update tlv prototypes to accept message header
To support creating and parsing requests and indications as well qmic
adds an extra parameter to the tlv alloc and decode functions, so that
this can be used to generate and validate that the qmi packet header is
of the correct type.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2016-02-08 11:49:55 -08:00
Bjorn Andersson
1f12cea75b rmtfs: Initial rmtfs implementation
The rmtfs tool pushlishes the two QMI services "rmtfs" and "rfsa", and
implements the necessary requests for rmtfs that's needed to boot the
modem subsystem on a Qualcomm based board.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2016-02-07 09:32:14 -08:00
Bjorn Andersson
1e0cc246ed Initial commit for rmtfs 2016-02-07 09:29:38 -08:00