summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2017-09-13 18:05:08 +0200
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2017-12-16 00:56:09 +0000
commit8071d602af098a7ecf1c8796d7ccc239bd2c8388 (patch)
tree1f94e9c6abb5ed60896835ed6b64c98b30c1a278
parentbc1e26fb89f2271aec0f2e7373fa342d8770d53e (diff)
downloadchrome-ec-8071d602af098a7ecf1c8796d7ccc239bd2c8388.tar.gz
g: fix short packets on USB control endpoint
In the USB 2.0 specification, the "8.5.3 Control Transfers" chapter says that "When all of the data structure is returned to the host, the function should indicate that the Data stage is ended by returning a packet that is shorter than the MaxPacketSize for the pipe. If the data structure is an exact multiple of wMaxPacketSize for the pipe, the function will return a zero-length packet to indicate the end of the Data stage." When doing a 'Control Read' transfer and the returned data (in IN packets) was a multiple of MaxPacketSize, we were omitting the zero-length packet and so the host was blocked waiting for a successful IN transaction. This corner-case was a regression introduced by the re-writing of the control transfer handling done by CL 318864. So the STM32 USB code which is similar to the former code is dealing properly with this case. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=cr50 BUG=none TEST=manual, extend the configuration descriptor to be exactly 64 bytes, and see the enumeration is no longer failing. Change-Id: I108e8c6bb9eb727c41f3e1c607f0919fa1192d5a Reviewed-on: https://chromium-review.googlesource.com/664814 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Marius Schilder <mschilder@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org> (cherry picked from commit b5d9913241046764855ed49450dfed51dbf309a3) Reviewed-on: https://chromium-review.googlesource.com/828411 Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r--chip/g/usb.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/chip/g/usb.c b/chip/g/usb.c
index e29ade61ca..a490a5204d 100644
--- a/chip/g/usb.c
+++ b/chip/g/usb.c
@@ -391,7 +391,7 @@ static void got_RX_packet(void)
int load_in_fifo(const void *source, uint32_t len)
{
uint8_t *buffer = ep0_in_buf;
- int zero_packet = !len;
+ int zero_packet = (len % USB_MAX_PACKET_SIZE) == 0;
int d, l;
/* Copy the data into our FIFO buffer */