From patchwork Mon Oct 28 10:25:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3593 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 571C33F338 for ; Mon, 28 Oct 2024 11:26:15 +0100 (CET) Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-5cbb0b2c6e8sf2153523a12.0 for ; Mon, 28 Oct 2024 03:26:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1730111175; cv=pass; d=google.com; s=arc-20240605; b=EqQyYD5IFb0LpWZaSSDUpWqTn1lTQmeIlpF9NagG3U5QtLTlb4QSSR9Q4Ri3PoXR5M AmZnPDLj1hFYwZz1KVWqTQlLK8/oWPuU5LVOAkoFPvpVc19WGsN8csbgIN/yswhzmExD /v8ycqZ+foGAFnvmRDpYsCX0XmCWAWzog7khfhS6esCnQtV1/kRpZOYFOKnB/9VA77uJ SEhC/9WskZnEFH09qv9YsK40eLSXrYtvJCqblCU6SxOjJjjwId32vDJvSFVtcpxAOhVL A1wu9sgKzpv4SBowyzgPz/BFvA3WvyumO13uS19Cfi2FSs0NJ5YwHHbO+LeTj2A52MY0 bwfw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Bm4/dxyhe3GBXJsO+CGWz0hY9MjzhHmAsfv9r9xjF9A=; fh=3pv0GCGjNnwC0RSypNBWnhulyda9NoCkdRHDeATK6KY=; b=VgNd+wKJj7A9CznPeNHklygZY+MODD/fjIgX11F11j/aForqP+uCkGEw2usHghtnYe I3VFDSw04iHlAKbSBTaOvZtmsEohGl4iDLWDcdH1Ako52qUAB6HE8Trk7qRvdx0nObdK FnaWU+mC2QWwxwBOCdlUbIOm8SGqrYMCcpBkm1ONftcwuT2HBffnWuyb1gA0BWVv+IYU BSy6Pun5O+tsbWnbtKX4FRjNKocqF/JKwGXaQvAg+b2TnSNQbTSdTIfvYbInjgykwhHh 5pyxLb/4Nd4HZV7om/cK8iCFKe3G1/QGwlTjFJ79dSnmM2VcyADEUBNG8FfShSh4YisZ hJeg==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=R8MrJ+6K; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1730111175; x=1730715975; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Bm4/dxyhe3GBXJsO+CGWz0hY9MjzhHmAsfv9r9xjF9A=; b=jMezA6iGSEkehJXZgaqO7HArOSH+SLIZbuMdQf6WkscrKf59QunfmlCk2IGGKn3y1z lHUZ32VEt6rPxdDjXA78CEksos02slx1gKS6Df75VQWi10boFdtIvDNOsPwThRUJRzGv Ka89bU+mhhgJRD8ktTA3KIA/RPw1LSFUrk6gM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730111175; x=1730715975; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Bm4/dxyhe3GBXJsO+CGWz0hY9MjzhHmAsfv9r9xjF9A=; b=aDCa6HD4e4PAOaorzvnge6qXm8ILl4XDMCB3NwipYV2dvm7WgiIigI6WKOfJTfJ9AN 8tRVf4MFzQYm4C1tXigJtV5kwj74K+TOpnW6WYJlHskCuvXf2trA2o1FO3DqIVIIeiQM feOVNTGL/Bk9LO1ZHU/zbIGLLNSqvhSFAyytGRam//HLV3c6bbXNAHhyE36Vk3gpynjj 6yVeTREYLP3lmTO0axGCGFovYFHPddPuKaWI6rXhPwn8pFBSjl1s3ijDkPfDa1BlwyqC 85WZNBhn4EZP+cbfHdqzWLZhkrDginIyYpWp7MJ90T6qMeWnn375f+p0i75cUaq6t21V ZeKg== X-Forwarded-Encrypted: i=2; AJvYcCWUU+/GdIzXanqhns5YARwQBaXdr/WBCl/U046wmpfgD9myvjdI+r9TtNWMApyfZ0JwvpRhdiym3nggqYFt@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YwZVTfOlPuBJI5Mfmrj5KUCJfEvqZbV0spm6STPan79BVaw0q2W U5aZ4Jf9QsWACdF515T0O6a9x9ZFxRtfabAolUSDLgvjLjaEEpi8Z0tHVWXLnw4Lcg== X-Google-Smtp-Source: AGHT+IFBBKnm2Kcv57HQ77IzATIyzy3aUfxFTUlz9F/khtCwLYa1mlPptlTq+y0Cagz3Y6DVhe4AcQ== X-Received: by 2002:a05:6402:524c:b0:5c9:7e10:4fc5 with SMTP id 4fb4d7f45d1cf-5cbbfa93ce0mr5526815a12.30.1730111174916; Mon, 28 Oct 2024 03:26:14 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:5245:b0:5c9:85d4:d942 with SMTP id 4fb4d7f45d1cf-5cb99882f5els99414a12.0.-pod-prod-02-eu; Mon, 28 Oct 2024 03:26:13 -0700 (PDT) X-Received: by 2002:a17:907:3da4:b0:a99:f77f:b489 with SMTP id a640c23a62f3a-a9de619eb04mr746793666b.43.1730111173294; Mon, 28 Oct 2024 03:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730111173; cv=none; d=google.com; s=arc-20240605; b=lkWoAXpWYYDvRatpixTf+UGDsOkPc0aliTNwdyj5ZQNB4qCJWS76a8ETF/EQzEpZt5 fwtEaEJu4kS1uOhDZmYJX68U7Yvf9aTi7J5Njh+Vw7N/4gDAiZOjCyKmDSawZ1zySUYO GRbufHBQ2u6YTe9N9EHg9Kh7SdxdjLuOR4aNzodNHGOcH+zbIlQM/4FrYZfk1CjNlFM1 xNPY1w08foq6GgDsmkk7w30ELEVunLfkVJV/r9SJqYwqvek5OnLk87W7PNneHOIqZVOa QApS3Tkj10h3oDzBAQIPHi/n3Ya7PkVwwNs/UAYdUn6jf8ob0QJbd+opFVYYRBz5ld5h AiRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=ErPoXh63XrcFWpHe9zG8v9aPuGfFzlqWX+d+j6TRc4A=; fh=+53FcJ8iShPe8LYolsw1afMZMD14hl7RdVueLqfhGeI=; b=gIeFYtA0hiZlzsfviXjKie/pJTTtFmXLlmzSDG9v4tD+eXYiQGM6REUSNylGCpNBVr evrBjfFRvK/ttrLzo5LrGnc6U/gD9aOwskAHLSSSe7eKUGEl8COkmRWcsAniUPne+hjs 0uGVdiyyYqv8YERo88zSsC8+8mM96ILaAFjbQqK/lSOdL2NrvyixsxDiSRTvbY0/R5/v BLwUtRFRLcAtb+0G5na+xuhFL7aTt8GPnop9imV2JbPrr5jdGY17rDJR9GmsV9ejJrpT PvL9OGzqDe3kbX52FRo3NCqBqA2sYhkjrDSsvw8sYEfkpidnzO59tAQr4Jm/5nmVkhew 0myg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=R8MrJ+6K; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id a640c23a62f3a-a9b1f290efbsor259085466b.15.2024.10.28.03.26.13 for (Google Transport Security); Mon, 28 Oct 2024 03:26:13 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:9712:b0:a9a:2afc:e4d7 with SMTP id a640c23a62f3a-a9de619d18bmr803160866b.44.1730111172695; Mon, 28 Oct 2024 03:26:12 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.41.121]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f297b04sm363613966b.134.2024.10.28.03.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 03:26:12 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Michael Trimarchi , Fabio Estevam , Marek Vasut , Peng Fan , Pengutronix Kernel Team , Sascha Hauer , Shawn Guo , Ulf Hansson , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Subject: [RFC PATCH 02/10] pmdomain: imx8m-blk-ctrl: don't turn on a power domain already on Date: Mon, 28 Oct 2024 11:25:25 +0100 Message-ID: <20241028102559.1451383-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241028102559.1451383-1-dario.binacchi@amarulasolutions.com> References: <20241028102559.1451383-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=R8MrJ+6K; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The patch, by informing pm_genpd_init() with the "is_off" parameter that the power domain is already on, prevents the power_on() callback from being called, thus avoiding the unnecessary repetition of the hardware power-on procedure. This feature is crucial when supporting the simple framebuffer, as the power domains have already been initialized by the bootloader. Co-developed-by: Michael Trimarchi Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- drivers/pmdomain/imx/imx8m-blk-ctrl.c | 51 ++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/drivers/pmdomain/imx/imx8m-blk-ctrl.c b/drivers/pmdomain/imx/imx8m-blk-ctrl.c index ca942d7929c2..8dc1508571dd 100644 --- a/drivers/pmdomain/imx/imx8m-blk-ctrl.c +++ b/drivers/pmdomain/imx/imx8m-blk-ctrl.c @@ -166,6 +166,24 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd) static struct lock_class_key blk_ctrl_genpd_lock_class; +static bool imx8m_blk_ctrl_is_off(struct device *dev, struct generic_pm_domain *genpd) +{ + struct device_node *node = dev->of_node; + struct imx8m_blk_ctrl_domain *domain = to_imx8m_blk_ctrl_domain(genpd); + const struct imx8m_blk_ctrl_domain_data *data = domain->data; + u32 boot_on; + int index; + + index = of_property_match_string(node, "power-domain-names", + data->gpc_name); + if (index < 0 || of_property_read_u32_index(node, + "fsl,power-domains-boot-on", + index, &boot_on)) + return true; + + return !boot_on; +} + static int imx8m_blk_ctrl_probe(struct platform_device *pdev) { const struct imx8m_blk_ctrl_data *bc_data; @@ -173,6 +191,8 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev) struct imx8m_blk_ctrl *bc; void __iomem *base; int i, ret; + bool init_off; + bool *pm_runtime_cleanup; struct regmap_config regmap_config = { .reg_bits = 32, @@ -221,6 +241,11 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev) "failed to attach power domain \"bus\"\n"); } + pm_runtime_cleanup = devm_kcalloc(dev, bc_data->num_domains, + sizeof(*pm_runtime_cleanup), GFP_KERNEL); + if (!pm_runtime_cleanup) + return -ENOMEM; + for (i = 0; i < bc_data->num_domains; i++) { const struct imx8m_blk_ctrl_domain_data *data = &bc_data->domains[i]; struct imx8m_blk_ctrl_domain *domain = &bc->domains[i]; @@ -274,7 +299,8 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev) domain->genpd.power_off = imx8m_blk_ctrl_power_off; domain->bc = bc; - ret = pm_genpd_init(&domain->genpd, NULL, true); + init_off = imx8m_blk_ctrl_is_off(dev, &domain->genpd); + ret = pm_genpd_init(&domain->genpd, NULL, init_off); if (ret) { dev_err_probe(dev, ret, "failed to init power domain \"%s\"\n", @@ -283,6 +309,24 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev) goto cleanup_pds; } + if (!init_off) { + ret = pm_runtime_get_sync(bc->bus_power_dev); + if (ret < 0) { + pm_runtime_put_noidle(bc->bus_power_dev); + dev_err_probe(dev, ret, "failed to power up bus domain\n"); + goto cleanup_pds; + } + + ret = pm_runtime_get_sync(domain->power_dev); + if (ret < 0) { + pm_runtime_put(bc->bus_power_dev); + dev_err_probe(dev, ret, "failed to power up peripheral domain\n"); + goto cleanup_pds; + } + + pm_runtime_cleanup[i] = true; + } + /* * We use runtime PM to trigger power on/off of the upstream GPC * domain, as a strict hierarchical parent/child power domain @@ -324,6 +368,11 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev) of_genpd_del_provider(dev->of_node); cleanup_pds: for (i--; i >= 0; i--) { + if (pm_runtime_cleanup[i]) { + pm_runtime_put(bc->domains[i].power_dev); + pm_runtime_put(bc->bus_power_dev); + } + pm_genpd_remove(&bc->domains[i].genpd); dev_pm_domain_detach(bc->domains[i].power_dev, true); }