CV-Bowen opened a new pull request, #22263:
URL: https://github.com/apache/nuttx/pull/22263
## Summary
Depends on apache/nuttx#22262
Make the rpmsg endpoint reference count usable without the device lock.
In the order the changes were made:
- `openamp: skip atomic_wchar_t in libmetal when libc++ lacks it`
(libmetal patch 0004): libc++ declares `std::atomic_wchar_t` only with
wide character support, so a C++ file including `metal/atomic.h`
fails. The next patch makes `openamp/rpmsg.h` include it.
- `openamp: let an endpoint reference outlive its registration` (patch
0029): `refcnt` becomes an `atomic_uint` changed without the lock;
`ept->rdev` is cleared when the endpoint is unregistered instead of
when the last reference goes; registering adds the device reference
instead of setting the count to one, so a reference taken before
registration is kept. A second `rpmsg_destroy_ept()` is a no-op.
- `drivers/rpmsg: print the endpoint refcount with atomic_load()`:
passing the atomic field to `syslog()` is an implicit atomic load that
clang lowers to an `__atomic_load` libcall NuttX does not provide.
## Impact
- `struct rpmsg_endpoint.refcnt` is an `atomic_uint`. Code reading it
directly must use `atomic_load()`.
- An endpoint must be zeroed before `rpmsg_create_ept()`, since
registration now adds to the count. Every in-tree caller uses static or
zero-allocated storage.
- No Kconfig or protocol change.
## 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
`openamp/open-amp` and `openamp/libmetal` extracted with the new patch
lists are identical (`diff -r`) to the trees the patches were generated
from. Every commit builds sim:rpserver, sim:rpproxy, qemu-armv8a:rpserver,
qemu-armv8a:rpproxy, sim:rpserver_uart, sim:rpserver with
`CONFIG_OPENAMP_VIRTIO_DEVICE_SUPPORT=n` and sim:rpserver with
`CONFIG_RPMSG_POOL_COUNT=8` + `CONFIG_RPMSG_WQUEUE_NUMBER=2` with 0
warnings.
Not tested at runtime: a C++ file including `metal/atomic.h` with libc++
(the libmetal patch). The atomic count is used by every endpoint in the
baseline below.
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]