From patchwork Tue Sep 3 15:31:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3404 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 327363F1F3 for ; Tue, 3 Sep 2024 17:32:04 +0200 (CEST) Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-5334efaf344sf6369573e87.0 for ; Tue, 03 Sep 2024 08:32:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1725377523; cv=pass; d=google.com; s=arc-20240605; b=QDrsNr09zgRgHA4P/N1PPC0JqxS5fm3LHPg9A5chCL1kHjz6tL1gTnYjpNf3bCU3Ur KyXJtN62H+FNqQoxDYkQo3ZTE0E1IzkFcpxxfwhOT7cI+zjeTw590ZZhFpwOSrNlpWC4 cYX5k2Gnzo9Dln5ObkxHKa4f2HbNR1m5jeM0iteF3B+qsIc2Vj+Kha53UN8Nba8ih4eE ShA+vOqlhAK9n0F4/Db+RQbC8nQFpAr4uZna5EyN6oA2NE715EPhNhZtLkx7arr5TWFV JMSd9dQXWZGw3E+mIaIJo5BYL7Lf5e1qTdd0kpRy2ZLRE2knx79UV+4vrZex9wP6EFRe vYbQ== 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:to:from:dkim-signature; bh=flPCFMtcjcKeYt1oy0Qvb1wGMY+4laxck1M6ljgkxWM=; fh=+m6uaNoW6agPDHbtn9RsDr1e1RHAzvYpFK387dPxW54=; b=R+2GIkm7g+qwbL1zkHAPhSe1k1/GvuBYUkWkYfYMoOuXwDeHXbTuQ4+MeL7BUgjdMz IP+lzjFGl0u/uqWg9948rpIALV4ZMhA6VoobFAxdOuNb40X7Yk/7Lb9sGdzCpUzJtAtK Sr09a+02cOyazrrU92nKdWNkFKhkpK7OiEjee0EOCRzU7yvfTOpZ619lKEvtOpvC2pCu d3zt8UDeHgsGse50mwEPyx8vfae+Xmcjkyec+R1r05sqQlQWVvtzADAa4HmZYFCK3j4W BrHUwDXTo7QMdegEhZ7Jkqvz4k7lH8jSr++2groetn3qwsjlSn5yT1EAjU6Qv9Kax+Pe oyIQ==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ol5lgdzZ; 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=1725377523; x=1725982323; 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:to:from:from:to:cc:subject:date:message-id:reply-to; bh=flPCFMtcjcKeYt1oy0Qvb1wGMY+4laxck1M6ljgkxWM=; b=Yt/+cvYGygSnl3qgI6iD4zPbmw43LwcZG57L4jZISzCwRTWLsWHz6Qnato3tZh7YPR 4+nXHPr8+i5sy7NBClSy5VhqwcmYPML81Po23ddDH6WN3DR4fIJO10inw4vY9AjvHkxx W0DLAMIFyPoqIe4bLctSTErm+ZdnuIZxDR7Uc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725377523; x=1725982323; 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:to:from:x-beenthere :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=flPCFMtcjcKeYt1oy0Qvb1wGMY+4laxck1M6ljgkxWM=; b=t0rHIqOMTvtig/UtdWT6x9AHY0RyFo3eGWM1i3hcUvWG3dz13b+6v2sEOCAwze7MQa aNRWSAqO4A7HjI0v5nYlzNCMlmMaBquVravBZAe6Q/eJkNZm9SrgvBuFU6ydimnJdBPl d1JBSOEA3n56gfg/9nnMMj16NJMn2Vlpd0GM+V3433wFo/54W8YMRwydkrGcxPm4lXVc itfdOYXEnDjnwc1o0ROvfVK9Ud0w6eAPBlkCBHS3h3b/zXdmxE88HERCv3UzA4OMQBcd kHxiv2izlR46209oe+/uyqqACtKCDmznX6ppHdHPnW4HFhjPZh3c2K9/6HdQsJpAxtJ4 HOBg== X-Forwarded-Encrypted: i=2; AJvYcCUSh+zNiIcIYWwhb20TZtGsAGI7Gc3ZuNxvp20B94+iv8c+T5hRjzgkMUo5VLHAXGcL1PKU++miueao6PeV@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YweSrnleBGmS8YUkkq0osIQuHRbe+fnAhcL9sMT7kN3RFARomp/ jfSYqG2joC+A2zr0xvpnSfSTnqO1lOc7rnME1cZe6xkYCOYW4eIHkMg/r7yux0Sy8A== X-Google-Smtp-Source: AGHT+IGc9O5pt33M5umA42NKFF44qXTlTO2RukifmFpQ4qhk7JkUfEvtrKaI8bWVdzG4NotKnslnFg== X-Received: by 2002:a05:6512:3984:b0:533:efaf:ab26 with SMTP id 2adb3069b0e04-53546b44d77mr8430451e87.36.1725377523461; Tue, 03 Sep 2024 08:32:03 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6512:3b8f:b0:533:45dc:5477 with SMTP id 2adb3069b0e04-5353d8125adls331433e87.1.-pod-prod-07-eu; Tue, 03 Sep 2024 08:32:02 -0700 (PDT) X-Received: by 2002:a05:6512:e94:b0:533:483f:9563 with SMTP id 2adb3069b0e04-53546b8d711mr8876490e87.45.1725377521769; Tue, 03 Sep 2024 08:32:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725377521; cv=none; d=google.com; s=arc-20160816; b=LO7OUXl2HqLiandnjGKX1ANJVv5ttNDtGJkGMlezNIaQEWICgyaMFKyy8Au/BzdeEs CCvDB+6H15olv/JENpWDwvnRHIOZKKzYbRoozG67+mp/JQe2o/QX73Sl8t62p1dpI7MV GQEtuve01SJ/oyUC1k4wWrgWc3tTmfvg62puFYYlS2+C0noO0occ/CagFxqzpdGQPpN7 5nWwiy9X3TTwvlLcvxBhbnNFuojDCfIMSGsa9JuR1dJr0pdl8uDuiYblWo5jmm1zr667 FW5KGdAOETFZUvQh9OUPQxonsnGPx+fc8677NQE8CxCItKJbRoUeczzhS6QBzTMzMwhd 93+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=u754FsTh92kSCeEwlHoxvBGzK4iDD3LIN1G5Kljo444=; fh=FtQepR0uNoeKT2PVdKfTKOkvEYfwbRmoVE9BmlYw3tk=; b=kAXjeBi2f9P3cY/X97KDW8MS+4QHPuoGwINpTiifGr/2t462NlS43wi979+/EaSxb2 qZyg7E7IcDdpvwJzRyavghw26+3SLS3vB+P4xy6Mbrod/MmFP6iaDXq3rI1qcNyRCEo6 N+MvMgk7HcfrGdTtYdal88tQQql5X0vu9+Nfpg6cZ8R5ter4WVcoT9IDXUhyCO09g0YP scu4AODD4UWQcR6XYUiHiTABbYVaDPQ/R6PxQ1qRnzcZDPpMS4AsBsPtGsBgBOTfw71s 4gSJn8v85vrwJaD/3QN8oAKciAFkv65pUFWUgI3qxmumZccKFezKMzTCbxUDmUMMKcdm nzTw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ol5lgdzZ; 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 2adb3069b0e04-53540849f0asor3358041e87.27.2024.09.03.08.32.01 for (Google Transport Security); Tue, 03 Sep 2024 08:32:01 -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:a05:6512:2810:b0:530:ae0a:ab7a with SMTP id 2adb3069b0e04-53546b0ba94mr8348017e87.17.1725377521007; Tue, 03 Sep 2024 08:32:01 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.42.65]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42baf1b0c18sm192963055e9.37.2024.09.03.08.32.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 08:32:00 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Subject: [PATCH 03/10] pmdomain: imx8m-blk-ctrl: don't turn on a power domain already on Date: Tue, 3 Sep 2024 17:31:50 +0200 Message-ID: <20240903153157.918185-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240903153157.918185-1-dario.binacchi@amarulasolutions.com> References: <20240903153157.918185-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=ol5lgdzZ; 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: Dario Binacchi --- drivers/pmdomain/imx/imx8m-blk-ctrl.c | 49 ++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/drivers/pmdomain/imx/imx8m-blk-ctrl.c b/drivers/pmdomain/imx/imx8m-blk-ctrl.c index ca942d7929c2..83e68e87651c 100644 --- a/drivers/pmdomain/imx/imx8m-blk-ctrl.c +++ b/drivers/pmdomain/imx/imx8m-blk-ctrl.c @@ -166,6 +166,22 @@ 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, *child; + struct imx8m_blk_ctrl_domain *domain = to_imx8m_blk_ctrl_domain(genpd); + const struct imx8m_blk_ctrl_domain_data *data = domain->data; + + for_each_child_of_node(node, child) { + if (!of_node_name_eq(child, data->gpc_name)) + continue; + + return !of_property_read_bool(child, "fsl,boot-on"); + } + + return true; +} + static int imx8m_blk_ctrl_probe(struct platform_device *pdev) { const struct imx8m_blk_ctrl_data *bc_data; @@ -173,6 +189,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 +239,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 +297,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 +307,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 +366,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); }