Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6982049rdb; Tue, 2 Jan 2024 23:45:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhvEQ76KJRcYkeiHMdgRkmHyW+Nk+K4zllZRttO88tpiRpViw8uxNH6rrB1RIJXf7NczCP X-Received: by 2002:a05:620a:6408:b0:77f:77d:8c25 with SMTP id pz8-20020a05620a640800b0077f077d8c25mr24131772qkn.134.1704267942168; Tue, 02 Jan 2024 23:45:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704267942; cv=none; d=google.com; s=arc-20160816; b=eQbZrDoS82Adq502KlSLgxEBUdyUukHiIVae37vIW2O8Mu7uthpe8I9JXJmKG+vFS7 j+caLqZJblix3aI91i1CVxwsGWUYQlgOu30AWcnNcgxxgi0rHhg+GvKpumhhUiyGwzr4 ynn5kOnf4P0hZ2bkduSBx39qlXJu7lQ6GXUW8IK9uNjgAlB73AQdea+5rOmQoiA46wgu D5b0EAxwbGWF9GdZ0yGBfHPMn+ZAxy+7hI+2mQpBY3bOJtqNBO/BDSkabss1gxUnewai hgq0bFUbop5yKTZP5IFz/AU4yNfSSes3KLY0PAObKtMxgFF+73+8ja2tyyl+LwTDkK1i Uf/w== 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=Qp6FcFL6ukPLR5E+VXKBAlytc1GJbe7ZjRNXKkg7yJE=; fh=FsAMATVq/YNr4+Uc7byimodAAyTjx8mtp+I6gP594VY=; b=LopEmFIKtrE4oMv0MF53IyFesG18iHywUNXkGQL/hkcF29dQkzFfS7VpzZ3/4AHA/w NG2ZLJeLsaq1QC9wJGu294CFVVy8hiaMdObtCCoxGeGoFTwXgCm3cnLQMBDVPV2Qrui6 Va9S/bwEcxQ9tk8YJwx962ujzLtol3qsLofRPvQtJGKr1VqqkbQmDOpMaOtbS+Dm2HK4 PFp22znkVjL3Fk8/ZGZ+Jgaj1lxXi8MOxLaCv44JM9Jj1wJmc1Fq+AoUB9rxy2bJFFAK OQbmqEK+6rLYNbwHM9aKt4kRtqLIY1jBa/zohnywsVq35II60vzSUTAIKAWNXquJT/wG P/jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NznUv0QM; spf=pass (google.com: domain of linux-kernel+bounces-15246-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15246-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id j6-20020a05620a410600b0078172891423si14223263qko.604.2024.01.02.23.45.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 23:45:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15246-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NznUv0QM; spf=pass (google.com: domain of linux-kernel+bounces-15246-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15246-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id DFC2C1C21C82 for ; Wed, 3 Jan 2024 07:45:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A8D4F18056; Wed, 3 Jan 2024 07:45:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="NznUv0QM" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 1EFFD18040 for ; Wed, 3 Jan 2024 07:45:29 +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-lf1-f42.google.com with SMTP id 2adb3069b0e04-50e4e3323a6so177615e87.0 for ; Tue, 02 Jan 2024 23:45:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1704267928; x=1704872728; 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=Qp6FcFL6ukPLR5E+VXKBAlytc1GJbe7ZjRNXKkg7yJE=; b=NznUv0QM2orzzFlteTkyn1/7uH1FabGzGJRHX3M9+oy/9chgciVnqFK+Heesb0SqIw ssJu0+1P9t/cVtESScNy04KtpW9rfYKAvX4jpfO2wGqmW0e8iMTOSPsmJ6+Jh7q4dSpP J9WsmGB76fnhxE3qQjfeyqhmoHRmyk3Ysh/FM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704267928; x=1704872728; 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=Qp6FcFL6ukPLR5E+VXKBAlytc1GJbe7ZjRNXKkg7yJE=; b=nUyA9GaiLdaIjsz5gqTncKvwbCA2g8PWt0YwvFERQLq8lQssLX1sWgdZ7AdaaaAxEa 4yQlll0zhFkKailLE5UO9/tLtBtFf8XA9ra01mbz/ycd9qAkQijmtPDxEfJq8oZhADu/ EBfroCp0U3pkQFXe5JelKQx23hMsRbjUBknlX7aJ5i4tGwOCoYglIqjgiCPro3MpE8KN 0VBpBvK472NlkBFQmCFoKXyRg/1qwCWOt1fwZtjyXNpNiBwi52uLBFxJygfLM8AicC/K aFGyCI8GEeiXLGY7Qwj6r7bJosTkLAzEW1nDPjS2kME3Wm9tRRfadd0a+h6LHmY9Vpm9 UG4g== X-Gm-Message-State: AOJu0YxgAT7V6P1gc/OZKrDSz58HAa+4nP3Mu/2fZjOiRrDqgbqFXrDd 2YgxtFH152CzvvVBf3jy0DRDkdx3d11Z4c8xmWMA5/7J5TU1 X-Received: by 2002:a2e:a487:0:b0:2cd:19ba:36f0 with SMTP id h7-20020a2ea487000000b002cd19ba36f0mr130664lji.17.1704267928052; Tue, 02 Jan 2024 23:45:28 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240102081402.1226795-1-treapking@chromium.org> In-Reply-To: <20240102081402.1226795-1-treapking@chromium.org> From: Chen-Yu Tsai Date: Wed, 3 Jan 2024 15:45:17 +0800 Message-ID: Subject: Re: [PATCH v2 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-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Weiyi Lu , linux-mediatek@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jan 2, 2024 at 4:14=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 on the clock controller during the > probing stage. No. The flag indicates that the clock controller needs runtime PM for its operation, likely because it needs some power domain enabled. The runtime PM get during the probe phase is a workaround to prevent a deadlock in clk_register. These are two separate things. The second part also should be documented in the code with a comment, i.e. a comment should be placed before pm_runtime_resume_and_get(). ChenYu > Signed-off-by: Pin-yen Lin > --- > > Changes in v2: > - Fix the order of error handling > - Update the commit message and add a comment before the runtime PM call > > 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); > + 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); > 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 >