Message ID | 20231009075018.2836020-1-devarsht@ti.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1708472vqo; Mon, 9 Oct 2023 00:51:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPGzwQuKRie0wajFRb5U9oynk4q3E2nU6WQZm9Y5RaTOxnJVJ5NLHDicswwSOyTXT1ecHW X-Received: by 2002:a05:6a21:789a:b0:14e:6c19:60f6 with SMTP id bf26-20020a056a21789a00b0014e6c1960f6mr14980971pzc.50.1696837898447; Mon, 09 Oct 2023 00:51:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696837898; cv=none; d=google.com; s=arc-20160816; b=W8WVX6fZxKHLBoMSj+fVwneIkPkjouJav/MZNvfJPWjINuqwXPoAuS4+JRscUfIf5u gwsH+fM4YurXgoARHOC0ANG2l9sTjNajDSLeCcuKEoMFksWLNnu/Ht2VelmCPcIHEJYC DK7zXtItkK9rRDPfLsTSoJId5pCX2cpsiCbKyEU5kDXXJxia8mkiOCopFXHL6e5YRdIX fj5pfTGbWjz8uB4nM82QgYYN2+7wFHWY5dhTjeUFlvF6vEkQvF986PuAQuY+YnRoBM+P OT9PpW30HCLihcpdO6kK3VCMwlg/7arWkR0wSfXx/jnZiD1s6IRezb6+HJHIUcc5jRn0 3yXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=hMhNhiQXIqGgkhXjrKdWywjOqrAnsFm8Fb6SqEbSumo=; fh=39zwI4Kcfm7CC6FRPRnJMzgleizEtK3o1oVp5N6zpAU=; b=cwiLq9z/jjsFlt+Nko6aFVtzE/j4VHOFplVisfm2M9j3Wc+pEWpCZNcUv08u1rKa1Y YssdaS0NVsgJNkPDFDLPFsLi+SrcQaRVPQ3ubABa3Zk0bI46nmpi+Xceu52TLMEYcizu CnoSoWExjfpdSyX7BpooRHcZ6ePd2Zt/l0fra9SrYoQN1USD28ozfMdhnplccyuy8L3D g5CQhuVmpV4SUZKDLrmRgW3e0+Oa06I6NpFiZiLWRClVGsG4SYwMH7hCNnjZ2M9jAmfT MhlwZEAaWfBFRHILcd2MWWPIT7Yu6VE8U6YQpPXW5h4CJN2tcMDSADwl9+Ld6Ei848IP BtaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=V+zpjydL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id lm5-20020a170903298500b001c20db2510asi9124242plb.53.2023.10.09.00.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 00:51:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=V+zpjydL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 9547E8089867; Mon, 9 Oct 2023 00:51:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345420AbjJIHux (ORCPT <rfc822;ezelljr.billy@gmail.com> + 18 others); Mon, 9 Oct 2023 03:50:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232666AbjJIHuv (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 9 Oct 2023 03:50:51 -0400 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8193794 for <linux-kernel@vger.kernel.org>; Mon, 9 Oct 2023 00:50:49 -0700 (PDT) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3997oKU9105316; Mon, 9 Oct 2023 02:50:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1696837820; bh=hMhNhiQXIqGgkhXjrKdWywjOqrAnsFm8Fb6SqEbSumo=; h=From:To:CC:Subject:Date; b=V+zpjydLJUEB+8gWr7uWNdNyjZzRIHxJSsvsVC9v4efGhsveFmQUXxtwcXdkPlJRq J8bwQfROhUEb75G3JUhRt0BRLeRlKKITrTahD5XBRj+SRUAfLX6Koi7zzfdlja8yOc /GBvgbdAcVS7DPUB26GdTeq1pnNoh9UgXKckJ8ec= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 3997oKqa093936 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Oct 2023 02:50:20 -0500 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE113.ent.ti.com (157.170.170.24) 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 02:50:20 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE115.ent.ti.com (157.170.170.26) 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 02:50:20 -0500 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 3997oJ5K031125; Mon, 9 Oct 2023 02:50:19 -0500 From: Devarsh Thakkar <devarsht@ti.com> To: <jyri.sarha@iki.fi>, <tomi.valkeinen@ideasonboard.com>, <airlied@gmail.com>, <daniel@ffwll.ch>, <maarten.lankhorst@linux.intel.com>, <mripard@kernel.org>, <tzimmermann@suse.de>, <dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org> CC: <praneeth@ti.com>, <nm@ti.com>, <vigneshr@ti.com>, <a-bhatia1@ti.com>, <j-luthra@ti.com>, <r-ravikumar@ti.com>, <j-choudhary@ti.com>, <devarsht@ti.com> Subject: [PATCH] drm/tidss: Power up attached PM domains on probe Date: Mon, 9 Oct 2023 13:20:18 +0530 Message-ID: <20231009075018.2836020-1-devarsht@ti.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 09 Oct 2023 00:51:10 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779263496480438862 X-GMAIL-MSGID: 1779263496480438862 |
Series |
drm/tidss: Power up attached PM domains on probe
|
|
Commit Message
Devarsh Thakkar
Oct. 9, 2023, 7:50 a.m. UTC
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 <devarsht@ti.com>
---
drivers/gpu/drm/tidss/tidss_drv.c | 76 +++++++++++++++++++++++++++++++
drivers/gpu/drm/tidss/tidss_drv.h | 5 ++
2 files changed, 81 insertions(+)
Comments
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 <devarsht@ti.com> > --- > 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 <linux/of.h> > #include <linux/module.h> > #include <linux/pm_runtime.h> > +#include <linux/pm_domain.h> > > #include <drm/drm_atomic.h> > #include <drm/drm_atomic_helper.h> > @@ -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. Thanks! Maxime
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 <devarsht@ti.com> >> --- >> 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 <linux/of.h> >> #include <linux/module.h> >> #include <linux/pm_runtime.h> >> +#include <linux/pm_domain.h> >> >> #include <drm/drm_atomic.h> >> #include <drm/drm_atomic_helper.h> >> @@ -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
Hi Maxime, On 09/10/23 16:40, Devarsh Thakkar wrote: > 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 <devarsht@ti.com> >>> --- >>> 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 <linux/of.h> >>> #include <linux/module.h> >>> #include <linux/pm_runtime.h> >>> +#include <linux/pm_domain.h> >>> >>> #include <drm/drm_atomic.h> >>> #include <drm/drm_atomic_helper.h> >>> @@ -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. > My bad, I think it is not the ti sci power domain controller driver but the kernel core itself which seems to have a check to only allow one power domain per device (thanks to Vignesh for pointing out) : /* * Devices with multiple PM domains must be attached separately, * as we can only attach one PM domain per device. */ if (of_count_phandle_with_args(dev->of_node, "power-domains", "#power-domain-cells") != 1) return 0; https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/base/power/domain.c?h=next-20231012#n2828 But anyways, I talked to team internally and there are some plans to have separate OLDI bridge driver which would inherit these new power domains, so I guess we may not need this patch at all. Regards Devarsh > Regards > Devarsh > >> >> Thanks! >> Maxime
On 09/10/23 13:20, 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. > NAK, for this patch, as discussed with team there are already plans to have separate OLDI bridge driver which should eventually handle the additional power domains. Sorry for the noise. Regards Devarsh > Signed-off-by: Devarsh Thakkar <devarsht@ti.com> > --- > 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 <linux/of.h> > #include <linux/module.h> > #include <linux/pm_runtime.h> > +#include <linux/pm_domain.h> > > #include <drm/drm_atomic.h> > #include <drm/drm_atomic_helper.h> > @@ -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; > +} > + > static int tidss_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -136,6 +203,13 @@ static int tidss_probe(struct platform_device *pdev) > > platform_set_drvdata(pdev, tidss); > > + /* powering up associated OLDI domains */ > + ret = tidss_attach_pm_domains(tidss); > + if (ret < 0) { > + dev_err(dev, "failed to attach power domains %d\n", ret); > + return ret; > + } > + > ret = dispc_init(tidss); > if (ret) { > dev_err(dev, "failed to initialize dispc: %d\n", ret); > @@ -193,6 +267,7 @@ static int tidss_probe(struct platform_device *pdev) > dispc_runtime_suspend(tidss->dispc); > #endif > pm_runtime_disable(dev); > + tidss_detach_pm_domains(tidss); > > return ret; > } > @@ -220,6 +295,7 @@ static void tidss_remove(struct platform_device *pdev) > /* devm allocated dispc goes away with the dev so mark it NULL */ > dispc_remove(tidss); > > + tidss_detach_pm_domains(tidss); > dev_dbg(dev, "%s done\n", __func__); > } > > diff --git a/drivers/gpu/drm/tidss/tidss_drv.h b/drivers/gpu/drm/tidss/tidss_drv.h > index d7f27b0b0315..3c8b37b3aba6 100644 > --- a/drivers/gpu/drm/tidss/tidss_drv.h > +++ b/drivers/gpu/drm/tidss/tidss_drv.h > @@ -31,6 +31,11 @@ struct tidss_device { > > spinlock_t wait_lock; /* protects the irq masks */ > dispc_irq_t irq_mask; /* enabled irqs in addition to wait_list */ > + > + int num_domains; /* Handle attached PM domains */ > + struct device **pd_dev; > + struct device_link **pd_link; > + > }; > > #define to_tidss(__dev) container_of(__dev, struct tidss_device, ddev)
Hi, On Thu, Oct 12, 2023 at 05:10:06PM +0530, Devarsh Thakkar wrote: > On 09/10/23 13:20, 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. > > > > NAK, for this patch, as discussed with team there are already plans > to have separate OLDI bridge driver which should eventually handle > the additional power domains. Just for the record in case your current plan doesn't work out and we need to revisit this patch: my point was that it's something that deviates by a margin from what drivers are usually expected to do, so we should document why that deviation is there. The patch itself looks reasonable to me otherwise. Maxime
Hi Maxime, On 12/10/23 18:10, Maxime Ripard wrote: > Hi, > > On Thu, Oct 12, 2023 at 05:10:06PM +0530, Devarsh Thakkar wrote: >> On 09/10/23 13:20, 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. >>> >> >> NAK, for this patch, as discussed with team there are already plans >> to have separate OLDI bridge driver which should eventually handle >> the additional power domains. > > Just for the record in case your current plan doesn't work out and we > need to revisit this patch: my point was that it's something that > deviates by a margin from what drivers are usually expected to do, so we > should document why that deviation is there. > Sure, thanks for suggesting, I agree that if going with this logic, we should definitely put a comment in driver regarding same. > The patch itself looks reasonable to me otherwise. Yes, it's just that we are planning a separate driver for OLDI. We will see if we need similar logic in that driver too. Regards Devarsh > > Maxime
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 <linux/of.h> #include <linux/module.h> #include <linux/pm_runtime.h> +#include <linux/pm_domain.h> #include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> @@ -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; +} + static int tidss_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -136,6 +203,13 @@ static int tidss_probe(struct platform_device *pdev) platform_set_drvdata(pdev, tidss); + /* powering up associated OLDI domains */ + ret = tidss_attach_pm_domains(tidss); + if (ret < 0) { + dev_err(dev, "failed to attach power domains %d\n", ret); + return ret; + } + ret = dispc_init(tidss); if (ret) { dev_err(dev, "failed to initialize dispc: %d\n", ret); @@ -193,6 +267,7 @@ static int tidss_probe(struct platform_device *pdev) dispc_runtime_suspend(tidss->dispc); #endif pm_runtime_disable(dev); + tidss_detach_pm_domains(tidss); return ret; } @@ -220,6 +295,7 @@ static void tidss_remove(struct platform_device *pdev) /* devm allocated dispc goes away with the dev so mark it NULL */ dispc_remove(tidss); + tidss_detach_pm_domains(tidss); dev_dbg(dev, "%s done\n", __func__); } diff --git a/drivers/gpu/drm/tidss/tidss_drv.h b/drivers/gpu/drm/tidss/tidss_drv.h index d7f27b0b0315..3c8b37b3aba6 100644 --- a/drivers/gpu/drm/tidss/tidss_drv.h +++ b/drivers/gpu/drm/tidss/tidss_drv.h @@ -31,6 +31,11 @@ struct tidss_device { spinlock_t wait_lock; /* protects the irq masks */ dispc_irq_t irq_mask; /* enabled irqs in addition to wait_list */ + + int num_domains; /* Handle attached PM domains */ + struct device **pd_dev; + struct device_link **pd_link; + }; #define to_tidss(__dev) container_of(__dev, struct tidss_device, ddev)