Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4259207rwb; Tue, 6 Sep 2022 05:10:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR5C42GgSzxDQb0hLLdU4FxrGOuD/aPhikvzTuOvY/hX0VXyhHyqHMKJbgg2j4LLmHCOHC95 X-Received: by 2002:a17:907:9812:b0:742:2865:eca8 with SMTP id ji18-20020a170907981200b007422865eca8mr23917934ejc.537.1662466236638; Tue, 06 Sep 2022 05:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662466236; cv=none; d=google.com; s=arc-20160816; b=QyY2BTBkNjXSTqaxqArVVkTx2pPjzv7Czg9Ma3XIC/vIdCEr8HyaWgIPJpqxAqc9fn Kr+mg6gPqL/rGKAl7Z/PJLajSre5mKjXr4e/Sclvbj3LzTMgjhJXVtkhkj/gm4MnpvKw c2ReaPguoQOccygJHL/iEcoCsaHVUon/s/2T+LtD0wZAC7VTrq7/WLtWOrUUbQhwXPm6 /+x7BBptkx0qkL+eBsk5oXT3dCHB53aFJoReIoo8jaW3DW8/MoI+ud9V/xRI/1HvNN8h aBC/fBGQdrJKK5M+Bh51uEL/mnh4/OQ4vPZBjsAdcyB2lQ9sTe6J3GAP2u8bAepVLErs rW7Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=S7qLiiIcDWRKvdI1yFH7z/qavIQkR4alQDku3tMatpo=; b=zt8oryF0fHJSnogZvDOUD5KZknsRhXif8DW7rP7IuEViyGU9cK3iwK6Hv9l57wTm8Z Q2KS3Jo4iPLVYhiW+0JxZJNEikFEOl9+GV4Sj9/V4L+vzmip3CEBzZs1Duos0LY4YGMQ 8GxPGahH6y922m2HQ/E1pnfgqA2cCQp4300XTLfjzOFtqULmvq0CIsE87qxyMRl8DInb XJk83/9T55tyLctFQy595BzUByb22q69Ht9CBjOOzb9XnGEvNs+8gY/eUpv1DWF/fvMS 5GHHFVyyz77SzOm1RLsK9Kah2LLcQPDyDi3Lo4acdSJGYX1fCjPERCedhwC8Lg5mI1hw Mwzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ChYjdbrp; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x2-20020a05640225c200b00446b76abb29si9819707edb.540.2022.09.06.05.10.10; Tue, 06 Sep 2022 05:10:36 -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=@kernel.org header.s=k20201202 header.b=ChYjdbrp; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238030AbiIFMHQ (ORCPT + 99 others); Tue, 6 Sep 2022 08:07:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238054AbiIFMHM (ORCPT ); Tue, 6 Sep 2022 08:07:12 -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 2810F73323; Tue, 6 Sep 2022 05:07:08 -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 920C0614F0; Tue, 6 Sep 2022 12:07:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E83E5C43470; Tue, 6 Sep 2022 12:07:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662466027; bh=pcVvEgnnTmGV/Ce4ZKDYgV+N2mcV9Aux8sG4V5CY2Jk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ChYjdbrpvtBmLdeVQjUdVlEISpeeDaREi+ucHtv6U4BmHIt0nx7g90wpk0s+1zrkk GzYC1tSujrpJXeXWmfC2uGf4bfN4qyjmSAqfcT6BBNqUZgopkHa3Onj1GezHy9q3ug boE4JmJxcON3TWN1HZIF/9P9tTCxbKEXklHkVMSeyo0xTOjR76bXE1i1Z2kDBADnOu fNaTTX6iMN+RZsEZBV3ZsvxUF0lskovIuHLJsWLNqniqT0nwvLNv5qOLt85eVUGoy1 w8VPztghhZXCxT10YV7q1Ty95b68xbiQffZIsDMIVAgwqcTxFVEZi4V2G6fvDz5URR yQ98Y1rCdFNZw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oVXME-00050I-V7; Tue, 06 Sep 2022 14:07:10 +0200 From: Johan Hovold To: Greg Kroah-Hartman Cc: stable@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , Andrew Halaney , Matthias Kaehlcke , Manivannan Sadhasivam Subject: [PATCH stable-5.15 1/3] usb: dwc3: fix PHY disable sequence Date: Tue, 6 Sep 2022 14:07:00 +0200 Message-Id: <20220906120702.19219-2-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220906120702.19219-1-johan@kernel.org> References: <20220906120702.19219-1-johan@kernel.org> MIME-Version: 1.0 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 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 5.15 ] Signed-off-by: Johan Hovold --- drivers/usb/dwc3/core.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index cfac5503aa66..9c24cf46b9a0 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -731,15 +731,16 @@ static void dwc3_core_exit(struct dwc3 *dwc) { 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_unprepare(dwc->num_clks, dwc->clks); reset_control_assert(dwc->reset); } @@ -1662,16 +1663,16 @@ static int dwc3_probe(struct platform_device *pdev) 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: -- 2.35.1