Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3384673pxb; Mon, 17 Jan 2022 19:14:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJxQWZE/e4t/w1Hr306IpgbpOrIp6/Mh3VA/M7tofsVEGa+b5TkkkMH8fJiOpHfjwyEiGYRa X-Received: by 2002:aa7:9802:0:b0:4bf:f7a0:83b6 with SMTP id e2-20020aa79802000000b004bff7a083b6mr24238939pfl.17.1642475681590; Mon, 17 Jan 2022 19:14:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642475681; cv=none; d=google.com; s=arc-20160816; b=epSiu2vynEXVJSAM2EuySDnlAI5tibsPcI1KGcAOsHGNNd7ODe8JEtM6+Tm5avPPds wbjdbzUC4VqQMdaoPo9COjwPrVATQjtZ5BRVAh+gvEDbYTDQdas7DzfTNfuDT09UuBOP WX2FykYGDiUxTmpjsShwZ1hCkINt6kboEDNyYrjRaFpUbpUuBrM4XpYWoKNqsvirIQ3b N44KCnDq1SVeD8U1nKm4gDwd/tcoQ6fKhY1dMHy2sqfaqWyFTQgeuNz7/ND5p3/0wk4R NZxQb0enWSo16qOp3Sp2mYQ0325Uitr3mBNumN4pq+/0rmEfhgQXIWU7mUaKxnCE9090 vOHQ== 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=cBE3/0qqulpgdnb2IeBDi+FT8TXcDOK47somr7bwj0c=; b=C+IxOcUrSQaviyHGQM5hRTO8rWXAhDtWJrKiYpeIKSMBMS9FjMWA2tqmbISrxVQGQj WB/MXYDEMH9qYypzbh58OaxpQHfYQMPF2UbVYqj1Tc+BZ3AePctwhtLyk5V92Ev0nUMh r8vKpY8iSbDneKZsDbCmrVbH2j5d6Qy3uBHlKNzh6hsjxM6oFQPUQfii5FWn85273l2y e1rz1o4Z6100nW2oRauokBqx3Kr9UdyV7wrmmo1QnB0yIgmrQDWQ+eqj+8wzpfioEJuj RIyv6rFnjtB2Mr8rsRkSIvKEbNyckxzzXNvEx0yKgTWPCteFszGrjsVeKC5/QaU0RfzV ObFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UWKdolOR; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u10si15221093pfc.346.2022.01.17.19.14.19; Mon, 17 Jan 2022 19:14:41 -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=@kernel.org header.s=k20201202 header.b=UWKdolOR; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244982AbiARCXm (ORCPT + 99 others); Mon, 17 Jan 2022 21:23:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244566AbiARCVa (ORCPT ); Mon, 17 Jan 2022 21:21:30 -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 88B96C06175C; Mon, 17 Jan 2022 18:21:29 -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 4DCF8B81236; Tue, 18 Jan 2022 02:21:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9749C36AE3; Tue, 18 Jan 2022 02:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642472487; bh=KuDx/9P+Wps9AtzStWZ2hI77/d8sYbhn6+5ghzmQjp0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UWKdolORwwfQVXdJfYNLLmeAVgZ7i1HAwEUO3EfuT1EnALSjd+Whw2cZv3uBv/XQy LnDCS2ai1HRjFaj2RPlI91aPMStiCH5j7Ipf9FKCpo/u/jjEeFqGpptxabBgPOpIjv HUCGwZ9V/Bl+ZvAJtbIVbOGEl1ruc3m94GheNvcgpXyZEBnXQgBCz/JIS/BYKM49X+ qx0xAxut7kNPs2Sdx/pyuUHGZvdBEYHAinD/onjL0KcVh4tooatsKWOIdvO8HjXmWM hbjOdN9Ke7Fto1h7uyxwyVznn0nJd6V2mlZHYNc0EjMdz4hUnxpKSt3NgXEe5JuiFD R9O/ysKyIbUZA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Amjad Ouled-Ameur , Jerome Brunet , Greg Kroah-Hartman , Sasha Levin , balbi@kernel.org, narmstrong@baylibre.com, khilman@baylibre.com, p.zabel@pengutronix.de, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org Subject: [PATCH AUTOSEL 5.16 029/217] usb: dwc3: meson-g12a: fix shared reset control use Date: Mon, 17 Jan 2022 21:16:32 -0500 Message-Id: <20220118021940.1942199-29-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220118021940.1942199-1-sashal@kernel.org> References: <20220118021940.1942199-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev) 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