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: 336498 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-21.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F59EC8300F for ; Tue, 1 Dec 2020 19:02:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 37BED21741 for ; Tue, 1 Dec 2020 19:02:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="PyDW5rz9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389825AbgLATCE (ORCPT ); Tue, 1 Dec 2020 14:02:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731300AbgLATCD (ORCPT ); Tue, 1 Dec 2020 14:02:03 -0500 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46001C0613CF for ; Tue, 1 Dec 2020 11:01:23 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id z7so4379406wrn.3 for ; Tue, 01 Dec 2020 11:01:23 -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=cRljp67OkOzg/iZ3x8iQwLqOAjmrtaFemoXeJ3e0GlpujkKcbYXCtJiHB/YGKXLS2u 7iUeTPOz3dzp1XKQ8P/WyqtUjllK6Gcj8j+V5qifSehtDmBW9Ky2j0oO/eSzrPOAhFlJ ndhpGsrOb1e9PUs6CxB1qqk+tLyui3G2HbZdpbM+iKkeAWYKojxKXiGuWU3jiOuu+m5k 1rRfq0NmnCvdgmW5UNpFfgoym15Fkl8VzDjIbweSZehgL1Dhrp4oF4hu7qE2PfpqyDU3 28p80CDONI7AZCQtm2tiZ0HhHhg8dGXMNKDnne3xYHizZZLxi85nPhgqlWYNVlxLylvt AusQ== X-Gm-Message-State: AOAM530hhSQzEqZ6vkTP6raMpE3E4xGL/oMMgOc7oXQu0ejkr37/873r XUGGdKtJ1jEQqdO3o9DeWyG5fA== 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 Cc: Amjad Ouled-Ameur , Philipp Zabel , Felipe Balbi , Jerome Brunet , linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org 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> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.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: 335549 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-21.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2EB1C83013 for ; Tue, 1 Dec 2020 19:02:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6559217A0 for ; Tue, 1 Dec 2020 19:02:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="k3zSsZ2Y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392303AbgLATCI (ORCPT ); Tue, 1 Dec 2020 14:02:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726704AbgLATCH (ORCPT ); Tue, 1 Dec 2020 14:02:07 -0500 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A7FAC061A04 for ; Tue, 1 Dec 2020 11:01:27 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id i2so4367344wrs.4 for ; Tue, 01 Dec 2020 11:01:27 -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=cCI4fhoWtf2mj4Xd8/p0lbtTYYREek5feSfyonjM+B4pFNe2WAWO2WycfgIsqGqWXd WaxM3Ip9fQsOKybm9Zab9A4hSuCY7xVHUIKVcPxk79tsWxhFtqgFnnco+FGe5HHpBwP8 FgVw6dX1368ZoT1tcBeAzZelxOlPEkG7ACpqmMdYYbswLCN3R35ImXBW207Nex8xALmV xlkWfUWdC7JlEjrAmHoQA6TlqpGDMYBAiKvaPScqVClcksLSMzAzY9yOK3kwhk2mMJh+ OG0hj75iHfT4s6iyBiSbvFHZ+webF12tnWEoXgo2UsyrkQ5N9qb1lCtic/Vdin8H9Q/d j2oQ== X-Gm-Message-State: AOAM533IQI0g1T7tXQrYmd/5xY/eEEV72XeR92ACRF6Uj6f690Zf6D0i DU86k//YATrr+OHvQTa3M7xvtg== 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 Cc: Amjad Ouled-Ameur , Philipp Zabel , Kevin Hilman , Jerome Brunet , linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org 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> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.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: 336497 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-21.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91F09C83014 for ; Tue, 1 Dec 2020 19:02:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F946217A0 for ; Tue, 1 Dec 2020 19:02:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="EstpTfjB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392325AbgLATCY (ORCPT ); Tue, 1 Dec 2020 14:02:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392316AbgLATCY (ORCPT ); Tue, 1 Dec 2020 14:02:24 -0500 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BDE5C061A49 for ; Tue, 1 Dec 2020 11:01:30 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id t4so4324673wrr.12 for ; Tue, 01 Dec 2020 11:01:30 -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=Zp2WStyNj9OLpTh6/T5PIeA0VunxEPwYUzfcvPhPjJyGzv1sNWs7eMitReMT5x0+Jb yRJ17/0lQ/w7q4DaE0aiLwHhDoiTbyyVwO8Ksd0SUrZxO/CXBBCohNBHHLqFk4/MeGHu mGdWwkZ2IT1po65kxCp9yRwgS/Wp4hkWicXUau5KnNb8Cz5Nw6w8yGd1f9fipig5kcTy zRTzNgTq/vaI8TgfQw8ILGeN80qOCrqTBNW2Pt7hu3LS9Z1aAM3vu+dqMmWfg2Ly0vFL N75ZJodW3H8x5MvCIvOTRpNSS70LJ/68J4HXHw3DfbtOoTVoc/LEC4KXw5fWdPcFqt7r fMkw== X-Gm-Message-State: AOAM533u6R1cKDnwshGx2iVTO59Y/g9kTnQEJ39xLqt7u4R0fsKXflCP talvOHGC/8cBWvtXj2fE8Qk42Q== 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 Cc: Amjad Ouled-Ameur , Philipp Zabel , Felipe Balbi , Jerome Brunet , linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org 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> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.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; }