Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3669370pxb; Mon, 24 Jan 2022 14:57:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJyqYTBcaN/Mvlo+6XLuE6xy+y/pYGqpLZxpWUX+R17hTbeXtwE/FqwdX8nCJvwBu0V6Z0Gn X-Received: by 2002:a63:6f08:: with SMTP id k8mr13125095pgc.51.1643065052504; Mon, 24 Jan 2022 14:57:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643065052; cv=none; d=google.com; s=arc-20160816; b=DkLHL76aPEujj2qVVmJM6F8+TqauJEiSqWvRTXtKulJ6CZBkeHYrJiP8mIftS78naY 1vZIQD4AEwP5Nvz3CIPBlxu2uSYOglS/XTIZwLS4zvdt7pmaLyMF+iP2sjPEXNPGkSJN /w+WTMijl83edYuAzcBFvOAHbVqNSV38XRT3qlSMqfWGKq/v4hAGEIMzATlJ8HW2/Aeu CDW8S1T3Ei0Uxh5b5oFnD2AMUJK1Jv/7Im6kk3KLHTw4xPbNmE8zJyp3yM6vQ4Fa3dqn FRaLnqeGgsrwE5jcQP5UnGdsEDNq1bPA2w+Qzx6CpfAwBYYDiYLbJ9xn3Jtx/OiPj77o F6CQ== 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=HnT0LInbGt8oaG4Ya7NfDFGLLjqPpLkyL183Yrj8xDU=; b=LRaCX07boAZpdv3BhbR+gSiUdnMl33Ye7lYe8Yi65zLx3DYcJCYjQqQlshIj4ShE93 JcgzMWUEW8c4AEwg5NWKvPC225ZDUKD/tdktrmU4RynyeBV79CAR6taXKSSD+dvvHjau sOGza+qBGNVM9yMHWxgeI9/E5yUgBVF/Imkx1QJ8PDkctyJZmGF9EMjI26tySYkV2QTd 66Ile/Aer+ghXTDd0YzhBA+LronzCQy9sNTvItDkN3A/NMgNiSsoT23w0E1rLJkSW15Y 6q26RNbGOFVQD21dozP3SQgVpuyoVw8EHs3gSedK/g4nIabkqI7nPel3DjkfsPDkZ9pl qHbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tFY5y9sW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x6si13541892pll.588.2022.01.24.14.57.20; Mon, 24 Jan 2022 14:57:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tFY5y9sW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1840365AbiAXWxS (ORCPT + 99 others); Mon, 24 Jan 2022 17:53:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1575061AbiAXVu7 (ORCPT ); Mon, 24 Jan 2022 16:50:59 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD970C0885BE; Mon, 24 Jan 2022 12:33:45 -0800 (PST) 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 75A46B811FB; Mon, 24 Jan 2022 20:33:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2161C340E5; Mon, 24 Jan 2022 20:33:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056423; bh=EZGfL1TCmkidrIE1+PMXiJ6X9E2Pb7CtXObzgF6wVFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tFY5y9sWBgKXoCVxhNczGxz7ZVNRprly53D2tgnhlKZEx1r7HEdkED7QoKwA3FlXS nIZLbYlMM0feoOXG7Y0y1SUvniLXJeBu8AvX3eGDNBnl6nptqkI9c6PrVOUA97MWjc D7wFYO07Sp/ufYaQtM2Gd7wT0a3wKjuiJNIh5RQA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amjad Ouled-Ameur , Jerome Brunet , Sasha Levin Subject: [PATCH 5.15 480/846] usb: dwc3: meson-g12a: fix shared reset control use Date: Mon, 24 Jan 2022 19:39:57 +0100 Message-Id: <20220124184117.576053005@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Amjad Ouled-Ameur [ Upstream commit 4ce3b45704d5ef46fb4b28083c8aba6716fabf3b ] reset_control_(de)assert() calls are called on a shared reset line when reset_control_reset has been used. This is not allowed by the reset framework. Use reset_control_rearm() call in suspend() and remove() as a way to state that the resource is no longer used, hence the shared reset line may be triggered again by other devices. Use reset_control_rearm() also in case probe fails after reset() has been called. reset_control_rearm() keeps use of triggered_count sane in the reset framework, use of reset_control_reset() on shared reset line should be balanced with reset_control_rearm(). Signed-off-by: Amjad Ouled-Ameur Reported-by: Jerome Brunet Link: https://lore.kernel.org/r/20211112162827.128319-3-aouledameur@baylibre.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/dwc3/dwc3-meson-g12a.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c index d0f9b7c296b0d..bd814df3bf8b8 100644 --- a/drivers/usb/dwc3/dwc3-meson-g12a.c +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c @@ -755,16 +755,16 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev) ret = dwc3_meson_g12a_get_phys(priv); if (ret) - goto err_disable_clks; + goto err_rearm; ret = priv->drvdata->setup_regmaps(priv, base); if (ret) - goto err_disable_clks; + goto err_rearm; if (priv->vbus) { ret = regulator_enable(priv->vbus); if (ret) - goto err_disable_clks; + goto err_rearm; } /* Get dr_mode */ @@ -825,6 +825,9 @@ err_disable_regulator: if (priv->vbus) regulator_disable(priv->vbus); +err_rearm: + reset_control_rearm(priv->reset); + err_disable_clks: clk_bulk_disable_unprepare(priv->drvdata->num_clks, priv->drvdata->clks); @@ -852,6 +855,8 @@ static int dwc3_meson_g12a_remove(struct platform_device *pdev) pm_runtime_put_noidle(dev); pm_runtime_set_suspended(dev); + reset_control_rearm(priv->reset); + clk_bulk_disable_unprepare(priv->drvdata->num_clks, priv->drvdata->clks); @@ -892,7 +897,7 @@ static int __maybe_unused dwc3_meson_g12a_suspend(struct device *dev) phy_exit(priv->phys[i]); } - reset_control_assert(priv->reset); + reset_control_rearm(priv->reset); return 0; } @@ -902,7 +907,9 @@ static int __maybe_unused dwc3_meson_g12a_resume(struct device *dev) struct dwc3_meson_g12a *priv = dev_get_drvdata(dev); int i, ret; - reset_control_deassert(priv->reset); + ret = reset_control_reset(priv->reset); + if (ret) + return ret; ret = priv->drvdata->usb_init(priv); if (ret) -- 2.34.1