Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp801987rdb; Thu, 30 Nov 2023 21:05:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IGsPGQr2/IN6IQDvKjRmh0GbeZtR/oIL7mgeyES2wBgyQP8HAErpQuM/msNfl3NFKJQ9MBs X-Received: by 2002:a17:902:cec4:b0:1d0:265:6a2c with SMTP id d4-20020a170902cec400b001d002656a2cmr10684279plg.11.1701407135203; Thu, 30 Nov 2023 21:05:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701407135; cv=none; d=google.com; s=arc-20160816; b=bYvXeZULnUtDofPt08yDswPnhyeFVYIwjHnO5Kf49z71Uiv0VuAVag8t3ad/erOqGE /MGTqlcj2Q5QAjH4ouhp51/OUZk4SP4LIEtdBHZMYGZ8awXuVhk+SFI4OKBr0nfp+EOH FhBkcua3ARdxMnfymRGz9LRcWH7Xe9N3v5uz0s89o0VsGpbyLa5pAMkAid1wJViI9CdG ijFjUu0sbtPMFWiHMJ2eE89avjEtKvxToMbsd1+CAzOYSFYPHHt9Sj08aT7kSH7vp12t HnPY+2XoS8AIRQWtMZWrWN4VVpTjQhf0VFQlmxtgT7Qkl4uKablr3w6zVqYviPYHszmd PWzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=VaoifbxNcCu6nJVvBrW+8U/ODJZuudYc8IT5Yil3US8=; fh=qjyuAZtnBDAP5VV5yupeXWqG7dBA1spPLDpGIgUrZDc=; b=B/XeMIZbr+oI1cFyd+v+FyXsUOw3BRCbCva/PT/m3ckY/G8+FQtFrTM7iioL8t46Ij PiD6RVbntsey0KVc/BMHjfherTKaSGa+icK+dy4oKgsGUse/sMcooicGi3H1hxL9l4Bk UdYYQxhHiBtYPMhkBdLY6HVjaTgJeX+I2buyd+RKiRgNSMOb+E4DBd4538TIc9mRX/Tk lqSv5d20HrmXHzbW9bPgqwLEn2hU1HYoT1GOG2x7nW6hc/+KmFJuPCrcfWQ8X4Bh962h TtBImWfSJBVNBeUXcLimbwGUWmDJrKHCh3iInZwCiB4sdKju+GR67t/vxRVs52wF8G6R 8TpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=IjRd+cBj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id w14-20020a170902e88e00b001c446b59c8dsi2819382plg.271.2023.11.30.21.05.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 21:05:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=IjRd+cBj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id B125B810F6ED; Thu, 30 Nov 2023 21:05:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377389AbjLAFFG (ORCPT + 99 others); Fri, 1 Dec 2023 00:05:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377413AbjLAFEk (ORCPT ); Fri, 1 Dec 2023 00:04:40 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6071A1730; Thu, 30 Nov 2023 21:04:46 -0800 (PST) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B14oQQL025033; Fri, 1 Dec 2023 05:04:06 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; s=qcppdkim1; bh=VaoifbxNcCu6nJVvBrW+8U/ODJZuudYc8IT5Yil3US8=; b=IjRd+cBjqAMB+CyAesZNJZ9rbUQYI1/AezDcJ/HE8XyJkpvbwKSfWL5smCQpzOWbwHZx fG9Kho/TxlttJfs3/gqkxJ3tk9FRsb5TtUoAQhQaTIkDkLyZ+4WJ3BrplLSNSiL4p5U6 IYvm6ZqQnXA0Kp/2MdaZDFZCv7CvYYDHvEbSaTIehqxjOeZcXuABqI4+6fGThxEoKPlS HRdy/CE6YkrnLha8ODpUjhEy1nKPu0Gps88nffJW8gQcdEb158sl/xnoVmp+jKmVK9FO oMulTj7UXXEs0vnfZFM2HqSWCZXZNrfvuxIJum9+gCHQVC5Fm2V668FTC7MUXvzQcI6R yQ== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3upw12sryw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Dec 2023 05:04:06 +0000 Received: from pps.filterd (NASANPPMTA04.qualcomm.com [127.0.0.1]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 3B14v6V8025713; Fri, 1 Dec 2023 05:04:05 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NASANPPMTA04.qualcomm.com (PPS) with ESMTP id 3unmewu5hm-1; Fri, 01 Dec 2023 05:04:05 +0000 Received: from NASANPPMTA04.qualcomm.com (NASANPPMTA04.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B152Ehv002633; Fri, 1 Dec 2023 05:04:04 GMT Received: from stor-dylan.qualcomm.com (stor-dylan.qualcomm.com [192.168.140.207]) by NASANPPMTA04.qualcomm.com (PPS) with ESMTP id 3B1544SX004581; Fri, 01 Dec 2023 05:04:04 +0000 Received: by stor-dylan.qualcomm.com (Postfix, from userid 359480) id 0B5A020A69; Thu, 30 Nov 2023 21:04:01 -0800 (PST) From: Can Guo To: quic_cang@quicinc.com, bvanassche@acm.org, mani@kernel.org, adrian.hunter@intel.com, vkoul@kernel.org, beanhuo@micron.com, avri.altman@wdc.com, junwoo80.lee@samsung.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linux-arm-msm@vger.kernel.org, Andy Gross , Bjorn Andersson , Konrad Dybcio , "James E.J. Bottomley" , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v7 04/10] scsi: ufs: ufs-qcom: Allow the first init start with the maximum supported gear Date: Thu, 30 Nov 2023 21:03:14 -0800 Message-Id: <1701407001-471-5-git-send-email-quic_cang@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1701407001-471-1-git-send-email-quic_cang@quicinc.com> References: <1701407001-471-1-git-send-email-quic_cang@quicinc.com> X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: foHvakcEYP59TyVN1-D3N33u1nFEtcIF X-Proofpoint-ORIG-GUID: foHvakcEYP59TyVN1-D3N33u1nFEtcIF 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-01_02,2023-11-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 phishscore=0 priorityscore=1501 spamscore=0 impostorscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2312010028 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 30 Nov 2023 21:05:31 -0800 (PST) During host driver init, the phy_gear is set to the minimum supported gear (HS_G2). Then, during the first power mode change, the negotiated gear, say HS-G4, is updated to the phy_gear variable so that in the second init the updated phy_gear can be used to program the PHY. But the current code only allows update the phy_gear to a higher value. If one wants to start the first init with the maximum support gear, say HS-G4, the phy_gear is not updated to HS-G3 if the device only supports HS-G3. The original check added there is intend to make sure the phy_gear won't be updated when gear is scaled down (during clock scaling). Update the check so that one can start the first init with the maximum support gear without breaking the original fix by checking the ufshcd_state, that is, allow update to phy_gear only if power mode change is invoked from ufshcd_probe_hba(). Reviewed-by: Manivannan Sadhasivam Signed-off-by: Can Guo --- drivers/ufs/host/ufs-qcom.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 9a90019..81056b9 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -916,11 +916,12 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba, } /* - * Update phy_gear only when the gears are scaled to a higher value. This is - * because, the PHY gear settings are backwards compatible and we only need to - * change the PHY gear settings while scaling to higher gears. + * During UFS driver probe, always update the PHY gear to match the negotiated + * gear, so that, if quirk UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH is enabled, + * the second init can program the optimal PHY settings. This allows one to start + * the first init with either the minimum or the maximum support gear. */ - if (dev_req_params->gear_tx > host->phy_gear) + if (hba->ufshcd_state == UFSHCD_STATE_RESET) host->phy_gear = dev_req_params->gear_tx; /* enable the device ref clock before changing to HS mode */ -- 2.7.4