Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1818649rdb; Mon, 9 Oct 2023 04:11:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsSUjG2M8usE1jSNMe/0DiUX4sBcOP678q9eSMK0yDJ/Y4eyEDdVCgKRHNNQOz/LisiuMW X-Received: by 2002:a05:6a21:7882:b0:160:dacc:8ac with SMTP id bf2-20020a056a21788200b00160dacc08acmr18347082pzc.8.1696849883061; Mon, 09 Oct 2023 04:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696849883; cv=none; d=google.com; s=arc-20160816; b=jlq5RTuQQl6MhQWh8OWq6KhSwf5CeqbhK9t8Q6QiSmIBCGaqV8Ma4krsS6hdGx1HZn x/hbuvdPhFvgcQjMI4F487KcOM/rqoec5teVmrUYW/R/RyG3tmZElOXtHgX8kGdGz3O2 +BzEk9SGtgSt8nT1yvjtRfWS8F3A6tAl0vtKAi6LGh0wQfqTAlgm7yEbqVGfF9huUa5H yFH+5lbQ5jhiDmYEnocHZ+oT97WUiGZAqA0SC2LwPKFr0PUU6yl2rt/2XFLmur92G/pW nidt/84bJMD/OPkPQ9TPJwWmGzrnhzf/nY7esd7vgdURnAkugTkde1dPn6WI/jTd4iBX RuWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=gF3ltA5crJt+JrOf3lwJUGac88GUPpKqmKtpfO96kSo=; fh=dhzQ6f/cpDffcX2GZL3cbRgUV/V7+9FVGBw8VHQBaPY=; b=jBp3w6/oArfsQQDiGTVxzKWdo8BKEPvKR4eZXn9mreHAG/WRsuCvOk3QoZKVV+H3ho G4g18afyROiQBY1Y/m+IVtcL0QMj7vL7DLsz46lhsTRWOiun3DHEnhSF2uIYdjjzU+uU I7bLvYjgq4GsxFN5edwzOTVpw3ljVaNYlgubKnFEEnfn6pAFuAMvwsW53vs65pEgrRgL iwYdOAa2fPDJUBEoI5LU6PJ3/vp4w5J5gLiZjMF2OsQkRH5fDF6FIgU4mlggt2kkw/HK wx87fQ9CkrlpS/1AKuwuL0YGjnTtmnC/FXNml89g1TuwBzuznCzDw4fiPCfI2D0+XoXk 1ArQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ywhUeh3N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id d63-20020a633642000000b0058988dc95d0si7128917pga.557.2023.10.09.04.11.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 04:11:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ywhUeh3N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 539D78097882; Mon, 9 Oct 2023 04:11:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346187AbjJILLC (ORCPT + 99 others); Mon, 9 Oct 2023 07:11:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346171AbjJILLB (ORCPT ); Mon, 9 Oct 2023 07:11:01 -0400 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7E1E94 for ; Mon, 9 Oct 2023 04:10:56 -0700 (PDT) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 399BAZnH029406; Mon, 9 Oct 2023 06:10:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1696849835; bh=gF3ltA5crJt+JrOf3lwJUGac88GUPpKqmKtpfO96kSo=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=ywhUeh3NcbHDhCo4C4TZLyH8RuZ7wfJcPY501IF/1caj3C1SDkrtW2l1Jq8c20zLi HYUJU5LYd7U2szDazrrzKPB5KZzV5OUT59NapIbhLHO4+n7H51gSTCASO78BIxt/cT NFkM9su9hYmh0KwXXnqgGzC9JKreG8nLAfPZL1Wc= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 399BAZJC006911 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Oct 2023 06:10:35 -0500 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 9 Oct 2023 06:10:34 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 9 Oct 2023 06:10:34 -0500 Received: from [172.24.227.6] (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 399BASAh024013; Mon, 9 Oct 2023 06:10:29 -0500 Message-ID: <3c6e6538-bce6-e9f0-4307-72b3ffe6030e@ti.com> Date: Mon, 9 Oct 2023 16:40:28 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] drm/tidss: Power up attached PM domains on probe Content-Language: en-US To: Maxime Ripard CC: , , , , , , , , , , , , , , References: <20231009075018.2836020-1-devarsht@ti.com> From: Devarsh Thakkar In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 09 Oct 2023 04:11:07 -0700 (PDT) Hi Maxime, Thanks for the review. On 09/10/23 14:53, Maxime Ripard wrote: > Hi Devarsh, > > On Mon, Oct 09, 2023 at 01:20:18PM +0530, Devarsh Thakkar wrote: >> Some SoC's such as AM62P have dedicated power domains >> for OLDI which need to be powered on separetely along >> with display controller. >> >> So during driver probe, power up all attached PM domains >> enumerated in devicetree node for DSS. >> >> This also prepares base to add display support for AM62P. >> >> Signed-off-by: Devarsh Thakkar >> --- >> drivers/gpu/drm/tidss/tidss_drv.c | 76 +++++++++++++++++++++++++++++++ >> drivers/gpu/drm/tidss/tidss_drv.h | 5 ++ >> 2 files changed, 81 insertions(+) >> >> diff --git a/drivers/gpu/drm/tidss/tidss_drv.c b/drivers/gpu/drm/tidss/tidss_drv.c >> index 4d063eb9cd0b..a703a27d17bf 100644 >> --- a/drivers/gpu/drm/tidss/tidss_drv.c >> +++ b/drivers/gpu/drm/tidss/tidss_drv.c >> @@ -8,6 +8,7 @@ >> #include >> #include >> #include >> +#include >> >> #include >> #include >> @@ -114,6 +115,72 @@ static const struct drm_driver tidss_driver = { >> .minor = 0, >> }; >> >> +static int tidss_detach_pm_domains(struct tidss_device *tidss) >> +{ >> + int i; >> + >> + if (tidss->num_domains <= 1) >> + return 0; >> + >> + for (i = 0; i < tidss->num_domains; i++) { >> + if (tidss->pd_link[i] && !IS_ERR(tidss->pd_link[i])) >> + device_link_del(tidss->pd_link[i]); >> + if (tidss->pd_dev[i] && !IS_ERR(tidss->pd_dev[i])) >> + dev_pm_domain_detach(tidss->pd_dev[i], true); >> + tidss->pd_dev[i] = NULL; >> + tidss->pd_link[i] = NULL; >> + } >> + >> + return 0; >> +} >> + >> +static int tidss_attach_pm_domains(struct tidss_device *tidss) >> +{ >> + struct device *dev = tidss->dev; >> + int i; >> + int ret; >> + struct platform_device *pdev = to_platform_device(dev); >> + struct device_node *np = pdev->dev.of_node; >> + >> + tidss->num_domains = of_count_phandle_with_args(np, "power-domains", >> + "#power-domain-cells"); >> + if (tidss->num_domains <= 1) { >> + dev_dbg(dev, "One or less power domains, no need to do attach domains\n"); >> + return 0; >> + } >> + >> + tidss->pd_dev = devm_kmalloc_array(dev, tidss->num_domains, >> + sizeof(*tidss->pd_dev), GFP_KERNEL); >> + if (!tidss->pd_dev) >> + return -ENOMEM; >> + >> + tidss->pd_link = devm_kmalloc_array(dev, tidss->num_domains, >> + sizeof(*tidss->pd_link), GFP_KERNEL); >> + if (!tidss->pd_link) >> + return -ENOMEM; >> + >> + for (i = 0; i < tidss->num_domains; i++) { >> + tidss->pd_dev[i] = dev_pm_domain_attach_by_id(dev, i); >> + if (IS_ERR(tidss->pd_dev[i])) { >> + ret = PTR_ERR(tidss->pd_dev[i]); >> + goto fail; >> + } >> + >> + tidss->pd_link[i] = device_link_add(dev, tidss->pd_dev[i], >> + DL_FLAG_STATELESS | >> + DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); >> + if (!tidss->pd_link[i]) { >> + ret = -EINVAL; >> + goto fail; >> + } >> + } >> + >> + return 0; >> +fail: >> + tidss_detach_pm_domains(tidss); >> + return ret; >> +} > > My understanding is that this will be done automatically at probe time. > Why do we need to roll our own there? A comment on top of the function > and the commit log would help. By default, the TI SCI power domain controller driver only powers up one power domain associated with device, With AM62P, we now have separate power domains for OLDI Tx ports (for more efficient power-saving control) which is different from core DSS device power domain, so this patch powers on the associated power domains too if enumerated in device-tree. Regards Devarsh > > Thanks! > Maxime