casaroli commented on code in PR #22142:
URL: https://github.com/apache/nuttx/pull/22142#discussion_r4665492151
##########
drivers/misc/rpmsgdev.c:
##########
@@ -407,39 +443,29 @@ static ssize_t rpmsgdev_read(FAR struct file *filep, FAR
char *buffer,
priv = filep->f_priv;
DEBUGASSERT(dev != NULL && priv != NULL);
- /* Call the host to perform the read */
-
- read.iov_base = buffer;
- read.iov_len = 0;
+ command = priv->nonblock ? RPMSGDEV_READ_NONBLOCK : RPMSGDEV_READ;
Review Comment:
A blocking read can no longer be interrupted. On master the client waits for
data in `rpmsgdev_wait()` with `nxsem_wait()`, so a signal ends the read with
-EINTR. Now `rpmsgdev_read()` sends RPMSGDEV_READ, the server replies only when
data arrives, and the client waits in `rpmsgdev_send_recv()` (line 953) in
`rpmsg_wait()`, which is `nxsem_wait_uninterruptible()`. So `cat
/dev/server-fifo0` with no data ignores Ctrl-C until data arrives or the peer
goes away. If the task is killed (SIG_DEFAULT), it exits inside this wait and
`cookie` stays linked in `priv->cookies` on the freed stack.
Fix: wait for RPMSGDEV_READ with `nxsem_wait()`; on -EINTR, tell the server
to drop the pending read (and wait for its answer), unlink the cookie and
return -EINTR.
##########
drivers/misc/rpmsgdev.c:
##########
@@ -1085,6 +1243,8 @@ static void rpmsgdev_device_destroy(FAR struct
rpmsg_device *rdev,
if (strcmp(priv->remotecpu, rpmsg_get_cpuname(rdev)) == 0)
{
+ rpmsgdev_fail_cookies(priv);
+ rpmsg_wait(&priv->ept, &priv->wait);
Review Comment:
`priv->wait` is posted only by `rpmsgdev_ns_bound()`. If the endpoint was
never bound (the remote has no rpmsgdev server, or rptun stops before the
bind), this `rpmsg_wait()` never returns and `rptun stop` hangs.
Fix: take the count back only if it is there, e.g.
`nxsem_trywait(&priv->wait)`.
##########
drivers/misc/Kconfig:
##########
@@ -60,6 +60,18 @@ config DEV_RPMSG_SERVER
default n
depends on RPMSG
+config DEV_RPMSG_OPEN_MAX
+ int "Rpmsg Device max concurrent opens per device"
+ default 2
+ depends on DEV_RPMSG || DEV_RPMSG_SERVER
+ ---help---
+ Maximum number of concurrent open() instances supported per
rpmsg
+ device. The per-open data blocks (client: struct
rpmsgdev_priv_s,
+ server: struct rpmsgdev_device_s) are preallocated as a
fixed-size
+ array inside each device/endpoint instance to avoid dynamic
+ allocation. open() is rejected with -EMFILE once all slots are
in
Review Comment:
The code returns -ENOMEM when all slots are in use (`rpmsgdev_open()`,
`rpmsgdev_open_handler()`), not -EMFILE.
Fix: say -ENOMEM here, or return -EMFILE in both places.
##########
drivers/rpmsg/Kconfig:
##########
@@ -138,11 +138,13 @@ config RPMSG_PANIC_DUMP_LEVEL
config RPMSG_POOL_COUNT
int "rpmsg pool buffer count"
- default 0
+ default 16 if ARCH_STACK_PROTECT || ARCH_KSTACK_PROTECT
Review Comment:
No Kconfig in the tree defines `ARCH_STACK_PROTECT` or
`ARCH_KSTACK_PROTECT`, so this default never applies. And since "keep request
messages on the stack again", rpmsgdev does not use the rpmsg pool.
Fix: drop this change and its row in the BREAKING CHANGE table.
--
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]