* [PATCH 0/1] rpmsg: char - treat `ENOMEM` as `EAGAIN`
@ 2022-02-14 9:30 Tim Blechmann
2022-02-14 9:30 ` [PATCH 1/1] " Tim Blechmann
0 siblings, 1 reply; 5+ messages in thread
From: Tim Blechmann @ 2022-02-14 9:30 UTC (permalink / raw)
To: linux-remoteproc; +Cc: Tim Blechmann
This patch should allow the use of `rpmsg_char` character devices with
libraries that do a `poll`/`write` loop and expect `EAGAIN` when sending
fails and the user space application needs to `poll` to wait for more
space to be available.
`boost::asio::write` is a notable example of a library, which implements
such a loop.
Tim Blechmann (1):
rpmsg: char - treat `ENOMEM` as `EAGAIN`
drivers/rpmsg/rpmsg_char.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--
2.35.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/1] rpmsg: char - treat `ENOMEM` as `EAGAIN`
2022-02-14 9:30 [PATCH 0/1] rpmsg: char - treat `ENOMEM` as `EAGAIN` Tim Blechmann
@ 2022-02-14 9:30 ` Tim Blechmann
2022-03-12 15:14 ` Bjorn Andersson
0 siblings, 1 reply; 5+ messages in thread
From: Tim Blechmann @ 2022-02-14 9:30 UTC (permalink / raw)
To: linux-remoteproc; +Cc: Tim Blechmann, Arnaud Pouliquen
`rpmsg_trysend` returns `-ENOMEM` when no rpmsg buffer can be allocated.
this causes `::write` to fail with this error as opposed to `-EAGAIN`.
this is what user space applications (and libraries like boost.asio)
would expect when using normal character devices.
Signed-off-by: Tim Blechmann <tim@klingt.org>
CC: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
---
drivers/rpmsg/rpmsg_char.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c
index 5663cf799c95..5b9e708d595a 100644
--- a/drivers/rpmsg/rpmsg_char.c
+++ b/drivers/rpmsg/rpmsg_char.c
@@ -239,14 +239,17 @@ static ssize_t rpmsg_eptdev_write_iter(struct kiocb *iocb,
if (!eptdev->ept) {
ret = -EPIPE;
goto unlock_eptdev;
}
- if (filp->f_flags & O_NONBLOCK)
+ if (filp->f_flags & O_NONBLOCK) {
ret = rpmsg_trysendto(eptdev->ept, kbuf, len, eptdev->chinfo.dst);
+ if (ret == -ENOMEM)
+ ret = -EAGAIN;
+ }
else
ret = rpmsg_sendto(eptdev->ept, kbuf, len, eptdev->chinfo.dst);
unlock_eptdev:
mutex_unlock(&eptdev->ept_lock);
--
2.35.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] rpmsg: char - treat `ENOMEM` as `EAGAIN`
2022-02-14 9:30 ` [PATCH 1/1] " Tim Blechmann
@ 2022-03-12 15:14 ` Bjorn Andersson
2022-03-13 2:45 ` [PATCH 0/1 v2] " tim.blechmann
0 siblings, 1 reply; 5+ messages in thread
From: Bjorn Andersson @ 2022-03-12 15:14 UTC (permalink / raw)
To: Tim Blechmann; +Cc: linux-remoteproc, Tim Blechmann, Arnaud Pouliquen
On Mon 14 Feb 03:30 CST 2022, Tim Blechmann wrote:
> `rpmsg_trysend` returns `-ENOMEM` when no rpmsg buffer can be allocated.
Please use the form rpmsg_trysend() - without ``. You can omit that
around -ENOMEM as well.
> this causes `::write` to fail with this error as opposed to `-EAGAIN`.
Please drop the :: here as well.
> this is what user space applications (and libraries like boost.asio)
> would expect when using normal character devices.
>
> Signed-off-by: Tim Blechmann <tim@klingt.org>
I attempted to fix up the above details, but unfortunately your
Signed-off-by doesn't match your From:, so I can't apply the patch
anyways.
Can you please resubmit this with appropriate author/s-o-b?
> CC: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
> ---
> drivers/rpmsg/rpmsg_char.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c
> index 5663cf799c95..5b9e708d595a 100644
> --- a/drivers/rpmsg/rpmsg_char.c
> +++ b/drivers/rpmsg/rpmsg_char.c
> @@ -239,14 +239,17 @@ static ssize_t rpmsg_eptdev_write_iter(struct kiocb *iocb,
>
> if (!eptdev->ept) {
> ret = -EPIPE;
> goto unlock_eptdev;
> }
>
> - if (filp->f_flags & O_NONBLOCK)
> + if (filp->f_flags & O_NONBLOCK) {
> ret = rpmsg_trysendto(eptdev->ept, kbuf, len, eptdev->chinfo.dst);
> + if (ret == -ENOMEM)
> + ret = -EAGAIN;
> + }
> else
> ret = rpmsg_sendto(eptdev->ept, kbuf, len, eptdev->chinfo.dst);
./script/checkpatch.pl --strict tells me that you should have {} around
the else block as well..
Thanks,
Bjorn
>
> unlock_eptdev:
> mutex_unlock(&eptdev->ept_lock);
>
> --
> 2.35.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 0/1 v2] rpmsg: char - treat `ENOMEM` as `EAGAIN`
2022-03-12 15:14 ` Bjorn Andersson
@ 2022-03-13 2:45 ` tim.blechmann
2022-03-13 2:45 ` [PATCH 1/1] rpmsg: char - treat ENOMEM as EAGAIN tim.blechmann
0 siblings, 1 reply; 5+ messages in thread
From: tim.blechmann @ 2022-03-13 2:45 UTC (permalink / raw)
To: Bjorn Andersson; +Cc: linux-remoteproc, Tim Blechmann
From: Tim Blechmann <tim@klingt.org>
This patch should allow the use of `rpmsg_char` character devices with
libraries that do a `poll`/`write` loop and expect `EAGAIN` when sending
fails and the user space application needs to `poll` to wait for more
space to be available.
`boost::asio::write` is a notable example of a library, which implements
such a loop.
Tim Blechmann (1):
rpmsg: char - treat `ENOMEM` as `EAGAIN`
drivers/rpmsg/rpmsg_char.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--
2.35.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/1] rpmsg: char - treat ENOMEM as EAGAIN
2022-03-13 2:45 ` [PATCH 0/1 v2] " tim.blechmann
@ 2022-03-13 2:45 ` tim.blechmann
0 siblings, 0 replies; 5+ messages in thread
From: tim.blechmann @ 2022-03-13 2:45 UTC (permalink / raw)
To: Bjorn Andersson; +Cc: linux-remoteproc, Tim Blechmann, Arnaud Pouliquen
From: Tim Blechmann <tim@klingt.org>
rpmsg_trysend() returns -ENOMEM when no rpmsg buffer can be allocated.
this causes write to fail with this error as opposed to -EAGAIN.
this is what user space applications (and libraries like boost.asio)
would expect when using normal character devices.
Signed-off-by: Tim Blechmann <tim@klingt.org>
CC: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
---
drivers/rpmsg/rpmsg_char.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c
index 5663cf799c95..5b9e708d595a 100644
--- a/drivers/rpmsg/rpmsg_char.c
+++ b/drivers/rpmsg/rpmsg_char.c
@@ -239,14 +239,17 @@ static ssize_t rpmsg_eptdev_write_iter(struct kiocb *iocb,
if (!eptdev->ept) {
ret = -EPIPE;
goto unlock_eptdev;
}
- if (filp->f_flags & O_NONBLOCK)
+ if (filp->f_flags & O_NONBLOCK) {
ret = rpmsg_trysendto(eptdev->ept, kbuf, len, eptdev->chinfo.dst);
+ if (ret == -ENOMEM)
+ ret = -EAGAIN;
+ }
else
ret = rpmsg_sendto(eptdev->ept, kbuf, len, eptdev->chinfo.dst);
unlock_eptdev:
mutex_unlock(&eptdev->ept_lock);
--
2.35.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-13 2:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-14 9:30 [PATCH 0/1] rpmsg: char - treat `ENOMEM` as `EAGAIN` Tim Blechmann
2022-02-14 9:30 ` [PATCH 1/1] " Tim Blechmann
2022-03-12 15:14 ` Bjorn Andersson
2022-03-13 2:45 ` [PATCH 0/1 v2] " tim.blechmann
2022-03-13 2:45 ` [PATCH 1/1] rpmsg: char - treat ENOMEM as EAGAIN tim.blechmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.