From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E865FC433EF for ; Wed, 6 Jul 2022 09:50:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229647AbiGFJuc (ORCPT ); Wed, 6 Jul 2022 05:50:32 -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 Precedence: bulk List-ID: X-Mailing-List: linux-tegra@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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 45EF1C43334 for ; Wed, 6 Jul 2022 09:50:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3F83810FBC2; Wed, 6 Jul 2022 09:50:32 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 7F91B10F788; Wed, 6 Jul 2022 09:50:30 +0000 (UTC) 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 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-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-samsung-soc@vger.kernel.org, Vincent Guittot , lima@lists.freedesktop.org, linux-pm@vger.kernel.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4AEC9C433EF for ; Wed, 6 Jul 2022 10:06:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0j2o/4zsWxojzu4f17CcOQb1eGyyPezz/C1vG7a52I0=; b=N9sOBs/+Thfk9a KZBSh/8qJMDiPnvUXX5ErJPcHlLkOQGiJzk0y9Sk0+oMo80J9ZY9rjUsQbbLzBBZXC2QeXMZEJ6Nz KLzlh3g5Sb70ePNcCEF3pAtusHxNYG2fcQ22FOTmLAwTIpTnf0EBNwHq57ljZF9WbjIR9W7NxHCtT mlIpZ0Q5ql4nZ/tGznkLWGB/vFVXr5gurLDxWDEF/gGj2avvmcJevppSpq/+WHYUeINGtTXRGyjZ5 aWdBqiKH41baRxwVPMK8clAKAMEc4s5ByNLtg7B5UyoYoCWt2K/eZMCM2/zBJH4blf/Zoi7W1dyIR WRAtEUDgoyvdJxpkP5IQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o91uO-0088Ex-U8; Wed, 06 Jul 2022 10:05:25 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o91fy-007wao-Oz; Wed, 06 Jul 2022 09:50:32 +0000 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: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220706_025030_950702_0F9D03D6 X-CRM114-Status: GOOD ( 21.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel