-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers/serial/serial.c: adapt to the iovec-based api #14898
base: master
Are you sure you want to change the base?
Conversation
[Experimental Bot, please feedback here] Fill In The Commit Message: This PR contains a Commit with an Empty Commit Message. Please fill in the Commit Message with the PR Summary. No, this PR does not fully meet the NuttX requirements. While it provides a summary and mentions testing, it lacks crucial details. Here's a breakdown of missing information:
Specifically, the author needs to:
|
97c844f
to
786ab3b
Compare
This can simplify partial result handling.
"total" is a bit confusing after the introduction of uio_advance().
although i'm not quite happy with the "offset" functionality, it's necessary to simplify the adaptation of some drivers like drivers/serial/serial.c, which (ab)uses the user-supplied buffer as a line-buffer.
This would fix readv/writev issues mentioned in apache#12674. (only for this specific driver though. with this approach, we basically have to fix every single drivers and filesystems.) Lightly tested on the serial console, using micropython REPL on toywasm with esp32s3-devkit:toywasm, which used to be suffered by the readv issue.
@@ -45,6 +45,7 @@ struct uio | |||
{ | |||
FAR const struct iovec *uio_iov; | |||
int uio_iovcnt; | |||
size_t uio_offset_in_iov; /* offset in uio_iov[0].iov_base */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uio_offset
@@ -102,6 +101,11 @@ static ssize_t file_readv_compat(FAR struct file *filep, | |||
remaining -= nread; | |||
} | |||
|
|||
if (ntotal >= 0) | |||
{ | |||
uio_advance(uio, ntotal); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's benefit to update the offset in one of uio entry
* Or -EOVERFLOW. | ||
* | ||
****************************************************************************/ | ||
|
||
ssize_t uio_total_len(FAR const struct uio *uio) | ||
ssize_t uio_resid(FAR const struct uio *uio) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uio_remain?
} | ||
|
||
sz -= iov->iov_len; | ||
iov++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we set iov->iov_offset_in_iov to iov->iov_len
{ | ||
return -EOVERFLOW; | ||
} | ||
|
||
len += iov[i].iov_len; | ||
len += iov[i].iov_len - offset_in_iov; | ||
offset_in_iov = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we set ti iov[i].iov_offset_in_iov
* | ||
****************************************************************************/ | ||
|
||
void uio_copyto(FAR struct uio *uio, size_t offset, FAR void *buf, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how to support call uio_copyto/from mulitple time with the same uio and the partial buffer
@@ -84,6 +84,7 @@ void uio_advance(FAR struct uio *uio, size_t sz) | |||
int iovcnt = uio->uio_iovcnt; | |||
size_t offset_in_iov = uio->uio_offset_in_iov; | |||
|
|||
DEBUGASSERT(sz <= uio_resid(uio)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge tl the patch which add uio_advance
Summary
drivers/serial/serial.c: adapt to the iovec-based api
This would fix readv/writev issues mentioned in
#12674.
(only for this specific driver though. with this approach,
we basically have to fix every single drivers and
filesystems.)
Impact
Testing
Lightly tested on the serial console, using micropython REPL
on toywasm with esp32s3-devkit:toywasm, which used to be
suffered by the readv issue.