Skip to content

USB: cdc_acm: use ringbuf library and fixes #14677

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

Merged
merged 5 commits into from
Mar 25, 2019

Conversation

finikorg
Copy link
Collaborator

@finikorg finikorg commented Mar 19, 2019

Remove old artefacts and use ringbuf for RX path.

Fixes #14697
Fixes #14698
Might Fixes #14288

usb_read(ep, dev_data->rx_buf, bytes_to_read, &read);

if (!ring_buf_put(dev_data->rx_ringbuf, dev_data->rx_buf, read)) {
LOG_WRN("Rinf buffer full");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New data will be dropped? Also we can not block here as it could be called from ISR (drivers without worker or own thread). I would change it to LOG_ERR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jfischer-phytec-iot why do you think it can block? The new data would be dropped the same way it was done before, functionality should not change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to LOG_ERR()

u8_t rx_ready; /* Rx ready status */
u8_t tx_irq_ena; /* Tx interrupt enable status */
u8_t rx_irq_ena; /* Rx interrupt enable status */
s8_t tx_ready;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit does not describe the motivation behind the change from unsigned to signed. Why not bit field?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to eliminate 'U' after assignments.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to use bool or bit field.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to bool

@@ -1075,9 +1042,11 @@ static const struct uart_driver_api cdc_acm_driver_api = {
#endif /* CONFIG_USB_COMPOSITE_DEVICE */

#define DEFINE_CDC_ACM_DEV_DATA(x) \
RING_BUF_DECLARE(rx_ringbuf_##x, 512); \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it an option to make the ring buffer size configurable in Kconfig? I tested the patch and ran into issues when the buffer was filled and started dropping data before the callback was served from the system workqueue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can make it configurable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@finikorg finikorg changed the title USB: cdc_acm fixes USB: cdc_acm: use ringbuf library and fixes Mar 20, 2019
@codecov-io
Copy link

codecov-io commented Mar 20, 2019

Codecov Report

Merging #14677 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #14677   +/-   ##
=======================================
  Coverage   52.51%   52.51%           
=======================================
  Files         309      309           
  Lines       45048    45048           
  Branches    10419    10419           
=======================================
  Hits        23657    23657           
  Misses      16583    16583           
  Partials     4808     4808

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7d3fbfc...b3f00b1. Read the comment docs.

@masz-nordic
Copy link
Collaborator

Tested the throughput, cdc_acm without loopback and logs is at 312 kB/s.

@jfischer-no jfischer-no added bug The issue is a bug, or the PR is fixing a bug area: USB Universal Serial Bus labels Mar 20, 2019
@jfischer-no jfischer-no added this to the v1.14.0 milestone Mar 20, 2019
Copy link
Collaborator

@jfischer-no jfischer-no left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Remove 'U' after every assignment and make code more logical.

Signed-off-by: Andrei Emeltchenko <[email protected]>
Use ringbuf library for handling RX CDC ACM path. Remove old code
artifacts handling specific hardware.

Fixes zephyrproject-rtos#14288

Signed-off-by: Andrei Emeltchenko <[email protected]>
If there are several queued interrupts we can miss some of them. Use
while() loop to catch them all.

Signed-off-by: Andrei Emeltchenko <[email protected]>
Add new configuration parameter USB_CDC_ACM_RINGBUF_SIZE, default to
1024.

Signed-off-by: Andrei Emeltchenko <[email protected]>
Instead of relying on overlays which requires to write overlay for
every board (100+) define console device name.

Fixes zephyrproject-rtos#14698

Signed-off-by: Andrei Emeltchenko <[email protected]>
@carlescufi carlescufi merged commit 9722214 into zephyrproject-rtos:master Mar 25, 2019
@finikorg finikorg deleted the cdc_acm branch March 26, 2019 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: USB Universal Serial Bus bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants