From patchwork Wed Sep 20 19:57:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 113170 Delivered-To: patches@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1171331qgf; Wed, 20 Sep 2017 12:57:33 -0700 (PDT) X-Received: by 10.84.130.35 with SMTP id 32mr3112580plc.368.1505937453803; Wed, 20 Sep 2017 12:57:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505937453; cv=none; d=google.com; s=arc-20160816; b=Nf/M40b5Pax1rLt7FEvIdQcQu+lJlYZPV9Ng/MmXirml4LUy+ySmcwnDUzLXEDDywz E1MO1Yumc91OqgQxQkVDICvu2/hBMv/K6qyesn+sk5llEh6dFmVLJ6yOQGwM2CAtEEMI ABns4sdybFbh9PVGGce/M9wC6XGqlTxFhAW+xq3WShKBTrUMQHmL5FNvhzwuQQL/09hG +pTBW1r172bkHUQhUkdb2V+BFdwRROFW2919vbgbIWIMsSUSegOscvBvBFgBJP2CfmSm /177h2ll7dAPr88OQU737352E6IZYgm3gYchY4hSAfRt57SgbbMOkI3nbBti3EIZhgAW AxxQ== 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=vreeTt5H6dL+R0fJJeuxucZiVbd7Px180f2ZGzmtpX4a0fFFfFSP/QSHysfGUL7eVQ PeEgUweaOQEy8287mJOUQDlIVNrk8k363G4LyOqULUTAMQmJ1kFlx4VGxHCH9LvIHlmh Wcn2yUuqX5TTxn00zxxd61wZKSworESRkR93REvkkCfr2NoWB/V7Mtz+KOjt9P9t0mTU l/JbG9paHvOxGasukoSv/3N84ja6ptslnLZtmoi5l1Dx+bjVWk+73EC0qNEC/uqBQePX asb3U1nvFtf2JhfzgH3Q+PBPRjHLYGjdjAh1fkrNWOzt1GP2v/yGRLCvZdQneVIJZdYx PTDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EEXoHFgf; 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 i5sor2344776pgt.368.2017.09.20.12.57.33 for (Google Transport Security); Wed, 20 Sep 2017 12:57:33 -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=EEXoHFgf; 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=EEXoHFgfmaqAwhNzjMmooPRPSzKO4yD5fnG5LjdayffLnF2l2SszBuZuzXGTzohJnU AnVHx5N19IHi0YFr4BDvhaOuBxdV8IAp69XO82Pc/rxY25u0/fZbTFqnzRF+Ae2hfDGc 3UGBOxr1Ej0lpzEaLOgy6M17QQ8P4x5ztZFxk= 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=HeJfHzXdS2XPMh/jl1hrtiBeELiYm+VbgwyVqK6dqJkiPKFEtPWCUeagjgtveuNqA6 jQDeUjmYGo3CaNZNuPSb5ajO/exhhgU3t1bS6CDRP6Kafvkh5ma+eRz7lgRtlw/Rjv6j M6lr1tKcBVXBfo4/sp8UYxmvmRydp2C5X3qxKiztZynv9v0SCpfLAB9OK2ArtDTLWw6G V3VsH9/jvZmYltRkCxe/khMVVThvvMJ6eUhHHI3ZAwjh22/5yEKlCQt1sAiQkOb5B/gb G8xZXOl9X8TO11cIwiZTz/ZeHQNFjbsFAEub/uEaV2v8DMhAATwEYVHAYUvjojfsnFui Nxzg== X-Gm-Message-State: AHPjjUhCe1M8bJsZcfaIDAgPTXUBKlQqYBcVeeOpmTA0fcbDhugMjxGS RhVKnIyo7aI2gCsT3cnJX2ds3ZWt X-Google-Smtp-Source: AOwi7QDFAne6TyhYil7FYhx/L3kTgBh98LR8TCKJWIMNUzO0RC1SMXMuj0zo/EP3FDEHKLzt87Z+ag== X-Received: by 10.99.151.2 with SMTP id n2mr3390752pge.315.1505937453483; Wed, 20 Sep 2017 12:57:33 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id i2sm9991660pfd.21.2017.09.20.12.57.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Sep 2017 12:57:32 -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 x2][PATCH 1/3] usb: dwc2: Improve gadget state disconnection handling Date: Wed, 20 Sep 2017 12:57:26 -0700 Message-Id: <1505937448-13475-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505937448-13475-1-git-send-email-john.stultz@linaro.org> References: <1505937448-13475-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 Wed Sep 20 19:57:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 113171 Delivered-To: patches@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1171356qgf; Wed, 20 Sep 2017 12:57:35 -0700 (PDT) X-Received: by 10.98.201.21 with SMTP id k21mr3290725pfg.262.1505937455609; Wed, 20 Sep 2017 12:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505937455; cv=none; d=google.com; s=arc-20160816; b=Wss3NbBqkhbv2eORs7cjzrHxfPW+qFCnik9cm56Amhv8g0igb9Gx+tjXTqdAAvRdAE yaOwE9eNRH35y+vOuEBYw+QAoU76T9E4PaL8MAhlovXUtj5fr6UpEMr0OEDHayUMOC16 helq7dbI3AAkn0bGRrpaSedng5vgt8mOQisQvFBi9AJbPLnOMsQniXsMu3/WDFw5zhxH yqPl0X+tM3VW9AspYC3/UD9NdYr5nkeSv7XHfus/ctyQf6HfjjgY3qz9H1jEaftNaWCR b17czAn3VUj2Qt2tEBUm+sypP7Terffj/zesr41zt84FOPmee74w1WP/Gwxu0G+uh4pM L80Q== 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=LPI3szkAcZBDQZz3bykwIN622opm+0cMW2LKhiUQllRKiE77HHEYO+WNeMZmRuos4h pik2LsVAP4X4UseG40CyKwPnZdRWq1oVOdYCWggmiMyp2v0wN0WMH/oDGtK//s64r1EN Dwy00dnzJeo+ykqgbv31mqfvINn+AXZ74A3ojvSRdPT0DeFy4SjkistRKLYMcOvDBWsr fDTAROoXlAb3SGirMxpCr6hJ9axQnm8O60UV/1JbBkxlM0VdXp64JUeqwexHfyharyck mDqnFx9gV7PNrhjfOdvUtUNFpGm6JlurLNRrrIv1FBhHsXT52lLE3K4e435oLdWd4HPZ 9zJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RS7fAyNF; 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 3sor1392929plz.67.2017.09.20.12.57.35 for (Google Transport Security); Wed, 20 Sep 2017 12:57:35 -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=RS7fAyNF; 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=RS7fAyNF5QKc9W0BeJmyQSlvEThJg/0vtILReTOhR7rasucTjZKhDeLWkht19QL4Gc D3MJPmpMG4Cpm8fQf5j7DWjCg56GIxwE5CRtCIhOm80wv721POn84A4d0+yFMVjbOP6L 8/rAzZ2yTRmBt2fpn8pStJZ/vm7H+HM5kiMII= 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=kqx53jg1t7S5yzN5YVA/a3fmlydoKTr1HeCpSG/dpcdDYB5jueBH8wnsU3VLJVroWX yQZAVDugVddJuJg/1EE6ww2xj0qQVdtD719pdyOlmtTzaT7TvpseqDivyukdvza8HGLz jvFjljjtNmmfmVhCt1a/KtYzGRrEDnyu64Bv3xtrvOeERSZ5ML1ngC5hHisZe/GVM9L4 6tj0BH6o1qM9TauaOHQm8gdrCthoH20BmCQ4Fo4NzwWPLBZoEPypHfmRRlNgHVfxMsKG Du/CgcWYQ12pcP9iCjlASWEqqSXxU5XuBJXyVt+DdVTYjmkpFUxFcMaqO9RjhRm250wG sD/w== X-Gm-Message-State: AHPjjUjIA0xWqcFpEqrThxU8LBfo/7BYsZraEkmHT1VmV45wkQZGXFPL C1i+e0wM3F71jsub6kbOweuaAyKA X-Google-Smtp-Source: AOwi7QAz8K2an9ZWAyrHHHTv3t2UvW+6MHweCrHkhA+fkeiOWjYqpUAv3klObLZJkRkOrw/i0N3UKw== X-Received: by 10.84.177.129 with SMTP id x1mr3206601plb.161.1505937455277; Wed, 20 Sep 2017 12:57:35 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id i2sm9991660pfd.21.2017.09.20.12.57.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Sep 2017 12:57:34 -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 x2][PATCH 2/3] usb: dwc2: Error out of dwc2_hsotg_ep_disable() if we're in host mode Date: Wed, 20 Sep 2017 12:57:27 -0700 Message-Id: <1505937448-13475-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505937448-13475-1-git-send-email-john.stultz@linaro.org> References: <1505937448-13475-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 Wed Sep 20 19:57:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 113172 Delivered-To: patches@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1171381qgf; Wed, 20 Sep 2017 12:57:37 -0700 (PDT) X-Received: by 10.101.64.72 with SMTP id h8mr3345613pgp.110.1505937457409; Wed, 20 Sep 2017 12:57:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505937457; cv=none; d=google.com; s=arc-20160816; b=LCjW974Y7z21ADAc5D9VcOEDfRkAnvdt5GwQBYACFw4XKvf1tkQyE2T0xGVHFhRnJh w9suP1DtxuwnPP1v3RnHuLQpagRWJNHV3xm2BFpv1qnn8P3o95NiT8U9Al13tUQmGKXk qszW8OVa/XOj6JavKgD4XG76mDO5K80g8y8Llcq9N+tNr5T+Ic8WTRDOWGG2IzYJ1MV1 9g2ZnLD+UBN4l9aOtU/2Pl2GmAc2h+Ytl5nZGBPIK9qMsZqLRztdl16YvnYT4Qv6yDIe hNqIraLPB/P4gqYCRF/839u54y/dIX8ujxKjR5ig/pDg+FrrkmKydI/E+1yMDLdS5lMo tK+A== 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=G8DnrRUlKAM749Vbf9PvJpPHAC3WTIikCRv1clO5Sy/5Q9KaKzftjoQZU6fylfBSfp jV9Koa5a02GNTGyf3Wzvi8dA999tBW+EG82BAL1oOHGJJVwI1frAX+mGKrLQzfkaxyMw 6Akeh8xuAzImcOCo5+QUPzNeVYCFHroj44jDTAad+2KN52rj8yA6gNdeUo8Rygjl4xm6 zPpSRCCmB2nhtT572FX/yhHqeJ+IDBNJNvotrvyYDUD3cmsw8Bahhup26hAV71ZQ4MSN uXuUlEqCwWlYQcNqgr2hzW68fbIXReSzyVz1yCYr9PpsCoRPc9vapZxhpnvGgbLk/hC/ KnVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C1+PWnAl; 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 1sor159798pli.77.2017.09.20.12.57.37 for (Google Transport Security); Wed, 20 Sep 2017 12:57:37 -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=C1+PWnAl; 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=C1+PWnAlFbD7zV0nEtQhu0RO0DPAOJLV/d0zEwQLF5LjXUYjqlG9vTRaKf8W8cXOsW ga6k7HxvF8dUBznGSIS7N9Xw1IT3xfj1KjAMEE7kVcfrWKrPGa8jgFeEaov2ITT15FjL sG1U2JFLVXunio7JzUduF+/g69TroyNhKUpjY= 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=WibAsiQK65u8mtkqAq5JMYfmL9zyx0FsJ7nvDCxmUAnUyvf4qTYjQ0r59zdvh+g1Hb McjTLxTr6v3Mjig32ISYblqunB25dAWiikkDTTqk9Z3TpRJncZUC+ip1LoOCFcc5OvgS Z3hEbQ2Je4IsxBthIDhKHDZSNMganNSHpria3n+Iv1jl8yU6BCDAE9X1rJq63cReJ0TD SO4pbOOLOkOuktDs2Mk92ZfvzSoO25amWHVldhWkvrRxrtzmEI4lri1G0E3382J+7Dw1 VZb0rhZ1TyzskSf8v3fu5MU6a3dkvhcHhjOnl4OYFBQIvv+9zQcaJKUOnMPfOr5A3t8F /+lg== X-Gm-Message-State: AHPjjUh7T8R284M9LOHUK1YWAFoyhEMdDpOk7L8AKGRbgVMkGB+F53qZ pmDhPdCDhO7KoI/jvJhAFcnfib9j X-Google-Smtp-Source: AOwi7QDXzM/DlKScNCsj9CPfID6PRkmSXfYbNfacDSsYUlxX4P5IpiPnJIwro/NLqAIhUiIPt1Lf5w== X-Received: by 10.84.171.129 with SMTP id l1mr3155142plb.39.1505937457131; Wed, 20 Sep 2017 12:57:37 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id i2sm9991660pfd.21.2017.09.20.12.57.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Sep 2017 12:57:35 -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 x2][PATCH 3/3] usb: dwc2: Fix UDC state tracking Date: Wed, 20 Sep 2017 12:57:28 -0700 Message-Id: <1505937448-13475-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505937448-13475-1-git-send-email-john.stultz@linaro.org> References: <1505937448-13475-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); } /**