From patchwork Thu Sep 7 00:30:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 111843 Delivered-To: patches@linaro.org Received: by 10.140.94.239 with SMTP id g102csp54567qge; Wed, 6 Sep 2017 17:31:10 -0700 (PDT) X-Received: by 10.99.0.5 with SMTP id 5mr879976pga.431.1504744270429; Wed, 06 Sep 2017 17:31:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504744270; cv=none; d=google.com; s=arc-20160816; b=f4Yi4sSLX00NBxwlQOEJtvhQosDTSW91JHhnAs/aJG5kn6dZWOFF3YIRxQHOdezHAZ D3G7eVgbBS/ukA3YitFMc87JkRK+ATmwmTykR5vIekeRPIgETg/+V4A33pWro+2vaBb1 XWgZCFzpEKfnnfFx5Io9rXIyImQJfYpyDewq2DeITeoHppv6cpkLE94RmYq0BeuMI7P1 KsSlByiX0OTrrPhHG4+JZdLNaOGty8rjVDpslImr+4KhKAAHRFfpQRYABjKCyzNmnrLT W0OE68KpEnZnDrhegGg6DKMvUGjQiReCUUJZ3UCQD1mZ1JtTXmYd+YrQuSlBGVS9eyGB qUEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=WzRpO7O4HpoKSNDDao5G6Y7W0aa0YkMXH2f3IzKXZCE=; b=j+e6s058YoOAbxPZwoZfC1QVgQ/beqNmCFuu+nNn3TVRTQZfsXen4YXq+jd5gvgnJk Mxm9VaL/1s/B3SBtK8/7F6SzXtgSEe3VUmLnnXWIl/srkD1JfXCarmzk5Plh3gq2BnN6 f0npcY/UTUJpvv7+sNGuDbjPgZjErnUDDiGcfz3aA4QzvQnwg9XSkR4O8ZiFol+a8Cp6 OcvKoR2Vw21onAle051PI6+pQlfTskfHsdFPG9DGjxY7Glo/lazzlHD9GEjhHSxGiHvx ZBYYC7edfMWnnUuCnZFSRorfkzD0CQGrSpZTD0me/teiZTE3/6huh+Am/4R2XZWDmANm T6PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S7tdJmhO; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id g34sor600500pld.114.2017.09.06.17.31.10 for (Google Transport Security); Wed, 06 Sep 2017 17:31:10 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S7tdJmhO; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WzRpO7O4HpoKSNDDao5G6Y7W0aa0YkMXH2f3IzKXZCE=; b=S7tdJmhOv9MopwK8zFDyWRlO9eKKmTrwSprYC3R0/w3XmhQ5oc8oFnPLsLa9mYI3ke klIO2+mFi5zBaqAQcb0jtKP10U0tAP6thfHQrudcmoJWlFZu7Ic5pB9XPn7h8p1xlaBO rfOGUuiRBPqP9x0Dt3Xtg4ksV7myLzlLtlin0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WzRpO7O4HpoKSNDDao5G6Y7W0aa0YkMXH2f3IzKXZCE=; b=FNI9wWDhtd+MMKBdNoqhKTmLjscxiq5ApPYQwordBP5PUK4JxRMACvllbWv3POohbQ 20BMDDiAovV/smc1rNB7p07LZ+KqKZyd1Mm2mDaNktcnU/giOlKNuR6D3Ia0ntORl9oi QTmteO285GwWW2uDI3u+ZHWutlLxaud5i7hudqGumftB7NFw8m4uowwaDWjcxtu8x59Y XvHAiqlyb6y9wITEmv2fnz1xBLRDGxT3bnZWaOlupvFBX++SAc9R+pDAXi4LEueZ2GVS 5HVQU9MlxRBbOzBxZHFeP5Kl/H6dnIcwkPg/wRHoEoNhi7CaxsZN/70A0Z9cnmnJryrt +PkQ== X-Gm-Message-State: AHPjjUhq9P7tC+/IFd0vgCagz2TQ6nalfobSsb/ysOCMUtUVPxLrhDjX LELxSc13DWmDsq8N0vg= X-Google-Smtp-Source: ADKCNb6/o02wk5zaH5dOY6ebZWYt0qu3c1gdb56eyzbnAKq98HcDN/jZ6LxbAgJKtcWsC1nvoP7f+Q== X-Received: by 10.84.232.6 with SMTP id h6mr1005904plk.435.1504744270132; Wed, 06 Sep 2017 17:31:10 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id o19sm987378pgn.76.2017.09.06.17.31.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Sep 2017 17:31:08 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Wei Xu , Guodong Xu , Amit Pundir , YongQin Liu , John Youn , Minas Harutyunyan , Douglas Anderson , Chen Yu , Felipe Balbi , Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: [RESEND][PATCH 1/3] usb: dwc2: Improve gadget state disconnection handling Date: Wed, 6 Sep 2017 17:30:53 -0700 Message-Id: <1504744255-25281-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504744255-25281-1-git-send-email-john.stultz@linaro.org> References: <1504744255-25281-1-git-send-email-john.stultz@linaro.org> In the earlier commit dad3f793f20f ("usb: dwc2: Make sure we disconnect the gadget state"), I was trying to fix up the fact that we somehow weren't disconnecting the gadget state, so that when the OTG port was plugged in the second time we would get warnings about the state tracking being wrong. The fix there was somewhat simple, as it just made sure to call dwc2_hsotg_disconnect() before we connected things up in OTG mode. But in looking at a different issue I was seeing with UDC state handling, I realized that it would be much better to call dwc2_hsotg_disconnect when we get the state change signal moving to host mode. Thus, this patch removes the earlier disconnect call I added and moves it (and the needed locking) to the host mode transition. Cc: Wei Xu Cc: Guodong Xu Cc: Amit Pundir Cc: YongQin Liu Cc: John Youn Cc: Minas Harutyunyan Cc: Douglas Anderson Cc: Chen Yu Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Signed-off-by: John Stultz --- drivers/usb/dwc2/hcd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index c263114..df54428 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -3277,7 +3277,6 @@ static void dwc2_conn_id_status_change(struct work_struct *work) dwc2_core_init(hsotg, false); dwc2_enable_global_interrupts(hsotg); spin_lock_irqsave(&hsotg->lock, flags); - dwc2_hsotg_disconnect(hsotg); dwc2_hsotg_core_init_disconnected(hsotg, false); spin_unlock_irqrestore(&hsotg->lock, flags); dwc2_hsotg_core_connect(hsotg); @@ -3296,8 +3295,13 @@ static void dwc2_conn_id_status_change(struct work_struct *work) if (count > 250) dev_err(hsotg->dev, "Connection id status change timed out\n"); - hsotg->op_state = OTG_STATE_A_HOST; + spin_lock_irqsave(&hsotg->lock, flags); + dwc2_hsotg_disconnect(hsotg); + dwc2_hsotg_core_init_disconnected(hsotg, false); + spin_unlock_irqrestore(&hsotg->lock, flags); + + hsotg->op_state = OTG_STATE_A_HOST; /* Initialize the Core for Host mode */ dwc2_core_init(hsotg, false); dwc2_enable_global_interrupts(hsotg); From patchwork Thu Sep 7 00:30:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 111844 Delivered-To: patches@linaro.org Received: by 10.140.94.239 with SMTP id g102csp54609qge; Wed, 6 Sep 2017 17:31:12 -0700 (PDT) X-Received: by 10.84.131.100 with SMTP id 91mr970880pld.247.1504744272754; Wed, 06 Sep 2017 17:31:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504744272; cv=none; d=google.com; s=arc-20160816; b=mrf2RQlNqGC4BLosnFLsHcpX8vWtvQxPZe+JVE2akBwYSx8qWqpKcGlioSvSXoMs6h 8Jkp2kY4et33qV254Gv7JDgiqqkuM1Yda5JpmAerUJ0GSl8bQO1fnqMy54qD1ow8S3xT et9f8miSea7izhCLcXF5xqAtWLYIYM5qkL2wLPpxyhGs2CURBaC+MWKSdBlMP8JXEszL HgCprbGcMZTVcLLc64Ix1xryywJ51KapO/ArTElw9zB9IV52TBAqpzLR7mtTTmyyoR19 NxywN+/CfwOYo9zINNFb9uYo5nkPffQdS3Yd7oJUde/1Pzx3iNunQCaUrx2SLh+i1wBY R8Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=QMQJfVjGhCqQeebsMU/4Yes5HlBi27BS34HjyHfo2gM=; b=jZEVX/zpIFC3AYeWMyvCQQwrMmeFSCRtzuZcFOENntYNL1bk7wpIW35M0b//ybGXl0 eg7rEt5weuz7RGt1pxbVEaW5GlvDM/OmmfRt7QmTHnbPTw8MU+YYVqTeIadkVR4cFlrg PE2TsVkw/ioRj2YA1omm8rSYzraoboCxtaxOPZfFJDGPFdA7nCJQF88KAk38+AHxQ8bz cz4LUq8SMzB58JeA4syqYHRPcNMUsvBE9lQfB0Ktbfq8MkV+0ObhdEJZFvgCyIjkHwKI NbfIiuGj8pkSBd8iviaWr30+P08ePuDEKaIcX+/j3Grjsgij2wF782NxW4A1Oo0Wd919 3SgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fyH0yCjD; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id y79sor544170pfb.107.2017.09.06.17.31.12 for (Google Transport Security); Wed, 06 Sep 2017 17:31:12 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fyH0yCjD; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QMQJfVjGhCqQeebsMU/4Yes5HlBi27BS34HjyHfo2gM=; b=fyH0yCjDK3xjc450Xr/bsa1e1PU9nQHxb0ypvAE3Zht5q48uSDtAXqsEmD/TIDQi8I 5r4dmV6C7hQJ48B8Cq7QIBOPxi8fxUvbliUAJZA3sv7JuKMF1waZcpSraRMsRoummjVR GtvaJ/g8wXmnzc23ZG+TSLoRs1dPjwz8q546s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QMQJfVjGhCqQeebsMU/4Yes5HlBi27BS34HjyHfo2gM=; b=imPxB0cn6X1V2Uo0HDHReE4zFblDy8AU5K3mpJyIb8q8PVNk9U+5rTlLG03zmfs5hB JoGTUw4SRIF9j461wzMviudqAqUAhQK/t6MFm+il+nKpP/EEfvr2u8aUrf4hG/TNlAsi Iqr4o37lEbxP3i1gtsYY5b66uNQGSkq0jx3EdTMmlZTqrCMBuUYZSagmYrHxuTXLgRW4 hH1p+J2cvX74ReaCSJYBkyInuHUxTsLM83n8K1E+bHHVyYWNbwgcqX9F4CcfH32ejsr1 1k2ZaiDDspw2DGjGT1ttYSXKty+SJ2m6ST273WKWwp0LLtfnCqRUIrHeKq7syIpQKhjo DQcw== X-Gm-Message-State: AHPjjUhVpTcXlR6+U2ifH5962igmfL3qDV3SNnDMOaIWsQppWH0DLdo0 x7oUxms13tK7G3okBFI= X-Google-Smtp-Source: ADKCNb7uiBOet+4danWCAv4I4fU2LQwlU6bB+CZwVAUKv1Xrh4OZfhPYB/Q04gY3myLhwI4AQbPnAQ== X-Received: by 10.98.215.18 with SMTP id b18mr938849pfh.25.1504744272427; Wed, 06 Sep 2017 17:31:12 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id o19sm987378pgn.76.2017.09.06.17.31.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Sep 2017 17:31:10 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Wei Xu , Guodong Xu , Amit Pundir , YongQin Liu , John Youn , Minas Harutyunyan , Douglas Anderson , Chen Yu , Felipe Balbi , Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: [RESEND][PATCH 2/3] usb: dwc2: Error out of dwc2_hsotg_ep_disable() if we're in host mode Date: Wed, 6 Sep 2017 17:30:54 -0700 Message-Id: <1504744255-25281-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504744255-25281-1-git-send-email-john.stultz@linaro.org> References: <1504744255-25281-1-git-send-email-john.stultz@linaro.org> We've found that while in host mode, using Android, if one runs the command: stop adbd The existing usb devices being utilized in host mode are disconnected. This is most visible with usb networking devices. This seems to be due to adbd closing the file: /dev/usb-ffs/adb/ep0 Which calls ffs_ep0_release() and the following backtrace: [] dwc2_hsotg_ep_disable+0x148/0x150 [] dwc2_hsotg_udc_stop+0x60/0x110 [] usb_gadget_remove_driver+0x58/0x78 [] usb_gadget_unregister_driver+0x74/0xe8 [] unregister_gadget+0x28/0x58 [] unregister_gadget_item+0x2c/0x40 [] ffs_data_clear+0xe8/0xf8 [] ffs_data_reset+0x20/0x58 [] ffs_data_closed+0x98/0xe8 [] ffs_ep0_release+0x20/0x30 Then when dwc2_hsotg_ep_disable() is called, we call kill_all_requests() which causes a bunch of the following messages: dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode dwc2 f72c0000.usb: Mode Mismatch Interrupt: currently in Host mode init: Service 'adbd' (pid 1915) killed by signal 9 init: Sending signal 9 to service 'adbd' (pid 1915) process group... init: Successfully killed process cgroup uid 0 pid 1915 in 0ms init: processing action (init.svc.adbd=stopped) from (/init.usb.configfs.rc:15) dwc2 f72c0000.usb: dwc2_hc_chhltd_intr_dma: Channel 8 - ChHltd set, but reason is unknown dwc2 f72c0000.usb: hcint 0x00000002, intsts 0x04200029 dwc2 f72c0000.usb: dwc2_hc_chhltd_intr_dma: Channel 12 - ChHltd set, but reason is unknown dwc2 f72c0000.usb: hcint 0x00000002, intsts 0x04200029 dwc2 f72c0000.usb: dwc2_hc_chhltd_intr_dma: Channel 15 - ChHltd set, but reason is unknown dwc2 f72c0000.usb: hcint 0x00000002, intsts 0x04200029 dwc2 f72c0000.usb: dwc2_hc_chhltd_intr_dma: Channel 3 - ChHltd set, but reason is unknown dwc2 f72c0000.usb: hcint 0x00000002, intsts 0x04200029 dwc2 f72c0000.usb: dwc2_hc_chhltd_intr_dma: Channel 4 - ChHltd set, but reason is unknown dwc2 f72c0000.usb: hcint 0x00000002, intsts 0x04200029 dwc2 f72c0000.usb: dwc2_update_urb_state_abn(): trimming xfer length And the usb devices connected are basically hung at this point. It seems like if we're in host mode, we probably shouldn't run the dwc2_hostg_ep_disable logic, so this patch returns an error in that case. With this patch (along with the two previous patches mailed out earlier: https://lkml.org/lkml/2017/8/3/1008 https://lkml.org/lkml/2017/8/3/1010 ), we avoid the mismatched interrupts and connected usb devices continue to function. I'm not sure if some other solution would be better here, but this seems to work, so I wanted to send it out for input on what the right approach should be. Cc: Wei Xu Cc: Guodong Xu Cc: Amit Pundir Cc: YongQin Liu Cc: John Youn Cc: Minas Harutyunyan Cc: Douglas Anderson Cc: Chen Yu Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Reported-by: YongQin Liu Signed-off-by: John Stultz --- drivers/usb/dwc2/gadget.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.7.4 diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 0d8e09c..7fd0e38 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -4004,6 +4004,11 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep) return -EINVAL; } + if (hsotg->op_state != OTG_STATE_B_PERIPHERAL) { + dev_err(hsotg->dev, "%s: called in host mode?\n", __func__); + return -EINVAL; + } + epctrl_reg = dir_in ? DIEPCTL(index) : DOEPCTL(index); spin_lock_irqsave(&hsotg->lock, flags); From patchwork Thu Sep 7 00:30:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 111845 Delivered-To: patches@linaro.org Received: by 10.140.94.239 with SMTP id g102csp54645qge; Wed, 6 Sep 2017 17:31:14 -0700 (PDT) X-Received: by 10.84.248.13 with SMTP id p13mr968753pll.447.1504744274537; Wed, 06 Sep 2017 17:31:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504744274; cv=none; d=google.com; s=arc-20160816; b=FXA1N7XDmxtcgSwLo2/sBEn7c07zeiUsOxeRpSvRmdumBisOpBQXQUw8Of0y8CWLA8 K64liIFPx4MQdsHnf401u8L/BNc8vBvuGeC7TDYz3hMhKTRr+Zh3mVx+bJirKKuFMsp6 /p8G/N9/4HWtIaHkd2PiuNfqvva6HxrAtuC+Yl+pTzlQiUrO6rsW1nQsynpbPL9S2wIc FgHLVUAl8ahbnsuU6VZ5eflLhMgb4pWEt4i4u1cFeRusabiV314DBwUb1l9P6xHJkuGv PNmfjgtVdhtk8ZI32mjD/fVTaTaExFRHCYvcjctCqEtWoUqO8lTlPvUsvEdpzXnDtHVl Je7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=M3WxAtVNlo56ELffA0RgMLbcU0FcXpzP/gl3tIwdcNI=; b=1JI1zr7z/ztQioPK3tBDsgQz1pawhQT35HLXGNabqos4k1DXcngcJH5Fv/ZAXhMRAq 22DEHpW8+LbmYa4DGjTbOjZxEgwJV0nhhWoZSlfsWer1+5X2u5uROihE3PWLE2ep+Mj2 JqdT9UdB0oy0fCWfeV8uwpy3p/rEvZIu9ArdFxJ65efaXgvtokwiQGSC2fShjDDIjeKB GF2MhJ+RNNAM68ex9z/pYskoSguCBCNZb104aD9AGDEI/dqRbwFYr3XPfFokRHGnLhDm so8HbS7703hMGZYiyWS1o3lI+840ePla8CloqjZhNjvEBE69aZh1k6jOrA14N485VQws Mmdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dg9jdPNN; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id r16sor545580pfk.115.2017.09.06.17.31.14 for (Google Transport Security); Wed, 06 Sep 2017 17:31:14 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dg9jdPNN; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=M3WxAtVNlo56ELffA0RgMLbcU0FcXpzP/gl3tIwdcNI=; b=Dg9jdPNNLcjbtoEnWfAoxgL34E2k4g+yzq6V3hHjzTiQIUiomdfG18nCFTGHW26GFx GezJ2d9vOK5tTuZuJsYw4MDnyOsk4uJVVCypwveTnjF7fqBD+VH3gdPpVxLwA1CzNyJx 8/2mxWvGVI5NtWPcZ0qksSyZZQSqlmp8JpUpE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=M3WxAtVNlo56ELffA0RgMLbcU0FcXpzP/gl3tIwdcNI=; b=lBRyKQFZ7jug8hLqAc7zpB4UHgRKAnum+Si/lgwpniTHLwulgraFkwlqDx4gAMqgDd Y+UbQOjXS1JxaNubP/AWx/kR/kYYSk44HqL7EwsW/WIHkMyK+z6Lbgkf3vg3zTlDq4U1 iOhYa8KZOMJbkm+Flg1SQagyQdlblkp2N+KeelGp7d1uAfDvfpWM+TOoToV2iZU0+S3h 59sIfAAWj0N4a5FVBBd8+0Bxw6MwOlTqtV/dXdbHiL0ZKOJv/cjo5KiYBw7npjWLaGY6 qlFHhQL9C3mr7/Gh/7wdlsBDr3WOOkT0xrbV65qDT/q8+d+nDDeKMRqfpZSfaevN4hnv EBMA== X-Gm-Message-State: AHPjjUjKu1Cc22rtFu9d3I+gHBt1DsXIf+HRJDreo7iY4NsmzakkED7O 6q2gVnArTSEeSZIQLjI= X-Google-Smtp-Source: ADKCNb6Z7sjLMwk5TQ7maPpgJ8HAgUuAwYYk0uJp+wFrzS2tTOmRxYaz7u93Xskg+lfY5tlMqdbIlw== X-Received: by 10.98.17.216 with SMTP id 85mr961586pfr.206.1504744274229; Wed, 06 Sep 2017 17:31:14 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id o19sm987378pgn.76.2017.09.06.17.31.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Sep 2017 17:31:13 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Wei Xu , Guodong Xu , Amit Pundir , YongQin Liu , John Youn , Minas Harutyunyan , Douglas Anderson , Chen Yu , Felipe Balbi , Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: [RESEND][PATCH 3/3] usb: dwc2: Fix UDC state tracking Date: Wed, 6 Sep 2017 17:30:55 -0700 Message-Id: <1504744255-25281-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504744255-25281-1-git-send-email-john.stultz@linaro.org> References: <1504744255-25281-1-git-send-email-john.stultz@linaro.org> It has been noticed that the dwc2 udc state reporting doesn't seem to work (at least on HiKey boards). Where after the initial setup, the sysfs /sys/class/udc/f72c0000.usb/state file would report "configured" no matter the state of the OTG port. This patch adds a call so that we report to the UDC layer when the gadget device is disconnected. Cc: Wei Xu Cc: Guodong Xu Cc: Amit Pundir Cc: YongQin Liu Cc: John Youn Cc: Minas Harutyunyan Cc: Douglas Anderson Cc: Chen Yu Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Reported-by: Amit Pundir Signed-off-by: John Stultz --- drivers/usb/dwc2/gadget.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.7.4 diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 7fd0e38..603c216 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3202,6 +3202,8 @@ void dwc2_hsotg_disconnect(struct dwc2_hsotg *hsotg) call_gadget(hsotg, disconnect); hsotg->lx_state = DWC2_L3; + + usb_gadget_set_state(&hsotg->gadget, USB_STATE_NOTATTACHED); } /**