Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2259208imw; Wed, 6 Jul 2022 02:53:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uWfOpuMSFnVkGz0qllBf3N9sfO/dG8glUK6sp7bimneo8YtJWU+5D5VkirsSOJN38htVXD X-Received: by 2002:a17:90b:3596:b0:1ef:76fb:d8b7 with SMTP id mm22-20020a17090b359600b001ef76fbd8b7mr26776265pjb.109.1657101212161; Wed, 06 Jul 2022 02:53:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657101212; cv=none; d=google.com; s=arc-20160816; b=Y7Oeod4o9m+sVhd6M6/fqaMVGaxmq51+K2DwUabmq6sodfOKf86klGZeGjzPUieA8t XDT7jcr9EUgBF3ph21FCFIPeiEBTVW+PkZwGeJ6LG0fSPTz9UA1N/Ef9D62Ttl6tDOyt tGnB9G7w6rQ4tnVEpyFJPkl70K2hQvdHMKEhigAHxdHdX0JUyv+Pn5cQR0i6LmhLj+nG b2RIA2LIUJ1TTatyJVIRKsqCVFs4i+rSY2LEsiGj9akA+S/6EmbnSZB2PNOY1Y+kYLGl rVz4JmLmWbdcXxQkvlmhg9QXXIGSPMDvjx0cwamcIaroOSctEULMPAXcG+7+v7cle1xD X3Iw== 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=Uws7ZBBTv1acYBJZ6w2kSLSiJ9SPBwS66raiWd4kIqM=; b=xRE+tB0icIYYREjlKI7rUDavRCX7g65e42BUy8pZA/jrrTgxuCFGEKlUchb8gxiwGD ce2bcQZqMkH7tVldYmgdJKImKRQv7k5aUonmlJlnZ11F7sHLFiioqZgIZhF1q5LbAXAd PMW6yXV27xf8qCR4hUm8+aFQaaCOPQpNcINkoN2pnM1xyP21XU7Dk5uavwnB14FVRJEC 9et5hFedG1eNc1MW8SRBk3CFu8LkkrRmV/wJegMjyMkwc68g4in/TACleo2DsjCJs5Tj AInOQbKG7DmkLKcpu7NwH/O8+5rrexxAdstjyALAIVgknuF/y0F0kSnkehCj2bSYnDPP VIBA== 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 t8-20020a656088000000b0040d28f1a116si19754468pgu.328.2022.07.06.02.53.19; Wed, 06 Jul 2022 02:53:32 -0700 (PDT) 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 S230481AbiGFJue (ORCPT + 99 others); Wed, 6 Jul 2022 05:50:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229558AbiGFJub (ORCPT ); Wed, 6 Jul 2022 05:50:31 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 249561580C; Wed, 6 Jul 2022 02:50:30 -0700 (PDT) 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 3259A1042; Wed, 6 Jul 2022 02:50:30 -0700 (PDT) Received: from [10.57.42.44] (unknown [10.57.42.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9DB933F66F; Wed, 6 Jul 2022 02:50:25 -0700 (PDT) Message-ID: Date: Wed, 6 Jul 2022 10:50:23 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH V3.1 02/20] OPP: Make dev_pm_opp_set_regulators() accept NULL terminated list Content-Language: en-GB To: Viresh Kumar , "Rafael J. Wysocki" , Chanwoo Choi , MyungJoo Ham , Kyungmin Park , Krzysztof Kozlowski , Alim Akhtar , Qiang Yu , Rob Herring , Tomeu Vizoso , Alyssa Rosenzweig , Nishanth Menon , Stephen Boyd , Thierry Reding , Jonathan Hunter , Matthias Brugger Cc: linux-pm@vger.kernel.org, Vincent Guittot , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, lima@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org References: <9730e011004b7526e79c6f409f5147fb235b414a.1656935522.git.viresh.kumar@linaro.org> From: Steven Price In-Reply-To: Content-Type: text/plain; charset=UTF-8 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_NONE,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 06/07/2022 09:18, Viresh Kumar wrote: > Make dev_pm_opp_set_regulators() accept a NULL terminated list of names > instead of making the callers keep the two parameters in sync, which > creates an opportunity for bugs to get in. > > Suggested-by: Greg Kroah-Hartman > Signed-off-by: Viresh Kumar > --- > V3->V3.1: > - Update panfrost_drv.c to include the NULL element. > > drivers/cpufreq/cpufreq-dt.c | 9 ++++----- > drivers/cpufreq/ti-cpufreq.c | 7 +++---- > drivers/devfreq/exynos-bus.c | 4 ++-- > drivers/gpu/drm/lima/lima_devfreq.c | 3 ++- > drivers/gpu/drm/panfrost/panfrost_devfreq.c | 3 +-- > drivers/gpu/drm/panfrost/panfrost_drv.c | 15 ++++++++++----- > drivers/opp/core.c | 18 ++++++++++++------ > drivers/soc/tegra/pmc.c | 4 ++-- > include/linux/pm_opp.h | 9 ++++----- > 9 files changed, 40 insertions(+), 32 deletions(-) > [...] > diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c > index 194af7f607a6..5110cd9b2425 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c > +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c > @@ -101,8 +101,7 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) > return 0; > } > > - ret = devm_pm_opp_set_regulators(dev, pfdev->comp->supply_names, > - pfdev->comp->num_supplies); > + ret = devm_pm_opp_set_regulators(dev, pfdev->comp->supply_names); > if (ret) { > /* Continue if the optional regulator is missing */ > if (ret != -ENODEV) { > diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c > index 7fcbc2a5b6cd..8a4bef65d38c 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_drv.c > +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c > @@ -625,24 +625,29 @@ static int panfrost_remove(struct platform_device *pdev) > return 0; > } > > -static const char * const default_supplies[] = { "mali" }; > +/* > + * The OPP core wants the supply names to be NULL terminated, but we need the > + * correct num_supplies value for regulator core. Hence, we NULL terminate here > + * and then initialize num_supplies with ARRAY_SIZE - 1. > + */ > +static const char * const default_supplies[] = { "mali", NULL }; > static const struct panfrost_compatible default_data = { > - .num_supplies = ARRAY_SIZE(default_supplies), > + .num_supplies = ARRAY_SIZE(default_supplies) - 1, > .supply_names = default_supplies, > .num_pm_domains = 1, /* optional */ > .pm_domain_names = NULL, > }; > > static const struct panfrost_compatible amlogic_data = { > - .num_supplies = ARRAY_SIZE(default_supplies), > + .num_supplies = ARRAY_SIZE(default_supplies) - 1, > .supply_names = default_supplies, > .vendor_quirk = panfrost_gpu_amlogic_quirk, > }; > > -static const char * const mediatek_mt8183_supplies[] = { "mali", "sram" }; > +static const char * const mediatek_mt8183_supplies[] = { "mali", "sram", NULL }; > static const char * const mediatek_mt8183_pm_domains[] = { "core0", "core1", "core2" }; > static const struct panfrost_compatible mediatek_mt8183_data = { > - .num_supplies = ARRAY_SIZE(mediatek_mt8183_supplies), > + .num_supplies = ARRAY_SIZE(mediatek_mt8183_supplies) - 1, > .supply_names = mediatek_mt8183_supplies, > .num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains), > .pm_domain_names = mediatek_mt8183_pm_domains, Reviewed-by: Steven Price Thanks for the rework, much cleaner. Steve