Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp3704208rdb; Wed, 27 Dec 2023 17:52:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGEAbJEtFC/9EbQPijsRgQIi2QPSfFHei9J95OVhD8HLataenNNJyH7cymmsMcOGpiv0Pfv X-Received: by 2002:a17:902:f68b:b0:1d4:3f42:45be with SMTP id l11-20020a170902f68b00b001d43f4245bemr3397518plg.106.1703728321321; Wed, 27 Dec 2023 17:52:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703728321; cv=none; d=google.com; s=arc-20160816; b=V/P8ggkikWOMTVqo49/S3z64XJMPSuJHLX9U4k/6LEYsSEDUhSyTt0jW6QS4tNkVUr SC6ORG7AmWy+OWMpJW3q+lr6HARmat7/pAsoYVWA7MHiG2YH0JUR+G4+S3TbfSaynWtx sTbovomRDI5w23P8ZyM/Tg3Wex8Jnm8iKWc+tKUiqtdQpFk94eaP7CqqhH3mpHOt5Ppn SntfbswCmhD5kObRUzUAzkDdgyc+9EAEe9uAq9KRG0pUOtXwQt4wVwwCVVwDuXO6mnAa wn7Z/XfPyI4E1A7ZZGLTbCGsV2GpNmmgiRn2t1VZemHyAlAyRfAlNR0aa9wjAYqna9zh a4kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=abPHoTgkKdKqNv7pVii73M9V/jiTguCmzH4R/B50i7k=; fh=wRhdHcbDeXbps90+R7SZ5rBfA/1VD+z1I4R005VfgLQ=; b=Xxj0jyZzmGm8l3F6gUGuPARXxBdK8/YvejDOR7uQOZTzjcm8/MD+XPRU2Hxt5lQxMv xsC4Iy1bWTbNR06ACPCcpgPnNU53XG/lUf0rz9FcfKjCcIJu4iJtqYTCrmJ0TzsbguZF jL0yepCT5cBH6H4i6lo3cBWoowqRKv0dx63YM/Q/yh+d4+I8dq+Nr7kN9D4elz6f/Oep EUB/Bt2RhhaV5kVjLGpe2NrzSkvDb357UZu/N5hwztqvcf0/gb+0fHYap+D1awKkwunG vv3OY9kx2Dr0yduIsaEZqm/Z4NCoHLiE7PQKdzga3skRiksjWoBAB5yfJ+UkV/am8csj e0Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="boaX16/u"; spf=pass (google.com: domain of linux-kernel+bounces-12384-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12384-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x15-20020a170902a38f00b001d38d9dee98si12076217pla.573.2023.12.27.17.52.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:52:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12384-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="boaX16/u"; spf=pass (google.com: domain of linux-kernel+bounces-12384-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12384-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C72C4B219E5 for ; Thu, 28 Dec 2023 01:47:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3941F63B6; Thu, 28 Dec 2023 01:46:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="boaX16/u" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DC45613C for ; Thu, 28 Dec 2023 01:45:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2ccc34a9f90so26946141fa.0 for ; Wed, 27 Dec 2023 17:45:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1703727955; x=1704332755; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=abPHoTgkKdKqNv7pVii73M9V/jiTguCmzH4R/B50i7k=; b=boaX16/uPmjxMEQGH3Oh2SDlkIQyduzJBCnJLuzucXiIMUdlmYFYD+bSsrI0xU3qKG PlXXwa+ONVxCHi0+EJFjxeQp/1okTC+/Nz9yR9j5Fs1BUDJVwkDAds9XJMs7rwa3D+oJ hbaZV+2ux71SPg/cXYPRmEDXiOHENXcUWwf4E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703727955; x=1704332755; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=abPHoTgkKdKqNv7pVii73M9V/jiTguCmzH4R/B50i7k=; b=pkoC3OwnCt3ZEjrLjmcuTVZjUs626PYgLZIbpyjFPMOBRKNO+koFU0e2Hap6SrzyMp qdtwe1pY+G77JUUWlmvFxOys1rxYNTDl3CZ1Af7pyysm08YhBy1d29OiJDhIRZd8kzgh iDzQMFcKhagKFCD3YHkCZJ9K+Ryh55ktZEcuXOuXsrUCJZEDAGRoAHThK2jLm1MrD93w xYfaLUPTOo5xRoVuqu60h0TZpTjJSON5Qk6EnVpIdosaVU6kRzfIHRC+HpZCMQSN6wtX qjQFmT1gCP/ex4MUQXuRnx+301NVPsSJxGSWGdWzEB3LC9BZ2uEAPW7p5g5pE7coyvcB vhLg== X-Gm-Message-State: AOJu0Yy6RE4opNCxESfl0Pnejx85x6vTOaRMzbxVVHI6vat7GZayetG2 9tzJkzUIeala0IfCtFY/eDue28WbrRHu5Tt+FKZXYhQ8n0u7 X-Received: by 2002:a2e:460a:0:b0:2cc:7445:bbc2 with SMTP id t10-20020a2e460a000000b002cc7445bbc2mr3496636lja.32.1703727955400; Wed, 27 Dec 2023 17:45:55 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231227090448.2216295-1-treapking@chromium.org> In-Reply-To: <20231227090448.2216295-1-treapking@chromium.org> From: Chen-Yu Tsai Date: Thu, 28 Dec 2023 10:45:44 +0900 Message-ID: Subject: Re: [PATCH 1/2] clk: mediatek: Introduce need_pm_runtime to mtk_clk_desc To: Pin-yen Lin Cc: Michael Turquette , Stephen Boyd , Matthias Brugger , AngeloGioacchino Del Regno , linux-mediatek@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Weiyi Lu , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Dec 27, 2023 at 6:05=E2=80=AFPM Pin-yen Lin wrote: > > Introduce a new need_pm_runtime variable to mtk_clk_desc to indicate this > clock needs a runtime PM get during the probing stage. Actually it means (based on our discussions and your code here) that runtime PM should be enabled for the clock controller. If runtime PM is not enabled before the clocks are registered, the CCF subsequently never toggles runtime PM. The runtime PM get during the probe stage is to avoid triggering runtime suspend/resume during each clock registration, and hopefully avoid a deadlock. It should be mentioned separately. A comment should be added so that folks going over the code in the future don't remove it. > Signed-off-by: Pin-yen Lin > --- > > drivers/clk/mediatek/clk-mtk.c | 15 +++++++++++++++ > drivers/clk/mediatek/clk-mtk.h | 2 ++ > 2 files changed, 17 insertions(+) > > diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mt= k.c > index 2e55368dc4d8..c31e535909c8 100644 > --- a/drivers/clk/mediatek/clk-mtk.c > +++ b/drivers/clk/mediatek/clk-mtk.c > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > #include > > #include "clk-mtk.h" > @@ -494,6 +495,14 @@ static int __mtk_clk_simple_probe(struct platform_de= vice *pdev, > return IS_ERR(base) ? PTR_ERR(base) : -ENOMEM; > } > > + > + if (mcd->need_runtime_pm) { > + devm_pm_runtime_enable(&pdev->dev); > + r =3D pm_runtime_resume_and_get(&pdev->dev); A comment for the resume and get should be added. Otherwise someone looking at this and the CCF could think that this isn't needed, since the CCF alrea= dy has similar calls. > + if (r) > + return r; > + } > + > /* Calculate how many clk_hw_onecell_data entries to allocate */ > num_clks =3D mcd->num_clks + mcd->num_composite_clks; > num_clks +=3D mcd->num_fixed_clks + mcd->num_factor_clks; > @@ -574,6 +583,9 @@ static int __mtk_clk_simple_probe(struct platform_dev= ice *pdev, > goto unregister_clks; > } > > + if (mcd->need_runtime_pm) > + pm_runtime_put(&pdev->dev); > + > return r; > > unregister_clks: > @@ -604,6 +616,9 @@ static int __mtk_clk_simple_probe(struct platform_dev= ice *pdev, > free_base: > if (mcd->shared_io && base) > iounmap(base); > + > + if (mcd->need_runtime_pm) > + pm_runtime_put(&pdev->dev); Please keep the error path calls strictly in reverse order of the setup calls. So this should go before iounmap(). ChenYu > return r; > } > diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mt= k.h > index 22096501a60a..c17fe1c2d732 100644 > --- a/drivers/clk/mediatek/clk-mtk.h > +++ b/drivers/clk/mediatek/clk-mtk.h > @@ -237,6 +237,8 @@ struct mtk_clk_desc { > > int (*clk_notifier_func)(struct device *dev, struct clk *clk); > unsigned int mfg_clk_idx; > + > + bool need_runtime_pm; > }; > > int mtk_clk_pdev_probe(struct platform_device *pdev); > -- > 2.43.0.472.g3155946c3a-goog >