Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp895883rdb; Wed, 6 Dec 2023 03:09:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhFR+u/4cAW1AwyUT5nk3W2bLUVkdwNnQXKnyYySDVMdrWjGCsawvFWfz+DrWBrLeef1aY X-Received: by 2002:a17:90a:35a:b0:288:8146:cec with SMTP id 26-20020a17090a035a00b0028881460cecmr55064pjf.69.1701860949219; Wed, 06 Dec 2023 03:09:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701860949; cv=none; d=google.com; s=arc-20160816; b=Rfeqf9qIPIBElaJDvnqAO8/KH4920cfd0cZUyn+HHGEVJ+UtSBL0OtjYq6+pfwB0a3 rtC9hmug7B2jJs19hvtdoQrLkeBkK1koexOeEwb1k0lQEERDyqhs52OkVgHFwyujmvjK 9uiMOwGuTW2JX0Gu1PHqGULHZcdtwIb3KrsnNBAhg50HwkRBO9FLPRd/GnkPV4nU2thK yCtoeO/tYvBTqfcJn4Ev365qvEk7OknhmCvTeAhhMycy68KWbRiMT7v+uoVe+dmRmdrb PE4xx4sJJ458oQfPXgOy97g+AkSzaGSKCIsyZg1uqyFfNW35rOHmtnp1ZelcVgXFGjDa NNrQ== 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=KO41K6KCZ2q9y86UP2tuixxqWTDsGs9XPyef5FhT5kQ=; fh=2CDVQj+SsFV5nZzEERijReHmf+eAKXje++W3dEuJpv4=; b=sCIg4xFhSXYYbCejeB8QkhRSgDkCebouYvaZC0xJNBO7n2Y1UllcNlpG2UkWgsJPgq 3P4I0FFEK5sBBmacj1ada0D/IfaePZ/aVmRyIk2+B/mEVn+GOotuYGN3oMrPWX4yPYtL iEFyCt6gmIyakcrm0UisXGxGDPPq4vdEIk+TG80GU+ku+jMkfbc5R+rgvwBI0Ynug0gb nX9arEsdG0MoIkSgr0wo6rSBN8y/z3zr4ZUiaTzPNsuRf3pQjC1A95lcsKbbnVp4//iY Qxu3eEHg/EaNBzRbYzgkuZ7NQbvziVR26uW++zsqlF5s4LkjwMOMIAGpvoI7XJ40H7/+ r3MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=o7JIM2i9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id oo14-20020a17090b1c8e00b002869b531c26si6055017pjb.96.2023.12.06.03.09.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 03:09:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=o7JIM2i9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id C3AE580AC47A; Wed, 6 Dec 2023 03:09:05 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377892AbjLFLIr (ORCPT + 99 others); Wed, 6 Dec 2023 06:08:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378025AbjLFLIp (ORCPT ); Wed, 6 Dec 2023 06:08:45 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 440C510EB; Wed, 6 Dec 2023 03:08:41 -0800 (PST) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B63w8AZ019177; Wed, 6 Dec 2023 11:05:34 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=KO41K6KCZ2q9y86UP2tuixxqWTDsGs9XPyef5FhT5kQ=; b=o7JIM2i9jzM9HEP4gJBaXC5QEIOK40K01kcNv+p8fWTWTG096aL/+Qm/0ulZ00KzBilZ hcH4Y9wf7JmDljD7Pt1kw8/8LKvtlugmJ4ebAdAz7wK1fRUdea3nnHdSHXgzeWNtSGyl p8Qk52XITgEXx4vBYWtcAluNAViXU9kubDo8b2qucBN0xOQ/VgXzqx41gZiGQdmzJTlv /tCqIjXSwqqcULtfvDj983E/LoAVGKGZcnsMeAR+glb3vqrZ/QjkTehciBEBvCt+ukZT S6ZRqO3i8iyynYGGU7XTrn8kMpGwafRR6xlnGi37cLYOZ+B7lEKQCzWFXW+Jca1nYZsX Tw== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3utdmd1922-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Dec 2023 11:05:33 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3B6B5WdS011560 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 6 Dec 2023 11:05:32 GMT Received: from [10.50.48.217] (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.1118.40; Wed, 6 Dec 2023 03:05:28 -0800 Message-ID: Date: Wed, 6 Dec 2023 16:35:24 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.2 Subject: Re: [PATCH V1] scsi: ufs: core: store min and max clk freq from OPP table Content-Language: en-US To: Manivannan Sadhasivam CC: "James E.J. Bottomley" , "Martin K. Petersen" , Matthias Brugger , AngeloGioacchino Del Regno , Krzysztof Kozlowski , , , , , , Manish Pandey References: <20231206053628.32169-1-quic_nitirawa@quicinc.com> <20231206075447.GA4954@thinkpad> From: Nitin Rawat In-Reply-To: <20231206075447.GA4954@thinkpad> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit 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: qSbYtsBwejFTsUUazuBVvGHNKH21h9YI X-Proofpoint-ORIG-GUID: qSbYtsBwejFTsUUazuBVvGHNKH21h9YI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-06_06,2023-12-06_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 spamscore=0 clxscore=1015 impostorscore=0 adultscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312060091 X-Spam-Status: No, score=-4.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 03:09:06 -0800 (PST) On 12/6/2023 1:24 PM, Manivannan Sadhasivam wrote: > On Wed, Dec 06, 2023 at 11:06:28AM +0530, Nitin Rawat wrote: >> OPP support will make use of OPP table in device tree and removes >> freq-table-hz property from device tree. >> >> With OPP enabled in devicetree, clki->min_freq and clki->maxfreq >> currently is not getting updated and the value is set to 0. >> >> Soc vendors like qcom, mediatek uses clki->minfreq and clki->maxfreq >> in vendor specific file. These frequencies values are used to update >> vendor specific configurations. Since the value is 0, it is causing >> functional issue. > > How about, > > "OPP support added by commit 72208ebe181e ("scsi: ufs: core: Add support > for parsing OPP") doesn't update the min_freq and max_freq of each clocks > in 'struct ufs_clk_info'. > > But these values are used by the vendor host drivers internally for controller > configuration. When the OPP support is enabled in devicetree, these values will > be 0, causing boot issues on the respective platforms. > > So let's parse the min_freq and max_freq of all clocks while parsing the OPP > table." > >> >> Add code to store the min and max ufs clk frequency from OPP table. Sure. Will update in next patchset. >> >> Fixes: 72208ebe181e ("scsi: ufs: core: Add support for parsing OPP") >> Co-developed-by: Manish Pandey >> Signed-off-by: Manish Pandey >> Signed-off-by: Nitin Rawat >> --- >> drivers/ufs/host/ufshcd-pltfrm.c | 56 ++++++++++++++++++++++++++++++++ >> 1 file changed, 56 insertions(+) >> >> diff --git a/drivers/ufs/host/ufshcd-pltfrm.c b/drivers/ufs/host/ufshcd-pltfrm.c >> index da2558e274b4..12fa6f7d6a97 100644 >> --- a/drivers/ufs/host/ufshcd-pltfrm.c >> +++ b/drivers/ufs/host/ufshcd-pltfrm.c >> @@ -13,6 +13,7 @@ >> #include >> #include >> #include >> +#include > > Sort includes alphabetically. Sure. Will update in next patchset > >> >> #include >> #include "ufshcd-pltfrm.h" >> @@ -213,6 +214,55 @@ static void ufshcd_init_lanes_per_dir(struct ufs_hba *hba) >> } >> } >> >> +/** >> + * ufshcd_config_min_max_clk_freq - update min and max freq > > "ufshcd_parse_clock_min_max_freq - Parse MIN and MAX frequencies of clocks" > >> + * @hba: per adapter instance >> + * >> + * This function store min and max freq for all the clocks. >> + * > > "This function parses MIN and MAX frequencies of all clocks required by the > vendor host drivers." > >> + * Returns 0 for success and non-zero for failure >> + */ >> +static int ufshcd_config_min_max_clk_freq(struct ufs_hba *hba) >> +{ >> + struct list_head *head = &hba->clk_list_head; >> + struct dev_pm_opp *opp; >> + struct ufs_clk_info *clki; > > Please maintain reverse Xmas tree order. It's not a rule for this driver, but my > own preference. > >> + unsigned long freq; >> + u8 idx = 0; >> + int ret; > > This won't be needed if all the return values are directly returned as I shared > below. Will Addressed all ret comments in next patchset. > >> + >> + list_for_each_entry(clki, head, list) { >> + if (!clki->name) >> + continue; >> + >> + clki->clk = devm_clk_get(hba->dev, clki->name); >> + if (!IS_ERR_OR_NULL(clki->clk)) { > > This function won't return NULL, so IS_ERR() is sufficient. > >> + /* Find Max Freq */ >> + freq = ULONG_MAX; >> + opp = dev_pm_opp_find_freq_floor_indexed(hba->dev, &freq, idx); > > Use idx++ and get rid of the increment at the end of the 'if' condition. If we increment idx++ here, dev_pm_opp_find_freq_ceil_indexed will use incremented idx which is not correct. Hence i added at end after both the call. > >> + if (IS_ERR(opp)) { >> + dev_err(hba->dev, "failed to find dev_pm_opp\n"); > > "Failed to find OPP for MAX frequency" > >> + ret = PTR_ERR(opp); > > return PTR_ERR(opp); > >> + return ret; >> + } >> + clki->max_freq = dev_pm_opp_get_freq_indexed(opp, idx); >> + > > Missing dev_pm_opp_put() Thanks. Will update in next patchset. > >> + /* Find Min Freq */ >> + freq = 0; >> + opp = dev_pm_opp_find_freq_ceil_indexed(hba->dev, &freq, idx); >> + if (IS_ERR(opp)) { >> + dev_err(hba->dev, "failed to find dev_pm_opp\n"); > > "Failed to find OPP for MIN frequency" > >> + ret = PTR_ERR(opp); > > return PTR_ERR(opp); > >> + return ret; >> + } >> + clki->min_freq = dev_pm_opp_get_freq_indexed(opp, idx); > > Missing dev_pm_opp_put() > >> + idx++; >> + } >> + } >> + >> + return 0; >> +} >> + >> static int ufshcd_parse_operating_points(struct ufs_hba *hba) >> { >> struct device *dev = hba->dev; >> @@ -279,6 +329,12 @@ static int ufshcd_parse_operating_points(struct ufs_hba *hba) >> return ret; >> } >> >> + ret = ufshcd_config_min_max_clk_freq(hba); >> + if (ret) { >> + dev_err(dev, "Failed to get min max freq: %d\n", ret); > > Since we already print error message inside the function, no need to do the same > here. Sure. Will update in next patchset > > - Mani > >> + return ret; >> + } >> + >> hba->use_pm_opp = true; >> >> return 0; >> -- >> 2.17.1 >> > Thanks, Nitin