Received: by 10.192.165.148 with SMTP id m20csp328674imm; Fri, 20 Apr 2018 07:27:17 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Po0e2OvnfniAerpC4HhsnYWaYD2xBPP0gZxy99RXaKWTiFpmmsGfW5vxcHKPkqFjQ2LQw X-Received: by 10.98.35.11 with SMTP id j11mr566078pfj.177.1524234437208; Fri, 20 Apr 2018 07:27:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524234437; cv=none; d=google.com; s=arc-20160816; b=kpeAOmskuagg8hPOhJsuVlDLupAfkK1AWXvw+niBEedMN1kRTFovxdr8EG1VXfsl96 guBMW10qMUSrbZ3DVkuKGXBcvNcK8LKgHUQXap9EiQaa20bcc7q8fvpruFKoYMWgoQU0 Gjm0/Pp7ue+u0gNWbwyMPZtllMprRZsiEj7/XV2gYkJMlKIWv+JlhgcmOyUSVY0/CwpR B79/Kd7/I5UIYsSovO0Wvnl4gI3qVXAcgLJhS28cuuh197PDIqsvYmJy8CMTLuPlq2++ rTI+Tcv7mDXUKI+pJejd6fbNksmE9qMbzNoiLgMf/SLi/XLNywl2rvkzh5lhLsRn/m45 PdJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=SzaY70idKtePIK+t8g+k6yRZRfxhCB9nxzJwZQZBdAg=; b=Pmcl4t/GBCQBiAGCMxueC8lthOlLpSqilvvxtbrEQMqGSkBCpuPAe2DYywywDZLQ31 avCrX0YXbdUn8g6z5X4c8mmix2deAF/UOSujcDrEM5HGk2fVf3bHPghiW6TjL787q5XC M3PeT1+j32489/waByDaK7tOocsmDGHYIVtUUF++hQSFPbntM0GtCogKpGSzpgiz6e9U gi85kXfr3LJGKmj0EHj/73DT/ZDuHfyAX0ycBX/0cOLZFy2qpCfDyHS4mAORhyvKObqX fDpnT/q1/zUXhov5cDRsOdlxVOg/SMksvazTVqwRBZ/GwaBJ9E01EWG7ijNGbtGVD9ZQ 9BnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Ci/iit2q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h23-v6si5627684plr.576.2018.04.20.07.27.02; Fri, 20 Apr 2018 07:27:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Ci/iit2q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755281AbeDTOZr (ORCPT + 99 others); Fri, 20 Apr 2018 10:25:47 -0400 Received: from fllnx209.ext.ti.com ([198.47.19.16]:12413 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755147AbeDTOZn (ORCPT ); Fri, 20 Apr 2018 10:25:43 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id w3KEPPZP007908; Fri, 20 Apr 2018 09:25:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1524234325; bh=ly8lpEC0YkniXkaQ/2CADZocRYxyYuAA23oZSeRXg4U=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=Ci/iit2q1bWYBveK/PsbfdIIxy2IfbrDxA/W1fmq3Neqhp4lqrH8WLT1yFx9Z6uBG uvT+Kl4ZngLZYI8XbucJLKgWXKPgm44PcVc/evpeMpuYvp4rDddqun0AjHB9SXCR0h xlWcL2BoGuQkerLd5TuKhwwTvZZkZFgZSWDgkaYA= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w3KEPPwJ002419; Fri, 20 Apr 2018 09:25:25 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 20 Apr 2018 09:25:24 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 20 Apr 2018 09:25:24 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w3KEPOZh017151; Fri, 20 Apr 2018 09:25:24 -0500 Date: Fri, 20 Apr 2018 09:25:24 -0500 From: Bin Liu To: Paul Kocialkowski CC: Maxime Ripard , , , Greg Kroah-Hartman , Chen-Yu Tsai , Paul Kocialkowski Subject: Re: [PATCH] usb: musb: Support gadget mode when the port is set to dual role Message-ID: <20180420142524.GB29011@uda0271908> Mail-Followup-To: Bin Liu , Paul Kocialkowski , Maxime Ripard , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Greg Kroah-Hartman , Chen-Yu Tsai , Paul Kocialkowski References: <20180328215213.29538-1-contact@paulk.fr> <20180329092326.dayuccomq5zrywqo@flea> <1522324644.1746.19.camel@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1522324644.1746.19.camel@bootlin.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 29, 2018 at 01:57:24PM +0200, Paul Kocialkowski wrote: > Hi, > > On Thu, 2018-03-29 at 11:23 +0200, Maxime Ripard wrote: > > On Wed, Mar 28, 2018 at 11:52:13PM +0200, Paul Kocialkowski wrote: > > > This allows dual-role ports to be reported as having gadget mode by > > > the > > > musb_has_gadget helper. This is required to enable MUSB at all with > > > MUSB > > > glue layers that set the port mode to MUSB_PORT_MODE_DUAL_ROLE at > > > init. > > > > > > Most notably, this allows calling musb_start when needed in the > > > virtual > > > MUSB root HUB, regardless of whether the current mode should be > > > gadget > > > or host. > > > > > > This fixes USB OTG on Allwinner devices that I could test it with, > > > mainly A20 devices. > > > > > > Signed-off-by: Paul Kocialkowski > > > > Surely there's more to it than that. The gadget mode of A20 boards > > have been working in the past, including when compiling with mUSB > > setup as dual role. > > > > Is this a regression since a particular commit? Or is there another, > > deeper issue overlooked in the commit log? > > The root of the issue here is that musb_start is not called at any point > without this patch. My understanding of the flow is the following: when > the PHY detects that there was a VBUS/ID change, it will notify its > listeners (mainly the musb sunxi glue layer). This will then schedule > the driver's work (sunxi_musb_work), which does nothing since the > SUNXI_MUSB_FL_ENABLED bit was never set. This bit is only set after > calling sunxi_musb_enable, which is called from musb_platform_enable, > that originates from musb_start. > > Currently I see two places where musb_start is called: > * musb_virthub > * musb_gadget > > In the latter case, it is in turn called from udc_start, which should > probably (correct me if I'm wrong) happen later in the call chain than > ID/VBUS change notification time. I don't think it is correct that udc_start() is triggered by ID/VBUS events, but I don't have an Allwinner platform to verify the callflow. Have you tried to load with a gadget driver? When a gadget function is bound to UDC, udc_start() is triggered, which in turn calls musb_start(). > > In the former case, musb_start is called in the root controller hub > control, when setting the USB_PORT_FEAT_POWER feature. This looks > perfectly legit and IMO this is where it should be initially calling > musb_start in the dual role case. The kernel is indeed setting the No actually. A dual-role port should be in b_idle state by default, so logically all actions should go to the gadget path until the port switches to host mode. > feature, only that it fails to enable musb without this patch. > > First, I'd like to make sure that this understanding of the flow is > correct as I may have missed something here. Does it make sense? I am guessing you didn't load a gadget driver when testing? > Then, it seems that the offending commit is: be9d39881fc4f > ("usb: musb: host: rely on port_mode to call musb_start()") > > That itself fixed: ae44df2e21b5 > ("usb: musb: call musb_start() only once in OTG mode") > > Still, this commit was authored in June 2015, so almost 3 years ago. > In the meantime, the sunxi driver has received feature improvements, so > it seems hard to believe that it was broken all this time... > > Cheers, Regards, -Bin.