Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp437110rwb; Thu, 12 Jan 2023 08:00:34 -0800 (PST) X-Google-Smtp-Source: AMrXdXvAdhOS0um6Iddx0Pr2UuxNEHHHecpay6OjdkgwVC3SVekNIPOGdjtDuI3BsBE624HOdqKx X-Received: by 2002:a05:6a20:138b:b0:a0:462f:8e3e with SMTP id w11-20020a056a20138b00b000a0462f8e3emr113568662pzh.55.1673539234702; Thu, 12 Jan 2023 08:00:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673539234; cv=none; d=google.com; s=arc-20160816; b=GO/8MqKfreIV3eq0Flqd/llHnuQZttrt6+EKDwzMRjvufvB6U1y/ap5FS7YP+2L913 /V5tLp03FMwaG5WpshvKbH2y6wEyjHu1PCl0WTsXzG4uZ4pbZL4bu2YIgl2uoPQ4/QlE lDN0pXi6hetPMZ5J7181Ry8VyupoqN0Vq7hg60dqAPGVVzklMNILFTOWoyWvDevCJ0RX 1BIbzoUCqSpqxSRuZVX1BhfqZW2iAaqdbbiUQ1uZl1tclTvuiyeKmYNIVsz+m/8ULL59 8oDivtKg9s3dbARC5TRTS4HrLBXbQA0aeu210MNfMf41sSUo6LdyqNaTuGzYobVR0aVK 7o7g== 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=zO7SE+CDm/f6aQ1GPxQ7xSwAd2yYIH7K/THLNefs+O8=; b=LdWLAYqWR/r41u2LTLqmxaYq92iGRhfYVAo95njYi030mreNDYHJ/NLtPJevBlh3GM C0ea38tUj54QPHNE8qGOdj8BOU9uByr46yVoztWvX7vAfmeSdMphz5iOq7pvrCuBSSe+ SLPBG4Hcfi1kRU7umXunHHWOvbnsA2IuD6jfwrA6JIJJ1HJSPKuuC/vCnUQeFI7GAzUv 9wI4sabrmAiiDQ4KbtuyXYDAQuEPx2p2QFZavYRMM1BKYxuujnXYS+dRZpQBV4jSy06f LE0tQnYJBOVTMRx+yT+RrAQf+L/bHo1hdH8JBPTJgVJfbRhydGWEv3J/9tqu6XPeE2kF JCrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O7IU4VWz; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 4-20020a631544000000b00476e62744a8si16904550pgv.388.2023.01.12.08.00.28; Thu, 12 Jan 2023 08:00:34 -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=@kernel.org header.s=k20201202 header.b=O7IU4VWz; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240542AbjALPrm (ORCPT + 50 others); Thu, 12 Jan 2023 10:47:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240481AbjALPrL (ORCPT ); Thu, 12 Jan 2023 10:47:11 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE1F7192B9; Thu, 12 Jan 2023 07:37:08 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6464462077; Thu, 12 Jan 2023 15:37:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8F33C433EF; Thu, 12 Jan 2023 15:37:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673537827; bh=5APceSExAsrf4VwDnGXlJySaXuHRaZgzWG4NnwXl+Jo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=O7IU4VWz85tfErlM/RwYKz5Pdon4CNtAKJnKzulWLSuCghMXTX3smxLR1or6853JL uYKsZaQe+8GBJhGGeOwMUbQ3AmCvMo5UQdx0ZiJ65jwR60ZIZa+QwXCRymp1kXN1v+ Bd8ui0hlVzhOBnrY2bJOiLpndAW+QLJoTnFhgz/A6AIl4fDLJ/Z98jO+6/XOto/0YV r82gOmbqah641Jm0UZbxAZTJTMLCHD8I5dxpAiyET3LR1Z7xDP7kuOfNbHTHwQ119j RzSvdwqz0xVdXloWwqVFbLiSYHgSzz8TShONiqJPtM6de62FZUdOy1rZbqKJXiHAu3 mukrIdkzkPdhw== Date: Thu, 12 Jan 2023 09:37:04 -0600 From: Bjorn Andersson To: Konrad Dybcio Cc: linux-arm-msm@vger.kernel.org, agross@kernel.org, krzysztof.kozlowski@linaro.org, marijn.suijten@somainline.org, "Rafael J. Wysocki" , Viresh Kumar , Rob Herring , Krzysztof Kozlowski , Manivannan Sadhasivam , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] cpufreq: qcom-hw: Ensure only freq-domain regs are counted in num_domains Message-ID: <20230112153704.6d37dygm4yfexdq6@builder.lan> References: <20230111205125.1860858-1-konrad.dybcio@linaro.org> <20230111205125.1860858-2-konrad.dybcio@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230111205125.1860858-2-konrad.dybcio@linaro.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 Wed, Jan 11, 2023 at 09:51:25PM +0100, Konrad Dybcio wrote: > In preparation for CPRh-aware OSM programming, change the probe > function so that we determine the number of frequency domains by > counting the number of reg-names entries that begin with > "freq-domain", as the aforementioned changes require introduction > of non-freq-domain register spaces. > Requiring reg-names would break backwards compatibility with at least sc7280 and sm6115. Regards, Bjorn > Fixes: 1a6a8b0080b0 ("cpufreq: qcom-hw: Fix reading "reg" with address/size-cells != 2") > Fixes: 054a3ef683a1 ("cpufreq: qcom-hw: Allocate qcom_cpufreq_data during probe") > Signed-off-by: Konrad Dybcio > --- > drivers/cpufreq/qcom-cpufreq-hw.c | 34 ++++++++++++++++++++++--------- > 1 file changed, 24 insertions(+), 10 deletions(-) > > diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c > index 9505a812d6a1..89d5ed267399 100644 > --- a/drivers/cpufreq/qcom-cpufreq-hw.c > +++ b/drivers/cpufreq/qcom-cpufreq-hw.c > @@ -651,8 +651,9 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev) > struct device *dev = &pdev->dev; > struct device_node *soc_node; > struct device *cpu_dev; > + const char *reg_name; > struct clk *clk; > - int ret, i, num_domains, reg_sz; > + int ret, i, num_reg_names, num_domains = 0; > > clk = clk_get(dev, "xo"); > if (IS_ERR(clk)) > @@ -684,19 +685,32 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev) > if (!soc_node) > return -EINVAL; > > - ret = of_property_read_u32(soc_node, "#address-cells", ®_sz); > - if (ret) > + num_reg_names = of_property_count_strings(dev->of_node, "reg-names"); > + if (num_reg_names <= 0) { > + ret = num_reg_names ? num_reg_names : -ENODATA; > goto of_exit; > + } > > - ret = of_property_read_u32(soc_node, "#size-cells", &i); > - if (ret) > - goto of_exit; > + for (i = 0; i < num_reg_names; i++) { > + ret = of_property_read_string_index(dev->of_node, "reg-names", i, ®_name); > + if (ret < 0) > + goto of_exit; > > - reg_sz += i; > + /* > + * Check if the i-th reg is a freq-domain base, no need to add 1 > + * more byte for idx, as sizeof counts \0 whereas strlen does not. > + */ > + if (strlen(reg_name) == sizeof("freq-domain")) { > + /* Check if this reg-name begins with "freq-domain" */ > + if (!strncmp(reg_name, "freq-domain", sizeof("freq-domain") - 1)) > + num_domains++; > + } > + } > > - num_domains = of_property_count_elems_of_size(dev->of_node, "reg", sizeof(u32) * reg_sz); > - if (num_domains <= 0) > - return num_domains; > + if (num_domains <= 0) { > + ret = -EINVAL; > + goto of_exit; > + } > > qcom_cpufreq.data = devm_kzalloc(dev, sizeof(struct qcom_cpufreq_data) * num_domains, > GFP_KERNEL); > -- > 2.39.0 >