Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp921825rdb; Wed, 6 Dec 2023 04:03:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpVfH5veIT5rwxnO/j28rxuEHU2qAauOGEztZ5DtXiTISGKnkbDSB6slKVEcTIChEJNo2U X-Received: by 2002:a05:6a00:1490:b0:6ce:4d11:4e32 with SMTP id v16-20020a056a00149000b006ce4d114e32mr967451pfu.27.1701864186506; Wed, 06 Dec 2023 04:03:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701864186; cv=none; d=google.com; s=arc-20160816; b=B+wwi6dkxXg1F0/mTmZhId/JDjOQXg0t2m3wyJX7GGowZ38VMr8rWjs3suixgSuBKL ekrqDgMOcQmJR6XTgEs9QzklxuVcWpswvMOBzOln5WCpxQikL/oM5bUbYXmnXM++BOPO /h/SSZqCCmBmGjoYEPoD+uIWzzDvqq8CtY88h0C2o8YoLcn9r/QkY53dXXoaL5eDvysL ZyptgM1+ifYDv3Qp1FHuOj5YcG9wKlCXyMc3QB0IyqCLZDYt5SJXadaMsZBh9Sb3EYMC 3HSgdjTRYbkWzL6/d79lvx6dF27mMitCiGRNOTPiU7d8cjz6mbeGSqVErT/4H52rhPLL xb/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=2VPIT88/TYjvhaEGfNYEzItSXIrOPwHfQN6lkzf+37w=; fh=YwBRAcw9ZSQmm9+GybNK/ZQSJGBeKOZK83ZQ/jHhYmc=; b=jO2WgcJON6ER296s4IJbQiBJDKVmL7HmdCPb0knqITl8j8EwLGFw9n/0sigQYwP2dX Cn1JoY8bZy5T05LP7ReWcffnT4ddWyNjt5bxAxg7J0rH/deFwJcTpG5WXH8MYPX+GxX+ 4kNLTSfjLP1V2SG3iJAbI7Fm2I3Z7AQPikjhW8GEHVupPy3zLu5jQQ33VNJc7F+RLgWo rUpoZKBM4Ajbutyg6rpvf7RUvLLumzbIG4IE347LQRaN2K6J/sx/b0UDhHxKIGEUJPkb KCkXQ1zM0C385j2a5RLlCtNT6xXGf/mG/gdH6ogQQM0L9cOW/vBLEmrPf7uUoCioSLXy rvbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iSWB1cH6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id h17-20020a056a00219100b006cdf20980fasi10559487pfi.80.2023.12.06.04.03.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 04:03:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iSWB1cH6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 20DDF809989E; Wed, 6 Dec 2023 04:03:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378256AbjLFMCu (ORCPT + 99 others); Wed, 6 Dec 2023 07:02:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378270AbjLFMCs (ORCPT ); Wed, 6 Dec 2023 07:02:48 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCFF81A5 for ; Wed, 6 Dec 2023 04:02:54 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CB5CC433C7; Wed, 6 Dec 2023 12:02:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701864174; bh=BiR1najpAX293kKEaaKpGpEKLDwjfEK+NqznOMhkJAY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iSWB1cH6k4OUEUk7A4FwcmEJhcyYVYQbwSOFpocRmdOMoffcD4DIWYZH872z09k44 /8sknIf9xxTRdZX+TAB+WuhaRAcoNAGycn2b7WpNU3wIxcQx1f8X/6yANsgQGUu4sO 1tJU1kaz//IjG0DT+0gSkB5+g3CVaAsRPFE8xyllM9Wx4I8evrBvU/u/KXzA1CJ8OP JNeE/Z5IrGl8Fug6swfSUPGhAv3SzqUjEvcYM225YUpaIj+CTqftJguV4zqugmZo1B o5f1Yg8TmiOBOqTrOF1azKCvlec4DFUUF5nGfomO/QIwrnUgkfTbYdb6gyHGfGE1vF ez3mX3nFcm5IA== Date: Wed, 6 Dec 2023 17:32:46 +0530 From: Manivannan Sadhasivam To: Nitin Rawat Cc: "James E.J. Bottomley" , "Martin K. Petersen" , Krzysztof Kozlowski , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, quic_cang@quicinc.com, Manish Pandey Subject: Re: [PATCH V2] scsi: ufs: core: store min and max clk freq from OPP table Message-ID: <20231206120246.GB12802@thinkpad> References: <20231206114659.13009-1-quic_nitirawa@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231206114659.13009-1-quic_nitirawa@quicinc.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, 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 morse.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 (morse.vger.email [0.0.0.0]); Wed, 06 Dec 2023 04:03:04 -0800 (PST) On Wed, Dec 06, 2023 at 05:16:59PM +0530, Nitin Rawat wrote: > 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 add support to parse the min_freq and max_freq of all clocks while > parsing the OPP table. > > 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 Reviewed-by: Manivannan Sadhasivam Martin, please queue this patch for 6.7-rcS. - Mani > --- > Changes from v1: > As per Manivannan's comment: > - Updated commmit description > - Sort include file alphabetically > - Added missing dev_pm_opp_put > - updated function name and documention > - removed ret variable > --- > drivers/ufs/host/ufshcd-pltfrm.c | 53 ++++++++++++++++++++++++++++++++ > 1 file changed, 53 insertions(+) > > diff --git a/drivers/ufs/host/ufshcd-pltfrm.c b/drivers/ufs/host/ufshcd-pltfrm.c > index da2558e274b4..409efa0db8fa 100644 > --- a/drivers/ufs/host/ufshcd-pltfrm.c > +++ b/drivers/ufs/host/ufshcd-pltfrm.c > @@ -8,6 +8,7 @@ > * Vinayak Holikatti > */ > > +#include > #include > #include > #include > @@ -213,6 +214,54 @@ static void ufshcd_init_lanes_per_dir(struct ufs_hba *hba) > } > } > > +/** > + * ufshcd_parse_clock_min_max_freq - Parse MIN and MAX clocks freq > + * @hba: per adapter instance > + * > + * 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_parse_clock_min_max_freq(struct ufs_hba *hba) > +{ > + struct list_head *head = &hba->clk_list_head; > + struct ufs_clk_info *clki; > + struct dev_pm_opp *opp; > + unsigned long freq; > + u8 idx = 0; > + > + list_for_each_entry(clki, head, list) { > + if (!clki->name) > + continue; > + > + clki->clk = devm_clk_get(hba->dev, clki->name); > + if (!IS_ERR(clki->clk)) { > + /* Find Max Freq */ > + freq = ULONG_MAX; > + opp = dev_pm_opp_find_freq_floor_indexed(hba->dev, &freq, idx); > + if (IS_ERR(opp)) { > + dev_err(hba->dev, "Failed to find OPP for MAX frequency\n"); > + return PTR_ERR(opp); > + } > + clki->max_freq = dev_pm_opp_get_freq_indexed(opp, idx); > + dev_pm_opp_put(opp); > + > + /* 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 OPP for MIN frequency\n"); > + return PTR_ERR(opp); > + } > + clki->min_freq = dev_pm_opp_get_freq_indexed(opp, idx); > + dev_pm_opp_put(opp); > + } > + } > + > + return 0; > +} > + > static int ufshcd_parse_operating_points(struct ufs_hba *hba) > { > struct device *dev = hba->dev; > @@ -279,6 +328,10 @@ static int ufshcd_parse_operating_points(struct ufs_hba *hba) > return ret; > } > > + ret = ufshcd_parse_clock_min_max_freq(hba); > + if (ret) > + return ret; > + > hba->use_pm_opp = true; > > return 0; > -- > 2.17.1 > -- மணிவண்ணன் சதாசிவம்