Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4520821rwb; Tue, 6 Sep 2022 08:37:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR5fJ3AdW9a/o37ZqKpcTUtAl6bapqu4ba7O23ZrXSaIzxDDOn/lJyqUKtpM2X/DfBshHID5 X-Received: by 2002:a17:90a:4485:b0:1fa:cc1f:a7a with SMTP id t5-20020a17090a448500b001facc1f0a7amr25823442pjg.45.1662478660725; Tue, 06 Sep 2022 08:37:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662478660; cv=none; d=google.com; s=arc-20160816; b=acjuBBHoCk/iJYXsMtNe2nCSYs2EP4Z6Xwy3Jb+l9Kk9rro3f9NG8bQ1POpFDNklSV KDS3f1FkNEQAleLT6AEwKYGrNN6viJsYZOojOuqaNqQicA75J3GF2DmGRk+VYZkD6zPF 2PCuRTjQTvi3jqjZt3NJPNe6f1YShMuVFDTq2hi/h5uui6gvrB6d9m5J/obqN/cBktsP OX2Zs+9BrlGH35Md0+A2bNCZDPKjl/ylNEV2LDkg7txWedcxcS4aN9IW2+cSTOWo3y2w gLJ4UvqYLi0ylyFOHGl9OEv9DiNoNZeEzs6i1W+xvlzjLuL3AUD1FBPQEcJakZqKiDaq OuBA== 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=3P3kZZo1RYwJSPDNNeZSapb9kAIiVtgQvBr6SANcSJk=; b=K37WdDMMt4CuhBo9Ds3AiX9aP/iMBfwoX1ThZ7YRvHhrbpeFvObgYsyXcxeup4nx8J 3vrpuQnf9kzNnNL+HcEbGD5r+OzIJ97OqRYVkNb7j22GT4jMG7IC/Ubcos2TXn1cB1pJ MpxnP75CV5U0k/K7MLr8LmOkXjjh2sNYMSHE7/olomkk1kvDb3ExrNLEg0doR410KnOL JabenN3eiBzNUPdgxXcNaNALghA9M0Kd6g6Ha3vg5Ib3KCudSY3s1/cIeJFpRAfuEyvZ oi905QTI1EawDcou+l75nd1AA/Jcu36TI25wi6ggwXiZt0oz4xZMcqvNYbsvNeycD2I8 dVmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B7k7JYn5; 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 g4-20020a1709026b4400b0016f16417f6dsi12707791plt.16.2022.09.06.08.37.28; Tue, 06 Sep 2022 08:37: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=B7k7JYn5; 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 S240132AbiIFN4k (ORCPT + 99 others); Tue, 6 Sep 2022 09:56:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239892AbiIFNyQ (ORCPT ); Tue, 6 Sep 2022 09:54:16 -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 1CF2980526; Tue, 6 Sep 2022 06:41:10 -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 95E5F61551; Tue, 6 Sep 2022 13:35:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 934E3C433D6; Tue, 6 Sep 2022 13:35:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662471342; bh=4wMBIiOVRFEUQgZUCLPvtOAlNnzfJHtYdPAydFACWFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B7k7JYn5caGkg9xDIgW7rUhxiRNf5mjnYC4NvXcbEaKzsLMveUdSeR757OYyt+lY6 TGy6jYBW5+j4p2wp9/EZr5gCc7uDDDLJQ2Y3wNUJeBOo6sS8/a3zSMvNJM5bmXNnnn g9Q0a4IKx7yRh3V8U4RPaSjG9a1++JF59E+G7Bl0= 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 Subject: [PATCH 5.10 76/80] usb: dwc3: fix PHY disable sequence Date: Tue, 6 Sep 2022 15:31:13 +0200 Message-Id: <20220906132820.303080833@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132816.936069583@linuxfoundation.org> References: <20220906132816.936069583@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 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 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 @@ -728,15 +728,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_unprepare(dwc->num_clks, dwc->clks); reset_control_assert(dwc->reset); } @@ -1606,16 +1607,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: