From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: linux-usb@vger.kernel.org
Cc: balbi@kernel.org, Joel Stanley <joel@jms.id.au>,
Alan Stern <stern@rowland.harvard.edu>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: [PATCH v2 02/12] usb: gadget: aspeed: Cleanup EP0 state on port reset
Date: Fri, 12 Jul 2019 12:53:38 +1000 [thread overview]
Message-ID: <20190712025348.21019-3-benh@kernel.crashing.org> (raw)
In-Reply-To: <20190712025348.21019-1-benh@kernel.crashing.org>
Otherwise, we can have a stale state after a disconnect and reconnect
causing errors on the first SETUP packet to the device.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
drivers/usb/gadget/udc/aspeed-vhub/dev.c | 3 +++
drivers/usb/gadget/udc/aspeed-vhub/ep0.c | 9 +++++++++
drivers/usb/gadget/udc/aspeed-vhub/vhub.h | 1 +
3 files changed, 13 insertions(+)
diff --git a/drivers/usb/gadget/udc/aspeed-vhub/dev.c b/drivers/usb/gadget/udc/aspeed-vhub/dev.c
index 6b1b16b17d7d..678bbdbd0971 100644
--- a/drivers/usb/gadget/udc/aspeed-vhub/dev.c
+++ b/drivers/usb/gadget/udc/aspeed-vhub/dev.c
@@ -55,6 +55,9 @@ static void ast_vhub_dev_enable(struct ast_vhub_dev *d)
if (d->enabled)
return;
+ /* Cleanup EP0 state */
+ ast_vhub_reset_ep0(d);
+
/* Enable device and its EP0 interrupts */
reg = VHUB_DEV_EN_ENABLE_PORT |
VHUB_DEV_EN_EP0_IN_ACK_IRQEN |
diff --git a/drivers/usb/gadget/udc/aspeed-vhub/ep0.c b/drivers/usb/gadget/udc/aspeed-vhub/ep0.c
index e2927fb083cf..5e4714d7febb 100644
--- a/drivers/usb/gadget/udc/aspeed-vhub/ep0.c
+++ b/drivers/usb/gadget/udc/aspeed-vhub/ep0.c
@@ -459,6 +459,15 @@ static const struct usb_ep_ops ast_vhub_ep0_ops = {
.free_request = ast_vhub_free_request,
};
+void ast_vhub_reset_ep0(struct ast_vhub_dev *dev)
+{
+ struct ast_vhub_ep *ep = &dev->ep0;
+
+ ast_vhub_nuke(ep, -EIO);
+ ep->ep0.state = ep0_state_token;
+}
+
+
void ast_vhub_init_ep0(struct ast_vhub *vhub, struct ast_vhub_ep *ep,
struct ast_vhub_dev *dev)
{
diff --git a/drivers/usb/gadget/udc/aspeed-vhub/vhub.h b/drivers/usb/gadget/udc/aspeed-vhub/vhub.h
index 4ed03d33a5a9..2e7ef387f4f0 100644
--- a/drivers/usb/gadget/udc/aspeed-vhub/vhub.h
+++ b/drivers/usb/gadget/udc/aspeed-vhub/vhub.h
@@ -507,6 +507,7 @@ void ast_vhub_init_hw(struct ast_vhub *vhub);
/* ep0.c */
void ast_vhub_ep0_handle_ack(struct ast_vhub_ep *ep, bool in_ack);
void ast_vhub_ep0_handle_setup(struct ast_vhub_ep *ep);
+void ast_vhub_reset_ep0(struct ast_vhub_dev *dev);
void ast_vhub_init_ep0(struct ast_vhub *vhub, struct ast_vhub_ep *ep,
struct ast_vhub_dev *dev);
int ast_vhub_reply(struct ast_vhub_ep *ep, char *ptr, int len);
--
2.17.1
next prev parent reply other threads:[~2019-07-12 2:54 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-12 2:53 [PATCH 00/10] usb: gadget: aspeed: Bug fixes Benjamin Herrenschmidt
2019-07-12 2:53 ` [PATCH v2 01/12] usb: gadget: aspeed: Don't set port enable change bit on reset Benjamin Herrenschmidt
2019-07-12 2:53 ` Benjamin Herrenschmidt [this message]
2019-07-12 2:53 ` [PATCH v2 03/12] usb: gadget: aspeed: Fix EP0 stall handling Benjamin Herrenschmidt
2019-07-12 2:53 ` [PATCH v2 04/12] usb: gadget: aspeed: Improve debugging when nuking Benjamin Herrenschmidt
2019-07-12 9:01 ` Sergei Shtylyov
2019-07-12 9:06 ` Sergei Shtylyov
2019-07-12 23:40 ` Benjamin Herrenschmidt
2019-07-12 2:53 ` [PATCH v2 05/12] usb: gadget: aspeed: Don't reject requests on suspended devices Benjamin Herrenschmidt
2019-07-12 2:53 ` [PATCH v2 06/12] usb: gadget: aspeed: Check suspend/resume callback existence Benjamin Herrenschmidt
2019-07-12 2:53 ` [PATCH v2 07/12] usb: gadget: aspeed: Rework the reset logic Benjamin Herrenschmidt
2019-07-12 2:53 ` [PATCH v2 08/12] usb: gadget: aspeed: Remove unused "suspended" flag Benjamin Herrenschmidt
2019-07-12 2:53 ` [PATCH v2 09/12] usb: gadget: composite: Clear "suspended" on reset/disconnect Benjamin Herrenschmidt
2019-07-12 2:53 ` [PATCH v2 10/12] usb: gadget: mass_storage: Fix races between fsg_disable and fsg_set_alt Benjamin Herrenschmidt
2019-07-12 2:53 ` [PATCH v2 11/12] usb: Add definitions for the USB2.0 hub TT requests Benjamin Herrenschmidt
2019-07-12 2:53 ` [PATCH v2 12/12] usb: gadget: aspeed: Implement dummy " Benjamin Herrenschmidt
2019-07-12 2:59 ` [PATCH 00/10] usb: gadget: aspeed: Bug fixes Benjamin Herrenschmidt
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=20190712025348.21019-3-benh@kernel.crashing.org \
--to=benh@kernel.crashing.org \
--cc=balbi@kernel.org \
--cc=joel@jms.id.au \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/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;
as well as URLs for NNTP newsgroup(s).