Message ID | 20230623141806.13388-6-quic_kbajaj@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5815030vqr; Fri, 23 Jun 2023 07:31:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ub2h4DJ8z8eHZsHCmWiqil6YtiNxjXLy8K1BFRixGFa2Eyujj4iRUxUYgXT2g8/Ah+ZjK X-Received: by 2002:a17:90a:d50c:b0:25c:21eb:c2a7 with SMTP id t12-20020a17090ad50c00b0025c21ebc2a7mr38534970pju.16.1687530661726; Fri, 23 Jun 2023 07:31:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687530661; cv=none; d=google.com; s=arc-20160816; b=iy+Hdyi4YbCMwJeDpPtjlcoTE1GcTOZvkTsxFCBSlaSI4w5eQrvfEZ6VX5kZVrFBgn m20jk+zupcFkTNAK6ZyRr3TbLqcvXhIw3If+pjFEPRbPEDYUoJdM4rE0Lnn7MA3gBevR x4UaeK71iPvta/bbzqkQ8XH4Sk/eTZyCFTeSt2cHRH5QOTP2iPTmW/Id/OeIm6++c+Yl ZbfZaWxDYlteubsH3XDutlmp0ywSEO0YAUVXRjbUQSAOjEI1YgAnEUdV6JgEkNC/bk48 4w2VMRLDUPpYccpw+J9byir6OGV3fTMPlr2Tu1e2RxyNsLv8UbLC3x7NZIn5I+EeRHAz Y0uQ== 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=ztdeNjMOlMS3hnt8R1iJ/msS+N0+PEYQloQcaMXDqKg=; fh=gLxf8p77gYioOiaIK+kVZjjhOGfayo9ag2vpypRrBdM=; b=Iex/EOlZ5DID/0rWVcR+ICTti+cOpyWNlhtckqOjoUmqtfbko7aXhOy4XM48WC35Tt j4JL3em0z4cxT4L8/L54cULHZxC5dfTBx0z+lvH2Bbr1hB4h8vaTBvGTrj190+IEngod ydZj5mjLumYgBVbU4lEUeTtVE9yNu+Buv0pbyM3lphEhHW7k/KEYyg84igQk4BxlKSIh ismEHV+AW25dothw+vxHKbn23PB9nVzF2D3s0KO/IpVclCyXQu5uZOXDBISN87m+2g7t YQQFzk3+p63GDLtIiFG4eE7RVKzOlpjXvuAruhXIYYM5l7D+Ss8kQ+vYBWE8IbYm1McW nFTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=jDPLKN6F; 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 hg16-20020a17090b301000b0025667be94f0si1907089pjb.77.2023.06.23.07.30.46; Fri, 23 Jun 2023 07:31:01 -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; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=jDPLKN6F; 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 S232112AbjFWOTR (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Fri, 23 Jun 2023 10:19:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232017AbjFWOTA (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 23 Jun 2023 10:19:00 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 816ED2693; Fri, 23 Jun 2023 07:18:58 -0700 (PDT) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35NE2gK3009719; Fri, 23 Jun 2023 14:18:55 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-transfer-encoding : content-type; s=qcppdkim1; bh=ztdeNjMOlMS3hnt8R1iJ/msS+N0+PEYQloQcaMXDqKg=; b=jDPLKN6FTMPB70QW4RLum7Zr3cRWpoZVAQKWzGBbXeps/6AQ/5R8rwpxNbEqHGhJOntA oWe8KB996fi1/dJzBKjCH9bYkp1z8pZCuFvEnhWFhetBgyHZ+gfwjZsr/bXn+aY719os 9i7crIAOBuM6Z4FDjeDOsf4cYOFXW/XCaSVf7GqyQe1WUftEimUGgwizgUmZ28EMSQ/P 9uULKJUXTqPg/DNX/3AFhg3OlSs/iIbrbbH9eoDkFpSW2oKxdKqBjMTMTVVOGA0NbtTF /IBXKT1U+3Lm68ZARsBLOtR3TxTnGKjdoqnQeMAVeH3AzfYOQUiPsE86L2sZGjsQqtys GA== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rd64a0v53-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Jun 2023 14:18:55 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 35NEIsDd013593 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Jun 2023 14:18:54 GMT Received: from hu-kbajaj-hyd.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Fri, 23 Jun 2023 07:18:50 -0700 From: Komal Bajaj <quic_kbajaj@quicinc.com> To: Andy Gross <agross@kernel.org>, Bjorn Andersson <andersson@kernel.org>, Konrad Dybcio <konrad.dybcio@linaro.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Srinivas Kandagatla <srinivas.kandagatla@linaro.org>, Conor Dooley <conor+dt@kernel.org> CC: <linux-arm-msm@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>, Komal Bajaj <quic_kbajaj@quicinc.com> Subject: [PATCH v4 5/6] soc: qcom: Add LLCC support for multi channel DDR Date: Fri, 23 Jun 2023 19:48:05 +0530 Message-ID: <20230623141806.13388-6-quic_kbajaj@quicinc.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230623141806.13388-1-quic_kbajaj@quicinc.com> References: <20230623141806.13388-1-quic_kbajaj@quicinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: VGSDNmTnx1G88uooTdPkL3WjWYZiBPg7 X-Proofpoint-ORIG-GUID: VGSDNmTnx1G88uooTdPkL3WjWYZiBPg7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-23_08,2023-06-22_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 spamscore=0 phishscore=0 mlxscore=0 adultscore=0 mlxlogscore=833 clxscore=1015 priorityscore=1501 suspectscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306230130 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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1769504151241713858?= X-GMAIL-MSGID: =?utf-8?q?1769504151241713858?= |
Series |
soc: qcom: llcc: Add support for QDU1000/QRU1000
|
|
Commit Message
Komal Bajaj
June 23, 2023, 2:18 p.m. UTC
Add LLCC support for multi channel DDR configuration
based on a feature register. Reading DDR channel
confiuration uses nvmem framework, so select the
dependency in Kconfig. Without this, there will be
errors while building the driver with COMPILE_TEST only.
Signed-off-by: Komal Bajaj <quic_kbajaj@quicinc.com>
---
drivers/soc/qcom/Kconfig | 2 ++
drivers/soc/qcom/llcc-qcom.c | 33 ++++++++++++++++++++++++++++++---
2 files changed, 32 insertions(+), 3 deletions(-)
Comments
On Fri, 23 Jun 2023 at 17:19, Komal Bajaj <quic_kbajaj@quicinc.com> wrote: > > Add LLCC support for multi channel DDR configuration > based on a feature register. Reading DDR channel > confiuration uses nvmem framework, so select the > dependency in Kconfig. Without this, there will be > errors while building the driver with COMPILE_TEST only. > > Signed-off-by: Komal Bajaj <quic_kbajaj@quicinc.com> > --- > drivers/soc/qcom/Kconfig | 2 ++ > drivers/soc/qcom/llcc-qcom.c | 33 ++++++++++++++++++++++++++++++--- > 2 files changed, 32 insertions(+), 3 deletions(-) > > diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig > index a491718f8064..cc9ad41c63aa 100644 > --- a/drivers/soc/qcom/Kconfig > +++ b/drivers/soc/qcom/Kconfig > @@ -64,6 +64,8 @@ config QCOM_LLCC > tristate "Qualcomm Technologies, Inc. LLCC driver" > depends on ARCH_QCOM || COMPILE_TEST > select REGMAP_MMIO > + select NVMEM No need to select NVMEM. The used functions are stubbed if NVMEM is disabled > + select QCOM_SCM > help > Qualcomm Technologies, Inc. platform specific > Last Level Cache Controller(LLCC) driver for platforms such as, > diff --git a/drivers/soc/qcom/llcc-qcom.c b/drivers/soc/qcom/llcc-qcom.c > index 6cf373da5df9..3c29612da1c5 100644 > --- a/drivers/soc/qcom/llcc-qcom.c > +++ b/drivers/soc/qcom/llcc-qcom.c > @@ -12,6 +12,7 @@ > #include <linux/kernel.h> > #include <linux/module.h> > #include <linux/mutex.h> > +#include <linux/nvmem-consumer.h> > #include <linux/of.h> > #include <linux/of_device.h> > #include <linux/regmap.h> > @@ -943,6 +944,19 @@ static int qcom_llcc_cfg_program(struct platform_device *pdev, > return ret; > } > > +static int qcom_llcc_get_cfg_index(struct platform_device *pdev, u8 *cfg_index) > +{ > + int ret; > + > + ret = nvmem_cell_read_u8(&pdev->dev, "multi-chan-ddr", cfg_index); > + if (ret == -ENOENT) { || ret == -EOPNOTSUPP ? > + *cfg_index = 0; > + return 0; > + } > + > + return ret; > +} > + > static int qcom_llcc_remove(struct platform_device *pdev) > { > /* Set the global pointer to a error code to avoid referencing it */ > @@ -975,11 +989,13 @@ static int qcom_llcc_probe(struct platform_device *pdev) > struct device *dev = &pdev->dev; > int ret, i; > struct platform_device *llcc_edac; > - const struct qcom_llcc_config *cfg; > + const struct qcom_llcc_config *cfg, *entry; > const struct llcc_slice_config *llcc_cfg; > u32 sz; > + u8 cfg_index; > u32 version; > struct regmap *regmap; > + u32 num_entries = 0; > > drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL); > if (!drv_data) { > @@ -1040,8 +1056,19 @@ static int qcom_llcc_probe(struct platform_device *pdev) > > drv_data->version = version; > > - llcc_cfg = cfg[0]->sct_data; > - sz = cfg[0]->size; > + ret = qcom_llcc_get_cfg_index(pdev, &cfg_index); > + if (ret) > + goto err; > + > + for (entry = cfg; entry->sct_data; entry++, num_entries++) > + ; Please add num_cfgs to the configuration data instead. > + if (cfg_index >= num_entries || cfg_index < 0) { cfg_index is unsigned, so it can not be less than 0. > + ret = -EINVAL; > + goto err; > + } > + > + llcc_cfg = cfg[cfg_index].sct_data; > + sz = cfg[cfg_index].size; > > for (i = 0; i < sz; i++) > if (llcc_cfg[i].slice_id > drv_data->max_slices) > -- > 2.40.1 >
On 23.06.2023 16:18, Komal Bajaj wrote: > Add LLCC support for multi channel DDR configuration > based on a feature register. Reading DDR channel > confiuration uses nvmem framework, so select the > dependency in Kconfig. Without this, there will be > errors while building the driver with COMPILE_TEST only. > > Signed-off-by: Komal Bajaj <quic_kbajaj@quicinc.com> > --- > drivers/soc/qcom/Kconfig | 2 ++ > drivers/soc/qcom/llcc-qcom.c | 33 ++++++++++++++++++++++++++++++--- > 2 files changed, 32 insertions(+), 3 deletions(-) > > diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig > index a491718f8064..cc9ad41c63aa 100644 > --- a/drivers/soc/qcom/Kconfig > +++ b/drivers/soc/qcom/Kconfig > @@ -64,6 +64,8 @@ config QCOM_LLCC > tristate "Qualcomm Technologies, Inc. LLCC driver" > depends on ARCH_QCOM || COMPILE_TEST > select REGMAP_MMIO > + select NVMEM > + select QCOM_SCM > help > Qualcomm Technologies, Inc. platform specific > Last Level Cache Controller(LLCC) driver for platforms such as, > diff --git a/drivers/soc/qcom/llcc-qcom.c b/drivers/soc/qcom/llcc-qcom.c > index 6cf373da5df9..3c29612da1c5 100644 > --- a/drivers/soc/qcom/llcc-qcom.c > +++ b/drivers/soc/qcom/llcc-qcom.c > @@ -12,6 +12,7 @@ > #include <linux/kernel.h> > #include <linux/module.h> > #include <linux/mutex.h> > +#include <linux/nvmem-consumer.h> > #include <linux/of.h> > #include <linux/of_device.h> > #include <linux/regmap.h> > @@ -943,6 +944,19 @@ static int qcom_llcc_cfg_program(struct platform_device *pdev, > return ret; > } > > +static int qcom_llcc_get_cfg_index(struct platform_device *pdev, u8 *cfg_index) > +{ > + int ret; > + > + ret = nvmem_cell_read_u8(&pdev->dev, "multi-chan-ddr", cfg_index); > + if (ret == -ENOENT) { > + *cfg_index = 0; > + return 0; > + } > + > + return ret; > +} > + > static int qcom_llcc_remove(struct platform_device *pdev) > { > /* Set the global pointer to a error code to avoid referencing it */ > @@ -975,11 +989,13 @@ static int qcom_llcc_probe(struct platform_device *pdev) > struct device *dev = &pdev->dev; > int ret, i; > struct platform_device *llcc_edac; > - const struct qcom_llcc_config *cfg; > + const struct qcom_llcc_config *cfg, *entry; > const struct llcc_slice_config *llcc_cfg; > u32 sz; > + u8 cfg_index; > u32 version; > struct regmap *regmap; > + u32 num_entries = 0; > > drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL); > if (!drv_data) { > @@ -1040,8 +1056,19 @@ static int qcom_llcc_probe(struct platform_device *pdev) > > drv_data->version = version; > > - llcc_cfg = cfg[0]->sct_data; > - sz = cfg[0]->size; > + ret = qcom_llcc_get_cfg_index(pdev, &cfg_index); > + if (ret) > + goto err; > + > + for (entry = cfg; entry->sct_data; entry++, num_entries++) > + ; > + if (cfg_index >= num_entries || cfg_index < 0) { cfg_index is an unsigned variable, it can never be < 0 > + ret = -EINVAL; > + goto err; > + } > + if (cfg_index >= entry->size)? With that, you can also keep the config entries non-0-terminated in the previous patch, saving a whole lot of RAM. Konrad > + llcc_cfg = cfg[cfg_index].sct_data; > + sz = cfg[cfg_index].size; > > for (i = 0; i < sz; i++) > if (llcc_cfg[i].slice_id > drv_data->max_slices)
On 6/23/2023 8:28 PM, Konrad Dybcio wrote: > On 23.06.2023 16:18, Komal Bajaj wrote: >> Add LLCC support for multi channel DDR configuration >> based on a feature register. Reading DDR channel >> confiuration uses nvmem framework, so select the >> dependency in Kconfig. Without this, there will be >> errors while building the driver with COMPILE_TEST only. >> >> Signed-off-by: Komal Bajaj <quic_kbajaj@quicinc.com> >> --- >> drivers/soc/qcom/Kconfig | 2 ++ >> drivers/soc/qcom/llcc-qcom.c | 33 ++++++++++++++++++++++++++++++--- >> 2 files changed, 32 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig >> index a491718f8064..cc9ad41c63aa 100644 >> --- a/drivers/soc/qcom/Kconfig >> +++ b/drivers/soc/qcom/Kconfig >> @@ -64,6 +64,8 @@ config QCOM_LLCC >> tristate "Qualcomm Technologies, Inc. LLCC driver" >> depends on ARCH_QCOM || COMPILE_TEST >> select REGMAP_MMIO >> + select NVMEM >> + select QCOM_SCM >> help >> Qualcomm Technologies, Inc. platform specific >> Last Level Cache Controller(LLCC) driver for platforms such as, >> diff --git a/drivers/soc/qcom/llcc-qcom.c b/drivers/soc/qcom/llcc-qcom.c >> index 6cf373da5df9..3c29612da1c5 100644 >> --- a/drivers/soc/qcom/llcc-qcom.c >> +++ b/drivers/soc/qcom/llcc-qcom.c >> @@ -12,6 +12,7 @@ >> #include <linux/kernel.h> >> #include <linux/module.h> >> #include <linux/mutex.h> >> +#include <linux/nvmem-consumer.h> >> #include <linux/of.h> >> #include <linux/of_device.h> >> #include <linux/regmap.h> >> @@ -943,6 +944,19 @@ static int qcom_llcc_cfg_program(struct platform_device *pdev, >> return ret; >> } >> >> +static int qcom_llcc_get_cfg_index(struct platform_device *pdev, u8 *cfg_index) >> +{ >> + int ret; >> + >> + ret = nvmem_cell_read_u8(&pdev->dev, "multi-chan-ddr", cfg_index); >> + if (ret == -ENOENT) { >> + *cfg_index = 0; >> + return 0; >> + } >> + >> + return ret; >> +} >> + >> static int qcom_llcc_remove(struct platform_device *pdev) >> { >> /* Set the global pointer to a error code to avoid referencing it */ >> @@ -975,11 +989,13 @@ static int qcom_llcc_probe(struct platform_device *pdev) >> struct device *dev = &pdev->dev; >> int ret, i; >> struct platform_device *llcc_edac; >> - const struct qcom_llcc_config *cfg; >> + const struct qcom_llcc_config *cfg, *entry; >> const struct llcc_slice_config *llcc_cfg; >> u32 sz; >> + u8 cfg_index; >> u32 version; >> struct regmap *regmap; >> + u32 num_entries = 0; >> >> drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL); >> if (!drv_data) { >> @@ -1040,8 +1056,19 @@ static int qcom_llcc_probe(struct platform_device *pdev) >> >> drv_data->version = version; >> >> - llcc_cfg = cfg[0]->sct_data; >> - sz = cfg[0]->size; >> + ret = qcom_llcc_get_cfg_index(pdev, &cfg_index); >> + if (ret) >> + goto err; >> + > >> + for (entry = cfg; entry->sct_data; entry++, num_entries++) >> + ; >> + if (cfg_index >= num_entries || cfg_index < 0) { > cfg_index is an unsigned variable, it can never be < 0 Okay, will remove this condition. > >> + ret = -EINVAL; >> + goto err; >> + } >> + > if (cfg_index >= entry->size)? With that, you can also keep the config > entries non-0-terminated in the previous patch, saving a whole lot of RAM. entry->size represents the size of sct table whereas num_entries represents the number of sct tables that we can have. And by this check we are validating the value read from the fuse register. Am I understanding your comment correctly? > > Konrad >> + llcc_cfg = cfg[cfg_index].sct_data; >> + sz = cfg[cfg_index].size; >> >> for (i = 0; i < sz; i++) >> if (llcc_cfg[i].slice_id > drv_data->max_slices)
On 28.06.2023 10:52, Komal Bajaj wrote: > > > On 6/23/2023 8:28 PM, Konrad Dybcio wrote: >> On 23.06.2023 16:18, Komal Bajaj wrote: >>> Add LLCC support for multi channel DDR configuration >>> based on a feature register. Reading DDR channel >>> confiuration uses nvmem framework, so select the >>> dependency in Kconfig. Without this, there will be >>> errors while building the driver with COMPILE_TEST only. >>> >>> Signed-off-by: Komal Bajaj <quic_kbajaj@quicinc.com> >>> --- >>> drivers/soc/qcom/Kconfig | 2 ++ >>> drivers/soc/qcom/llcc-qcom.c | 33 ++++++++++++++++++++++++++++++--- >>> 2 files changed, 32 insertions(+), 3 deletions(-) >>> >>> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig >>> index a491718f8064..cc9ad41c63aa 100644 >>> --- a/drivers/soc/qcom/Kconfig >>> +++ b/drivers/soc/qcom/Kconfig >>> @@ -64,6 +64,8 @@ config QCOM_LLCC >>> tristate "Qualcomm Technologies, Inc. LLCC driver" >>> depends on ARCH_QCOM || COMPILE_TEST >>> select REGMAP_MMIO >>> + select NVMEM >>> + select QCOM_SCM >>> help >>> Qualcomm Technologies, Inc. platform specific >>> Last Level Cache Controller(LLCC) driver for platforms such as, >>> diff --git a/drivers/soc/qcom/llcc-qcom.c b/drivers/soc/qcom/llcc-qcom.c >>> index 6cf373da5df9..3c29612da1c5 100644 >>> --- a/drivers/soc/qcom/llcc-qcom.c >>> +++ b/drivers/soc/qcom/llcc-qcom.c >>> @@ -12,6 +12,7 @@ >>> #include <linux/kernel.h> >>> #include <linux/module.h> >>> #include <linux/mutex.h> >>> +#include <linux/nvmem-consumer.h> >>> #include <linux/of.h> >>> #include <linux/of_device.h> >>> #include <linux/regmap.h> >>> @@ -943,6 +944,19 @@ static int qcom_llcc_cfg_program(struct platform_device *pdev, >>> return ret; >>> } >>> +static int qcom_llcc_get_cfg_index(struct platform_device *pdev, u8 *cfg_index) >>> +{ >>> + int ret; >>> + >>> + ret = nvmem_cell_read_u8(&pdev->dev, "multi-chan-ddr", cfg_index); >>> + if (ret == -ENOENT) { >>> + *cfg_index = 0; >>> + return 0; >>> + } >>> + >>> + return ret; >>> +} >>> + >>> static int qcom_llcc_remove(struct platform_device *pdev) >>> { >>> /* Set the global pointer to a error code to avoid referencing it */ >>> @@ -975,11 +989,13 @@ static int qcom_llcc_probe(struct platform_device *pdev) >>> struct device *dev = &pdev->dev; >>> int ret, i; >>> struct platform_device *llcc_edac; >>> - const struct qcom_llcc_config *cfg; >>> + const struct qcom_llcc_config *cfg, *entry; >>> const struct llcc_slice_config *llcc_cfg; >>> u32 sz; >>> + u8 cfg_index; >>> u32 version; >>> struct regmap *regmap; >>> + u32 num_entries = 0; >>> drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL); >>> if (!drv_data) { >>> @@ -1040,8 +1056,19 @@ static int qcom_llcc_probe(struct platform_device *pdev) >>> drv_data->version = version; >>> - llcc_cfg = cfg[0]->sct_data; >>> - sz = cfg[0]->size; >>> + ret = qcom_llcc_get_cfg_index(pdev, &cfg_index); >>> + if (ret) >>> + goto err; >>> + >> >>> + for (entry = cfg; entry->sct_data; entry++, num_entries++) >>> + ; >>> + if (cfg_index >= num_entries || cfg_index < 0) { >> cfg_index is an unsigned variable, it can never be < 0 > > Okay, will remove this condition. > >> >>> + ret = -EINVAL; >>> + goto err; >>> + } >>> + >> if (cfg_index >= entry->size)? With that, you can also keep the config >> entries non-0-terminated in the previous patch, saving a whole lot of RAM. > > entry->size represents the size of sct table whereas num_entries represents the number > of sct tables that we can have. And by this check we are validating the value read from the > fuse register. Am I understanding your comment correctly? Oh you're right. I still see room for improvement, though. For example, you duplicate assigning need_llcc_cfg, reg_offset and edac_reg_offset. You can add a new struct, like "sct_config" and add a pointer to sct_config[] & the length of this array to qcom_llcc_config. Konrad > >> >> Konrad >>> + llcc_cfg = cfg[cfg_index].sct_data; >>> + sz = cfg[cfg_index].size; >>> for (i = 0; i < sz; i++) >>> if (llcc_cfg[i].slice_id > drv_data->max_slices) >
On 28/06/2023 11:45, Komal Bajaj wrote: No HTML emails on public mailing lists, please. > > > On 6/23/2023 7:56 PM, Dmitry Baryshkov wrote: >> On Fri, 23 Jun 2023 at 17:19, Komal Bajaj<quic_kbajaj@quicinc.com> wrote: >>> Add LLCC support for multi channel DDR configuration >>> based on a feature register. Reading DDR channel >>> confiuration uses nvmem framework, so select the >>> dependency in Kconfig. Without this, there will be >>> errors while building the driver with COMPILE_TEST only. >>> >>> Signed-off-by: Komal Bajaj<quic_kbajaj@quicinc.com> >>> --- >>> drivers/soc/qcom/Kconfig | 2 ++ >>> drivers/soc/qcom/llcc-qcom.c | 33 ++++++++++++++++++++++++++++++--- >>> 2 files changed, 32 insertions(+), 3 deletions(-) >>> >>> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig >>> index a491718f8064..cc9ad41c63aa 100644 >>> --- a/drivers/soc/qcom/Kconfig >>> +++ b/drivers/soc/qcom/Kconfig >>> @@ -64,6 +64,8 @@ config QCOM_LLCC >>> tristate "Qualcomm Technologies, Inc. LLCC driver" >>> depends on ARCH_QCOM || COMPILE_TEST >>> select REGMAP_MMIO >>> + select NVMEM >> No need to select NVMEM. The used functions are stubbed if NVMEM is disabled > > With the previous patch, where this config was not selected, below error > was flagged by kernel test robot - > > drivers/soc/qcom/llcc-qcom.c: In function 'qcom_llcc_get_cfg_index': > >> drivers/soc/qcom/llcc-qcom.c:951:15: error: implicit declaration > of function 'nvmem_cell_read_u8'; did you mean > 'nvmem_cell_read_u64'? [-Werror=implicit-function-declaration] > 951 | ret = nvmem_cell_read_u8(&pdev->dev, > "multi_chan_ddr", cfg_index); > | ^~~~~~~~~~~~~~~~~~ > | nvmem_cell_read_u64 > cc1: some warnings being treated as errors Judging from the rest of nvmem-consumer.h, it appears that not having stubs for this function is an omission. Please fix the header instead. > >>> + select QCOM_SCM >>> help >>> Qualcomm Technologies, Inc. platform specific >>> Last Level Cache Controller(LLCC) driver for platforms such as, >>> diff --git a/drivers/soc/qcom/llcc-qcom.c b/drivers/soc/qcom/llcc-qcom.c >>> index 6cf373da5df9..3c29612da1c5 100644 >>> --- a/drivers/soc/qcom/llcc-qcom.c >>> +++ b/drivers/soc/qcom/llcc-qcom.c >>> @@ -12,6 +12,7 @@ >>> #include <linux/kernel.h> >>> #include <linux/module.h> >>> #include <linux/mutex.h> >>> +#include <linux/nvmem-consumer.h> >>> #include <linux/of.h> >>> #include <linux/of_device.h> >>> #include <linux/regmap.h> >>> @@ -943,6 +944,19 @@ static int qcom_llcc_cfg_program(struct platform_device *pdev, >>> return ret; >>> } >>> >>> +static int qcom_llcc_get_cfg_index(struct platform_device *pdev, u8 *cfg_index) >>> +{ >>> + int ret; >>> + >>> + ret = nvmem_cell_read_u8(&pdev->dev, "multi-chan-ddr", cfg_index); >>> + if (ret == -ENOENT) { >> || ret == -EOPNOTSUPP ? > > Okay > >>> + *cfg_index = 0; >>> + return 0; >>> + } >>> + >>> + return ret; >>> +} >>> + >>> static int qcom_llcc_remove(struct platform_device *pdev) >>> { >>> /* Set the global pointer to a error code to avoid referencing it */ >>> @@ -975,11 +989,13 @@ static int qcom_llcc_probe(struct platform_device *pdev) >>> struct device *dev = &pdev->dev; >>> int ret, i; >>> struct platform_device *llcc_edac; >>> - const struct qcom_llcc_config *cfg; >>> + const struct qcom_llcc_config *cfg, *entry; >>> const struct llcc_slice_config *llcc_cfg; >>> u32 sz; >>> + u8 cfg_index; >>> u32 version; >>> struct regmap *regmap; >>> + u32 num_entries = 0; >>> >>> drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL); >>> if (!drv_data) { >>> @@ -1040,8 +1056,19 @@ static int qcom_llcc_probe(struct platform_device *pdev) >>> >>> drv_data->version = version; >>> >>> - llcc_cfg = cfg[0]->sct_data; >>> - sz = cfg[0]->size; >>> + ret = qcom_llcc_get_cfg_index(pdev, &cfg_index); >>> + if (ret) >>> + goto err; >>> + >>> + for (entry = cfg; entry->sct_data; entry++, num_entries++) >>> + ; >> Please add num_cfgs to the configuration data instead. > > Shall I create a new wrapper struct having a field num_cfg and a pointer > to those cfgs > because configuration data is itself an instance of "struct > qcom_llcc_config" and > we can have multiple instances of it. A wrapper struct is a better approach in my opinion. > > >>> + if (cfg_index >= num_entries || cfg_index < 0) { >> cfg_index is unsigned, so it can not be less than 0. > > Okay. > >>> + ret = -EINVAL; >>> + goto err; >>> + } >>> + >>> + llcc_cfg = cfg[cfg_index].sct_data; >>> + sz = cfg[cfg_index].size; >>> >>> for (i = 0; i < sz; i++) >>> if (llcc_cfg[i].slice_id > drv_data->max_slices) >>> -- >>> 2.40.1 >>> >
On 6/28/2023 4:43 PM, Konrad Dybcio wrote: > On 28.06.2023 10:52, Komal Bajaj wrote: >> >> On 6/23/2023 8:28 PM, Konrad Dybcio wrote: >>> On 23.06.2023 16:18, Komal Bajaj wrote: >>>> Add LLCC support for multi channel DDR configuration >>>> based on a feature register. Reading DDR channel >>>> confiuration uses nvmem framework, so select the >>>> dependency in Kconfig. Without this, there will be >>>> errors while building the driver with COMPILE_TEST only. >>>> >>>> Signed-off-by: Komal Bajaj <quic_kbajaj@quicinc.com> >>>> --- >>>> drivers/soc/qcom/Kconfig | 2 ++ >>>> drivers/soc/qcom/llcc-qcom.c | 33 ++++++++++++++++++++++++++++++--- >>>> 2 files changed, 32 insertions(+), 3 deletions(-) >>>> >>>> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig >>>> index a491718f8064..cc9ad41c63aa 100644 >>>> --- a/drivers/soc/qcom/Kconfig >>>> +++ b/drivers/soc/qcom/Kconfig >>>> @@ -64,6 +64,8 @@ config QCOM_LLCC >>>> tristate "Qualcomm Technologies, Inc. LLCC driver" >>>> depends on ARCH_QCOM || COMPILE_TEST >>>> select REGMAP_MMIO >>>> + select NVMEM >>>> + select QCOM_SCM >>>> help >>>> Qualcomm Technologies, Inc. platform specific >>>> Last Level Cache Controller(LLCC) driver for platforms such as, >>>> diff --git a/drivers/soc/qcom/llcc-qcom.c b/drivers/soc/qcom/llcc-qcom.c >>>> index 6cf373da5df9..3c29612da1c5 100644 >>>> --- a/drivers/soc/qcom/llcc-qcom.c >>>> +++ b/drivers/soc/qcom/llcc-qcom.c >>>> @@ -12,6 +12,7 @@ >>>> #include <linux/kernel.h> >>>> #include <linux/module.h> >>>> #include <linux/mutex.h> >>>> +#include <linux/nvmem-consumer.h> >>>> #include <linux/of.h> >>>> #include <linux/of_device.h> >>>> #include <linux/regmap.h> >>>> @@ -943,6 +944,19 @@ static int qcom_llcc_cfg_program(struct platform_device *pdev, >>>> return ret; >>>> } >>>> +static int qcom_llcc_get_cfg_index(struct platform_device *pdev, u8 *cfg_index) >>>> +{ >>>> + int ret; >>>> + >>>> + ret = nvmem_cell_read_u8(&pdev->dev, "multi-chan-ddr", cfg_index); >>>> + if (ret == -ENOENT) { >>>> + *cfg_index = 0; >>>> + return 0; >>>> + } >>>> + >>>> + return ret; >>>> +} >>>> + >>>> static int qcom_llcc_remove(struct platform_device *pdev) >>>> { >>>> /* Set the global pointer to a error code to avoid referencing it */ >>>> @@ -975,11 +989,13 @@ static int qcom_llcc_probe(struct platform_device *pdev) >>>> struct device *dev = &pdev->dev; >>>> int ret, i; >>>> struct platform_device *llcc_edac; >>>> - const struct qcom_llcc_config *cfg; >>>> + const struct qcom_llcc_config *cfg, *entry; >>>> const struct llcc_slice_config *llcc_cfg; >>>> u32 sz; >>>> + u8 cfg_index; >>>> u32 version; >>>> struct regmap *regmap; >>>> + u32 num_entries = 0; >>>> drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL); >>>> if (!drv_data) { >>>> @@ -1040,8 +1056,19 @@ static int qcom_llcc_probe(struct platform_device *pdev) >>>> drv_data->version = version; >>>> - llcc_cfg = cfg[0]->sct_data; >>>> - sz = cfg[0]->size; >>>> + ret = qcom_llcc_get_cfg_index(pdev, &cfg_index); >>>> + if (ret) >>>> + goto err; >>>> + >>>> + for (entry = cfg; entry->sct_data; entry++, num_entries++) >>>> + ; >>>> + if (cfg_index >= num_entries || cfg_index < 0) { >>> cfg_index is an unsigned variable, it can never be < 0 >> Okay, will remove this condition. >> >>>> + ret = -EINVAL; >>>> + goto err; >>>> + } >>>> + >>> if (cfg_index >= entry->size)? With that, you can also keep the config >>> entries non-0-terminated in the previous patch, saving a whole lot of RAM. >> entry->size represents the size of sct table whereas num_entries represents the number >> of sct tables that we can have. And by this check we are validating the value read from the >> fuse register. Am I understanding your comment correctly? > Oh you're right. > > I still see room for improvement, though. > > For example, you duplicate assigning need_llcc_cfg, reg_offset > and edac_reg_offset. You can add a new struct, like "sct_config" and add > a pointer to sct_config[] & the length of this array to qcom_llcc_config. > > Konrad Okay, will follow this approach. > >>> Konrad >>>> + llcc_cfg = cfg[cfg_index].sct_data; >>>> + sz = cfg[cfg_index].size; >>>> for (i = 0; i < sz; i++) >>>> if (llcc_cfg[i].slice_id > drv_data->max_slices)
On 6/28/2023 6:44 PM, Dmitry Baryshkov wrote: > On 28/06/2023 11:45, Komal Bajaj wrote: > > No HTML emails on public mailing lists, please. > >> >> >> On 6/23/2023 7:56 PM, Dmitry Baryshkov wrote: >>> On Fri, 23 Jun 2023 at 17:19, Komal Bajaj<quic_kbajaj@quicinc.com> >>> wrote: >>>> Add LLCC support for multi channel DDR configuration >>>> based on a feature register. Reading DDR channel >>>> confiuration uses nvmem framework, so select the >>>> dependency in Kconfig. Without this, there will be >>>> errors while building the driver with COMPILE_TEST only. >>>> >>>> Signed-off-by: Komal Bajaj<quic_kbajaj@quicinc.com> >>>> --- >>>> drivers/soc/qcom/Kconfig | 2 ++ >>>> drivers/soc/qcom/llcc-qcom.c | 33 ++++++++++++++++++++++++++++++--- >>>> 2 files changed, 32 insertions(+), 3 deletions(-) >>>> >>>> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig >>>> index a491718f8064..cc9ad41c63aa 100644 >>>> --- a/drivers/soc/qcom/Kconfig >>>> +++ b/drivers/soc/qcom/Kconfig >>>> @@ -64,6 +64,8 @@ config QCOM_LLCC >>>> tristate "Qualcomm Technologies, Inc. LLCC driver" >>>> depends on ARCH_QCOM || COMPILE_TEST >>>> select REGMAP_MMIO >>>> + select NVMEM >>> No need to select NVMEM. The used functions are stubbed if NVMEM is >>> disabled >> >> With the previous patch, where this config was not selected, below >> error was flagged by kernel test robot - >> >> drivers/soc/qcom/llcc-qcom.c: In function 'qcom_llcc_get_cfg_index': >> >> drivers/soc/qcom/llcc-qcom.c:951:15: error: implicit declaration >> of function 'nvmem_cell_read_u8'; did you mean >> 'nvmem_cell_read_u64'? [-Werror=implicit-function-declaration] >> 951 | ret = nvmem_cell_read_u8(&pdev->dev, >> "multi_chan_ddr", cfg_index); >> | ^~~~~~~~~~~~~~~~~~ >> | nvmem_cell_read_u64 >> cc1: some warnings being treated as errors > > Judging from the rest of nvmem-consumer.h, it appears that not having > stubs for this function is an omission. Please fix the header instead. Okay, I will add the stub for this function in the header. > >> >>>> + select QCOM_SCM >>>> help >>>> Qualcomm Technologies, Inc. platform specific >>>> Last Level Cache Controller(LLCC) driver for platforms >>>> such as, >>>> diff --git a/drivers/soc/qcom/llcc-qcom.c >>>> b/drivers/soc/qcom/llcc-qcom.c >>>> index 6cf373da5df9..3c29612da1c5 100644 >>>> --- a/drivers/soc/qcom/llcc-qcom.c >>>> +++ b/drivers/soc/qcom/llcc-qcom.c >>>> @@ -12,6 +12,7 @@ >>>> #include <linux/kernel.h> >>>> #include <linux/module.h> >>>> #include <linux/mutex.h> >>>> +#include <linux/nvmem-consumer.h> >>>> #include <linux/of.h> >>>> #include <linux/of_device.h> >>>> #include <linux/regmap.h> >>>> @@ -943,6 +944,19 @@ static int qcom_llcc_cfg_program(struct >>>> platform_device *pdev, >>>> return ret; >>>> } >>>> >>>> +static int qcom_llcc_get_cfg_index(struct platform_device *pdev, >>>> u8 *cfg_index) >>>> +{ >>>> + int ret; >>>> + >>>> + ret = nvmem_cell_read_u8(&pdev->dev, "multi-chan-ddr", >>>> cfg_index); >>>> + if (ret == -ENOENT) { >>> || ret == -EOPNOTSUPP ? >> >> Okay >> >>>> + *cfg_index = 0; >>>> + return 0; >>>> + } >>>> + >>>> + return ret; >>>> +} >>>> + >>>> static int qcom_llcc_remove(struct platform_device *pdev) >>>> { >>>> /* Set the global pointer to a error code to avoid >>>> referencing it */ >>>> @@ -975,11 +989,13 @@ static int qcom_llcc_probe(struct >>>> platform_device *pdev) >>>> struct device *dev = &pdev->dev; >>>> int ret, i; >>>> struct platform_device *llcc_edac; >>>> - const struct qcom_llcc_config *cfg; >>>> + const struct qcom_llcc_config *cfg, *entry; >>>> const struct llcc_slice_config *llcc_cfg; >>>> u32 sz; >>>> + u8 cfg_index; >>>> u32 version; >>>> struct regmap *regmap; >>>> + u32 num_entries = 0; >>>> >>>> drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL); >>>> if (!drv_data) { >>>> @@ -1040,8 +1056,19 @@ static int qcom_llcc_probe(struct >>>> platform_device *pdev) >>>> >>>> drv_data->version = version; >>>> >>>> - llcc_cfg = cfg[0]->sct_data; >>>> - sz = cfg[0]->size; >>>> + ret = qcom_llcc_get_cfg_index(pdev, &cfg_index); >>>> + if (ret) >>>> + goto err; >>>> + >>>> + for (entry = cfg; entry->sct_data; entry++, num_entries++) >>>> + ; >>> Please add num_cfgs to the configuration data instead. >> >> Shall I create a new wrapper struct having a field num_cfg and a >> pointer to those cfgs >> because configuration data is itself an instance of "struct >> qcom_llcc_config" and >> we can have multiple instances of it. > > A wrapper struct is a better approach in my opinion. Okay, will follow this approach then. Thanks Komal > >> >> >>>> + if (cfg_index >= num_entries || cfg_index < 0) { >>> cfg_index is unsigned, so it can not be less than 0. >> >> Okay. >> >>>> + ret = -EINVAL; >>>> + goto err; >>>> + } >>>> + >>>> + llcc_cfg = cfg[cfg_index].sct_data; >>>> + sz = cfg[cfg_index].size; >>>> >>>> for (i = 0; i < sz; i++) >>>> if (llcc_cfg[i].slice_id > drv_data->max_slices) >>>> -- >>>> 2.40.1 >>>> >> >
On Fri, Jun 23, 2023 at 07:48:05PM +0530, Komal Bajaj wrote: > Add LLCC support for multi channel DDR configuration > based on a feature register. Reading DDR channel > confiuration uses nvmem framework, so select the > dependency in Kconfig. Without this, there will be > errors while building the driver with COMPILE_TEST only. You may drop the last sentence, I don't think it's entirely correct. > > Signed-off-by: Komal Bajaj <quic_kbajaj@quicinc.com> > --- > drivers/soc/qcom/Kconfig | 2 ++ > drivers/soc/qcom/llcc-qcom.c | 33 ++++++++++++++++++++++++++++++--- > 2 files changed, 32 insertions(+), 3 deletions(-) > > diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig > index a491718f8064..cc9ad41c63aa 100644 > --- a/drivers/soc/qcom/Kconfig > +++ b/drivers/soc/qcom/Kconfig > @@ -64,6 +64,8 @@ config QCOM_LLCC > tristate "Qualcomm Technologies, Inc. LLCC driver" > depends on ARCH_QCOM || COMPILE_TEST > select REGMAP_MMIO > + select NVMEM > + select QCOM_SCM I don't see anything your patch that warrants adding QCOM_SCM here, is it needed, should it be a separate commit? > help > Qualcomm Technologies, Inc. platform specific > Last Level Cache Controller(LLCC) driver for platforms such as, > diff --git a/drivers/soc/qcom/llcc-qcom.c b/drivers/soc/qcom/llcc-qcom.c > index 6cf373da5df9..3c29612da1c5 100644 > --- a/drivers/soc/qcom/llcc-qcom.c > +++ b/drivers/soc/qcom/llcc-qcom.c > @@ -12,6 +12,7 @@ > #include <linux/kernel.h> > #include <linux/module.h> > #include <linux/mutex.h> > +#include <linux/nvmem-consumer.h> > #include <linux/of.h> > #include <linux/of_device.h> > #include <linux/regmap.h> > @@ -943,6 +944,19 @@ static int qcom_llcc_cfg_program(struct platform_device *pdev, > return ret; > } > > +static int qcom_llcc_get_cfg_index(struct platform_device *pdev, u8 *cfg_index) > +{ > + int ret; > + > + ret = nvmem_cell_read_u8(&pdev->dev, "multi-chan-ddr", cfg_index); > + if (ret == -ENOENT) { > + *cfg_index = 0; > + return 0; > + } > + > + return ret; > +} > + > static int qcom_llcc_remove(struct platform_device *pdev) > { > /* Set the global pointer to a error code to avoid referencing it */ > @@ -975,11 +989,13 @@ static int qcom_llcc_probe(struct platform_device *pdev) > struct device *dev = &pdev->dev; > int ret, i; > struct platform_device *llcc_edac; > - const struct qcom_llcc_config *cfg; > + const struct qcom_llcc_config *cfg, *entry; > const struct llcc_slice_config *llcc_cfg; > u32 sz; > + u8 cfg_index; > u32 version; > struct regmap *regmap; > + u32 num_entries = 0; > > drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL); > if (!drv_data) { > @@ -1040,8 +1056,19 @@ static int qcom_llcc_probe(struct platform_device *pdev) > > drv_data->version = version; > > - llcc_cfg = cfg[0]->sct_data; > - sz = cfg[0]->size; > + ret = qcom_llcc_get_cfg_index(pdev, &cfg_index); > + if (ret) > + goto err; > + > + for (entry = cfg; entry->sct_data; entry++, num_entries++) > + ; This is still unnecessarily "clever": "For each valid entry, do nothing, while incrementing num_entries". How about just writing: "For each valid entry, increment num_entries" for (entry = cfg; entry->sct_data; entry++) num_entries++; > + if (cfg_index >= num_entries || cfg_index < 0) { cfg_index is an unsiged number, so it's unlikely to be negative. Also, "cfg_index" and "num_entries" are values in the same domain, so keeping their names related is beneficial - i.e. rename num_entries to num_cfgs. Regards, Bjorn > + ret = -EINVAL; > + goto err; > + } > + > + llcc_cfg = cfg[cfg_index].sct_data; > + sz = cfg[cfg_index].size; > > for (i = 0; i < sz; i++) > if (llcc_cfg[i].slice_id > drv_data->max_slices) > -- > 2.40.1 >
diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index a491718f8064..cc9ad41c63aa 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -64,6 +64,8 @@ config QCOM_LLCC tristate "Qualcomm Technologies, Inc. LLCC driver" depends on ARCH_QCOM || COMPILE_TEST select REGMAP_MMIO + select NVMEM + select QCOM_SCM help Qualcomm Technologies, Inc. platform specific Last Level Cache Controller(LLCC) driver for platforms such as, diff --git a/drivers/soc/qcom/llcc-qcom.c b/drivers/soc/qcom/llcc-qcom.c index 6cf373da5df9..3c29612da1c5 100644 --- a/drivers/soc/qcom/llcc-qcom.c +++ b/drivers/soc/qcom/llcc-qcom.c @@ -12,6 +12,7 @@ #include <linux/kernel.h> #include <linux/module.h> #include <linux/mutex.h> +#include <linux/nvmem-consumer.h> #include <linux/of.h> #include <linux/of_device.h> #include <linux/regmap.h> @@ -943,6 +944,19 @@ static int qcom_llcc_cfg_program(struct platform_device *pdev, return ret; } +static int qcom_llcc_get_cfg_index(struct platform_device *pdev, u8 *cfg_index) +{ + int ret; + + ret = nvmem_cell_read_u8(&pdev->dev, "multi-chan-ddr", cfg_index); + if (ret == -ENOENT) { + *cfg_index = 0; + return 0; + } + + return ret; +} + static int qcom_llcc_remove(struct platform_device *pdev) { /* Set the global pointer to a error code to avoid referencing it */ @@ -975,11 +989,13 @@ static int qcom_llcc_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; int ret, i; struct platform_device *llcc_edac; - const struct qcom_llcc_config *cfg; + const struct qcom_llcc_config *cfg, *entry; const struct llcc_slice_config *llcc_cfg; u32 sz; + u8 cfg_index; u32 version; struct regmap *regmap; + u32 num_entries = 0; drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL); if (!drv_data) { @@ -1040,8 +1056,19 @@ static int qcom_llcc_probe(struct platform_device *pdev) drv_data->version = version; - llcc_cfg = cfg[0]->sct_data; - sz = cfg[0]->size; + ret = qcom_llcc_get_cfg_index(pdev, &cfg_index); + if (ret) + goto err; + + for (entry = cfg; entry->sct_data; entry++, num_entries++) + ; + if (cfg_index >= num_entries || cfg_index < 0) { + ret = -EINVAL; + goto err; + } + + llcc_cfg = cfg[cfg_index].sct_data; + sz = cfg[cfg_index].size; for (i = 0; i < sz; i++) if (llcc_cfg[i].slice_id > drv_data->max_slices)