Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6032500pxb; Mon, 14 Feb 2022 13:35:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwC9FeCGRnt70kz/GSzn5H7gkBtXKgeCVlTgtTMpX5LOLc9fSnQGPFPOU+NfhQliPTYh97l X-Received: by 2002:a65:4b82:: with SMTP id t2mr815231pgq.607.1644874548065; Mon, 14 Feb 2022 13:35:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644874548; cv=none; d=google.com; s=arc-20160816; b=aSy2DRJy44GqHq9q189zCOfMcDMXXnsLa0Ea1UyyNLFwHCjfMGv6ovkZpvAHwguWhP HDdqxn8xEYM6kGL+dOY4+HJzSe3g/HecQJptVRB79RrmBxUOC88EZWIO24VGSHLLm+Rj sz16+k/6FaAYfgYl4TQ4LRD0maqJuYmPZruQk5UF7lNssFtynFSWIMd+JTM9bCJepntO AVATujXC4D2Q+6Pv4BaS9TZjK4ur4NfiyfFWGUyXTedMS4KSwh2lkZpyLII9tSf77RyV 6Gf8l0/FWyVkvxQZ76t0rRMbyArx7Uljf5H/GNpyL6Yqna/YTvN8FNRYr/qDQmAc7pA1 COvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=VtSlld4MPAZs4KMJu2RMj30bvWf/dCeoEnPqkasgJKY=; b=ri6dsifN34trNcdeXSuso0OvrDXzANQVqXF4ckRMyPwH4imP0280FaNtNmHIQB/XSB rzE3FFifJTL8RSb5S25PpI9xTGaJVFU3RUrmVZFRkFAj4eGa/8mn3Mmm6HEE+ThoHzpw bZ6tedYizFhNLXT65hHXQw1nvofZwl29RlyhcP2htTKnHg64WdxNONkH4w+RFgBgOnzd X/AEA8DBGi2gy4z3gwvHtk4fN61iHCd7jll6w2UhKX5HKetagAJqg3IliM5GtTHi2UM/ hMap8NGCS5vU1aOhuFR1g1Mtez5oD+EYTm9dKu4X1USe23f8YGokLMAOPNsU04DC6uLZ NgqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=h7bvmDJK; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 184si766087pgc.643.2022.02.14.13.35.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 13:35:48 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=h7bvmDJK; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BDA95D1D6E; Mon, 14 Feb 2022 12:58:39 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229946AbiBNU45 (ORCPT + 99 others); Mon, 14 Feb 2022 15:56:57 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230078AbiBNU4u (ORCPT ); Mon, 14 Feb 2022 15:56:50 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB47E110EEF for ; Mon, 14 Feb 2022 12:56:25 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: alyssa) with ESMTPSA id 0684A1F43F8A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1644872138; bh=FhWthb7qNxu03PTR+1xu680Z2C1ejB/i7ZmEdzpMulc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=h7bvmDJKC/KLr4wErTlMsyAfKeEyGqSN6gQTzua8c952ikB5zzidLyuqZj/TmEacs y0YqIAKrwnY7a2hNH1aCH5UuWsRK3+1SOs/aH/NXsIA7MJy9fDzCmfK+sun84KWgX+ sywl+KZvKaya4FjMpVwt6+yvpC3l68VBJp11/y3VLGMxzojyzM0KR6LDs05abIasap UN1GWUHQpLTOh8bSLc92ByJyQ3ejdBHgFfb3lD8f/sF3BryDEsMrZAVgH7XTQu5TN4 ymmZSQTxVGkaaV0g1kdEbkROA2OYHVmxI92OptcZPPM25ICEcvkcUufskkBr+GBBt4 EP48qKEq6heJw== Date: Mon, 14 Feb 2022 15:55:31 -0500 From: Alyssa Rosenzweig To: Alyssa Rosenzweig Cc: dri-devel@lists.freedesktop.org, Rob Herring , Tomeu Vizoso , Steven Price , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org, AngeloGioacchino Del Regno Subject: Re: [PATCH] drm/panfrost: Dynamically allocate pm_domains Message-ID: References: <20220214203132.4722-1-alyssa.rosenzweig@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220214203132.4722-1-alyssa.rosenzweig@collabora.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=no 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 mali_kbase hardcodes MAX_PM_DOMAINS (=5 for the mt8192 kernel). I have no real objection to it but Angelo did. Maybe should've marked this RFC. On Mon, Feb 14, 2022 at 03:31:32PM -0500, 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); > > 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 >