usb: gadget: aspeed: Cleanup EP0 state on port reset
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Fri, 26 Jul 2019 05:05:31 +0000 (15:05 +1000)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Mon, 12 Aug 2019 05:54:48 +0000 (08:54 +0300)
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>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/gadget/udc/aspeed-vhub/dev.c
drivers/usb/gadget/udc/aspeed-vhub/ep0.c
drivers/usb/gadget/udc/aspeed-vhub/vhub.h

index 6b1b16b17d7d5f6423f1c3e4760b144e7f5f2c07..678bbdbd0971083f458c0eeb35bbab8cd0d5f130 100644 (file)
@@ -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 |
index e2927fb083cf14f3119fc71945a286176fa7990d..5e4714d7febb30222282a8a5e3ede58db1299b0d 100644 (file)
@@ -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)
 {
index 4ed03d33a5a92b53f836d9d6930722aa5c418cfe..2e7ef387f4f0d81d1a4d32095a7fea2bd016e266 100644 (file)
@@ -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);