Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp281323pxu; Tue, 1 Dec 2020 11:06:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwU3AAftke6k79kKEKpnZq7iHU6HcedRG4FQMiJuagd1mItfYMrwJo2wU9nJIpV1lwnYifE X-Received: by 2002:a17:907:60a:: with SMTP id wp10mr4515048ejb.205.1606849571531; Tue, 01 Dec 2020 11:06:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606849571; cv=none; d=google.com; s=arc-20160816; b=u+8pv0BXfWKD1gaLd7oZk2DVUf/bOahNVwgs4iwWfhqRxKHbfA2FjasOWeMpzxueTP CrCQ9UNU6+mfs/i0wD45SIzE/2LamyY1q1OTf5mJuxc/tztHtSH8koh3QccKvTwjeInV w4cz1tGQIcDsClidu9weHqZjPBLO7XoSndyBUHYeGNVv4MHfsIJvqMYRg2q1++Tze7YU vePrEFYOYTdzMRYT/Y8B0aCXvwc4Cs6dyKH33btoNIhLxJOy2Yzt8fG0GNwJn83AseVi COBpDU4/HxhjKoxfD4HQjtP0wT9ecVXnCGjz4HYMG/ov6alwDvB17Sc1oDnQbpUwJH+E 9bZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=4db92qgs7Cx19eXkYKoRrrPswVYgwmdMYfhe9hzWuuk=; b=jlzI4SiMOoyp9QakxyzZVlOemNkpegZ6KVYc+fWuTtP3es9qzRnr0AGsCseDIrInOd 5pJ37QuZkINVb/2ls3PQfL2HqYbCYClscNv3x5ITeJ0WhUUlyyv8rIMGuJaU0EyqWNkY w+ju95uZzPPerz5bt4/IoxF2oFxybRF/28y+Dne5A9k3quGuK9WeCghdlvDB3TWicUr/ JbbQdq53jNn5j1HW1ajZ4RamPyN2hYxCNSvebp6HjX1xc22ff1CulL+ajjkVRpzbAr4a rDOfOnl3qVuiei+D4ZtRrt/+S2B88NjkCTazdJfByY7xHIBkmeJczXT/oNaYvQt17lma 8GSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=EstpTfjB; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l4si493881edt.49.2020.12.01.11.05.46; Tue, 01 Dec 2020 11:06:11 -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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=EstpTfjB; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392319AbgLATCM (ORCPT + 99 others); Tue, 1 Dec 2020 14:02:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392316AbgLATCK (ORCPT ); Tue, 1 Dec 2020 14:02:10 -0500 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29D9DC061A48 for ; Tue, 1 Dec 2020 11:01:30 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id t4so4324671wrr.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=t0FwB7u1Ovp1lRa5D/I1tTps8Tz8ZjUQZ5ZCF54yW1ItFDw6kZpO9SgfACtmvBL3nW KnWymB33E0T3i8AA+l8qy66uyRIHBYdCV+JTCPaiuHxnijsuI2r8+t6Z+2Fx5gVQj4H+ 5NeDle+RYh1G1a6LLTDhl9B/k7PKqjlUwOV6j+g+GLOeNws1ooEsMUtz0qYUtICXtsjF /ZcOHS2hZ0WoD0upMQ0qxyrQtdfcmJ6kwD+3gK3XIjFUS8XDjllX3Is3PTb5A0a8W1Aq eeoqA0QJy0NDm3rzxfnXJAgvO7mYWmzj5+rgr/SmbJL5bbCOUGqckkLZqvskKnLg8hN7 Ewug== X-Gm-Message-State: AOAM531Aj2BEidGSxSlnEe/X82zHmTJjwbSs7TcTxd2XyzJvH0EY8e1P lcc9GS8ZWD1acNYtt1/6MnNNtQ== 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-kernel@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 --- 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; } -- 2.17.1