From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752544AbdHICaH (ORCPT ); Tue, 8 Aug 2017 22:30:07 -0400 Received: from m50-112.126.com ([123.125.50.112]:38243 "EHLO m50-112.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752265AbdHICaG (ORCPT ); Tue, 8 Aug 2017 22:30:06 -0400 From: Meng Dongyang To: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, johnyoun@synopsys.com, heiko@sntech.de Cc: wulf@rock-chips.com, frank.wang@rock-chips.com, Meng Dongyang Subject: [PATCH v2] usb: dwc2: skip L2 state of hcd if controller work in device mode Date: Wed, 9 Aug 2017 10:34:09 +0800 Message-Id: <1502246049-29373-2-git-send-email-daniel.meng@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1502246049-29373-1-git-send-email-daniel.meng@rock-chips.com> References: <1502246049-29373-1-git-send-email-daniel.meng@rock-chips.com> X-CM-TRANSID: j9KowAD3_t6Gc4pZ+y0CIA--.627S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrury7trykurW7Aw18WryDZFb_yoWkZFgEgF n5XF4DKr47Zas5t3Wjyw1a9ryftF1jgw1xuFn2vrW5tFs0qr95Xr4jvrZxur98WFW0yF9r AF42qr13ur1UujkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUeznmtUUUUU== X-Originating-IP: [58.22.7.114] X-CM-SenderInfo: h0xd06xkxd01pltxt0a6rslhhfrp/1tbiEwkvj1hglBHJnwAAsR Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the case hcd autosuspend is enabled, the hcd will enter L2 state if no device connected. But if the controller works in otg mode, the gadget driver still works in L0 state if connected with host. This may result in transfer fail when gadget enqueue new request but the hcd driver has set the global state into L2. This patch prevent the hcd enter L2 state if the controller work in device mode. Signed-off-by: Meng Dongyang --- Changes in v2:None drivers/usb/dwc2/hcd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 740c7e8..c263114 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4388,6 +4388,9 @@ static int _dwc2_hcd_suspend(struct usb_hcd *hcd) spin_lock_irqsave(&hsotg->lock, flags); + if (dwc2_is_device_mode(hsotg)) + goto unlock; + if (hsotg->lx_state != DWC2_L0) goto unlock; @@ -4446,6 +4449,9 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd) spin_lock_irqsave(&hsotg->lock, flags); + if (dwc2_is_device_mode(hsotg)) + goto unlock; + if (hsotg->lx_state != DWC2_L2) goto unlock; -- 1.9.1