Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6829450rwn; Tue, 13 Sep 2022 09:31:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7QfrLWrz5rtqeYvTrHYYpO24mOS56TNCpOYIoMCjDLDIYfzmmAJefDs1lPZmIYu6wj3RIv X-Received: by 2002:a17:90b:3d04:b0:200:9d93:f6f with SMTP id pt4-20020a17090b3d0400b002009d930f6fmr90483pjb.185.1663086693082; Tue, 13 Sep 2022 09:31:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663086693; cv=none; d=google.com; s=arc-20160816; b=N+IcNxK6nakQfhRW85IYwvlK+sIvJ2SqQV8zEnD5zWx+xQbWqmQHvBspDqWHhTu80c i8aNRTnEy6/GxrymkXAGiIGbHrPSCefvSN5ovmdDsGjtsyKu96g1fNfUp3jIeWe6Aibg 2fgxvC3oJ2DF9x8tNBohlAAJZ3psWsOoSTqbmuaY0YTl4HLa+fwuo6wwE023x+Z5IaNB KTXX2vaV+5JrMBaJ37TLANixoaNF18lg33PRn0BfxWgnvK/g342gjDd1mbl3ObJ53UcV UjPsmNVTa8kuMI+IDz/5N6tcB3kl4qCZwZI70EndGAmYoheo3yjY/9iT6+nn4ss9kFCR VCzA== 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=LTxAytbSoBoxqRiyeWBl011u16dENoeCnBRCU+kJNRo=; b=omkD+zAWaDc6JdT/8oMFEkT8Sn6+pGvea1nTLOE3DX04NrUHxyWEUlBlLYAYkJcEmL besxRK8g7CUZxXJvl72reOCIciMrcZrvuL8kGdzAUnprQYAjnx60uiIbl6aYINYKJtme u/OCbsLXhZrszlxs5NJESyaZKJyC6YJvKKlVmVyCXIl4BqRpICm/YttkoqikM+J5+pPj 8cNBnyyEmpnq8sLrYyfa9lrLEcukweDTo/mFR+jFXwSk28rcP5ai1DBCi20xtsknfq5z af0HwaHHyIfNybigkaRDqMyxsQDzCFJeiPNQX3yg86tDor2JbYLMuJv8WTXdVm2GlbCt xHXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fNOK51Gt; 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 d32-20020a631d20000000b004301e6b2ec6si1366899pgd.601.2022.09.13.09.31.19; Tue, 13 Sep 2022 09:31:33 -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=fNOK51Gt; 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 S235093AbiIMPAy (ORCPT + 99 others); Tue, 13 Sep 2022 11:00:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235105AbiIMO7N (ORCPT ); Tue, 13 Sep 2022 10:59:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3904E167F2; Tue, 13 Sep 2022 07:28:44 -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 2D765B80F1A; Tue, 13 Sep 2022 14:27:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A24CC433C1; Tue, 13 Sep 2022 14:27:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663079253; bh=UuyQn3qu/BZoLdKG9QeWcEFtx/A4cWpod+WFlNADWdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fNOK51GtCumZLIY4aHxvauyr5LMfW+spKFQ1+Cx/Eo0sOEyE4wM4iZcGJZUf9siLE 2C+myBMUkOXvM94GRNiNkD+qe1sN3ccPrxe3UyClQwZjYpLMSHl/cX+dGQ8SA5e2qQ ChR73BRMg4RYwapwMPzdzdNMAXveIN4R8GBK2YzM= 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.4 063/108] usb: dwc3: fix PHY disable sequence Date: Tue, 13 Sep 2022 16:06:34 +0200 Message-Id: <20220913140356.327666582@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140353.549108748@linuxfoundation.org> References: <20220913140353.549108748@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 @@ -694,15 +694,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); } @@ -1537,16 +1538,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: