Message ID | 20230303092859.22094-2-quic_tdas@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp319321wrd; Fri, 3 Mar 2023 01:44:18 -0800 (PST) X-Google-Smtp-Source: AK7set99zTM9At5krV1rCrlTKxeo1L2X4OVuLgzi1kEnz5vUqV0zPxweGWqxvSygiRHUif5QeVdG X-Received: by 2002:a17:907:a44:b0:8b1:29ed:e206 with SMTP id be4-20020a1709070a4400b008b129ede206mr1140923ejc.28.1677836658762; Fri, 03 Mar 2023 01:44:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677836658; cv=none; d=google.com; s=arc-20160816; b=IKuX4zoBeDfmTqE9oc0Zs08uQFxyhjcstmSqo5z6n5d9iuJyWsKfOiui4ZlzuunTRL +Tpg7ja7SGEJ1DSX73xyCWenk0wZQxen0kMhc5TXVA7/82FwQtyOgPrtSzZU8tZMfq97 l2R05gF/cC7ZDxaC0QDTOxngIze0M0hsA4NOpr6j/nc+xzK6Vz2lZyD4CjBO+vQP5FGY CSjDnZLgazfn1q5BJ/WRHn0/GyrqiQQksP/Zb6FH58j8Uo8kHGo8Mwx12rMR/8AlO4hf zPqY14n/8Dyl0UB1DDrXlzksc77DAPk1eCe7LIGBPgEa8Wv2jVAc00gRt6TExO/SRaw7 qzaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eW7zZr44zXmONsCh8kh4YmrKE1J7ANRxhC4Py1i2X/w=; b=X6J8wWetvcP4pA+isZrc9eDfABC8li6SrNct8gRgu6MHS3/mtY9m1CggLNNQfzLWSQ entUQs3vmD7gl7gc5hChGuETc17y9dpoO7S1uewhioZSsUPCf56E4za4MiZAaYoKVAXF EtvFCf7cM1W2Z/XNTERvqf6aPwzSCefGxvf8sPPcx0e+D6HU3CB/XB41+EC3cutIkk3N gvikgOBrOlJMD2XCgvWvjUYuLO/4rM0gGeFucBmuLnpTX0sQFXtxDn6o0p4K/pBmL1bA u46e0GlWtM5psXTq1PDJnx7XahG3s5/Y4YlOefYnxJefnlhsXjN09DvAbwDIqbXJaEPh D2Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=nCQkS74O; 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=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m7-20020a1709062b8700b008b19489a9eesi276747ejg.602.2023.03.03.01.43.43; Fri, 03 Mar 2023 01:44:18 -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=@quicinc.com header.s=qcppdkim1 header.b=nCQkS74O; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230044AbjCCJa2 (ORCPT <rfc822;davidbtadokoro@gmail.com> + 99 others); Fri, 3 Mar 2023 04:30:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231240AbjCCJaC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 3 Mar 2023 04:30:02 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E4A5117; Fri, 3 Mar 2023 01:29:50 -0800 (PST) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32355Wr7032092; Fri, 3 Mar 2023 09:29:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=qcppdkim1; bh=eW7zZr44zXmONsCh8kh4YmrKE1J7ANRxhC4Py1i2X/w=; b=nCQkS74OBLq+rFIiOK8PFwdKw8EVy2SqTau9s1h50Djz9FrpZ8geHvwAlf79WMkRb80w 66H64RJTLmvPFaDm+uSbAu5+n5pbr/t46O6wAQInT5hX+THcsM6WkK3r1zc41TqGNEhn 8/Em/H2kna61F/lSfRBNULJX6ndW42bt9LKd4QixZy+cUpcC9kysSf04vsaDhsEbzUgn lSyexFH8FQzZlW53UyZNBj5AZ6jNhzqcG+i7iEonch/OKuDuwXplsRo8QVv6xz1yhi45 oeQzSMYSFDLpyAWUFL7IxaNzh9v+tIYgC0acqvkhger6nDga8OvvlXKfltLoMTBP6aT/ SQ== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3p2rbgbfut-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 03 Mar 2023 09:29:39 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3239Tcfw016974 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 3 Mar 2023 09:29:38 GMT Received: from hu-tdas-hyd.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 3 Mar 2023 01:29:35 -0800 From: Taniya Das <quic_tdas@quicinc.com> To: Andy Gross <agross@kernel.org>, Michael Turquette <mturquette@baylibre.com>, Stephen Boyd <sboyd@kernel.org> CC: Bjorn Andersson <andersson@kernel.org>, Konrad Dybcio <konrad.dybcio@linaro.org>, <linux-arm-msm@vger.kernel.org>, <linux-clk@vger.kernel.org>, <linux-kernel@vger.kernel.org>, Taniya Das <quic_tdas@quicinc.com> Subject: [PATCH 1/2] clk: qcom: common: Handle invalid index error Date: Fri, 3 Mar 2023 14:58:58 +0530 Message-ID: <20230303092859.22094-2-quic_tdas@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230303092859.22094-1-quic_tdas@quicinc.com> References: <20230303092859.22094-1-quic_tdas@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: yNn3D6vya5rV2xsZ48gpSx2KEe8792Gc X-Proofpoint-ORIG-GUID: yNn3D6vya5rV2xsZ48gpSx2KEe8792Gc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-03_01,2023-03-02_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=839 lowpriorityscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 mlxscore=0 spamscore=0 malwarescore=0 adultscore=0 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303030084 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759339252374193969?= X-GMAIL-MSGID: =?utf-8?q?1759339252374193969?= |
Series |
Handle invalid index error
|
|
Commit Message
Taniya Das
March 3, 2023, 9:28 a.m. UTC
Introduce start_index to handle invalid index error
seen when there are two clock descriptors assigned
to the same clock controller.
[ 3.600604] qcom_cc_clk_hw_get: invalid index 5
[ 3.625251] qcom_cc_clk_hw_get: invalid index 6
[ 3.648190] qcom_cc_clk_hw_get: invalid index 7
Fixes: 120c15528390 ("clk: qcom: Migrate to clk_hw based registration and OF APIs")
Signed-off-by: Taniya Das <quic_tdas@quicinc.com>
---
drivers/clk/qcom/common.c | 12 ++++++++----
drivers/clk/qcom/common.h | 1 +
2 files changed, 9 insertions(+), 4 deletions(-)
--
2.17.1
Comments
On Fri, 3 Mar 2023 at 11:30, Taniya Das <quic_tdas@quicinc.com> wrote: > > Introduce start_index to handle invalid index error > seen when there are two clock descriptors assigned > to the same clock controller. Please provide details of the exact case that you are trying to solve (this might go to the cover letter). I think the commit message is slightly misleading here. Are you trying to add error messages or to prevent them from showing up? I'm asking because error messages do not seem to correspond to patch 2. You add start_index to make the kernel warn for the clock indices less than LPASS_AUDIO_CC_CDIV_RX_MCLK_DIV_CLK_SRC = 4, while quoted messages show indices 5,6,7. Nit: please don't overwrap the commit message, the recommended line width is about 72-77 chars. > > [ 3.600604] qcom_cc_clk_hw_get: invalid index 5 > [ 3.625251] qcom_cc_clk_hw_get: invalid index 6 > [ 3.648190] qcom_cc_clk_hw_get: invalid index 7 > > Fixes: 120c15528390 ("clk: qcom: Migrate to clk_hw based registration and OF APIs") > Signed-off-by: Taniya Das <quic_tdas@quicinc.com> > --- > drivers/clk/qcom/common.c | 12 ++++++++---- > drivers/clk/qcom/common.h | 1 + > 2 files changed, 9 insertions(+), 4 deletions(-) > > diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c > index 75f09e6e057e..0e80535b61f2 100644 > --- a/drivers/clk/qcom/common.c > +++ b/drivers/clk/qcom/common.c > @@ -21,6 +21,7 @@ struct qcom_cc { > struct qcom_reset_controller reset; > struct clk_regmap **rclks; > size_t num_rclks; > + u32 rclks_start_index; > }; > > const > @@ -226,12 +227,13 @@ static struct clk_hw *qcom_cc_clk_hw_get(struct of_phandle_args *clkspec, > struct qcom_cc *cc = data; > unsigned int idx = clkspec->args[0]; > > - if (idx >= cc->num_rclks) { > + if (idx >= cc->rclks_start_index && idx < cc->num_rclks) > + return cc->rclks[idx] ? &cc->rclks[idx]->hw : NULL; > + else if (idx < cc->rclks_start_index && idx >= cc->num_rclks) > pr_err("%s: invalid index %u\n", __func__, idx); > - return ERR_PTR(-EINVAL); > - } > > - return cc->rclks[idx] ? &cc->rclks[idx]->hw : NULL; > + return ERR_PTR(-EINVAL); > + > } > > int qcom_cc_really_probe(struct platform_device *pdev, > @@ -281,6 +283,8 @@ int qcom_cc_really_probe(struct platform_device *pdev, > > cc->rclks = rclks; > cc->num_rclks = num_clks; > + if (desc->start_index) > + cc->rclks_start_index = desc->start_index; > > qcom_cc_drop_protected(dev, cc); > > diff --git a/drivers/clk/qcom/common.h b/drivers/clk/qcom/common.h > index 9c8f7b798d9f..924f36af55b3 100644 > --- a/drivers/clk/qcom/common.h > +++ b/drivers/clk/qcom/common.h > @@ -23,6 +23,7 @@ struct qcom_cc_desc { > const struct regmap_config *config; > struct clk_regmap **clks; > size_t num_clks; > + u32 start_index; > const struct qcom_reset_map *resets; > size_t num_resets; > struct gdsc **gdscs; > -- > 2.17.1 > -- With best wishes Dmitry
Hi Dmitry, Thanks for the comments. On 3/3/2023 4:14 PM, Dmitry Baryshkov wrote: > On Fri, 3 Mar 2023 at 11:30, Taniya Das <quic_tdas@quicinc.com> wrote: >> >> Introduce start_index to handle invalid index error >> seen when there are two clock descriptors assigned >> to the same clock controller. > > Please provide details of the exact case that you are trying to solve > (this might go to the cover letter). I think the commit message is > slightly misleading here. Are you trying to add error messages or to > prevent them from showing up? > We are trying to avoid error messages from showing up. > I'm asking because error messages do not seem to correspond to patch > 2. You add start_index to make the kernel warn for the clock indices > less than LPASS_AUDIO_CC_CDIV_RX_MCLK_DIV_CLK_SRC = 4, while quoted > messages show indices 5,6,7. > Right, we want the kernel to warn if the clock index is less than start_index, along with that we also want to handle the case where num_rclks is uninitialized because of same clock descriptor being assigned to two clock controllers. Earlier Invalid index error was showing up for valid indices 5,6,7 because of the simple if check(idx >= num_rclks), hence we enhanced the checks to handle the above case and compare the index to the start_index + num_rclks, instead of simply comparing it with num_clks. > Nit: please don't overwrap the commit message, the recommended line > width is about 72-77 chars. > Done. >> >> [ 3.600604] qcom_cc_clk_hw_get: invalid index 5 >> [ 3.625251] qcom_cc_clk_hw_get: invalid index 6 >> [ 3.648190] qcom_cc_clk_hw_get: invalid index 7 > >> >> Fixes: 120c15528390 ("clk: qcom: Migrate to clk_hw based registration and OF APIs") >> Signed-off-by: Taniya Das <quic_tdas@quicinc.com> >> --- >> drivers/clk/qcom/common.c | 12 ++++++++---- >> drivers/clk/qcom/common.h | 1 + >> 2 files changed, 9 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c >> index 75f09e6e057e..0e80535b61f2 100644 >> --- a/drivers/clk/qcom/common.c >> +++ b/drivers/clk/qcom/common.c >> @@ -21,6 +21,7 @@ struct qcom_cc { >> struct qcom_reset_controller reset; >> struct clk_regmap **rclks; >> size_t num_rclks; >> + u32 rclks_start_index; >> }; >> >> const >> @@ -226,12 +227,13 @@ static struct clk_hw *qcom_cc_clk_hw_get(struct of_phandle_args *clkspec, >> struct qcom_cc *cc = data; >> unsigned int idx = clkspec->args[0]; >> >> - if (idx >= cc->num_rclks) { >> + if (idx >= cc->rclks_start_index && idx < cc->num_rclks) >> + return cc->rclks[idx] ? &cc->rclks[idx]->hw : NULL; >> + else if (idx < cc->rclks_start_index && idx >= cc->num_rclks) >> pr_err("%s: invalid index %u\n", __func__, idx); >> - return ERR_PTR(-EINVAL); >> - } >> >> - return cc->rclks[idx] ? &cc->rclks[idx]->hw : NULL; >> + return ERR_PTR(-EINVAL); >> + >> } >> >> int qcom_cc_really_probe(struct platform_device *pdev, >> @@ -281,6 +283,8 @@ int qcom_cc_really_probe(struct platform_device *pdev, >> >> cc->rclks = rclks; >> cc->num_rclks = num_clks; >> + if (desc->start_index) >> + cc->rclks_start_index = desc->start_index; >> >> qcom_cc_drop_protected(dev, cc); >> >> diff --git a/drivers/clk/qcom/common.h b/drivers/clk/qcom/common.h >> index 9c8f7b798d9f..924f36af55b3 100644 >> --- a/drivers/clk/qcom/common.h >> +++ b/drivers/clk/qcom/common.h >> @@ -23,6 +23,7 @@ struct qcom_cc_desc { >> const struct regmap_config *config; >> struct clk_regmap **clks; >> size_t num_clks; >> + u32 start_index; >> const struct qcom_reset_map *resets; >> size_t num_resets; >> struct gdsc **gdscs; >> -- >> 2.17.1 >> > > > -- > With best wishes > > > > Dmitry
On 17/04/2023 07:40, Taniya Das wrote: > Hi Dmitry, > > Thanks for the comments. > > > On 3/3/2023 4:14 PM, Dmitry Baryshkov wrote: >> On Fri, 3 Mar 2023 at 11:30, Taniya Das <quic_tdas@quicinc.com> wrote: >>> >>> Introduce start_index to handle invalid index error >>> seen when there are two clock descriptors assigned >>> to the same clock controller. >> >> Please provide details of the exact case that you are trying to solve >> (this might go to the cover letter). I think the commit message is >> slightly misleading here. Are you trying to add error messages or to >> prevent them from showing up? >> > > We are trying to avoid error messages from showing up. > >> I'm asking because error messages do not seem to correspond to patch >> 2. You add start_index to make the kernel warn for the clock indices >> less than LPASS_AUDIO_CC_CDIV_RX_MCLK_DIV_CLK_SRC = 4, while quoted >> messages show indices 5,6,7. >> > > Right, we want the kernel to warn if the clock index is less than > start_index, This is arguable but logical. Usually we do not warn for absent clocks. > along with that we also want to handle the case where > num_rclks is uninitialized because of same clock descriptor being > assigned to two clock controllers. Hmm, but num_rclks is always initialized, isn't it? In the worst case it will default to 0 meaning that > Earlier Invalid index error was showing up for valid indices 5,6,7 > because of the simple if check(idx >= num_rclks), hence we enhanced the > checks to handle the above case and compare the index to the start_index > + num_rclks, instead of simply comparing it with num_clks. This is not a part of the patch and it will be incorrect anyway, since num_rclks = desc->num_clks = ARRAY_SIZE(some_cc_clocks). Checking idx against `start_index + num_rclks` will allow one to get clocks after the end of rclks array. For lpass_audio_cc_sc7280_desc num_rclks should get the value of 16, as the last entry in llpass_audio_cc_sc7280_clocks has index LPASS_AUDIO_CC_RX_MCLK_CLK_SRC = 15. My analysis might be completely wrong, but I can only assume that somehow wrong clock controller got used. Could you please give it a try with the https://lore.kernel.org/linux-clk/20230417114659.137535-1-dmitry.baryshkov@linaro.org/ being applied? > >> Nit: please don't overwrap the commit message, the recommended line >> width is about 72-77 chars. >> > > Done. > >>> >>> [ 3.600604] qcom_cc_clk_hw_get: invalid index 5 >>> [ 3.625251] qcom_cc_clk_hw_get: invalid index 6 >>> [ 3.648190] qcom_cc_clk_hw_get: invalid index 7 >> >>> >>> Fixes: 120c15528390 ("clk: qcom: Migrate to clk_hw based registration >>> and OF APIs") >>> Signed-off-by: Taniya Das <quic_tdas@quicinc.com> >>> --- >>> drivers/clk/qcom/common.c | 12 ++++++++---- >>> drivers/clk/qcom/common.h | 1 + >>> 2 files changed, 9 insertions(+), 4 deletions(-) >>> >>> diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c >>> index 75f09e6e057e..0e80535b61f2 100644 >>> --- a/drivers/clk/qcom/common.c >>> +++ b/drivers/clk/qcom/common.c >>> @@ -21,6 +21,7 @@ struct qcom_cc { >>> struct qcom_reset_controller reset; >>> struct clk_regmap **rclks; >>> size_t num_rclks; >>> + u32 rclks_start_index; >>> }; >>> >>> const >>> @@ -226,12 +227,13 @@ static struct clk_hw *qcom_cc_clk_hw_get(struct >>> of_phandle_args *clkspec, >>> struct qcom_cc *cc = data; >>> unsigned int idx = clkspec->args[0]; >>> >>> - if (idx >= cc->num_rclks) { >>> + if (idx >= cc->rclks_start_index && idx < cc->num_rclks) >>> + return cc->rclks[idx] ? &cc->rclks[idx]->hw : NULL; >>> + else if (idx < cc->rclks_start_index && idx >= cc->num_rclks) >>> pr_err("%s: invalid index %u\n", __func__, idx); >>> - return ERR_PTR(-EINVAL); >>> - } >>> >>> - return cc->rclks[idx] ? &cc->rclks[idx]->hw : NULL; >>> + return ERR_PTR(-EINVAL); >>> + >>> } >>> >>> int qcom_cc_really_probe(struct platform_device *pdev, >>> @@ -281,6 +283,8 @@ int qcom_cc_really_probe(struct platform_device >>> *pdev, >>> >>> cc->rclks = rclks; >>> cc->num_rclks = num_clks; >>> + if (desc->start_index) >>> + cc->rclks_start_index = desc->start_index; >>> >>> qcom_cc_drop_protected(dev, cc); >>> >>> diff --git a/drivers/clk/qcom/common.h b/drivers/clk/qcom/common.h >>> index 9c8f7b798d9f..924f36af55b3 100644 >>> --- a/drivers/clk/qcom/common.h >>> +++ b/drivers/clk/qcom/common.h >>> @@ -23,6 +23,7 @@ struct qcom_cc_desc { >>> const struct regmap_config *config; >>> struct clk_regmap **clks; >>> size_t num_clks; >>> + u32 start_index; >>> const struct qcom_reset_map *resets; >>> size_t num_resets; >>> struct gdsc **gdscs; >>> -- >>> 2.17.1 >>> >> >> >> -- >> With best wishes >> >> >> >> Dmitry >
Quoting Taniya Das (2023-04-16 21:40:48) > Hi Dmitry, > > Thanks for the comments. > > > On 3/3/2023 4:14 PM, Dmitry Baryshkov wrote: > > On Fri, 3 Mar 2023 at 11:30, Taniya Das <quic_tdas@quicinc.com> wrote: > >> > >> Introduce start_index to handle invalid index error > >> seen when there are two clock descriptors assigned > >> to the same clock controller. > > > > Please provide details of the exact case that you are trying to solve > > (this might go to the cover letter). I think the commit message is > > slightly misleading here. Are you trying to add error messages or to > > prevent them from showing up? > > > > We are trying to avoid error messages from showing up. > > > I'm asking because error messages do not seem to correspond to patch > > 2. You add start_index to make the kernel warn for the clock indices > > less than LPASS_AUDIO_CC_CDIV_RX_MCLK_DIV_CLK_SRC = 4, while quoted > > messages show indices 5,6,7. > > > > Right, we want the kernel to warn if the clock index is less than > start_index, along with that we also want to handle the case where > num_rclks is uninitialized because of same clock descriptor being > assigned to two clock controllers. The start_index should be 0.
diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c index 75f09e6e057e..0e80535b61f2 100644 --- a/drivers/clk/qcom/common.c +++ b/drivers/clk/qcom/common.c @@ -21,6 +21,7 @@ struct qcom_cc { struct qcom_reset_controller reset; struct clk_regmap **rclks; size_t num_rclks; + u32 rclks_start_index; }; const @@ -226,12 +227,13 @@ static struct clk_hw *qcom_cc_clk_hw_get(struct of_phandle_args *clkspec, struct qcom_cc *cc = data; unsigned int idx = clkspec->args[0]; - if (idx >= cc->num_rclks) { + if (idx >= cc->rclks_start_index && idx < cc->num_rclks) + return cc->rclks[idx] ? &cc->rclks[idx]->hw : NULL; + else if (idx < cc->rclks_start_index && idx >= cc->num_rclks) pr_err("%s: invalid index %u\n", __func__, idx); - return ERR_PTR(-EINVAL); - } - return cc->rclks[idx] ? &cc->rclks[idx]->hw : NULL; + return ERR_PTR(-EINVAL); + } int qcom_cc_really_probe(struct platform_device *pdev, @@ -281,6 +283,8 @@ int qcom_cc_really_probe(struct platform_device *pdev, cc->rclks = rclks; cc->num_rclks = num_clks; + if (desc->start_index) + cc->rclks_start_index = desc->start_index; qcom_cc_drop_protected(dev, cc); diff --git a/drivers/clk/qcom/common.h b/drivers/clk/qcom/common.h index 9c8f7b798d9f..924f36af55b3 100644 --- a/drivers/clk/qcom/common.h +++ b/drivers/clk/qcom/common.h @@ -23,6 +23,7 @@ struct qcom_cc_desc { const struct regmap_config *config; struct clk_regmap **clks; size_t num_clks; + u32 start_index; const struct qcom_reset_map *resets; size_t num_resets; struct gdsc **gdscs;