Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1763019rwb; Fri, 23 Sep 2022 18:54:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4WTGTHdIapjz+m/nS4qBQpr207WMADypk+qY57dhIYncVWRFA7xWvSToeTC/mZIg+6WYdp X-Received: by 2002:a17:90b:4a89:b0:202:b1b7:7ae with SMTP id lp9-20020a17090b4a8900b00202b1b707aemr24286375pjb.149.1663984453172; Fri, 23 Sep 2022 18:54:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663984453; cv=none; d=google.com; s=arc-20160816; b=wOP16w9YkRi93oc29edpzOAPDpwsRCNFvVb9xxALoBK7LXzNCTKD//OOhhFNIlsdVQ AMQZxwnVGGqABSj1IsYylS+I1l1hHGmtII//sgfFAVv2cYCfajvb82VFH++hxdCf/Ft3 MA7zPJaz/Yv5wGhzQW8aCyV+SQGw2zDmq1mtVI3znl8jUesKlTQmmGe/R70GX2lMajhx i21hwKhaU1yn78Qu+2Yfec5pyaqWKhAPG3baTL6Qk0e2mW+uH2YDSxcCTTohCmN9jWxB F1aSm9H6oCZdWlvzaXlRIyeHZTqhW5Hxf2c2R4+mZic7X1FsImt0RiXC3E6hOEfJ1uGJ prxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=FmXNgKNiR6L03MR28liqOUt594RqBBZGOnZhnHELJMk=; b=tlTc6iKfc4xNnld+wVcj9Pyu2LuxjBU2mrVZ0LbG+90Hi6+X8xxgQ0YYNEHjaUrNZ8 C3gpbe5WNBfXQwF7U/EYD7mQkIsivN5j1hXpMxMNboV9RrDItiS7EhonIQzl548WV3Vh WPGpu0bmH+RNwzGGl6ctOGqSADivdVz1mc62HwTsBkX4RGjzDn6S7U9SlMkxM/y7dBOx HMgetptvEGuayEUqFfgDHSKZotjA65OtIgXUwpmOebCPSdsVyOfzz7SefsyNH3Px6bJu LgvIHH1Gr4goLVrIV9k1k3tZvubVimXN48b2zmOiNcWW/6tQbjod/BBXTo7Tl6IrwAx2 G/3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=avhlzXJi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a186-20020a6366c3000000b0040c99b681a4si11272508pgc.23.2022.09.23.18.54.00; Fri, 23 Sep 2022 18:54:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=avhlzXJi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232923AbiIXBfN (ORCPT + 99 others); Fri, 23 Sep 2022 21:35:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231379AbiIXBfM (ORCPT ); Fri, 23 Sep 2022 21:35:12 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C96133F1FD; Fri, 23 Sep 2022 18:35:10 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id l14so3911729eja.7; Fri, 23 Sep 2022 18:35:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date; bh=FmXNgKNiR6L03MR28liqOUt594RqBBZGOnZhnHELJMk=; b=avhlzXJiFl2JtY7A4VK/eK93CT8mXZlE6+Iq/5dEiB/Lle6blMlzLEkbYwfYxBk6Ue 0pp8WoSyp/jlDPIQ/lGRRLJq9YMlK5AbPfJylxuEeEPBYxdFbBiyE0RdfGnLwP7usIsq y21X27Lrc6nrMCqx7V8i1r/KJgBeyvn+o+ZxtOUrll8zvluM3cP4jzvKa4NJWEUwIrF3 t7XwqgqddovyphLBUHTJXoFYdMPJzhGzMUh+QeivE/8HFOXjnOUs4Ckr9AvVgt6GCGnf sM342dsszjWMDJxMnvEOshZpQ4zwbq3vt4BoqrZGNG16OFHkLMJpbubmQiEmRAeLNwn5 XziQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=FmXNgKNiR6L03MR28liqOUt594RqBBZGOnZhnHELJMk=; b=zZayATP3IO4LgUG2iARRBdadTTu1ugeMqDCF1dRilZDOoOfJYxLkKC38PZyQG98jLo GhsmMYss0ziumCpytzO/HXfhv3b6Z0FwcytGAE3UuvUpzFvrzUGyXqr0Z3l+CbhseHBR oV2us7yq9hV3OWd9BNU08jJw9ze/KIgR6SOhg04x9Xam/Et28k469Rjg6mBi2Bcg9KzZ UdgC6IaE2tvdFXrlqfuxIPNceJdGBKCkMr2y1hwL0+FblohP9VVIZpnYIeo1d2MCHsKd Pc4ZTsq/nCH9LUtenGAPDq6KEwqgL6StWKc5OrnWNoJMt9ovUuGWgFE6IfsJYNbUUvqm zIDQ== X-Gm-Message-State: ACrzQf2FykeMgk0nD7jVmaHtxgf8HY54CSYW9p6lw3QFHMyhFqCLd1IK UVl3Yd5Ty+0kQzojnffd+KTM5Fh6upKBFa+xXqs= X-Received: by 2002:a17:907:6e27:b0:782:9f5f:fb5a with SMTP id sd39-20020a1709076e2700b007829f5ffb5amr5064100ejc.75.1663983309293; Fri, 23 Sep 2022 18:35:09 -0700 (PDT) MIME-Version: 1.0 References: <20220403164907.662860-1-andrew.smirnov@gmail.com> <691c3073-5105-9a2b-e6f2-ea0a4b8aaea8@gmail.com> <47a0249c-e129-7e98-503d-4254f216e485@gmail.com> In-Reply-To: <47a0249c-e129-7e98-503d-4254f216e485@gmail.com> From: Andrey Smirnov Date: Fri, 23 Sep 2022 18:34:57 -0700 Message-ID: Subject: Re: [PATCH v4] usb: dwc3: Don't switch OTG -> peripheral if extcon is present To: Ferry Toth Cc: Andy Shevchenko , Greg Kroah-Hartman , Felipe Balbi , Thinh Nguyen , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Thinh Nguyen Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 23, 2022 at 2:12 PM Ferry Toth wrote: > > Hi, > > Op 23-09-2022 om 18:42 schreef Andy Shevchenko: > > On Thu, Sep 22, 2022 at 04:32:55PM -0700, Andrey Smirnov wrote: > >> On Thu, Sep 22, 2022 at 3:23 AM Ferry Toth wrote: > >>> On 22-09-2022 12:08, Andy Shevchenko wrote: > >>> On Sun, Apr 03, 2022 at 09:49:07AM -0700, Andrey Smirnov wrote: > > FYI: For now I sent a revert, but if we got a solution quicker we alway= s > > can choose the course of actions. > > > >>> If the extcon device exists, get the mode from the extcon device. If > >>> the controller is DRD and the driver is unable to determine the mode, > >>> only then default the dr_mode to USB_DR_MODE_PERIPHERAL. > >>> > >>> According to Ferry (Cc'ed) this broke Intel Merrifield platform. Ferr= y, can you > >>> share bisect log? > >>> > >>> I can but not right now. But what I did was bisect between 5.18.0 (go= od) and 5.19.0 (bad) then when I got near the culprit (~20 remaining) based= on the commit message I tried 0f01017191384e3962fa31520a9fd9846c3d352f "us= b: dwc3: Don't switch OTG -> peripheral if extcon is present" (bad) and com= mit before that (good). > >>> > >>> The effect of the patch is that on Merrifield (I tested with Intel Ed= ison Arduino board which has a HW switch to select between host and device = mode) device mode works but in host mode USB is completely not working. > >>> > >>> Currently on host mode - when working - superfluous error messages fr= om tusb1210 appear. When host mode is not working there are no tusb1210 mes= sages in the logs / on the console at all. Seemingly tusb1210 is not probed= , which points in the direction of a relation to extcon. > >>> > >>> Taking into account the late cycle, I would like to revert the change= . And > >>> Ferry and I would help to test any other (non-regressive) approach). > >>> > >>> I have not yet tested if a simple revert fixes the problem but will t= onight. > >>> > >>> > >>> I would be happy to test other approaches too. > >> > >> It's a bit hard for me to suggest an alternative approach without > >> knowing how things are breaking in this case. I'd love to order one of > >> those boards to repro and fix this on my end, but it looks like this > >> HW is EOLed and out of stock in most places. If you guys know how to > >> get my hands on those boards I'm all ears. > > There are still some second hand Intel Edison boards flying around > > (but maybe cost a bit more than expected) and there are also > > Dell Venue 7 3740 tablets based on the same platform/SoC. The latter > > option though requires more actions in order something to be boot > > there. > > > > In any case, it's probably quicker to ask Ferry or me for testing. > > (Although currently I have no access to the board to test OTG, it's > > remote device which I can only power on and off and it has always > > be in host mode.) > > > >> Barring that, Ferry can you dig more into this failure? E.g. is it thi= s hunk > >> > >> @@ -85,7 +86,7 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc) > >> * mode. If the controller supports DRD but the dr_mo= de is not > >> * specified or set to OTG, then set the mode to peri= pheral. > >> */ > >> - if (mode =3D=3D USB_DR_MODE_OTG && > >> + if (mode =3D=3D USB_DR_MODE_OTG && !dwc->edev && > >> (!IS_ENABLED(CONFIG_USB_ROLE_SWITCH) || > >> !device_property_read_bool(dwc->dev, "usb-role-s= witch")) && > >> !DWC3_VER_IS_PRIOR(DWC3, 330A)) > >> @@ -1632,6 +1633,51 @@ static void dwc3_check_params(struct dwc3 *dwc) > >> } > >> } > >> > >> that's problematic or moving > > I think you wanted to revert only this line and test? > > On v6.0-rc6 and reverting manually only this line > > - if (mode =3D=3D USB_DR_MODE_OTG && !dwc->edev && > > + if (mode =3D=3D USB_DR_MODE_OTG && > > host mode still does not work (no change visible). Cool, thanks for checking that. Don't think I have any more experiments off the top of my head to run. I'll have to go read that code more. I'll reply in the thread if I have something new to try/say. > > > > >> static int dwc3_probe(struct platform_device *pdev) > >> { > >> struct device *dev =3D &pdev->dev; > >> @@ -1744,6 +1790,13 @@ static int dwc3_probe(struct platform_device *p= dev) > >> goto err2; > >> } > >> > >> + dwc->edev =3D dwc3_get_extcon(dwc); > >> + if (IS_ERR(dwc->edev)) { > >> + ret =3D PTR_ERR(dwc->edev); > >> + dev_err_probe(dwc->dev, ret, "failed to get extcon\n")= ; > >> + goto err3; > >> + } > >> + > >> ret =3D dwc3_get_dr_mode(dwc); > >> if (ret) > >> goto err3; > >> > >> to happen earlier? > > It is not always possible to have an extcon driver available, that's wh= y in > > some cases the probe of it defers. I dunno how your patch supposed to w= ork > > in that case. > > > >> Does tracing the "mrfld_bcove_pwrsrc" driver (the > >> excton provider in this case AFIACT) show anything interesting? > > I believe there is nothing interesting. > >