Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp22388579rwd; Fri, 30 Jun 2023 07:27:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7wrMzcPv4ByrwWNr/NI3s+ogfP8rzfIF0ZLqFG65SgLNI/hlLZX58TmaEXNCIrqFUo4sjS X-Received: by 2002:a17:902:e888:b0:1b0:4c6c:716 with SMTP id w8-20020a170902e88800b001b04c6c0716mr9753096plg.4.1688135264617; Fri, 30 Jun 2023 07:27:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688135264; cv=none; d=google.com; s=arc-20160816; b=CPJaKVvax2R9JKdbEJaQDxRPOI/wJ5K0PipxfHoJ9Z+Ze2COVgF9AhHEVdY8HdSRjO g9A5GpBPZFC30iXEWYoGAHgjR0giC1q8bD6hNsLGlChVX3LHBwagSLloXXp62cfmvfEG 1K0777JwuSP1RDrDwgGpjW5H6ivicKfUr70Cjjtl388khxsBk/1/ptvqScLKm3mZI7N4 AeGK7wEvPjTNlnd6ZsYJZMTDq2Zcq94tjmq3Oqu8escoURMTuIHiMhzBxtlBD+kyEOug M8g+E5nELbNlmtsURdbAo7K2S17rci3N2IU0uKMNv+LUGOaGw6iI9F2toyd5j5B01pFw ja2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=7WIZ51abadDkdHK19ZK8eWOhE0e++6LJo77oOIa5j9s=; fh=yy75A3gNbqNGCMOesUoj3R7dSFS+LONWF+j1mfF1dyg=; b=B5hCbKrWnbTJJ5O5p8QgHGRKzV4Gr7NR693e18h1tdPCgAJ8OGjBszJobr4hgq9u5h nraOqBq+kqDZei7rSjS7SgXmtGrpqPrkx5zfp59oMbpYcNYq4M8JMcHit0LAStirvA0J 1zn0JbAPmp+uvyb/w9XfUDhUFKZfReaHL0+PsUArJxZfoNGaRBHZgo9ovZ03VPjXaMUn 1XlO63EKd3QNs19qjzTjYUisVdNOVtQrVIbQYMH+XrJRFgCVyC5RNbsROujXbUhHCeW4 IPKJ13kjUPPlVPGyUJHlzgKs48tvGzl76Aji4+SPH2Z1z5g0UWYGFDHIQBODQhgS1SfY 3G/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="oW4iES/q"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bj20-20020a17090b089400b0025690f8610bsi1542944pjb.59.2023.06.30.07.27.32; Fri, 30 Jun 2023 07:27:44 -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="oW4iES/q"; 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 S232134AbjF3NvY (ORCPT + 99 others); Fri, 30 Jun 2023 09:51:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229522AbjF3NvX (ORCPT ); Fri, 30 Jun 2023 09:51:23 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3368230C5; Fri, 30 Jun 2023 06:51:21 -0700 (PDT) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35UDIOxg001644; Fri, 30 Jun 2023 13:51:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=7WIZ51abadDkdHK19ZK8eWOhE0e++6LJo77oOIa5j9s=; b=oW4iES/q+eQGW0rIGhT9oOCFKvAXztUZt59/b6QDpEVR2rU5PiGe8ylke2ZqyG69DUtq ZAsFPafgjOti6y0MYmBfUCIKywa5yBg/W4c16yl7eV2n3dOXMFUtR18EoQGKRZjyWa+l De0DwUBJ7q/P+jg36+RNlwuW7MNLbzyos6fxhqFhunBLxbM01VdGNbeneeOxJ8/W74E8 zgrnGERU/EuB4IGsiX9TDtEi1SbM5Pp8GaQtADwuRdbgaqQu+ypwUjpmj+aXXDQ0F1mj pVjSfP+7tmk85v3gYeRRssIaHeJPuWA8AN2IyQ1log3XvJQt3stNIAZhEsRG5EcLZTrM xQ== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rhw70rdex-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jun 2023 13:51:17 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 35UDpFu9015689 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jun 2023 13:51:15 GMT Received: from [10.216.15.2] (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.1118.7; Fri, 30 Jun 2023 06:51:11 -0700 Message-ID: <8b5bcae2-f849-ec35-4ea2-e2dd15f42af3@quicinc.com> Date: Fri, 30 Jun 2023 19:21:06 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH v4 5/6] soc: qcom: Add LLCC support for multi channel DDR Content-Language: en-US To: Konrad Dybcio , Andy Gross , Bjorn Andersson , Rob Herring , Krzysztof Kozlowski , Srinivas Kandagatla , Conor Dooley CC: , , References: <20230623141806.13388-1-quic_kbajaj@quicinc.com> <20230623141806.13388-6-quic_kbajaj@quicinc.com> <2dfa5bb8-3189-29f2-a85f-3dd392b27141@linaro.org> From: Komal Bajaj In-Reply-To: <2dfa5bb8-3189-29f2-a85f-3dd392b27141@linaro.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit 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-ORIG-GUID: 6e7LjCh6K7RqGUmlAWDTZwlztv6aOuhM X-Proofpoint-GUID: 6e7LjCh6K7RqGUmlAWDTZwlztv6aOuhM 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-30_05,2023-06-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 mlxlogscore=809 spamscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 lowpriorityscore=0 bulkscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306300118 X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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: X-Mailing-List: linux-kernel@vger.kernel.org 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 >>>> --- >>>>   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 >>>>   #include >>>>   #include >>>> +#include >>>>   #include >>>>   #include >>>>   #include >>>> @@ -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)