Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6768522rwn; Tue, 13 Sep 2022 08:46:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR6dFVEN9ELd7yYnZ29Hh7wZE0drhiQjIRHY+NMfpb0UD3o2zz2b60PEo7H4u3CrUVosb2o7 X-Received: by 2002:aa7:cd49:0:b0:451:e570:8a82 with SMTP id v9-20020aa7cd49000000b00451e5708a82mr7476235edw.369.1663084000141; Tue, 13 Sep 2022 08:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663084000; cv=none; d=google.com; s=arc-20160816; b=m6eo/+4LUf2u+851JNKlaOjNyzalYkwxJb+TyRGFmowKeWTVjhUXbz/e2zPy34ECcV 2luf341TXPXh5mKuGUdq2x4vXRxvj+X18JUDWPR2is+IpUv6gLVDH+r7ymHxw+OT+2Hz TnyxmTvppoBUQndrIO7mABc4aCpVtr4mjljoaV3jlJF/9TDq/0YxveBTHm4Vmy7KihIZ Xkr3rCcfdm4Yg09pJyeC1+sfsQ6eKfxJN6Tw2wOqouZnQOUpEAJq/G6+ZKHBq7vLsTm8 UxuW6oliByXXD7pFVZwLZ9lxnE0L2Mk8HqdCrTge0p9PzdzMa7jvKQTiKh1u+7xDe12F PmuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=u1xV4tm463sTIhMLHOK31DvnN9QIz5+c1OAJxzeY5dI=; b=EfAzQIVsN0trfalhhL68RIGs+g3TmnQaijMOk3LRVIDa6S4CiIFaGWrDCBFoQrfJ3p 2rfQ17s3xYrIZ7dBqLQNUTlBu+rzW8hZMj6biXI1lUpF7cXDJhKN7s9VFD2CsOeWDiDX ckq/8UJecodyZ0jHd8mgRIaf7irRZkwcD+fqaxXF7CUsOOlS/E0u5lEg7YCQG9PXEiqQ OJ+wQRU8ajhkiBeSyNo031lfgSfQhENSDODLNExXk6zIrlC9eR6VMxyvVeBFK3dGNcMD wYuL0s6CrAiEt5orjfTJGgJmt12F/WmoJAmHDQv2/4rWlae2g6zLgyywLqBYTB4w94JV ndAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nQcRgui6; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n18-20020a5099d2000000b0044f01473b5bsi8297725edb.205.2022.09.13.08.46.12; Tue, 13 Sep 2022 08:46:40 -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=@linuxfoundation.org header.s=korg header.b=nQcRgui6; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235764AbiIMPQN (ORCPT + 99 others); Tue, 13 Sep 2022 11:16:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235762AbiIMPNo (ORCPT ); Tue, 13 Sep 2022 11:13:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 002C4786DF; Tue, 13 Sep 2022 07:33:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C93B7614E9; Tue, 13 Sep 2022 14:32:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAEF3C433D6; Tue, 13 Sep 2022 14:32:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663079577; bh=03FPAWqRDDXD6zO7/j4hVdm8z2IOL/rQTzpJQKo/Wag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nQcRgui6jv7xJry5vj/D/1FYgreMoz3sqbHv/oDBDun4tV1W2gUteznJUwyGeZEFO 1eCmQr/Cbq8j71J8pheo3+mtc2QLbsyitHu+4uVMXbz2pQi9U6tD2hCEGrt+SJ8Apc XhXC8qEtGwv974t3wfzoW3kzvGM3B70C4bOisug8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrew Halaney , Matthias Kaehlcke , Manivannan Sadhasivam , Johan Hovold , Johan Hovold Subject: [PATCH 4.19 73/79] usb: dwc3: fix PHY disable sequence Date: Tue, 13 Sep 2022 16:07:31 +0200 Message-Id: <20220913140352.419102957@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140348.835121645@linuxfoundation.org> References: <20220913140348.835121645@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Johan Hovold From: Johan Hovold commit d2ac7bef95c9ead307801ccb6cb6dfbeb14247bf upstream. Generic PHYs must be powered-off before they can be tore down. Similarly, suspending legacy PHYs after having powered them off makes no sense. Fix the dwc3_core_exit() (e.g. called during suspend) and open-coded dwc3_probe() error-path sequences that got this wrong. Note that this makes dwc3_core_exit() match the dwc3_core_init() error path with respect to powering off the PHYs. Fixes: 03c1fd622f72 ("usb: dwc3: core: add phy cleanup for probe error handling") Fixes: c499ff71ff2a ("usb: dwc3: core: re-factor init and exit paths") Cc: stable@vger.kernel.org # 4.8 Reviewed-by: Andrew Halaney Reviewed-by: Matthias Kaehlcke Reviewed-by: Manivannan Sadhasivam Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20220804151001.23612-2-johan+linaro@kernel.org Signed-off-by: Greg Kroah-Hartman [ johan: adjust context to 4.19 ] Signed-off-by: Johan Hovold Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/core.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -673,15 +673,16 @@ static void dwc3_core_exit(struct dwc3 * { dwc3_event_buffers_cleanup(dwc); + usb_phy_set_suspend(dwc->usb2_phy, 1); + usb_phy_set_suspend(dwc->usb3_phy, 1); + phy_power_off(dwc->usb2_generic_phy); + phy_power_off(dwc->usb3_generic_phy); + usb_phy_shutdown(dwc->usb2_phy); usb_phy_shutdown(dwc->usb3_phy); phy_exit(dwc->usb2_generic_phy); phy_exit(dwc->usb3_generic_phy); - usb_phy_set_suspend(dwc->usb2_phy, 1); - usb_phy_set_suspend(dwc->usb3_phy, 1); - phy_power_off(dwc->usb2_generic_phy); - phy_power_off(dwc->usb3_generic_phy); clk_bulk_disable(dwc->num_clks, dwc->clks); clk_bulk_unprepare(dwc->num_clks, dwc->clks); reset_control_assert(dwc->reset); @@ -1509,16 +1510,16 @@ err5: dwc3_debugfs_exit(dwc); dwc3_event_buffers_cleanup(dwc); - usb_phy_shutdown(dwc->usb2_phy); - usb_phy_shutdown(dwc->usb3_phy); - phy_exit(dwc->usb2_generic_phy); - phy_exit(dwc->usb3_generic_phy); - usb_phy_set_suspend(dwc->usb2_phy, 1); usb_phy_set_suspend(dwc->usb3_phy, 1); phy_power_off(dwc->usb2_generic_phy); phy_power_off(dwc->usb3_generic_phy); + usb_phy_shutdown(dwc->usb2_phy); + usb_phy_shutdown(dwc->usb3_phy); + phy_exit(dwc->usb2_generic_phy); + phy_exit(dwc->usb3_generic_phy); + dwc3_ulpi_exit(dwc); err4: