From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 03/18] usb: host: ehci: Use to USBSTS to wait for transfer completion
Date: Wed, 22 May 2019 00:33:59 -0700 [thread overview]
Message-ID: <20190522073414.9308-4-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20190522073414.9308-1-andrew.smirnov@gmail.com>
Since we already set up our last qTD to have IOC flag set we may as
well take advange of that and poll USBSTS to wait for transfer
completion. Doesn't change much, but allows us to drop a custom
polling loop and re-use handshake() instead.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
drivers/usb/host/ehci-hcd.c | 21 +++++++--------------
drivers/usb/host/ehci.h | 1 +
2 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 4ccaec743..0757ea44a 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -238,12 +238,10 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
struct ehci_host *ehci = to_ehci(host);
struct QH *qh;
struct qTD *td;
- volatile struct qTD *vtd;
uint32_t *tdp;
uint32_t endpt, token, usbsts;
uint32_t c, toggle;
int ret = 0, i;
- uint64_t start, timeout_val;
dev_dbg(ehci->dev, "pipe=%lx, buffer=%p, length=%d, req=%p\n", pipe,
buffer, length, req);
@@ -375,18 +373,13 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
goto fail;
}
- /* Wait for TDs to be processed. */
- timeout_val = timeout_ms * MSECOND;
- start = get_time_ns();
- vtd = td;
- do {
- token = hc32_to_cpu(vtd->qt_token);
- if (is_timeout_non_interruptible(start, timeout_val)) {
- ehci_enable_async_schedule(ehci, false);
- ehci_writel(&qh->qt_token, 0);
- return -ETIMEDOUT;
- }
- } while (token & 0x80);
+ ret = handshake(&ehci->hcor->or_usbsts, STS_USBINT, STS_USBINT,
+ timeout_ms * 1000);
+ if (ret < 0) {
+ ehci_enable_async_schedule(ehci, false);
+ ehci_writel(&qh->qt_token, 0);
+ return -ETIMEDOUT;
+ }
if (IS_ENABLED(CONFIG_MMU)) {
for (i = 0; i < NUM_TD; i ++) {
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 39de76374..5b0920d0e 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -62,6 +62,7 @@ struct ehci_hcor {
#define STD_ASS (1 << 15)
#define STS_PSS (1 << 14)
#define STS_HALT (1 << 12)
+#define STS_USBINT BIT(0)
uint32_t or_usbintr;
uint32_t or_frindex;
uint32_t or_ctrldssegment;
--
2.21.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-05-22 7:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-22 7:33 [PATCH 00/18] EHCI improvements Andrey Smirnov
2019-05-22 7:33 ` [PATCH 01/18] usb: host: ehci: Do not zero out DMA coherent memory Andrey Smirnov
2019-05-22 7:33 ` [PATCH 02/18] usb: host: ehci: Share code to enable/disable async schedule Andrey Smirnov
2019-05-22 7:33 ` Andrey Smirnov [this message]
2019-05-22 7:34 ` [PATCH 04/18] usb: host: ehci: Replace magic number with macros Andrey Smirnov
2019-05-22 7:34 ` [PATCH 05/18] usb: host: ehci: Drop unnecessary cleanup code Andrey Smirnov
2019-05-22 7:34 ` [PATCH 06/18] usb: host: ehci: Introduce ehci_prepare_qtd() Andrey Smirnov
2019-05-22 7:34 ` [PATCH 07/18] usb: host: ehci: Simplify qTD buffer synchronization Andrey Smirnov
2019-05-22 7:34 ` [PATCH 08/18] usb: host: ehci: Simplify ehci_td_buffer() Andrey Smirnov
2019-05-22 7:34 ` [PATCH 09/18] usb: host: ehci: Initialize qTDs explicitly Andrey Smirnov
2019-05-22 7:34 ` [PATCH 10/18] usb: host: ehci: Simplify ehci_submit_async()'s epilogue Andrey Smirnov
2019-05-22 7:34 ` [PATCH 11/18] usb: host: ehci: Drop needless assignments in ehci_submit_async() Andrey Smirnov
2019-05-22 7:34 ` [PATCH 12/18] usb: host: ehci: Use bool to simplify ehci_submit_async() Andrey Smirnov
2019-05-22 7:34 ` [PATCH 13/18] usb: host: ehci: Add a comment explaing IOC setting for data Andrey Smirnov
2019-05-22 7:34 ` [PATCH 14/18] usb: host: ehci: Replace explicit printf() with dev_err() Andrey Smirnov
2019-05-22 7:34 ` [PATCH 15/18] usb: host: ehci: Drop explicit memset() in ehci_init() Andrey Smirnov
2019-05-22 7:34 ` [PATCH 16/18] usb: host: ehci: Treat ehci->qh_list as an array Andrey Smirnov
2019-05-22 7:34 ` [PATCH 17/18] ush: host: ehci: Simplify QH initialization in ehci_submit_async() Andrey Smirnov
2019-05-22 7:34 ` [PATCH 18/18] usb: host: ehci: Allocate only NUM_QH queue heads for qh_list Andrey Smirnov
2019-05-23 7:57 ` [PATCH 00/18] EHCI improvements Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190522073414.9308-4-andrew.smirnov@gmail.com \
--to=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox