Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2240333rwb; Sat, 24 Sep 2022 05:24:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6zUy9m8HcEe2Jf6ShlwKEOGIYvR/8Z/4z3AKzVYIN/8N6ceK406xTECARYGNNYfcf9qk9c X-Received: by 2002:a17:907:628f:b0:72f:58fc:3815 with SMTP id nd15-20020a170907628f00b0072f58fc3815mr10738904ejc.719.1664022263180; Sat, 24 Sep 2022 05:24:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664022263; cv=none; d=google.com; s=arc-20160816; b=zEnHU01ICKufHHTDm5xgLpQZzRYQZToTdjrNvEK/lqLv5qdgvV9W+S1V1uEErsasvG uojC2i6UXW5mzGq0ZdtrZUuYQUJx3OdsV1O5n04MJKbe9G6UObL2YuYk8jJG/bnAL+p4 o9/LWKGker6SAyD1CBPOas3amqu2+jjNmUk8SW9cePULMzKat2iKJA5j76ANvltTJszb ps+PFAWdjtgd7WPsLpb8/sczbpKy4QPgC3f0yP1Yw8zC+nQa6Ko9qgDJ9tiWlrs2veDm qAgvOeNRxw5IoBpysMxUjYdYdF55Q1VW3zi+DbWyY9LeeTbhjKYmcO8MFUK0Haqud4+1 73bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=F98fTUaqz/xgAnbNOjVz2gYVeA9O9kAzBF55v8LQ+9U=; b=kXmkNPyYC1l+YQkY3SJIFaTmUvvulsprAaG3P91EtiBTV2MxFBleLv7yCEc6EZPC4O +IvoCSL/8jQX8Iym+Dq3/UOt+f+h81m18yZ7Xy9+BxjlyU9qMfT72y0+QtapqOmo1ecS 26VTfW/a6MW/GnygMNUr5xklBUfm3rvSf2KwXEU4QOuFubf5/OUMYiCascPCWHJIMtCF XiVZoMK1H5j5oUmC5Eqmq1C6SbXlBhyjFpa9qBF/MjbW7fqG7B0ZDm0RkHI3RBMgtwPl V/RZ1HbQDZXIUAvN+WGV7/NcYR+lgMRdUj88MW9iagjUZA6Exa0iClQXdLy8Yf8MOJZT fSNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PuDVLGVn; 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 q18-20020a170906a09200b00774195db4e7si9358632ejy.117.2022.09.24.05.23.58; Sat, 24 Sep 2022 05:24:23 -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=PuDVLGVn; 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 S230331AbiIXLzS (ORCPT + 99 others); Sat, 24 Sep 2022 07:55:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230293AbiIXLzP (ORCPT ); Sat, 24 Sep 2022 07:55:15 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19E3E2251B; Sat, 24 Sep 2022 04:55:13 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id hy2so5448962ejc.8; Sat, 24 Sep 2022 04:55:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date; bh=F98fTUaqz/xgAnbNOjVz2gYVeA9O9kAzBF55v8LQ+9U=; b=PuDVLGVns39/bq1zoea1OIaiY/wKkRFJ5R96SLuxh40U9n+/AzFSKB7qeM8akTEXke 3ZH5Z4NWpkcYsd4u0QdobmSJ8VXRB6/6ddFX5Y57D+VkRkyqDuIDsclrlmzB1EcGeA1U +1r9RLXvmTujAABLGG6vinBnprZPv27Y+fSlf7xjz4Ku4gnlzZ2DsFb9nS5Kp5swBB/s 2XVgSQS/V8w1obJ7FFWFcXFvzBT/EvYbfI25QePU5mTNVWLlemuiTYTe9txAsN+cuVKB qhqbGKL90kWp1za33LjaJDvJvtuueIQsz1fjCl8Dc8wb/io6SpKylKIhcw0meLEVjKf8 DnhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=F98fTUaqz/xgAnbNOjVz2gYVeA9O9kAzBF55v8LQ+9U=; b=j9ds+AnIB1EWFfTDvLfJt4sKrP05ght1TiD5wMDVTtrtikoJwjMhCwCP/0RaLB/hBa tJoV2ReNOPRTWBSTNMo1A3gLQsEvFcizPWawM6MTq8f8K9Kl9m7BBT9J/rHUe5pNzto5 s6/cEB/lcngMtURga09j3HNT8slS2Fpj8qSBlFUzuCpbSCan7wxAFOW5cZlugadgHpd0 vGIBenYYGEj9jBIQsqJLCnduK/ZdNUh62QHScOM4nTWBofoz2itODHDc53H+cUfzH/vn WyUMbIGecZIraoHUR+VHGIzdRhM02N+hlngtu+4dVK6+VqRKLZaepjeaWj9kQEcuCpaN J5/w== X-Gm-Message-State: ACrzQf1fnn0FINARXfpO767JRrYKtlYya9ceJ2pQTmkN62oQfaVe14aP kc0aS6z2BWyrFEuofnqJUuA= X-Received: by 2002:a17:907:9807:b0:781:feee:f87c with SMTP id ji7-20020a170907980700b00781feeef87cmr10818222ejc.101.1664020511427; Sat, 24 Sep 2022 04:55:11 -0700 (PDT) Received: from ?IPV6:2a02:a466:68ed:1:3929:d307:8379:1a1e? (2a02-a466-68ed-1-3929-d307-8379-1a1e.fixed6.kpn.net. [2a02:a466:68ed:1:3929:d307:8379:1a1e]) by smtp.gmail.com with ESMTPSA id w8-20020a17090652c800b00780ab5a9116sm5388708ejn.211.2022.09.24.04.55.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 24 Sep 2022 04:55:11 -0700 (PDT) Message-ID: Date: Sat, 24 Sep 2022 13:55:10 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v4] usb: dwc3: Don't switch OTG -> peripheral if extcon is present To: Andrey Smirnov , Andy Shevchenko Cc: Greg Kroah-Hartman , Felipe Balbi , Thinh Nguyen , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Thinh Nguyen , Sven Peter References: <20220403164907.662860-1-andrew.smirnov@gmail.com> <691c3073-5105-9a2b-e6f2-ea0a4b8aaea8@gmail.com> Content-Language: en-US From: Ferry Toth In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, 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 Hi, Op 24-09-2022 om 03:27 schreef Andrey Smirnov: > On Fri, Sep 23, 2022 at 11:54 AM Andy Shevchenko > wrote: >> On Fri, Sep 23, 2022 at 11:23:23AM -0700, Andrey Smirnov wrote: >>> On Fri, Sep 23, 2022 at 9:42 AM Andy Shevchenko >>> wrote: >>>> 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 always >>>> can choose the course of actions. >>> I think we have another problem. This patch happened in parallel to mine >>> >>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc6&id=ab7aa2866d295438dc60522f85c5421c6b4f1507 >>> >>> so my changes didn't have that fix in mind and I think your revert >>> will not preserve that fix. Can you update your revert to take care of >>> that too, please? >>> >>> I'm really confused how the above commit could be followed up by: >>> >>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/usb/dwc3/drd.c?h=v6.0-rc6&id=0f01017191384e3962fa31520a9fd9846c3d352f >>> >>> the diffs in dwc3_drd_init seem contradictory >> I'm not sure I follow. Your patch has been merged and after that some kind of >> merge conflict was resolved by an additional change. To revert your stuff >> cleanly we need to revert the merge update patch first. That's why revert is a >> series of patches and not a single one. I have no idea how above mentioned >> commit at all related to all this. >> >> Can you elaborate more, please? >> > It's not important to clarify, just me voicing my confusion, we have > way too many threads of discussion already. > >>>>>> 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. Ferry, can you >>>>>> share bisect log? >>>>>> >>>>>> I can but not right now. But what I did was bisect between 5.18.0 (good) and 5.19.0 (bad) then when I got near the culprit (~20 remaining) based on the commit message I tried 0f01017191384e3962fa31520a9fd9846c3d352f "usb: dwc3: Don't switch OTG -> peripheral if extcon is present" (bad) and commit before that (good). >>>>>> >>>>>> The effect of the patch is that on Merrifield (I tested with Intel Edison 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 from tusb1210 appear. When host mode is not working there are no tusb1210 messages 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 tonight. >>>>>> >>>>>> 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. >>> OK, I'll check e-bay just in case. >>> >>>> 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 this hunk >>>>> >>>>> @@ -85,7 +86,7 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc) >>>>> * mode. If the controller supports DRD but the dr_mode is not >>>>> * specified or set to OTG, then set the mode to peripheral. >>>>> */ >>>>> - if (mode == USB_DR_MODE_OTG && >>>>> + if (mode == USB_DR_MODE_OTG && !dwc->edev && >>>>> (!IS_ENABLED(CONFIG_USB_ROLE_SWITCH) || >>>>> !device_property_read_bool(dwc->dev, "usb-role-switch")) && >>>>> !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? >>> Yes. >> Ferry, can you try that (but I believe it won't help anyway, because I don't >> see how we handle deferred probe). >> >>>>> static int dwc3_probe(struct platform_device *pdev) >>>>> { >>>>> struct device *dev = &pdev->dev; >>>>> @@ -1744,6 +1790,13 @@ static int dwc3_probe(struct platform_device *pdev) >>>>> goto err2; >>>>> } >>>>> >>>>> + dwc->edev = dwc3_get_extcon(dwc); >>>>> + if (IS_ERR(dwc->edev)) { >>>>> + ret = PTR_ERR(dwc->edev); >>>>> + dev_err_probe(dwc->dev, ret, "failed to get extcon\n"); >>>>> + goto err3; >>>>> + } >>>>> + >>>>> ret = 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 why in >>>> some cases the probe of it defers. I dunno how your patch supposed to work >>>> in that case. >>> I'm not sure I understand what you mean. AFAIU the logic is that if >>> the platform specifies the presence of extcon either via DT or, like >>> Merrifield, via and explicit "linux,extcon-name" device property in >>> the code then extcon is a mandatory component of the DRD stack and the >>> driver is expected to be present for the whole thing to work. >>> I don't >>> think I really changed that logic with my patch, even after the revert >>> dwc3_get_extcon() will be called as a part of a probing codepath, >> But it's not true as proved by the experiment. So with your patch it doesn't >> work anymore, so the logic _is_ changed. >> > I think you are jumping the gun here. We know that the patch breaks > USB host functionality on Merrifield. We know that "Seemingly tusb1210 > is not probed". Do we know that dwc3.ko (I think that'd be the > driver's name) is not probed? Did Ferry share that info with you in > some other thread? I don't deny it is possible, but I don't think this > is really clear at this moment to say definitively. I am not sure. I have dwc3 builtin. And intel_soc_pmic_mrfld and extcon-intel-mrfld as a module. But with the USB host broken this returns nothing: root@yuna:~# journalctl -k -b -0 | grep -i dwc While with the 2 reverts (and host working): root@yuna:~# journalctl -k -b -1 | grep -i dwc Sep 22 22:57:38 yuna kernel: tusb1210 dwc3.0.auto.ulpi: GPIO lookup for consumer reset ... Sep 22 22:57:38 yuna kernel: debugfs: Directory 'dwc3.0.auto' with parent 'ulpi' already present! ... Sep 22 22:57:39 yuna kernel: tusb1210 dwc3.0.auto.ulpi: error -110 writing val 0x41 to reg 0x80 Like I mentioned before, when host works I get warnings and errors on the console as well as in the logs. I also get this one, but believe that is related to another problem, something in hub.c. Which happens when the host works as a hub is plugin there. Sep 22 22:57:39 yuna kernel: DMA-API: dwc3 dwc3.0.auto: cacheline tracking EEXIST, overlapping mappings aren't supported >>> so >>> if the a missing driver is causing a probe deferral it should still be >>> happening, unless I missed something. >> The merge fix removes deferred probe by some reason. >> >>>>> Does tracing the "mrfld_bcove_pwrsrc" driver (the >>>>> excton provider in this case AFIACT) show anything interesting? >>>> I believe there is nothing interesting. >> -- >> With Best Regards, >> Andy Shevchenko >> >>