Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp39471pxb; Tue, 15 Feb 2022 05:12:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJydUbcG+qbe9ARcZpeLkuyf+D7TVnL+WVNElmrxTy+kqFIcfJbhed5yQGmAKD4SkofiKAyk X-Received: by 2002:a17:907:7674:: with SMTP id kk20mr2920048ejc.352.1644930730877; Tue, 15 Feb 2022 05:12:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644930730; cv=none; d=google.com; s=arc-20160816; b=OZGnyrPE1Vnwiil+E16oKvxgSWYn4rN8XImlk6CayfW6CUqB/gX7AwKHRBJSJzReXk y68s/K1o+MSgLhfaBs6B36A1e7F6cCOeHcfmiaWxzc3lN1JoYfWQZqcWQHhU8emEFtwM cWB2ngZU5KEKUmtCRX0LlTJ5U4sDoBQFnEhpWpX0+C2E2cjCEp32bQco9Dwksc4oY3U4 2nI1f5hEFkE9Cgo3NRF0P+eHkcfwneCYx3NSbsTUivLH9sd4qQp4B0XwyZbwnmXJMehb aEZEauuZm/uazkS2T6fVKjOEBJY/7EFdDc0p0TCcDMiW1Wa6RUDyFUUKdrSgkD+7xfiX BjdA== 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; bh=ZujhwwK15fogmMPbRDsiJaUjB6yzBQIJHioounFfL6Q=; b=EuvneVDKuMdLtdGqDOXgEURsLOsvyYe0oLHfCxoVTh4pKSy57ZcBZJSM2+19TxsBT6 QaiJXDHuXQ6oCzW9F15m+xaYhDZ5kBDQRjUWxJGA20KCavzKwrkrrQgfBLza+10evYlc oPvTp4pO7WURIT3Ch3ym3rXiJGY3s1j4oDWnew72V4R7pfF9t2TuOx2yAcjjoC2FXBJl OqxU+MCK3Q1Rt314prnYJO6hbhxEryuk5h+BrtsnuERwWliNcfN8NljERQP72pU2ldln P7V8eaaxAWlwVjja4kWjdaGIsGJtKDdTEy3FmEV74JDP1BK3Aw3n4jwvNoJFumN9CDs2 gFXQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eo14si2868983edb.344.2022.02.15.05.11.23; Tue, 15 Feb 2022 05:12:10 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237501AbiBOMJh (ORCPT + 99 others); Tue, 15 Feb 2022 07:09:37 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:60734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237486AbiBOMJd (ORCPT ); Tue, 15 Feb 2022 07:09:33 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 60D6EEF0B0 for ; Tue, 15 Feb 2022 04:09:22 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D0A9B1480; Tue, 15 Feb 2022 04:09:21 -0800 (PST) Received: from [10.57.70.89] (unknown [10.57.70.89]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AFF733F718; Tue, 15 Feb 2022 04:09:20 -0800 (PST) Message-ID: Date: Tue, 15 Feb 2022 12:09:16 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 Subject: Re: [PATCH] drm/panfrost: Dynamically allocate pm_domains Content-Language: en-GB To: Alyssa Rosenzweig , dri-devel@lists.freedesktop.org Cc: Tomeu Vizoso , David Airlie , linux-kernel@vger.kernel.org, Steven Price , AngeloGioacchino Del Regno References: <20220214203132.4722-1-alyssa.rosenzweig@collabora.com> From: Robin Murphy In-Reply-To: <20220214203132.4722-1-alyssa.rosenzweig@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On 2022-02-14 20:31, Alyssa Rosenzweig wrote: > 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); Since we're not really doing any detailed management of our device links, could we get away with using AUTOREMOVE_CONSUMER instead of STATELESS to avoid having to explicitly keep track of them ourselves? Robin. > > 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;