Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6778292rwn; Tue, 13 Sep 2022 08:54:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR7lcdJTpUuSr+MQ7cgQIrAncLIw9/8DT7lQ4uAkcwLBwVoSsaTyjE+4VVMB2zFFMAlUYpta X-Received: by 2002:aa7:d150:0:b0:44e:3c06:d719 with SMTP id r16-20020aa7d150000000b0044e3c06d719mr27365135edo.265.1663084496147; Tue, 13 Sep 2022 08:54:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663084496; cv=none; d=google.com; s=arc-20160816; b=0+WULQ/0N+Xe2cr4636r5b5DP6GcekimOsQKBidfP2hBpCSgrBXmh0s/EDaf0nTMbM EexttEKKACnEk6FY8HJsfznNVncWwzwPOcYRaIottQCBLbto5sJK9QdqZUARZbn+JoCA 26+cznd72CEfTyBq1UWEsEXQ8Z4Z/m3BLaY7ehowntc8OOWjDaNB9jmwJ5sgzRuoLvyL 4wiWoWjBvYhsqEfW01oF1mTR8pKXRyZZBab2wSEHh8kks26V6ikVfciOZGQ+adcvUsqm DkKI8MUT3+RLWDEwSS9tCc3bk5g0UZew1be3xs48ugii9lbfqUcc6IG7QuTnTQjxHmLP JFeA== 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=Qcfhk5C6rcoBtTCxqFnb2tCamW337YAP0B9+LGndSAM=; b=WGfZrpTlCDPoM7D0T5Xggt+kJOou7BdYZ09XbZi1b/aX1PTdupoJmdWz0kXeatQKLz jTkHP82EIAbDPEAiVNUUoQw+hQvzgkjVQtywT00dDSSDkx6gj9iJ4jKRNd4uMP8nnR8i v0B6Kd6I6CEioXIyAyXdW4NwQFU46alc/9ZHQsxmGrUS5It6cuwpNCY9QlnXZHO74fpA 3oxvSOUM7gB6rDYHrnK6jCEXD142nzeiOr1Itq2rc5jCNal51JOD0gYTjLAYJIShhe3X 1ZUZWIlfdW/rtl38hgoBEw/vtwqUbaz3no7heTGfiCLTwy5Ugf4uQ9NfnV1988srTdPJ +glQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JhcEYhCL; 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 gs16-20020a1709072d1000b0077c393f05e8si6215546ejc.750.2022.09.13.08.54.30; Tue, 13 Sep 2022 08:54:56 -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=JhcEYhCL; 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 S236535AbiIMPax (ORCPT + 99 others); Tue, 13 Sep 2022 11:30:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236548AbiIMP3E (ORCPT ); Tue, 13 Sep 2022 11:29:04 -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 D1175632E; Tue, 13 Sep 2022 07:39:31 -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 C1CA2B80FEF; Tue, 13 Sep 2022 14:37:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C710C433C1; Tue, 13 Sep 2022 14:37:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663079856; bh=FYzMawFm0/iJq4Jp+STVVe+Ezs1eDH3PxeUV24THizo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JhcEYhCLjIcKizZyhnC+k8lqd+hrYwDDEaMrU/qaOQaQk1WflXONZ4nu1uEvIlC+d ars57VLU0vojQBvm5/JcxPHhn3lT/CUN1K6lpgNswkBYasfKbT3w08t77oiUlrzv4F Efv0fVyX2Vmd0hITj7Ipfb+Zywz8ufE32/WZWgBA= 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 4.9 40/42] usb: dwc3: fix PHY disable sequence Date: Tue, 13 Sep 2022 16:08:11 +0200 Message-Id: <20220913140344.414340526@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140342.228397194@linuxfoundation.org> References: <20220913140342.228397194@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 [ johan: adjust context to 4.9 ] Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/core.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -602,15 +602,15 @@ static void dwc3_core_exit(struct dwc3 * { 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); } /** @@ -1149,16 +1149,16 @@ static int dwc3_probe(struct platform_de err5: 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: