From patchwork Wed Sep 11 15:15:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3460 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 18E6E3F263 for ; Wed, 11 Sep 2024 17:16:02 +0200 (CEST) Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-378929f1a4esf2251501f8f.1 for ; Wed, 11 Sep 2024 08:16:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1726067761; cv=pass; d=google.com; s=arc-20240605; b=LBaONOhFuDdWrEBUqo/WKEDz0q/eqaXlUcHr2MTgFxFPz5iA42mV5y/ZkDUy8EWsHQ +BeY0ZbRDRqDLqruYOJQOVipKgocUmCjonspWLbHohld5Bd1vwwWgoElE9btqDLY5gvX 3dd4E1SkrZHz2qpZB/UDAlL/hr5vagG8V9HOpG6r0+EsRpg5gLqen3Plu0FAq34KR2BZ tkVBszTwvEH13dSz3hKZY6Mw/E+LuYFoJZx+sPdEXV4eL4imrLYFFz5HRnqwWpMf76No ZrkBbdMPUE5DSysFk+pvZfrdpyKlsjqZ01XSk/fj14sBVHmqP4xQUdRqH518HoliqZJV SlBg== 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=v3gLhJtUOk62CdfD847q29XvrMZT36g0k4AzVYXq/as=; b=AwQ4OlmK0GTVCJmzZlHSe+KFcZyMjq/f+bZeJccDGKmzclrG3PHKRAGDcGmC1ls5/d 99DuXKlr5GdarbQRqv6g/KV1Q3uuOpba2oQosoX5ZFHi7W+yYX2mPo1IRjKGSRn9lVwS RaVakDpZKAdGGzkPFJlNUrhKuGStxx1pwv9tbHZD/0HinS5FKFOvvfLNFajNSgVHuyMu NaafNIGIVme3F/hAFFbyJw8FBQUJFnRtBSYC/jtpgjZgXfJU5OQ3oRXS5w1+wST65GVR n7w1B9AA5uBw3pGnjHGuta6M3O2lBMBIOmjlYHcwTe2UtjrH8zd6PxYuMotfu3iXxft2 P+zw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=iAFXbEZ1; 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=1726067761; x=1726672561; 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=IgUz5ojmYjNts+1r2dBem8kwN+4wpkpT1PHcZd4+BQN9F4mQERztcMpGABcB4YzByW nHkoD6tQ7kS6IRrUqGQGjgcNXgy8ZikT5rvb5UmwHXz+TgSCYjtuVXjK9ZfcGzU0sXZW 1Z86ScXPwblFCol/ETUKietghS3ptj2m/w7lg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726067761; x=1726672561; 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=Qk93euiuVld25pgn1/BkSgycTploVU9pVPDR0SOonGilXVd/2QasuRK5g9hXJlcEwf 4nW6MKu0fpoCcQugMg2CYoJgQmXBsHFoKKsO2yvJBbRoLiflpbbCdJgSZcx59fDxr228 JwoBlG9B20KerVoxGp91HhUobzLE2EKmmGQZjvpaPvu8Mtu39QtEJXWePYXPWW06bDyf UtUhA8Ej/A1oRSU5Oo/ST5pjdl0HGGIDLqBxZ7fTe6xM/h1q2+ME068S4yXF6dgapLpN v/c99kEHTWPrbcvrOndafhiQHuTuzt1ed379tx/qzhKtoBJhOXA8vYzGKX8/mV4m1byM cCfw== X-Forwarded-Encrypted: i=2; AJvYcCW93h6r4Gr3cazmvhQzFzyNk5tUUCWU61Iasl96xheAq/zGawd0natUKxrb64iHT2qJPWogFQJsGA57KGz/@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YySmmGW+ABw7NyMwWAJtqhBIM0Eh+u9+t+Ysj29zPRQC4i76alJ u59dCMfhvsxpNSgmMwzbakif/6VE5Yyd3R7DGg0GVgJ0qhzCvQG8BG2rTwFJ/4+46w== X-Google-Smtp-Source: AGHT+IGnzZ1Wve5LcNIQlZrKwVXAh9EwAuT+hw6yELM3abKwOo3OMZwivyodg3U5CdUiEB09nbdjLA== X-Received: by 2002:a5d:6942:0:b0:368:420e:b790 with SMTP id ffacd0b85a97d-378895ca946mr11041713f8f.14.1726067761601; Wed, 11 Sep 2024 08:16:01 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:46c5:b0:42c:ad31:3854 with SMTP id 5b1f17b1804b1-42cdb394087ls12055e9.0.-pod-prod-09-eu; Wed, 11 Sep 2024 08:16:00 -0700 (PDT) X-Received: by 2002:a05:600c:5102:b0:42c:bbd5:af60 with SMTP id 5b1f17b1804b1-42cbbd5b298mr71463825e9.24.1726067760013; Wed, 11 Sep 2024 08:16:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726067759; cv=none; d=google.com; s=arc-20160816; b=pHx2zLSycFjIFtFT+YVUpvtenBvF7PnxANY1WayK2Hy5UKf2DrQ6ac5BQstnATbjgi eTLkkylQ0AgZRz29NhsRN4dP2XGwGsvG00NV/lXqGar/NCQmDmF4jOfk+CMF8kPt1CNt RlnmJ28YKijZiBq/+i0B+qfBGSgHL1lWEDG189EIHKX6S6MejgJKybhRROJNdRHQASYe R1A2uK3IDKCEkHmlbM2ImSdQTo+3z/QhKLWx3vmraR/ZmyLVrGo7sxGHf+oxmw1f7WOi gA51RvaAIyc417p+YivUV2wUUQ+5rMhjpCx2FOVKMVgcD24UW84gDI7eSqGYbKjEkL2/ rTRg== 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=LQ6hq1lNwXjnPGX4XxNjaP3Gq+1EwnKoZgUZ67SplEBR318DOCY/QpIsSo2tEa+J6o 8u/yfYEPZCMH7WofLB25yejM0xbRWnWdbcG0u2IH/BGnHQmwxiVDQYMbR0uABUsqbjg5 DqvMfc6ksGmuWk7s2WJdGZFzH05yo3MZ8S8oxFH6nq2/rzcse8N8kKSgf7yPOwE1+zOu 007u6fT1dGqFOlWEnpmCMSFjJZuLDNq3RdJ/b4YsZP+hZXTj8dEFn/OD3EkyW6itPTbX r6Hue7tPF/2T8ojTqpylOXsLSaXW82YRlzThKBizLujCA0XI8WmrIfSJ+TRD3ioh/mfc 1oaA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=iAFXbEZ1; 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 5b1f17b1804b1-42caf2b2772sor20946815e9.5.2024.09.11.08.15.59 for (Google Transport Security); Wed, 11 Sep 2024 08:15:59 -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:600c:1d8a:b0:42c:b0f9:9b28 with SMTP id 5b1f17b1804b1-42cb0f99c0amr107429265e9.28.1726067759339; Wed, 11 Sep 2024 08:15:59 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.41.3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378956d37a1sm11797177f8f.77.2024.09.11.08.15.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 08:15:59 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Subject: [PATCH v2 03/10] pmdomain: imx8m-blk-ctrl: don't turn on a power domain already on Date: Wed, 11 Sep 2024 17:15:48 +0200 Message-ID: <20240911151555.2915258-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240911151555.2915258-1-dario.binacchi@amarulasolutions.com> References: <20240911151555.2915258-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=iAFXbEZ1; 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); }