From patchwork Tue Dec 1 19:00:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amjad Ouled-Ameur X-Patchwork-Id: 11943461 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B229C697 for ; Tue, 1 Dec 2020 19:01:40 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 48AC42168B for ; Tue, 1 Dec 2020 19:01:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="T8EKo03f"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="PyDW5rz9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48AC42168B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2xr2NN8r1lS3yE1RylK3nHdTrB22tlsSQNIK3Sh0gR8=; b=T8EKo03fNiCCcG0UZNyOunRk5x TVck+2Iyj7YgOhHhw3LfK/MTx93wH6erb64BCiJGrDWEa6ZMBDDcaUxkt2ps/afN1Su0Jqriohn1o syos++LtfAy1x8CZQTjeycWwxLlip5y5vIr3DetAyBq4ef1RVY+EYLn/izUVfIik5Yja13tTg3SbE /B/EHWciF4NS/z9DpCUGE628GfWB28u60cAvQliLWQai+2PSuI/tmPxyZB5Loe9uKlg9PokYwXVTs MaSl2GUQhKbtFf715KN7wC0I7mm0F6311YE13/UUe25wFvPVBQhn7TX9HFeOWt5Y8SaXWnOqgP/w2 5i2e1MXg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kkAtx-000181-MT; Tue, 01 Dec 2020 19:01:25 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kkAtv-00017Z-D4 for linux-amlogic@lists.infradead.org; Tue, 01 Dec 2020 19:01:24 +0000 Received: by mail-wr1-x444.google.com with SMTP id p8so4367334wrx.5 for ; Tue, 01 Dec 2020 11:01:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=G22eGyYxIipSs8w/AkbTh1vA6CiojhQuKpwoEPnVmtE=; b=PyDW5rz9AAyU3fm6J3ZjRcYcmz3GPTUIh6lMW7iKCGKKM+skNO8rt81pj6nZtrB19R FTuh7dU3kIxg3OcT4kjynAMMGRIHNVem2RgP5L+hF0GVXwM6aPHZ0ZjQJiyAf364bwuN LeU7hcuiUdWwVXTD/KOltCWNGdpPbwEJeJPPpfNdw4brncKHUp7kGIMU+thhEmTTKkGN +Z6mobzcoERS7bzx1/K8qWwuUprvVCa9x4IKFabe5pSZ/S1QD53yTs6LpahEgGfKKfZl 05U8Hxnb0MJ4zT3OMVTZU9sthGhfxunD79G9V3p5aObrTy8sZMFlWp1A1Ly5tB7sAyhD Flew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=G22eGyYxIipSs8w/AkbTh1vA6CiojhQuKpwoEPnVmtE=; b=I8nQIKD+xzD07F9MZCKXHAhS1I9vWH7OuaClhN2Q6LWV+buHINxaqtlkb6+b2ftxjs iTii+mIuhz+NhlZKVsraxrC61rh8bKGg4+rg1wla12b0l6DROYqcFulR7lUAdpbE4P4p OT+QQ4vCwF4yb2L1iEJ06ds1Pv3VVgRrubI4UyQ9G7Z3+vYGsx7Or2QPB4bzGKzili1h mdgr2/4PXtQOf0n4SZyrIcBWiqpIRqCbaLYU19Xz3KQGFRNUriaS5hwBSroPC6XsPtSD SiQPJckU4FZiNgDc5alCE/qCSlkCTC3rxGdZIx6FYY+6/5dPxJ8N6639JtPqrHzGB0rc VR/Q== X-Gm-Message-State: AOAM5322Vf50YKhU95NIGE9hPpL9oqu2lYUX/UakZ1EGWZW/G0DcWb7N sd4VLEpREvn50Yt7gxjC4yVtkQ== X-Google-Smtp-Source: ABdhPJw1Goa2Q0OjUHIOXSk8Lh0iFlfPPzooSWpjv2qA/Sds4esLvve/gf6qnlCpY7MINPiQdKNUhQ== X-Received: by 2002:a5d:40cd:: with SMTP id b13mr5784812wrq.52.1606849281924; Tue, 01 Dec 2020 11:01:21 -0800 (PST) Received: from localhost.localdomain ([2001:861:3a84:7260:40a4:a590:1da6:9599]) by smtp.googlemail.com with ESMTPSA id 138sm887733wma.41.2020.12.01.11.01.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2020 11:01:21 -0800 (PST) From: Amjad Ouled-Ameur To: Kevin Hilman Subject: [PATCH v2 1/3] phy: amlogic: phy-meson-gxl-usb2: fix shared reset controller use Date: Tue, 1 Dec 2020 20:00:58 +0100 Message-Id: <20201201190100.17831-2-aouledameur@baylibre.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201201190100.17831-1-aouledameur@baylibre.com> References: <20201201190100.17831-1-aouledameur@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201201_140123_483958_3ABDB93D X-CRM114-Status: GOOD ( 16.79 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:444 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Felipe Balbi , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Amjad Ouled-Ameur , Philipp Zabel , linux-amlogic@lists.infradead.org, Jerome Brunet MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org Use reset_control_rearm() call if an error occurs in case phy_meson_gxl_usb2_init() fails after reset() has been called ; or in case phy_meson_gxl_usb2_exit() is called i.e the resource is no longer used and the reset line may be triggered again by other devices. reset_control_rearm() keeps use of triggered_count sane in the reset framework. Therefore, 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 Reviewed-by: Martin Blumenstingl --- changes since v1: [1] * Moved reset_control_rearm after clk_disable_unprepare to clean things up in reverse order of initialization for phy: amlogic: meson drivers IMPORTANT: This patchset depends on this patch [2], it adds reset_control_rearm() call to the reset framework API, it has been approved by the maintainer, and will be applied to reset/next There is currently an immutable branch with it [3] [1]: https://lore.kernel.org/lkml/20201113000508.14702-1-aouledameur@baylibre.com/ [2]: https://lore.kernel.org/lkml/20201112230043.28987-1-aouledameur@baylibre.com/ [3]: git://git.pengutronix.de/git/pza/linux.git reset/shared-retrigger drivers/phy/amlogic/phy-meson-gxl-usb2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/phy/amlogic/phy-meson-gxl-usb2.c b/drivers/phy/amlogic/phy-meson-gxl-usb2.c index 43ec9bf24abf..1ddf5e5e4184 100644 --- a/drivers/phy/amlogic/phy-meson-gxl-usb2.c +++ b/drivers/phy/amlogic/phy-meson-gxl-usb2.c @@ -114,8 +114,10 @@ static int phy_meson_gxl_usb2_init(struct phy *phy) return ret; ret = clk_prepare_enable(priv->clk); - if (ret) + if (ret) { + reset_control_rearm(priv->reset); return ret; + } return 0; } @@ -125,6 +127,7 @@ static int phy_meson_gxl_usb2_exit(struct phy *phy) struct phy_meson_gxl_usb2_priv *priv = phy_get_drvdata(phy); clk_disable_unprepare(priv->clk); + reset_control_rearm(priv->reset); return 0; } From patchwork Tue Dec 1 19:00:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amjad Ouled-Ameur X-Patchwork-Id: 11943465 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 11C2790 for ; Tue, 1 Dec 2020 19:01:43 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8AFA520643 for ; Tue, 1 Dec 2020 19:01:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="GGZuRzxn"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="k3zSsZ2Y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8AFA520643 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yHIIxlYxZke2JcJrDG7lMEK4pqyagX6mnj9XSOG8iA8=; b=GGZuRzxnYdSNY1P70SKY+fW3zK F79QIJLiTC81l+p2heSOuej/jW4IdjKkl2D2ieGzkfcJrJQbiTMLM/NS66IbKM8ZlBAaTrVXVIklJ OIBCQdPZTYaAYsVheOhcK6cOIIazE9OL4gGev4OlvtwB937BDvlm3ZTr2fSOJahPTh5QQ/E6y9VfH uVALdK7zZmEdCvX1BxlzHfymWm3NOxeDbLtD/guzw2FLURhy4zYWX6nJSvl0LCf7uP9x3qZeoNUEu yDNgN4sqmNKKUVRxTuGdn7yhFN6RE58pbIA85EYPXVxUG7+ll+tsO7Mo5RZyBn8GwUCsdpPkXIGtX InTnhOQQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kkAu1-00018u-8D; Tue, 01 Dec 2020 19:01:29 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kkAtz-00018F-40 for linux-amlogic@lists.infradead.org; Tue, 01 Dec 2020 19:01:28 +0000 Received: by mail-wr1-x443.google.com with SMTP id l1so4359315wrb.9 for ; Tue, 01 Dec 2020 11:01:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1dEJUDuhS7iOpzRVv86r79ENM/jPrgw7u7JsYCWkYfU=; b=k3zSsZ2YWE86WW2dJvbafkB+cKYCqj+/dXRMk6wSEbaAMzM17lWDFS6pKZw3wW/ZkT IApg1a77UrpF1g+dFfOv4VaGH6r2bM+qt34+ZnvEAridm3NFwuFVC79jILvR2m52/Rdj xH2s5y+bq76LkLZKL5JgWE00QArs6sKwTYW4HavqlMxeAMprz9Q9MEu60WwI/TDRCDJG UJzC3PHE3mJrcR5nMy8V/eZSUnjKQpDa/y1UVtina4mzbdKoCsks1WTfXfsU7Hp9Y8np u+HiKvx3bb+k29/W6sq2tg8D34uU0+X/BEf+exjDTt7mUlYqx1gAClQTUvzVdlcjwbpV VM6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1dEJUDuhS7iOpzRVv86r79ENM/jPrgw7u7JsYCWkYfU=; b=H+8oCH28s6aTHIq2FRB2Tg1GC9u0zNta9pXcC+4UQzwflsEjk8moMTyXhKskQi5IZG lwbpRT/nXL65XFIna1otdp5n8aLT0fPsEJQ8IyE4hmtGv8HGGVAe+orkTx44f/4SRiWv uVwJZDhDY+C1TVbOMIrcIRCG2yRL9Ab8xqtTj2rrF8BXH6N9Dbdpfhu7oDPicj6rPn5+ zBBgSE5Vs05teSHgCvvmAVyKggiSoTVQH/OE70pFjIfyjX9J9IQSkyzgs3c2X68vbNeD AtBHXsFCeVJc5ILzlV2G5jqd7KBSkQwNxaTXaLpGE2QVj+5vnXvnQgU861lUgi6emZea UgtQ== X-Gm-Message-State: AOAM530IePFDPkrDrkXKrKyiZxvYnu380xQJgYrH4ZrarBflmpLxqWyR Z01FxDi/w/aXHlgU6QP5OjAIDrK3x1f49Q== X-Google-Smtp-Source: ABdhPJwVIic5SLd7j1ro/o0Nph5ICWIcaGxb0s8+eZQnKPwDgH3dWds5cFeB8K26G+y69nIC9lCztw== X-Received: by 2002:adf:902d:: with SMTP id h42mr5643737wrh.175.1606849286085; Tue, 01 Dec 2020 11:01:26 -0800 (PST) Received: from localhost.localdomain ([2001:861:3a84:7260:40a4:a590:1da6:9599]) by smtp.googlemail.com with ESMTPSA id 138sm887733wma.41.2020.12.01.11.01.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2020 11:01:25 -0800 (PST) From: Amjad Ouled-Ameur To: Felipe Balbi Subject: [PATCH v2 2/3] usb: dwc3: meson-g12a: fix shared reset control use Date: Tue, 1 Dec 2020 20:00:59 +0100 Message-Id: <20201201190100.17831-3-aouledameur@baylibre.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201201190100.17831-1-aouledameur@baylibre.com> References: <20201201190100.17831-1-aouledameur@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201201_140127_208490_41F69BB5 X-CRM114-Status: GOOD ( 18.29 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:443 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Hilman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Amjad Ouled-Ameur , Philipp Zabel , linux-amlogic@lists.infradead.org, Jerome Brunet MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org 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 --- changes since v1: [1] * None for this driver IMPORTANT: This patchset depends on this patch [2], it adds reset_control_rearm() call to the reset framework API, it has been approved by the maintainer, and will be applied to reset/next There is currently an immutable branch with it [3] [1]: https://lore.kernel.org/lkml/20201113000508.14702-1-aouledameur@baylibre.com/ [2]: https://lore.kernel.org/lkml/20201112230043.28987-1-aouledameur@baylibre.com/ [3]: git://git.pengutronix.de/git/pza/linux.git reset/shared-retrigger drivers/usb/dwc3/dwc3-meson-g12a.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c index 417e05381b5d..3fec8f591c93 100644 --- a/drivers/usb/dwc3/dwc3-meson-g12a.c +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c @@ -750,7 +750,7 @@ 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) @@ -759,7 +759,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev) if (priv->vbus) { ret = regulator_enable(priv->vbus); if (ret) - goto err_disable_clks; + goto err_rearm; } /* Get dr_mode */ @@ -772,13 +772,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev) ret = priv->drvdata->usb_init(priv); if (ret) - goto err_disable_clks; + goto err_rearm; /* Init PHYs */ for (i = 0 ; i < PHY_COUNT ; ++i) { ret = phy_init(priv->phys[i]); if (ret) - goto err_disable_clks; + goto err_rearm; } /* Set PHY Power */ @@ -816,6 +816,9 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev) for (i = 0 ; i < PHY_COUNT ; ++i) phy_exit(priv->phys[i]); +err_rearm: + reset_control_rearm(priv->reset); + err_disable_clks: clk_bulk_disable_unprepare(priv->drvdata->num_clks, priv->drvdata->clks); @@ -843,6 +846,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); @@ -883,7 +888,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; } @@ -893,7 +898,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) From patchwork Tue Dec 1 19:01:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amjad Ouled-Ameur X-Patchwork-Id: 11943467 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 57E4B90 for ; Tue, 1 Dec 2020 19:01:45 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 08E0320643 for ; Tue, 1 Dec 2020 19:01:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Mn/8Ztkq"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="EstpTfjB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08E0320643 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NRR4fHS9Z8MLSJTDwN1XPZy+0rFOf1brbKzrp4pxEMM=; b=Mn/8Ztkqg7ms66dXQe94p4ES7w 5VZMK/VrFHp8T2Pa4aXf0SGi3rkbt8DsNu/c1qBuJAkmhFjGj8ZseFeTc+94BPMKffS4mvLPt03Dm 9VzeFEl3Zmb4FGhcRN7OE/qVrKbF0Ub4yANelbETtgHzYD7UxjwVa0xvPBMDTn+YLf2O+BAgsHBJl qFxJDwiAZlWnwA1n2/Z0IKRh0Glmf8zaqR4ABgm48tagy4HKjWp+SWmDBeHN1KwIB5gLlc2nIk3vI wC4Q18qnFuPHTZ+MUbJY3fuCJol3PaIWijCTXuqH8TxiUCxMStEGxsHVwKxNDOOJ7uJPPKBeYqQnv HfMpnoTw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kkAu5-0001AE-Py; Tue, 01 Dec 2020 19:01:33 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kkAu1-00018x-P5 for linux-amlogic@lists.infradead.org; Tue, 01 Dec 2020 19:01:30 +0000 Received: by mail-wr1-x443.google.com with SMTP id r3so4378902wrt.2 for ; Tue, 01 Dec 2020 11:01:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4db92qgs7Cx19eXkYKoRrrPswVYgwmdMYfhe9hzWuuk=; b=EstpTfjBIGANDhV6j9xxplY0OMuMT3mXYXjXGWEmMkfck633Rx5GNrZCx+qvmEMTk+ 30qwQ2p/RMkaS/35v8gblXZPQ5pjuuuXUIHRjbcb/r9Lca2TSWINH0LzI3+v9pUWInbl CElsK8saKw913EWsTswc0UYIplLU1szE+p828DOBNswnjYIANOCm/BvG68L4F1O+we93 X7dAM1fkwe+svPyP9YY6x7ADIGtkL69IQ/GPwVjDdfEtqbl4TT7hnrslBLdpo+TKRQfs 2GYQE5TPX9j//2LJPbJxHR2IZ+EXn7+czPTTXYag0QyvyZSBDHHjtfEtv/BYbHQSDs01 fT3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4db92qgs7Cx19eXkYKoRrrPswVYgwmdMYfhe9hzWuuk=; b=a2DPWyyxo/QZotbLaOOMJ1mMLXDP8inzgLMxAWlWoMV6B/SNO6/NFN4gjzreizdGum 9Wj/Tn0zqniDV2hBG5N1dkvfgBbiAmw8WFLnNlHk6j/ZtrVlBzTXksyqc+/F6FJZsq4i XhBOWNUY7We8qg5I3KviDc5FbxWCaQNImVAAIsDSM048DGysH0tbALQG0NNR37BjkTdu wAu9meOUThaVseTnAAXstO3Kk7JEMNRYnN0XMxAREe4pd+8tFXsuHDd8zEiiAX4jDMFj qFZuXvxWNZPZTOZBiN0NmzQGFy9vSrO0sOYPs0xnl31YtpalcPq66B/NApyWX9q9jhOt Z6DA== X-Gm-Message-State: AOAM530Fm8J59Y9dkzE0+YI+C9kJ8i9XZsHB+gZmfqrG+pwqWRLD6OD7 uQS9qgzVmQReCGUSjubkAmy9gA== X-Google-Smtp-Source: ABdhPJwIXyPn73uqnfcK1Vyo37ATQR99pYmv4e0H6SMMvE1rbDlHUqqJvBW5/a62nbSNYjYvmSUivg== X-Received: by 2002:a5d:5651:: with SMTP id j17mr5761412wrw.221.1606849288897; Tue, 01 Dec 2020 11:01:28 -0800 (PST) Received: from localhost.localdomain ([2001:861:3a84:7260:40a4:a590:1da6:9599]) by smtp.googlemail.com with ESMTPSA id 138sm887733wma.41.2020.12.01.11.01.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2020 11:01:28 -0800 (PST) From: Amjad Ouled-Ameur To: Kevin Hilman Subject: [PATCH v2 3/3] phy: amlogic: meson8b-usb2: fix shared reset control use Date: Tue, 1 Dec 2020 20:01:00 +0100 Message-Id: <20201201190100.17831-4-aouledameur@baylibre.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201201190100.17831-1-aouledameur@baylibre.com> References: <20201201190100.17831-1-aouledameur@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201201_140129_836924_2272F396 X-CRM114-Status: GOOD ( 15.32 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:443 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Felipe Balbi , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Amjad Ouled-Ameur , Philipp Zabel , linux-amlogic@lists.infradead.org, Jerome Brunet MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org Use reset_control_rearm() call if an error occurs in case phy_meson8b_usb2_power_on() fails after reset() has been called, or in case phy_meson8b_usb2_power_off() is called i.e the resource is no longer used and the reset line may be triggered again by other devices. 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 Reviewed-by: Martin Blumenstingl Tested-by: Martin Blumenstingl # --- changes since v1: [1] * Moved reset_control_rearm after clk_disable_unprepare to clean things up in reverse order of initialization for phy: amlogic: meson drivers IMPORTANT: This patchset depends on this patch [2], it adds reset_control_rearm() call to the reset framework API, it has been approved by the maintainer, and will be applied to reset/next There is currently an immutable branch with it [3] [1]: https://lore.kernel.org/lkml/20201113000508.14702-1-aouledameur@baylibre.com/ [2]: https://lore.kernel.org/lkml/20201112230043.28987-1-aouledameur@baylibre.com/ [3]: git://git.pengutronix.de/git/pza/linux.git reset/shared-retrigger drivers/phy/amlogic/phy-meson8b-usb2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/phy/amlogic/phy-meson8b-usb2.c b/drivers/phy/amlogic/phy-meson8b-usb2.c index 03c061dd5f0d..651eec41a896 100644 --- a/drivers/phy/amlogic/phy-meson8b-usb2.c +++ b/drivers/phy/amlogic/phy-meson8b-usb2.c @@ -154,6 +154,7 @@ static int phy_meson8b_usb2_power_on(struct phy *phy) ret = clk_prepare_enable(priv->clk_usb_general); if (ret) { dev_err(&phy->dev, "Failed to enable USB general clock\n"); + reset_control_rearm(priv->reset); return ret; } @@ -161,6 +162,7 @@ static int phy_meson8b_usb2_power_on(struct phy *phy) if (ret) { dev_err(&phy->dev, "Failed to enable USB DDR clock\n"); clk_disable_unprepare(priv->clk_usb_general); + reset_control_rearm(priv->reset); return ret; } @@ -199,6 +201,7 @@ static int phy_meson8b_usb2_power_on(struct phy *phy) dev_warn(&phy->dev, "USB ID detect failed!\n"); clk_disable_unprepare(priv->clk_usb); clk_disable_unprepare(priv->clk_usb_general); + reset_control_rearm(priv->reset); return -EINVAL; } } @@ -218,6 +221,7 @@ static int phy_meson8b_usb2_power_off(struct phy *phy) clk_disable_unprepare(priv->clk_usb); clk_disable_unprepare(priv->clk_usb_general); + reset_control_rearm(priv->reset); return 0; }