From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CB427C7EE29 for ; Fri, 2 Jun 2023 19:13:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=f9PjNUyynORonhb4VrGB+T0Q8AsZu+uzgQIgBVUzDEE=; b=2isSfgTVmkOfjq QZpC66I1xPlp0gbKixP1wwCVNoNVH/IXz3Vyp+xuqfaM3gtQvbe+86YtBZ71rfi/LCPkp83KD0Yvi zqlW4l19KADTrL+ILNn9Qlgs3HazSa9IvIs6IaZqBu0cdXNp/F9+18Osq90lC71uuWBPDCZb1AM+h VSA7rqHcEautGhNuR5of6yEgyOQQaTETJf1X09dQ95Wr0Jo4jxbAfQqd15EueGhdeTSBouW+V/3M9 +W+S6K4QEcb2GCwgvC/mXs37KZgOSmbT3nVqGevt5s/RhXhWkjhcSV2vd+8nbeURz/O2QnxorlBa4 GPJmc3xfjM6fUMFgiPLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q5ACS-007j1E-30; Fri, 02 Jun 2023 19:12:36 +0000 Received: from phobos.denx.de ([85.214.62.61]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q5ACP-007j0V-2E for linux-arm-kernel@lists.infradead.org; Fri, 02 Jun 2023 19:12:35 +0000 Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 6B3D384706; Fri, 2 Jun 2023 21:12:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1685733152; bh=lux7vqm5QP+Qotc3QhmUo2y8QJs39Wad5RGNCvVkHoE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=R8r6qV0yIY5B+toqqnbDkTukFJaVscrkLdohMazmOYcKwyN6z4ny8RAH6PkbxE48T IyzPPLBX3l5gRJ4/Zpn9kH7crOKhLB1fWMS5mxqWc5TOGos/UPQ9g9FRCtm/KGYOLj GH7oFouyqg7sMqKad7w45XxWzAKUKejy0NhZM85/9pLV37DnarcIVwHpuHs73r67WH IVq9LlJDKgg0asq0DvrvYYnXLXdgw8cs8HJ6+GtB1+Kmz+nYr1HBd7cv0PQul3YE8d eR4VMjSkNEXw0pM5SBTDzbDnH2xPx98b7ALeFFSgG11a0Zt0FMT4Y1zQhA/QgjAJHI 55unpObTbJEYg== Message-ID: Date: Fri, 2 Jun 2023 21:12:30 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH 2/2] soc: imx: gpcv2: prepare bus clocks early To: Lucas Stach , Shawn Guo Cc: Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , patchwork-lst@pengutronix.de, linux-arm-kernel@lists.infradead.org, Luca Ceresoli , Laurent Pinchart References: <20230602185417.4098937-1-l.stach@pengutronix.de> <20230602185417.4098937-2-l.stach@pengutronix.de> Content-Language: en-US From: Marek Vasut In-Reply-To: <20230602185417.4098937-2-l.stach@pengutronix.de> X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230602_121234_110425_6A0046E9 X-CRM114-Status: GOOD ( 23.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 6/2/23 20:54, Lucas Stach wrote: > Prepare the bus clocks during PGC domain driver probe. This avoids a > potential deadlock when there a clock providers inside the domain, > as this might end up trying to take the CCF prepare_lock from two > different contexts, when runtime PM is trying to resume the PGC domain > for the clock provider. By keeping the bus clocks prepared as long as > there is a PGC domain driver attached, we don't need to take the > prepare_lock in the domain power up/down paths. > > We don't want to do this for regular reset clocks, as this might lead > to some PLLs being kept prepared that could otherwise be shut down. > For the bus clocks this isn't a concern, as all the bus clocks are > derived from always-on system PLLs. > > Signed-off-by: Lucas Stach > --- > drivers/soc/imx/gpcv2.c | 41 ++++++++++++++++++++++++++++++++++------- > 1 file changed, 34 insertions(+), 7 deletions(-) > > diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c > index 706f852e5d87..428e2fd82f26 100644 > --- a/drivers/soc/imx/gpcv2.c > +++ b/drivers/soc/imx/gpcv2.c > @@ -337,10 +337,14 @@ static int imx_pgc_power_up(struct generic_pm_domain *genpd) > > reset_control_assert(domain->reset); > > - /* Enable reset clocks for all devices in the domain */ > - ret = clk_bulk_prepare_enable(domain->num_clks, domain->clks); > + if (!domain->bus_clocks) > + /* Enable reset clocks for all devices in the domain */ > + ret = clk_bulk_prepare_enable(domain->num_clks, domain->clks); > + else > + /* Enable bus clocks for this domain */ > + ret = clk_bulk_enable(domain->num_clks, domain->clks); > if (ret) { > - dev_err(domain->dev, "failed to enable reset clocks\n"); > + dev_err(domain->dev, "failed to enable clocks\n"); > goto out_regulator_disable; > } > > @@ -402,7 +406,10 @@ static int imx_pgc_power_up(struct generic_pm_domain *genpd) > return 0; > > out_clk_disable: > - clk_bulk_disable_unprepare(domain->num_clks, domain->clks); > + if (!domain->bus_clocks) > + clk_bulk_disable_unprepare(domain->num_clks, domain->clks); > + else > + clk_bulk_disable(domain->num_clks, domain->clks); > out_regulator_disable: > if (!IS_ERR(domain->regulator)) > regulator_disable(domain->regulator); > @@ -466,8 +473,11 @@ static int imx_pgc_power_down(struct generic_pm_domain *genpd) > } > } > > - /* Disable reset clocks for all devices in the domain */ > - clk_bulk_disable_unprepare(domain->num_clks, domain->clks); > + /* Disable bus or reset clocks for all devices in the domain */ > + if (!domain->bus_clocks) > + clk_bulk_disable_unprepare(domain->num_clks, domain->clks); > + else > + clk_bulk_disable(domain->num_clks, domain->clks); > > if (!IS_ERR(domain->regulator)) { > ret = regulator_disable(domain->regulator); > @@ -486,6 +496,8 @@ static int imx_pgc_power_down(struct generic_pm_domain *genpd) > out_clk_disable: > if (!domain->bus_clocks) > clk_bulk_disable_unprepare(domain->num_clks, domain->clks); > + else > + clk_bulk_disable(domain->num_clks, domain->clks); > > return ret; > } > @@ -1343,10 +1355,19 @@ static int imx_pgc_domain_probe(struct platform_device *pdev) > regmap_update_bits(domain->regmap, domain->regs->map, > domain->bits.map, domain->bits.map); > > + if (domain->bus_clocks) { > + ret = clk_bulk_prepare(domain->num_clks, domain->clks); > + if (ret) { > + dev_err(domain->dev, > + "Failed to prepare domain's clocks\n"); > + goto out_domain_unmap; > + } > + } > + > ret = pm_genpd_init(&domain->genpd, NULL, true); > if (ret) { > dev_err(domain->dev, "Failed to init power domain\n"); > - goto out_domain_unmap; > + goto out_disable_clocks; > } > > if (IS_ENABLED(CONFIG_LOCKDEP) && > @@ -1364,6 +1385,9 @@ static int imx_pgc_domain_probe(struct platform_device *pdev) > > out_genpd_remove: > pm_genpd_remove(&domain->genpd); > +out_disable_clocks: > + if (domain->bus_clocks) > + clk_bulk_unprepare(domain->num_clks, domain->clks); > out_domain_unmap: > if (domain->bits.map) > regmap_update_bits(domain->regmap, domain->regs->map, > @@ -1380,6 +1404,9 @@ static int imx_pgc_domain_remove(struct platform_device *pdev) > of_genpd_del_provider(domain->dev->of_node); > pm_genpd_remove(&domain->genpd); > > + if (domain->bus_clocks) > + clk_bulk_unprepare(domain->num_clks, domain->clks); > + > if (domain->bits.map) > regmap_update_bits(domain->regmap, domain->regs->map, > domain->bits.map, 0); Isn't this similar approach to [PATCH] [RFC] soc: imx: gpcv2: Split clock prepare from clock enable in the domain where Laurent (now on CC) reported that this still causes issues ? If not, then please ignore my comment here. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel