summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNamyoon Woo <namyoon@chromium.org>2019-06-05 12:20:07 -0700
committerVadim Bendebury <vbendeb@chromium.org>2019-09-21 19:11:23 -0700
commit0f795f8d8219f95a23ce4f9d10ed4167fe2ba8cf (patch)
tree23a6b788dc4bf13668def53c905aa33800fd780f
parentfe9ae819615c80c2f75c831cf00fd1f241f4ee2e (diff)
downloadchrome-ec-0f795f8d8219f95a23ce4f9d10ed4167fe2ba8cf.tar.gz
g: add rx_handled into USB_STREAM_CONFIG
The variable rx_handled tracks how many of the bytes in the HW FIFO was moved into the incoming queue. It used to be defined as local static variable for multiple USB_STREAM_CONFIGs, and could cause a problem if multiple USB downstream traffic get heavier. It should be defined for each USB_STREAM_CONFIG. This patch add rx_handled into USB_STREAM_CONFIG, which tracks how many of the bytes in the HW FIFO was moved into the incoming queue. BUG=None BRANCH=None TEST=manually ran uart_stress_tester.sh and flash_ec on Bob. Change-Id: I561a54b0594a71b557693007a181bde48155d403 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1644958 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> (cherry picked from commit 67114fa836c2c0d201dbb16ae88a6a9b66f1d94b) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1653654 Tested-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> (cherry picked from commit e8cf89e1d04ccb52f44ae4d75e3dfd6388ab8d71) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1705720 (cherry picked from commit 2d8a9b8ecd7882477cbb9f0426306e205b0358f9)
-rw-r--r--chip/g/usb-stream.c17
-rw-r--r--chip/g/usb-stream.h8
2 files changed, 15 insertions, 10 deletions
diff --git a/chip/g/usb-stream.c b/chip/g/usb-stream.c
index 4d552913e3..67dcbb163a 100644
--- a/chip/g/usb-stream.c
+++ b/chip/g/usb-stream.c
@@ -36,7 +36,7 @@ static inline int rx_fifo_is_ready(struct usb_stream_config const *config)
* other end of the queue (telling us that there's now more room in the queue
* if we still have bytes to shove in there).
*/
-int rx_stream_handler(struct usb_stream_config const *config)
+void rx_stream_handler(struct usb_stream_config const *config)
{
/*
* The HW FIFO buffer (rx_ram) is always filled from [0] by the
@@ -55,12 +55,13 @@ int rx_stream_handler(struct usb_stream_config const *config)
* the next time this function is called we can try to shove the rest
* of the HW FIFO bytes into the queue.
*/
- static int rx_handled;
+ int rx_handled;
/* If the HW FIFO isn't ready, then we're waiting for more bytes */
if (!rx_fifo_is_ready(config))
- return 0;
+ return;
+ rx_handled = *(config->rx_handled);
/*
* How many of the HW FIFO bytes have we not yet handled? We need to
* know both where we are in the buffer and how many bytes we haven't
@@ -91,7 +92,8 @@ int rx_stream_handler(struct usb_stream_config const *config)
} else {
hook_call_deferred(config->deferred_rx, 0);
}
- return rx_handled;
+
+ *(config->rx_handled) = rx_handled;
}
/* Rx/OUT interrupt handler */
@@ -111,21 +113,20 @@ static inline int tx_fifo_is_ready(struct usb_stream_config const *config)
}
/* Try to send some bytes to the host */
-int tx_stream_handler(struct usb_stream_config const *config)
+void tx_stream_handler(struct usb_stream_config const *config)
{
size_t count;
if (!*config->is_reset)
- return 0;
+ return;
if (!tx_fifo_is_ready(config))
- return 0;
+ return;
count = QUEUE_REMOVE_UNITS(config->consumer.queue, config->tx_ram,
config->tx_size);
if (count)
usb_enable_tx(config, count);
- return count;
}
/* Tx/IN interrupt handler */
diff --git a/chip/g/usb-stream.h b/chip/g/usb-stream.h
index 5eb03865b0..4787b50d08 100644
--- a/chip/g/usb-stream.h
+++ b/chip/g/usb-stream.h
@@ -46,6 +46,8 @@ struct usb_stream_config {
struct g_usb_desc *out_desc;
struct g_usb_desc *in_desc;
+
+ int *rx_handled;
};
/*
@@ -113,6 +115,7 @@ extern struct producer_ops const usb_stream_producer_ops;
DECLARE_DEFERRED(CONCAT2(NAME, _deferred_tx_)); \
static void CONCAT2(NAME, _deferred_rx_)(void); \
DECLARE_DEFERRED(CONCAT2(NAME, _deferred_rx_)); \
+ static int CONCAT2(NAME, _rx_handled); \
struct usb_stream_config const NAME = { \
.endpoint = ENDPOINT, \
.is_reset = &CONCAT2(NAME, _is_reset_), \
@@ -132,6 +135,7 @@ extern struct producer_ops const usb_stream_producer_ops;
.queue = &RX_QUEUE, \
.ops = &usb_stream_producer_ops, \
}, \
+ .rx_handled = &CONCAT2(NAME, _rx_handled), \
}; \
const struct usb_interface_descriptor \
USB_IFACE_DESC(INTERFACE) = { \
@@ -208,8 +212,8 @@ extern struct producer_ops const usb_stream_producer_ops;
/*
* Handle USB and Queue request in a deferred callback.
*/
-int rx_stream_handler(struct usb_stream_config const *config);
-int tx_stream_handler(struct usb_stream_config const *config);
+void rx_stream_handler(struct usb_stream_config const *config);
+void tx_stream_handler(struct usb_stream_config const *config);
/*
* These functions are used by the trampoline functions defined above to