Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

yamt
Copy link
Contributor

@yamt yamt commented Nov 22, 2024

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.

@github-actions github-actions bot added Area: Drivers Drivers issues Area: File System File System issues Size: M The size of the change in this PR is medium labels Nov 22, 2024
@nuttxpr
Copy link

nuttxpr commented Nov 22, 2024

[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:

  • Summary: While the "what" is explained, the "how" is missing. The summary should explain precisely how serial.c is adapted to the iovec-based API. What code changes were made? What functions were modified?
  • Impact: This section is entirely empty. All impact points need to be addressed, even if the answer is "NO". For example, if no user impact is expected, explicitly state "Impact on user: NO". The developer needs to consider and document every potential impact. Given that this PR mentions fixing a bug, there's likely impact on compatibility (fixing a bug improves compatibility, arguably).
  • Testing: The testing description is insufficient. "Lightly tested" is vague. What specific tests were run? What commands were issued? The provided information about the platform is good, but the actual logs are missing. Empty code blocks are provided for "Testing logs before change" and "Testing logs after change" - these must be populated with actual output.

Specifically, the author needs to:

  • Elaborate on the implementation details in the summary.
  • Complete the Impact section, addressing each point individually.
  • Provide concrete testing details and include the actual logs before and after the change.

@yamt yamt force-pushed the readv-serial branch 2 times, most recently from 97c844f to 786ab3b Compare November 22, 2024 04:30
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 */
Copy link
Contributor

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);
Copy link
Contributor

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)
Copy link
Contributor

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++;
Copy link
Contributor

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;
Copy link
Contributor

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,
Copy link
Contributor

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));
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Drivers Drivers issues Area: File System File System issues Size: M The size of the change in this PR is medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants