Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2619290imn; Tue, 2 Aug 2022 09:34:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vdMeaRhVT7dusK+cEANqGy4WyJPvkbRDPPKBPUhdJ0p8RJOWYlLw3CSEWelSewkUPlEJmA X-Received: by 2002:a05:6402:5418:b0:435:5a48:daa9 with SMTP id ev24-20020a056402541800b004355a48daa9mr21691835edb.304.1659458074397; Tue, 02 Aug 2022 09:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659458074; cv=none; d=google.com; s=arc-20160816; b=Ezkmn1XsaoGzng6NGvEZnLTH/lbTA6kEaD+Dqx7CMtPy6JHcyVIMGvZaFo8sSTwsez qSW2ssPYWaBIJyxAM8QBcukgq5KlRCE+bpNABGDQUDVmHDhzFF23IcmJXDhuqlUhzKuu NYxty1PkDZ4i7OfI+DO29yt5oPoBugsunJAxXRtqNsbIrC5+47cd1qw6/zGMsuJt66mA sLS7Y/H2f6SDW6Mvja5h5aTyIeyrOROB1NRKhisIsW4e049yU5fdQGXHsi+sK+EomU4N usV+s3nvBS7kYuMNxoz/wUVr4fXgUHM+03mYJ5MryyjyJgcAgbvBpC/ujv7TsZMMH5TW qcNA== 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=3iPs3I5+PDJ9MIQ0iVI9/akON3czP+YpeQ/EmaC+uvY=; b=vpr01gGxwz7bxiOs4owtIHzR+y2mTrfLnhrXNo4U0MnFpoMeP/Ixm+XQfio2QtDldn SRUc7xSNBLM4dnQD2vSQaP9uZqTQyev0V92jEwyjxrRAzrHxSXHlbnyTasTojyCGde16 Re9CJrBzLEroZpJhg/YoyroqXvXigBcZ6c4WhopDzesoQj4LecZzzPB0z9/Jvo7wCRw0 xpiDLQ4SBcj6WP7tTCGb+QUvA6bUKdBimSHN6PnZO3SvMhOufwRkFdC6pmkYaNc9Bwbd TQzJCuA3U/boIzpErFADTbMXfWUPwEBeg0dl9uFRcoM6e2Gc0M4rTUXV+o3rZYxrncjO vPKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LyoYXvT+; 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 c10-20020a50d64a000000b0043d44488b74si919316edj.165.2022.08.02.09.34.09; Tue, 02 Aug 2022 09:34:34 -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=LyoYXvT+; 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 S237448AbiHBPPC (ORCPT + 99 others); Tue, 2 Aug 2022 11:15:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236092AbiHBPOU (ORCPT ); Tue, 2 Aug 2022 11:14:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C45361836B; Tue, 2 Aug 2022 08:14:18 -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 ams.source.kernel.org (Postfix) with ESMTPS id 6FFAFB81F45; Tue, 2 Aug 2022 15:14:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A2D6C43143; Tue, 2 Aug 2022 15:14:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659453256; bh=yf1XNImaMaEMbAVVDfs/2GhFLLQGWcQ2dZe8Q8W1ecA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LyoYXvT+cARYDP/AyLTXHpoIPnOD2SQf1ZyIzPYbK0e0qIrehTdFWHFfrHMg6P7kR DFFiWFrflVaUpzER2mGO9dPKgcZaSWIqaci8WsaS28W2BD87h/UMV9uAtFKJ9nGz10 h+sOJlLuBxQHAGGSVjhLp4jOPsiGtPP+REIzRyiKNoa2MVhefkRUtyZr3qXIYAFyJo JH1xpAs3yUiK1e6pGyHplOeEtw5xZLZw1F7oyQWiGAfPKAh1+0Gi43LBzxwiYfeZYb lqCqAbXztDwA1qW/qsaRtR/Z77P5rvl+tDmEkyLFg7gc5ze4bcE7LtwYJmWlW8RxAX bCK9DxTAtoJ+g== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oItbM-0000TU-2x; Tue, 02 Aug 2022 17:14:32 +0200 From: Johan Hovold To: Greg Kroah-Hartman , Felipe Balbi Cc: Rob Herring , Krzysztof Kozlowski , Andy Gross , Bjorn Andersson , Manivannan Sadhasivam , Konrad Dybcio , Krishna Kurapati , Stephen Boyd , Doug Anderson , "Matthias Kaehlcke" , Pavankumar Kondeti , quic_ppratap@quicinc.com, quic_vpulyala@quicinc.com, linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH 1/8] usb: dwc3: fix PHY disable sequence Date: Tue, 2 Aug 2022 17:13:57 +0200 Message-Id: <20220802151404.1797-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220802151404.1797-1-johan+linaro@kernel.org> References: <20220802151404.1797-1-johan+linaro@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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 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 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 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 c5c238ab3083..16d1f328775f 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -833,15 +833,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); dwc3_clk_disable(dwc); reset_control_assert(dwc->reset); } @@ -1879,16 +1880,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