From patchwork Wed Jan 11 20:51:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 641870 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 9C9EBC46467 for ; Wed, 11 Jan 2023 20:51:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231764AbjAKUve (ORCPT ); Wed, 11 Jan 2023 15:51:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229558AbjAKUvd (ORCPT ); Wed, 11 Jan 2023 15:51:33 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5336E3C71D for ; Wed, 11 Jan 2023 12:51:32 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id j17so25402760lfr.3 for ; Wed, 11 Jan 2023 12:51:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=8Wr8laYn6BNAzfzpqrvLlNLWQHAe4YySPp4O0GFkETM=; b=q9MTHdUNZsoZCccIV45EDRaB5XTLW77ktAK3ck9tgnt6LvUlWqQ62MCG3X51lT05Vl Jkf+eQpS57GP2oe5RhIf2wSpwuHWXh1VeEbEYKttiOhWqN2GvePp0Iq0Lo8DgckRv1Ti cPOKlC1Zw1VDWlM7QNqV1pOcd+QJMzXxqY93CW9bqinBzXKsvHzRCplbKMPGc7hwGccO Ud1+tSghADiLFgVf4r4BjD8sKtZYXYiBzVVL5kuKUNAMB4T29Uy7x8/IdBH+Ql9z4TY/ uR/xCf4t1SMokPBMksLPD13yurM8QOD5aZe4WtYEkEmHUXycLDF5/8zuBBZgNUkGWk01 u2dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8Wr8laYn6BNAzfzpqrvLlNLWQHAe4YySPp4O0GFkETM=; b=rQe7d/sq/UqS8tCF97VMBo5zIxwrOjxqrnqtysfeBi6XFIw3fFU9ZJYEONHOgKyc+9 qqxvZ89/x9h+4fqJ74RhHy7ULFJ0OwBmamsebHlbjzcuW8UK5xyGCZS5JBVwVQipcb2R 33SuKIxcfeP9nNTFMx0CTod8cH/l/NN85veW3n7BCzUwCiJrlWRisxjBZRQ2LyDBD6L/ bTWm9N2CHVK+R46awb06sxfTnBuzq9nNVMrnt6/+VcKam/FJXXUEOTnGQJxHExrVYVHY T63k39Xk8FpiZe4bGBQtKXj8xe8yw99Nc2SlK23YdJ5KAVwTRBSAgeh/cUARgWTfQxbx BpvA== X-Gm-Message-State: AFqh2kp0nTre7gpHxysbJ5YsJ5b7l2m9EmaOgNTJxBT7dSDD7/Cak2jH jHHfV82DT6WMB4mkO+NpYMsaGg== X-Google-Smtp-Source: AMrXdXt/VUCoc2P2Ua3uU7A8tXp1xXb8mAOxGuI44LSvg5ywkrCP7Xou+h7hqVjHirE/hMXxKhOxJw== X-Received: by 2002:a05:6512:74:b0:4ca:fe23:7677 with SMTP id i20-20020a056512007400b004cafe237677mr16604710lfo.43.1673470290716; Wed, 11 Jan 2023 12:51:30 -0800 (PST) Received: from localhost.localdomain (abym53.neoplus.adsl.tpnet.pl. [83.9.32.53]) by smtp.gmail.com with ESMTPSA id q11-20020a056512210b00b004cc9042c9cfsm928888lfr.158.2023.01.11.12.51.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 12:51:29 -0800 (PST) From: Konrad Dybcio To: linux-arm-msm@vger.kernel.org, andersson@kernel.org, agross@kernel.org, krzysztof.kozlowski@linaro.org Cc: marijn.suijten@somainline.org, Konrad Dybcio , "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: [PATCH 1/2] dt-bindings: cpufreq: Make reg-names a required property Date: Wed, 11 Jan 2023 21:51:24 +0100 Message-Id: <20230111205125.1860858-1-konrad.dybcio@linaro.org> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org In preparation for determining the number of frequency domains based on reg-names entries, rather than performing calculations based on reg entries and parent #{address,size}-cells, make reg-names a required property. Signed-off-by: Konrad Dybcio --- Documentation/devicetree/bindings/cpufreq/cpufreq-qcom-hw.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-qcom-hw.yaml b/Documentation/devicetree/bindings/cpufreq/cpufreq-qcom-hw.yaml index 99e159bc5fb1..460a7ab7b87c 100644 --- a/Documentation/devicetree/bindings/cpufreq/cpufreq-qcom-hw.yaml +++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-qcom-hw.yaml @@ -74,6 +74,7 @@ properties: required: - compatible - reg + - reg-names - clocks - clock-names - '#freq-domain-cells' From patchwork Wed Jan 11 20:51:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 641566 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 C8201C46467 for ; Wed, 11 Jan 2023 20:51:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232785AbjAKUvh (ORCPT ); Wed, 11 Jan 2023 15:51:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbjAKUvg (ORCPT ); Wed, 11 Jan 2023 15:51:36 -0500 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FE063D9D7 for ; Wed, 11 Jan 2023 12:51:34 -0800 (PST) Received: by mail-lf1-x130.google.com with SMTP id g13so25387153lfv.7 for ; Wed, 11 Jan 2023 12:51:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DZVlKUhfc1i9OxoybHYHtIAo0AKIGGWqWJ2gIpTCzIM=; b=kosm8WJAxa8BwkKSfwwtXUZBKOjT5y21Dgn4xSAyNiKMjLtvJebhittim222BCFcDz +PtlOyLO9W/2+Mb+X9B+wjU85DUUwuF4LbU8QCpKkV65w+Amx3YkO3E9eksvnRagUuP5 grlIxhZX8Tfily2HjjxLjkWz+xukRrh1Ai8XaxW5hzoxisjtqtIZ3UqSf5Ge4csjcpfc bSpx9kGbwb+p5HFthnYHqDFbGt3d3eqshaI/Q4yybHvSEdUuPADE6GcMSYmNq8PXE0NH 7EVIhinKn4SIi3n0OL6ber55n5YD+zSKHl3DrGDj+k/xV5rmFn1k16x0t6Mjw5Zv1YzQ y3oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DZVlKUhfc1i9OxoybHYHtIAo0AKIGGWqWJ2gIpTCzIM=; b=EJGoiEl8r0sX16FRPqS+puseWa57s6idM9QPPEeMz7YQrojTfX1foBQbAeEcL0Lzpb VRmBTj0dLFZKUCLHtUX1wBQGZc1ULSHhpFDFpibMl9H5P5iwkyqplUATkAkYANbQUuqn aCBBZyUei/dzY7TiTfS4Qkz1noK2y3webin8D6mx37BuuG5llp5fz1UGeagsDg2nL8vU 32epTLi7lM0u5gPyefeH/LdQij9qbakZSBDJqA5ZfXnMDFkrZY5AQ7bBqR3VKovWwm0j 6y5OsohacCNAmKpkPtAxgE7aotZIuj8x//myQzke7Ppm1/bJKe2Tig02zGjjgmv6swJo x77w== X-Gm-Message-State: AFqh2krVJN8tQgOTrTGqZCfsIT9oovfZvx8A0qa9B3AUFzPjvOjC+ygJ hnem/KYJJnPXjmGr0HpgnFzbZA== X-Google-Smtp-Source: AMrXdXtL5bdHP+x3aZHb+F3kZF22VcBLLNZjyCGBmsJj4EEn23qL9UCqWMZuOG9S4FRGVBOZppIAKw== X-Received: by 2002:a19:f514:0:b0:4b5:61e8:8934 with SMTP id j20-20020a19f514000000b004b561e88934mr18782486lfb.64.1673470292525; Wed, 11 Jan 2023 12:51:32 -0800 (PST) Received: from localhost.localdomain (abym53.neoplus.adsl.tpnet.pl. [83.9.32.53]) by smtp.gmail.com with ESMTPSA id q11-20020a056512210b00b004cc9042c9cfsm928888lfr.158.2023.01.11.12.51.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 12:51:31 -0800 (PST) From: Konrad Dybcio To: linux-arm-msm@vger.kernel.org, andersson@kernel.org, agross@kernel.org, krzysztof.kozlowski@linaro.org Cc: marijn.suijten@somainline.org, Konrad Dybcio , "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: [PATCH 2/2] cpufreq: qcom-hw: Ensure only freq-domain regs are counted in num_domains Date: Wed, 11 Jan 2023 21:51:25 +0100 Message-Id: <20230111205125.1860858-2-konrad.dybcio@linaro.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230111205125.1860858-1-konrad.dybcio@linaro.org> References: <20230111205125.1860858-1-konrad.dybcio@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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. 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);