Received: by 10.213.65.68 with SMTP id h4csp1439925imn; Thu, 29 Mar 2018 04:59:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx486SnALOt43hdan+q0g4QUi+THoKznS+6CQBRKCQtVRyBfws6FzmcB7hNzAKar1L5M0AbhS X-Received: by 2002:a17:902:b086:: with SMTP id p6-v6mr8144360plr.392.1522324793430; Thu, 29 Mar 2018 04:59:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522324793; cv=none; d=google.com; s=arc-20160816; b=txktpQZLOmiNFdH8UHHz2T+VVRUMDiGxB+y+WHK3kGKmU7yvQQbH/AF1HrNBwrmsSN mxYiWWjONwJDMCByx//XEO0T2sSr9ClkFqWANBoFoElvcsKk3s2vTlATtXEyg8AJVbe/ mUu+R5SRhRi4U4XNmM2Ph1lnmsA5Z6abAA2X+TK+ax4Zw8afqtXifHQv+m1LVl8K9vL6 1+HOuUFtp8d+PVo+5Zofqfkd9zjjgLLmeOCsKUgIMI+LpJQhpnYHlHGWE859nDES0+OS sdwLTR5u7SVyRiTDpQRz8PBQA7VJnoRPSZ2+OPeW6bJi1FALyH7ktbNHLtpsaiN14lG5 7uYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:organization:references :in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=kQscFaJsojYiAaJlGEZtqOA+gEkhAhSsLMfwzvj7IEI=; b=h+/is5wLhy24fvskuOD+qEsvaMJ+XXEXbVzewYIJYReam/7feZAdpKK0D6amkayB96 KRZ6YtyUZXtBKNmmN77o5Jxd5G4SdnMuAlIpDuZevWt9nH6hnTZV3hxR2f3FT4WogdO2 UHjU4oF1Vjxr1G2JorGzbGR8//Qn5QtxrnWt0eG73i/rCtKMheMT1Q5r6hVlW+bGViid t7QyLvdq3Ei6cb8mX29nm0K6AruUjQnB8Iz/+IHkAHZTXAi/yLTMjc/X+lJrICQapl5j CwMUBpuPdh0ixcemEexssb91Ne8a7OuJ1YlXbO2dqrK1zUg4DsLBRqru7wPJbbRfL/15 5dMg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q10-v6si6360745plk.29.2018.03.29.04.59.39; Thu, 29 Mar 2018 04:59:53 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752791AbeC2L6d (ORCPT + 99 others); Thu, 29 Mar 2018 07:58:33 -0400 Received: from mail.bootlin.com ([62.4.15.54]:38492 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751896AbeC2L6a (ORCPT ); Thu, 29 Mar 2018 07:58:30 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 2291E2084E; Thu, 29 Mar 2018 13:58:29 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from aptenodytes (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.bootlin.com (Postfix) with ESMTPSA id D947C2082C; Thu, 29 Mar 2018 13:58:28 +0200 (CEST) Message-ID: <1522324644.1746.19.camel@bootlin.com> Subject: Re: [PATCH] usb: musb: Support gadget mode when the port is set to dual role From: Paul Kocialkowski To: Maxime Ripard Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Greg Kroah-Hartman , Bin Liu , Chen-Yu Tsai , Paul Kocialkowski Date: Thu, 29 Mar 2018 13:57:24 +0200 In-Reply-To: <20180329092326.dayuccomq5zrywqo@flea> References: <20180328215213.29538-1-contact@paulk.fr> <20180329092326.dayuccomq5zrywqo@flea> Organization: Bootlin Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-KcNAmPIYuaVfct/gmWzv" X-Mailer: Evolution 3.26.5 Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-KcNAmPIYuaVfct/gmWzv Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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. > >=20 > > 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. > >=20 > > This fixes USB OTG on Allwinner devices that I could test it with, > > mainly A20 devices. > >=20 > > Signed-off-by: Paul Kocialkowski >=20 > 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. 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 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? 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, --=-KcNAmPIYuaVfct/gmWzv Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEJZpWjZeIetVBefti3cLmz3+fv9EFAlq81KQACgkQ3cLmz3+f v9FG7wf/VJuW12NwGOEyikbF5OZwdaANUeHk2zHL+Zqx6b4qGIGIC9beqWsmXilk disH1wNFb6VA3D4iAQRuvqke4euBlofR+yOyhw+cdMaFglpgeBzI0yG+zsvHsXzj SxV34r7/pMLIv/6B6PFLZz9KprOu2+W7hWH2vYX49yo1EWrxb4IwKMbzjxCVQXWQ +IUZ3S28I79N+bHjU0E8XUh86tVrnw7zxN3m5h+8DcOslaUTTAcXiM2H1V952iNG tCC0ysdoAOSCNik39lW3N8LnDaQguViAElQkJZwqA43fJJEGyPUds6s3L0M8Ygrh HC+/cI6jbQR56hlDhqUEe3kizt7lAg== =KyHK -----END PGP SIGNATURE----- --=-KcNAmPIYuaVfct/gmWzv--