From patchwork Mon Oct 23 21:32:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 116882 Delivered-To: patches@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5100861qgn; Mon, 23 Oct 2017 14:32:58 -0700 (PDT) X-Received: by 10.99.111.197 with SMTP id k188mr13222091pgc.344.1508794377976; Mon, 23 Oct 2017 14:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508794377; cv=none; d=google.com; s=arc-20160816; b=NbG4g4mymRZDyzH07FPxVmd6NCe5uGX2xNlTKDwAtNWMNZhyqx0MMPdBWjXScdi9Lb atzkaTxMwB8BoNhV37XMfYnnHG7ojYkVwwy57GNbqMjByOm7wW747FuDss3P9vi0xHxT z8XFRj4dOtHujpmIeGNCV5ISBfGbbtzuzKs5fMM0CiYdsPhBmu3YPdmOrBdsKlkiuQwJ 8iwr+itJlRW37IE6GKD6yL71EZXuamLuFSJSLcYcvn9EYfK+NzB/vZ5UiKjyxnSuLrLu k9eqq0ohosf7ZMXLcB6GoOl8dKdTk2HONpWOPvM+B2RflH37UECyJmj5e1d3ibbJvhzA 0MeQ== 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=MsB5pqxwEl7mT8S9AtfCVQXAslPmMEZsyYkPakhkrBk=; b=nvnsU/XvyH8xlMIc4LJw9ceM8YM+L1rjbmRUwRuKt++EJyE9R8QQm0jty0XKGFcA6P gSFMq5F/jB0lC8oY8t6YXTqaSwnNafiMiU6zB4mgQnsV6/q35NfoklmN0J5o/N1HelGs ZnlzbUFUYb9lxsxQt1co8GIt0aZSW1hLRTmWxCMY5ZyHNNKdE3C5VBZuAyZk7NvYfJzM mZb+EQC8e1uJtm4oY6Cx+x33pNmkhMfSKZQQdh/Un4oR6QPnIqmpzBDnVEUVInYUKf0s BLaxxxFEiCArylnXdMeN8C6vXzDkuKzF6sqwtsVCdH1aXxaM/L+NlRmz3CCejEUpsi1m dmyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eQAfQk7B; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 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-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id m13sor1990577pgt.374.2017.10.23.14.32.57 for (Google Transport Security); Mon, 23 Oct 2017 14:32:57 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eQAfQk7B; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 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=MsB5pqxwEl7mT8S9AtfCVQXAslPmMEZsyYkPakhkrBk=; b=eQAfQk7BoJXXcglPN+fVAmtOVDaTHXTltrlUbcTP+HC6xgjBlNQfFoM9arkYcTznCs Gq4yPWsB3AUwvnUgio3F36ydVLtoh6LqWX65MfbbGqHVmmKaDyLDcDsKCCvZShLs7a4i 8CDj1TOMS/RdQIeFDl7y7Plm9GO8THs3mBDLY= 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=MsB5pqxwEl7mT8S9AtfCVQXAslPmMEZsyYkPakhkrBk=; b=GfDVhWmqQ6jO/+KXCC6pk30ji2wJGmvJQSInizZC++dfqthaiZEdq4Rq8+XXGOoDs0 X+Jd4U3v4FkSmekx6/oASA9K+emtyXVpuzwgTIUXHKnKzPD1poZb0xrkbrGhLbnc8Gd7 LjbZJ+2eNAt5qG0W9TNO0AoP7L46irrLLJdftJLyuRdGve2JdwRT0rOt2a9av8Xlt/43 HXsyDQ1Q0Ta15x5r6O2OT5Yq/TeEjK9HJ9506MKsA0CHKEgGcsoqqbfYElukG0I+81sU QGlpTcS2Xlghh3bpmXLqVO5UTb3Ejrhj4Q8nkbwQeD3TzJd+EdkroFuYwelIZbDLA5oG YFVQ== X-Gm-Message-State: AMCzsaXmnF6GMKyeXfWysOopcK9A3RicLaWl9bRFhAbGT6LtSCwKo1y/ osonnW4T8QYahOiCby+QtuMsYTX+ X-Google-Smtp-Source: ABhQp+TQmW+ORfBqGU+O63aVD9SDJaua1nIeo6gW5RqxZcqvLQmZ3IJWxmd6H8ksBk6VCHDUhSBD+A== X-Received: by 10.99.98.6 with SMTP id w6mr12881073pgb.189.1508794377617; Mon, 23 Oct 2017 14:32:57 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id f11sm4518766pfd.82.2017.10.23.14.32.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Oct 2017 14:32:56 -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: [PATCH 1/3 v2] usb: dwc2: Improve gadget state disconnection handling Date: Mon, 23 Oct 2017 14:32:48 -0700 Message-Id: <1508794370-29982-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508794370-29982-1-git-send-email-john.stultz@linaro.org> References: <1508794370-29982-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. (This seems to be due to a quirk of the HiKey board where we do not ever get any otg interrupts, particularly the session end detected signal. Instead we only see status change interrupt.) The fix there was somewhat simple, as it just made sure to call dwc2_hsotg_disconnect() before we connected things up in OTG mode, ensuring the state handling didn't throw errors. 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 --- v2: Remove the extra dwc2_hsotg_core_init_disconnected() call I had added, as suggested by Minas. --- drivers/usb/dwc2/hcd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 2.7.4 Acked-by: Minas Harutyunyan Tested-by: Minas Harutyunyan diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index c263114..9bd60ec 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,12 @@ 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); + 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 Mon Oct 23 21:32:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 116883 Delivered-To: patches@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5100885qgn; Mon, 23 Oct 2017 14:32:59 -0700 (PDT) X-Received: by 10.98.49.135 with SMTP id x129mr14303634pfx.315.1508794379595; Mon, 23 Oct 2017 14:32:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508794379; cv=none; d=google.com; s=arc-20160816; b=CzJAmtX2wTGJj5ImpDTltXEsONNgu7PmgVAWowEpa69W5100dHOpouJGduQAI48hdb QcUgRt36zXXwfAQIcPLhGZoA2789mx6sst78kVsTnU6+S1ZyJQ+us2zzPW3fmRMtOLcf r2NxUhvsGBHWpVrCCqgg9PiSTwVg3VCOKUCdC/GLm/8fjqFCpCgq+zj2Mv0gfQa+z0tz 2EIlc9MNZcVaUKAb2Xn2uXk+tXjnC/zqehFoGwM1Ihi5eayvj6fofrOEkuwI78EKCjKn muqqMmrfdFtXn45dtQC/BcxXb4YCntl8eLClf9+Hyry/H8YlLZFGLSMKzdGflMhP3opQ ElvQ== 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=loVuU1UqdmMrTK+5BAYNKFKPigJBJ6IV0x8xa9ER6WE=; b=OgAP+5IWjMbF3oOjjWsPSi7h8cnCrqClpuhBnsYeAGI+ULMEt7JuHH56mlGFuQu+qg PyYsS+/J2vQXfgn+kkL4vYs1yo1q4ihiGNDqyXoQZG9HXRJ03W5KTG1DTAkhLsnFAgIZ TP//jnt/1/U1zXEzxfkZ2vm37QwyugZLQvfDKmcj6+ScbMD5mE/Bbn+6l5ZVJ7UoS/+6 3s9P9gdrw2cxzLTCd121HDKVuOIIxz/w/6JLJqrQR7BLUUxre7Z4ALAXR05cRW2B/bPl ZeaxTnub6SulpNtKlP/lFKAd7t9keuRLvc86QsTwtvMe0Jz6vsBdia6YHN2YN73jVRGq FXZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QjZ28vYC; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 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-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id w13sor1866044pgc.93.2017.10.23.14.32.59 for (Google Transport Security); Mon, 23 Oct 2017 14:32:59 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QjZ28vYC; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 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=loVuU1UqdmMrTK+5BAYNKFKPigJBJ6IV0x8xa9ER6WE=; b=QjZ28vYCB2omMpjysctSXEzggMwso/KMRhw6S5UsyOjiSD9sWcTIO4dWpaidPZcB4V SOwWv6QlCzV6MW6kdML4/Rh8ycpMKj/I8SqDiKC0/AcLME7XIfB6y6BmhiTYx2M+Ur49 e999AKaETXddg+r3S4gFuVvFlO63j+oY2MH8M= 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=loVuU1UqdmMrTK+5BAYNKFKPigJBJ6IV0x8xa9ER6WE=; b=VvAyNDNzM1V4OQ6ahwIi9doOuPHHzhJLU1Ass8Mm0vMqOoFj9QBNYwW/YDtX9EM6VL 5/EfNyF+WG+kh55MdNkVznsmnmIQMJ1jmq+PWy0NymL8LmlbrJOM9qjJ1HxyJ3TQdi4T /h36wD/zO8QRCf8YhxnzHl1kV5Bi5bZpQVwdoItsTvfJfSd7uCZohiLPogqLpr57w4mA JMACji8IVUUeFlEdNmKBILyi/dJ4xIlqe6Ve9tkLWRqxMLVTVj/EV5wjt6uW3D8FiSXH izt6j6E6rfP0FkQmh19lO9j49Y47RnRK/LZ05I2MrpGxR5BNqj7U5wMnb0xHukUlBTyO uIlg== X-Gm-Message-State: AMCzsaV/kH9cYgq/jKswNEVkk1fbp22XEXdV6glXpGK9yBnF2QMCmaIm qjZNL5pOoFSmUqp0m9YuXxG7qmms X-Google-Smtp-Source: ABhQp+THH7eqIcGEpfGChOnr2KuECtp4xWl419OJ7S50bHgENLz8APIKO60NbBBedl08a6UZPvnKJg== X-Received: by 10.101.80.4 with SMTP id f4mr12660138pgo.432.1508794379228; Mon, 23 Oct 2017 14:32:59 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id f11sm4518766pfd.82.2017.10.23.14.32.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Oct 2017 14:32:58 -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: [PATCH 2/3 v2] usb: dwc2: Error out of dwc2_hsotg_ep_disable() if we're in host mode Date: Mon, 23 Oct 2017 14:32:49 -0700 Message-Id: <1508794370-29982-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508794370-29982-1-git-send-email-john.stultz@linaro.org> References: <1508794370-29982-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 previous patch in this set), 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 Tested by: Minas Harutyunyan Reported-by: YongQin Liu Signed-off-by: John Stultz --- drivers/usb/dwc2/gadget.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.7.4 Acked-by: Minas Harutyunyan Tested-by: Minas Harutyunyan 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 Mon Oct 23 21:32:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 116884 Delivered-To: patches@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5100913qgn; Mon, 23 Oct 2017 14:33:01 -0700 (PDT) X-Received: by 10.98.87.138 with SMTP id i10mr14502373pfj.185.1508794381179; Mon, 23 Oct 2017 14:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508794381; cv=none; d=google.com; s=arc-20160816; b=yeEwp+MGHOK/E11+UGrPBePxscUZab5b7GiD35bUyD/OnPYEkxBueRxk+jr2XxJliJ 8zPub/SPMO41/EDPLv7C8vVvoj7XDBQvOMQW9gkfRFToaOIZV+4AlfaAE1V6MEGAnrFf /xHkAZQaT12J8yJJc7MCy9iD3waw/ArrWZzjzmUZQ93RX3ehJ9DvmdzfjYtWqGEryj/v KLa/4AG+tfGTHtg0Kyr5F9IJCwtu8FGl+gZOrdieulSN7ea8BXSvQrK9b1ppWfKnlQK/ zgJee2aZUL9/YHNciwBNlvrEf3jhn3lbhseQo0DMpoYdU98T9lIY9MPglJs2eFLNEUdK Z2CQ== 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=31oYxj9j368ELcZ5rGSGpd+VxzOrOYW97h6rNwsG6c8=; b=RHII1PIYyvq98bJLh+8Ac6YUknGTnCO0rmisebW49IjHlPR/14rrpGVm6Z6f6ZMHin AT4uQuckR4g2JEHion9M/EkjjejWsRFlaGRM4LwDyKsU4ETD3QDmOQhyfC5juMgXNWJi UiMxY0oZZECXG9iObYXPYtasP3vbMIt0pDmZf56XTK/aPcyI6kN1Dcjhmg6ZEGs8Pxtc eXJ0IyLclYFCdw/dUao9+cuYCxoxcjhmhzjb9ze3U866F3DhSWw4lhrS90farsJvEwmT ZNf/NDRc9bvHvoNxI8e2tw3i0UAny/7kHtj2SYAeY3Jt+tK3XaQkgJArF3GJK4+UWaVP kJpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fuxNIjBw; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 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-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id y1sor2339220pfl.26.2017.10.23.14.33.01 for (Google Transport Security); Mon, 23 Oct 2017 14:33:01 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fuxNIjBw; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 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=31oYxj9j368ELcZ5rGSGpd+VxzOrOYW97h6rNwsG6c8=; b=fuxNIjBwOkBU2FLSPrfNKal3WJpSiv62eVWnKDZheCWJyAt2lKFUEVKGao6uJsxw2e YD2fhFX8EuSm+UFtX2ZfG9dDU+CM7JhwmE249MVYe7HBQtFeL+AEDzpHOGU0APxxlEn3 4fMCJ3WIPHWJu69QwbQX7BwnZkyHo4FVgrNkc= 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=31oYxj9j368ELcZ5rGSGpd+VxzOrOYW97h6rNwsG6c8=; b=sfTMuhVl31HfQjscSuVCP7wGLfE7dQ1UqGiW9O1Lr/t1/86qEjvVAx0j1DOFVM9OSQ 1pLz45Hd9RbBanAy8QfPVTtBr1T53D1kqC9AfoSZMJn+8AkiDucTy5iTS2nsN2H444Gx 6Udf3xVXwys8VZVCNbxlxnKi9zqeJ2wa0/O2vp7H000uhlWxNkD0niyruUdB5hOlK9c9 rOBdzUfYJYOtMCmN5vR3tgjvH2zPRylpmh3M83jgy+hF3LzYJvSYuYvIRg+FSPCBAKhi mrKgpWZonQDdUyR+6695rL/r31U8040W56hhozkbFnLyuBKDWoljTqE+AnUinOvCe5AP qMhA== X-Gm-Message-State: AMCzsaVlN3FMEkbCckfobW+Y+HmUk0NVQ1nfFBZ5IpYnh2S4FD8YwbUO 8M2Vz8YuxTRRZmAtKVM3QW4sUPIc X-Google-Smtp-Source: ABhQp+Q/8785Qc/sn5/s+N2Mz9OMzmbs4alTH8xB2bPeEZiE75w6odU1pTVuKhrbmNCfCiyYcjjmcg== X-Received: by 10.98.194.86 with SMTP id l83mr14101015pfg.314.1508794380856; Mon, 23 Oct 2017 14:33:00 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id f11sm4518766pfd.82.2017.10.23.14.32.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Oct 2017 14:32:59 -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: [PATCH 3/3 v2] usb: dwc2: Fix UDC state tracking Date: Mon, 23 Oct 2017 14:32:50 -0700 Message-Id: <1508794370-29982-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508794370-29982-1-git-send-email-john.stultz@linaro.org> References: <1508794370-29982-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. This patch does depend on the previous patch ("usb: dwc2: Improve gadget state disconnection handling") in this patch set in order to properly work. 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 Tested by: Minas Harutyunyan Reported-by: Amit Pundir Signed-off-by: John Stultz --- drivers/usb/dwc2/gadget.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.7.4 Acked-by: Minas Harutyunyan Tested-by: Minas Harutyunyan 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); } /**