Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6015304pxb; Mon, 14 Feb 2022 13:10:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwpigHfQIWuOWlmQnfSTCwgEbCNF1LecTSYlYq7OKGML0XDU2OniDAfw7HE1ylKGBroE6op X-Received: by 2002:a17:902:c409:: with SMTP id k9mr657917plk.91.1644873059378; Mon, 14 Feb 2022 13:10:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644873059; cv=none; d=google.com; s=arc-20160816; b=nSBj04tP7ir64ZFVxlVVGxz1ISnnP9/Cy7alBsuOCRbpVHw/1lNDrnqF1d4nYh9WV6 //9XLek764BPKWhK+GTpctOLF/sUTiMEGe4p8NQOJ4hPoUy/nVuIOsMWr7vp8GkMeOgN bR5Zoc+c6nW1Cf+WCfDuzF89cXVagQRxFswStasVVwJBjC9dAMdYPP7+A0OzVDJ0oRjc pwGSZ/ohWTMUqeBPobx58NsPx5XGwGKaUGVS4G1jekbdL6Q6uevWOWzb3VlJYeOaa1pu Sn8DHTs0/q23DXIFvUFmih00Qa1K/DHWecZ++6xUK6X2jMIypOYU/uTUnKKkKnpLs35s Ho+Q== 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=hNdyRpX3bKmZy1/WgC2wXK/SBB9Um0hxtZzoUT3oe7k=; b=ma1k78C08J/s1GEypuyynP5H+5+MFWmBHPsXvsjb2udJrbzMzwHVKOQrl0F4zOhMgI 5MnFJfOwrsws/6ouTLGzTyG+oRU2TUkhY6xMhF1+WEo9Ai7BRsy/Xm9EvI+UclYzxPZS 2w2SneMZQUI7TTSRYdWwdupD7uc/A1lseXqkE/k2wFxJVzicxpIbODxa/HRDhiBWTP5g gtt3cu9Msw5PrW/GIjILe77VyXAY8192bQatRn5XKqZPKcDKKtkHV/Lgx+bszHMhK9N4 FI/BcQtf4V2QCBPURwaWMKCetMtZfFcOLmpCtfT4liZGdAsn9rr8xBZtfkzD5oKKzwbB C/Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ievNAjv7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f5si3561300plr.290.2022.02.14.13.10.43; Mon, 14 Feb 2022 13:10:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ievNAjv7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230288AbiBNVIF (ORCPT + 99 others); Mon, 14 Feb 2022 16:08:05 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:60148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230391AbiBNVH5 (ORCPT ); Mon, 14 Feb 2022 16:07:57 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB99B119F63 for ; Mon, 14 Feb 2022 13:07:47 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: alyssa) with ESMTPSA id E04281F43F57 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1644870700; bh=CEk0DFXIUz+rib8Ps6KmDjMnwxb8SNNluWUTHums5hQ=; h=From:To:Cc:Subject:Date:From; b=ievNAjv7U7jDN0ChCw4YX7Jv0ZMu5Ut6BbrqUhRy3qDYLAUbYj6zDasWUaIIjgas5 tk4XlVsU7AKz0HOAwgqXkpAqdo+rD5/DrxhSwcvv22hyJAVZmrRSjwrj8cQi2MSxox SEy4WmOboddgpfuXSiOoe58Hfh+qBLnP34hyjH9ZtT+Mor28hjJeVpOFBp/lMjGhMX cIbIvoaPwkBbkBwA8xIWxQbAmB554GaaVSnUyPC/hGyhvSvJZ3vtxoSDcYs/fQrxOw +lGQA+duIA1IpCuxMdJL+XdR+a7h7vxpH/SPqNzhRSS/VNniqaiowOMCl6Zq0TFIkq PeVDBll6CCjOg== From: Alyssa Rosenzweig To: dri-devel@lists.freedesktop.org Cc: Rob Herring , Tomeu Vizoso , Steven Price , Alyssa Rosenzweig , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org, AngeloGioacchino Del Regno Subject: [PATCH] drm/panfrost: Dynamically allocate pm_domains Date: Mon, 14 Feb 2022 15:31:32 -0500 Message-Id: <20220214203132.4722-1-alyssa.rosenzweig@collabora.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY 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 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 Signed-off-by: Alyssa Rosenzweig --- 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