linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
To: dri-devel@lists.freedesktop.org
Cc: Rob Herring <robh@kernel.org>,
	Tomeu Vizoso <tomeu.vizoso@collabora.com>,
	Steven Price <steven.price@arm.com>,
	Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>,
	David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	linux-kernel@vger.kernel.org,
	AngeloGioacchino Del Regno 
	<angelogioacchino.delregno@collabora.com>
Subject: [PATCH] drm/panfrost: Dynamically allocate pm_domains
Date: Mon, 14 Feb 2022 15:31:32 -0500	[thread overview]
Message-ID: <20220214203132.4722-1-alyssa.rosenzweig@collabora.com> (raw)

MT8192 requires 5 power domains. Rather than bump MAX_PM_DOMAINS and
waste memory on every supported Panfrost chip, instead dynamically
allocate pm_domain_devs and pm_domain_links. This adds some flexibility;
it seems inevitable a new MediaTek device will require more than 5
domains.

On non-MediaTek devices, this saves a small amount of memory.

Suggested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
---
 drivers/gpu/drm/panfrost/panfrost_device.c | 14 ++++++++++----
 drivers/gpu/drm/panfrost/panfrost_device.h |  5 ++---
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c
index ee612303f076..661cdec320af 100644
--- a/drivers/gpu/drm/panfrost/panfrost_device.c
+++ b/drivers/gpu/drm/panfrost/panfrost_device.c
@@ -127,7 +127,10 @@ static void panfrost_pm_domain_fini(struct panfrost_device *pfdev)
 {
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(pfdev->pm_domain_devs); i++) {
+	if (!pfdev->pm_domain_devs || !pfdev->pm_domain_links)
+		return;
+
+	for (i = 0; i < pfdev->comp->num_pm_domains; i++) {
 		if (!pfdev->pm_domain_devs[i])
 			break;
 
@@ -161,9 +164,12 @@ static int panfrost_pm_domain_init(struct panfrost_device *pfdev)
 		return -EINVAL;
 	}
 
-	if (WARN(num_domains > ARRAY_SIZE(pfdev->pm_domain_devs),
-			"Too many supplies in compatible structure.\n"))
-		return -EINVAL;
+	pfdev->pm_domain_devs = devm_kcalloc(pfdev->dev, num_domains,
+					     sizeof(*pfdev->pm_domain_devs),
+					     GFP_KERNEL);
+	pfdev->pm_domain_links = devm_kcalloc(pfdev->dev, num_domains,
+					      sizeof(*pfdev->pm_domain_links),
+					      GFP_KERNEL);
 
 	for (i = 0; i < num_domains; i++) {
 		pfdev->pm_domain_devs[i] =
diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h
index 8b25278f34c8..98e3039696f9 100644
--- a/drivers/gpu/drm/panfrost/panfrost_device.h
+++ b/drivers/gpu/drm/panfrost/panfrost_device.h
@@ -22,7 +22,6 @@ struct panfrost_job;
 struct panfrost_perfcnt;
 
 #define NUM_JOB_SLOTS 3
-#define MAX_PM_DOMAINS 3
 
 struct panfrost_features {
 	u16 id;
@@ -87,8 +86,8 @@ struct panfrost_device {
 	struct regulator_bulk_data *regulators;
 	struct reset_control *rstc;
 	/* pm_domains for devices with more than one. */
-	struct device *pm_domain_devs[MAX_PM_DOMAINS];
-	struct device_link *pm_domain_links[MAX_PM_DOMAINS];
+	struct device **pm_domain_devs;
+	struct device_link **pm_domain_links;
 	bool coherent;
 
 	struct panfrost_features features;
-- 
2.34.1


             reply	other threads:[~2022-02-14 21:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-14 20:31 Alyssa Rosenzweig [this message]
2022-02-14 20:55 ` [PATCH] drm/panfrost: Dynamically allocate pm_domains Alyssa Rosenzweig
2022-02-15  9:23   ` AngeloGioacchino Del Regno
2022-02-15 12:09 ` Robin Murphy
2022-02-15 21:53 ` Rob Herring
2022-02-15 22:32   ` Alyssa Rosenzweig
2022-02-16  9:01     ` AngeloGioacchino Del Regno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220214203132.4722-1-alyssa.rosenzweig@collabora.com \
    --to=alyssa.rosenzweig@collabora.com \
    --cc=airlied@linux.ie \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=steven.price@arm.com \
    --cc=tomeu.vizoso@collabora.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).