Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp761466pxb; Thu, 12 Nov 2020 16:10:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGbgDfsOZ/SeGWDcAn7B3W9yiKUljSbXvgXDImNg1x9TTVVLd1U5WYCIFTSEHEgTIYNIAM X-Received: by 2002:a17:906:4057:: with SMTP id y23mr1742866ejj.299.1605226247481; Thu, 12 Nov 2020 16:10:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605226247; cv=none; d=google.com; s=arc-20160816; b=ywDmuHyqRjSqTT6oXCuH/UQ4+pSSldtcUpkf8AR+0eJ9hPiYQI8IVK1um+5Ui3f1L/ A7twluhyb6Lg7UcfEdNfxhnPcvs7D1PMehEMUCdwxH54JXIncHkq610XO+6MbTTZsGOx oL8w7x47RV805Nb2Osst1oiPwqQGNtE/vH+edtyrkOuDPYpxQpVOwdBa9/iCQ/K7p3xO gmbkFvg1V3xTlGYaEpH+HMx3UtS7ek1kBrnDulZ8uEaE5JnpBIxhHAsJFRTT8TJ0OlT0 M1vKZK9Z79xOj9Dd6KAmI17m6XxxzFPTGfubktXp9aQVuy+PvrPo3Gom1QLyVW9WcgL7 Gm7Q== 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=ZVUOLs2+wec7oUYLZkwPoiWAkG2vGu94t71XbGuqA0A=; b=f5R7cKLWGrK75HtzWmI48184lKRUPl581TcmGZZu+EOqWJmhM082r7kZZ3/r9a7+rR 12dOByWguEaDJBCJLgpg0VcVhJMCgt037aPU1r8a68Ccmo8dnkAhxkvMbmCS71K19UxY Tq2b+1XWLE0kwUspnWklxLujJoUBcPjBuc7t5gpHg90RkgGfkX43sXwFFArAcPz7DYPO 6DBSS/1XdQId4JA5ta/De+hAkWvJUngCfl6YY5KrzYN23cbaC3w/mhSUsS6TxQlBrDTM pS60YRpCdz6q8lCvymDagqequw8BFumYAkeonzWOpJPReSAfspdrCZ1qEFXF51zTKB+W 8zCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=niMmvWPE; 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 a3si4762578ejx.273.2020.11.12.16.10.24; Thu, 12 Nov 2020 16:10:47 -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=niMmvWPE; 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 S1726038AbgKMAGv (ORCPT + 99 others); Thu, 12 Nov 2020 19:06:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725894AbgKMAGv (ORCPT ); Thu, 12 Nov 2020 19:06:51 -0500 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F8ECC0613D4 for ; Thu, 12 Nov 2020 16:06:35 -0800 (PST) Received: by mail-wr1-x441.google.com with SMTP id 33so7856605wrl.7 for ; Thu, 12 Nov 2020 16:06:35 -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=ZVUOLs2+wec7oUYLZkwPoiWAkG2vGu94t71XbGuqA0A=; b=niMmvWPEl0fnMO6tMTcfpoR9YBUgH9zZ+Dt+igR122IRwmctAz3bKbFzybFAGY4KTn rBgHRqd+5WTm1+K4iHBPxBXjNjxewOhhq3oGz6A12hEUj5QytNgYQc7zZZPTM937L6b9 lEOGfiE06I38tAMZxkJMGCb0D7EryshByXQUhSVfAo2CFCgwzcJh909decva2s/PSriB MkdMo50zmMS/bWfNuECwrXRWxamjBQJ/f7EM+wzu0BCr/N5nOHvprUi2hKLOvG4PZ6ie bXk+lvywpWHOm1vL/5Y2ZAF9yEdl4HAxALCaKk/gg6n+JLKgWdBegvdV+Fj9yjwIlyJV xcnQ== 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=ZVUOLs2+wec7oUYLZkwPoiWAkG2vGu94t71XbGuqA0A=; b=Ajj+FcifSGq/mQdZKxStFwIYt5TNXv6KWa7T4eHzncglc5h9Jac2sf8Jrctl/dHetA TszfgbGnP2QorjzEEhEI4pLFgA65VY7qnRJWaO6ZGRX648Kh35o8m543Nb2jtCd6cZ1Q d8x5e0SY9wGvd5VbnHRVE9SW7kXRfm+3qDM4DtAyjFZN+DuDdQ1K6ocS2/GsyW/vmQf5 G/tE6yWCwXOUl1jgw1MNyHgmgskRqWEiMp7UsSrjwNUCunnqhUF87T92c6MMl3kF/AvL ZhE+ScxDZrDdkJP40gyM64Uj3tJ22pZFKiK+qx9R0mg1VMsOFGAXkuGft0+/FJU0cFJ8 W5pg== X-Gm-Message-State: AOAM532LS3ADeM9W5IukT1Y1Ey0AlMBWnJEPxYCqm1fjsuklgkJJYhQ4 7foXVRya2b9HKBdDNdiDYIfFYg== X-Received: by 2002:adf:f083:: with SMTP id n3mr2382435wro.391.1605225993485; Thu, 12 Nov 2020 16:06:33 -0800 (PST) Received: from localhost.localdomain ([2001:861:3a84:7260:5d3c:83d5:8524:33ca]) by smtp.googlemail.com with ESMTPSA id t11sm2010114wrm.8.2020.11.12.16.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Nov 2020 16:06:33 -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 2/3] usb: dwc3: meson-g12a: fix shared reset control use Date: Fri, 13 Nov 2020 01:05:07 +0100 Message-Id: <20201113000508.14702-3-aouledameur@baylibre.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201113000508.14702-1-aouledameur@baylibre.com> References: <20201113000508.14702-1-aouledameur@baylibre.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- Important: Please DO NOT merge before this patch [0] is merged, it adds reset_control_rearm() call to the reset framework API. [0] https://lore.kernel.org/lkml/20201112230043.28987-1-aouledameur@baylib re.com/ 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) -- 2.17.1