CV-Bowen opened a new pull request, #22034:
URL: https://github.com/apache/nuttx/pull/22034
## Summary
Rework of the rpmsg syslog client buffer (`drivers/syslog/syslog_rpmsg.c`)
so that the log lives in a self-describing buffer the driver owns, plus
two small options. First part of the rpmsg syslog changes; the buffer
fixes that build on this layout follow in a separate PR.
- `allow the driver to own its log buffer`: add
`CONFIG_SYSLOG_RPMSG_BUFSIZE`; the driver defines the buffer itself,
optionally in `CONFIG_SYSLOG_RPMSG_BUFFER_SECTION` (a no-init section
keeps the log across a reset).
- `protect the buffer with a spinlock`: replace the critical sections
with a spinlock, released around `rpmsg_send_nocopy()` and
`up_nputs()`.
- `remove the flush operation`: after `syslog_rpmsg_flush()` every later
message went to `up_nputs()` and was no longer scheduled for transfer.
- `add CONFIG_SYSLOG_RPMSG_DEVPATH`: the rpmsg syslog character device
was registered at `CONFIG_SYSLOG_DEVPATH`, the path of the RAMLOG or
character syslog device; give it its own path, `/dev/logrpmsg`.
- `keep the log in a self-describing buffer`: a header (magic, head,
tail, size) at the start of the buffer holds the indices, so the log
survives a reset and can be read by another core.
`syslog_rpmsg_init_early()` is removed together with the buffers in
the qemu, goldfish, rtl8730e and sim start-up code.
- `add syslog_rpmsg_dump()`: inline helper that prints the unsent part
of such a buffer, e.g. one left by a remote core.
- `keep head and tail within the buffer`: store them as offsets in
`[0, size)`, which is how `syslog_rpmsg_dump()` indexes them.
- `compare CONFIG_SYSLOG_RPMSG_BUFSIZE with > 0`.
- `require CONFIG_SYSLOG_RPMSG_BUFSIZE`: point `g_syslog_rpmsg` at the
buffer statically and drop the Kconfig default; 0 means the platform
supplies the buffer through `g_syslog_rpmsg.header`.
- `make the endpoint priority configurable` (server):
`CONFIG_SYSLOG_RPMSG_SERVER_PRIORITY`, default 126, one below
`RPMSG_PRIO_DEFAULT`.
- `initialize the buffer on first use only`: not in `syslog_rpmsg_init()`,
which on qemu runs before the platform has set a shared buffer, but on
the first write and when the endpoint is created.
## Impact
- API: `syslog_rpmsg_init_early()` and `syslog_rpmsg_flush()` are
removed. A board that passed its own buffer now sets
`CONFIG_SYSLOG_RPMSG_BUFSIZE`, or points `g_syslog_rpmsg.header` at its
buffer (with `size` filled in) and sets the option to 0.
`struct syslog_rpmsg_s`, `struct syslog_rpmsg_buffer_header_s` and
`g_syslog_rpmsg` are now in `include/nuttx/syslog/syslog_rpmsg.h`.
- Kconfig: new `SYSLOG_RPMSG_BUFSIZE` (no default, must be set when
`SYSLOG_RPMSG=y`), `SYSLOG_RPMSG_BUFFER_SECTION`,
`SYSLOG_RPMSG_DEVPATH`, `SYSLOG_RPMSG_SERVER_PRIORITY`. The four
in-tree configs with `SYSLOG_RPMSG=y` (sim:rpproxy, sim:rpproxy_uart,
qemu-armv7a:rpproxy, qemu-armv8a:rpproxy) get
`CONFIG_SYSLOG_RPMSG_BUFSIZE=4096`, the size of the buffers removed
from the start-up code.
- Behaviour: the rpmsg syslog character device moves from
`CONFIG_SYSLOG_DEVPATH` to `/dev/logrpmsg`. The rpmsg channel no
longer prints its buffer to the local console on `syslog_flush()`
(e.g. on panic).
## Testing
Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu
13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU
Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
sim:rpserver + sim:rpproxy, unchanged configs: the proxy logs through
syslog_rpmsg, the server prints what it receives. On the proxy (reached
with `cu /dev/ttyproxy`) `ls /dev`, then write a line to the rpmsg
syslog character device; on the server `rpmsg dump all`:
| | master | this PR |
|---|---|---|
| rpmsg syslog chardev on the proxy | `/dev/ttyS1` | `/dev/logrpmsg` |
| `echo P108MARK > <chardev>` shows up on the server console | `[proxy]
P108MARK` | `[proxy] P108MARK` |
| server `rpmsg-syslog` endpoint priority | 127 | 126 |
<details><summary>master</summary>
```
proxy> ls /dev
ttyS1
proxy> echo P108MARK > /dev/ttyS1
[ 8.600362] [proxy] P108MARK
server> rpmsg dump all
[ 10.140904] [server] ept rpmsg-syslog 0xe931f260: addr=1034 dest=1025
refcnt=1 priority=127 priv=0xe931f260
```
</details>
<details><summary>this PR</summary>
```
proxy> ls /dev
logrpmsg
proxy> echo P108MARK > /dev/logrpmsg
[ 8.600217] [proxy] P108MARK
server> rpmsg dump all
[ 10.141069] [server] ept rpmsg-syslog 0xf26f5260: addr=1034 dest=1025
refcnt=1 priority=126 priv=0xf26f5260
```
</details>
Every commit of the series: sim:rpproxy, sim:rpserver and
qemu-armv8a:rpproxy build without warnings, and the sim pair boots
with the proxy alive and its log reaching the server.
qemu-armv7a:rpproxy and sim:rpproxy_uart build at the last commit;
rtl8730e_evb:uart builds (its rpmsg syslog code is not enabled by any
config).
Not tested: a buffer in a no-init section across a reset, a
platform-supplied buffer (`CONFIG_SYSLOG_RPMSG_BUFSIZE=0`), and
`syslog_rpmsg_dump()`, which has no caller in tree yet; the arm
goldfish start-up code is not built, no in-tree board uses that chip.
No regression in rpmsg: sim:rpserver/rpproxy and
qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping,
rpmsgfs; 15/15). qemu-armv8a was built with LIBC_ENVPATH and BINFMT_CHECKEXEC
disabled, which current master needs for nxinit to start nsh there; unrelated
to this change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]