Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1653598rdb; Sat, 2 Dec 2023 04:40:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBQJ6M+SzA9UvKUETm55s8+IKB6uRBIIkxaHY0FNUCwSrx7sJrfdALAwUC96gq2WAJjZyU X-Received: by 2002:a92:6811:0:b0:35d:59a2:2cd with SMTP id d17-20020a926811000000b0035d59a202cdmr1291877ilc.109.1701520841849; Sat, 02 Dec 2023 04:40:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701520841; cv=none; d=google.com; s=arc-20160816; b=RM4BcnSbiwEY3P1Dhntw9bHizsp1mMC2Y/JIn56W8fkGiWQDu0JUxHknVQ3dpYkYM3 fjwds8ycvPXkGMtNYbWF1KAtJ8AjrOr8t9a3hbP3pc0lk4zm+CE2CCyRYh7BioItB3AM 2o0UAFBtmgvBitz6eMHgrXPIHCzB+7va+zYhFekwx8bUNR+unMIo6zn2dYebpo+9PHUI BwM85KGnHxmQIhuL95C8KayZjkf4pxwof1voqL/3LE4Kn+GziXCSgr4w58kVdCxTIdea txov8fFCo9DTqo7XP1/9e6addrY1/fZs/E3GK7RYzrIHPVL0Qr5zuN5kf3C9Bw5ilDmg jINQ== 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=W4ch+tubTZYeKnDC5ALhax4ioIC042gEkXsU4YqWJig=; fh=qjyuAZtnBDAP5VV5yupeXWqG7dBA1spPLDpGIgUrZDc=; b=cVukPpXjeuoI5JHx/iBqWttMdLKTJVzNTiQ7b8+dIMbIt2svcz8ImRpzUjC3jIGbxI ybMJcT+HnSRE1Doa+df/PVWHvzO0ibh2vHKe65HdwcLxe+74yu36sGPQoOkkpIpsnVcW pvZxIcwRgkOrybjQwbadoGHBygGaXG9/7CbbF+LZ/fkd+L9/kY3+mPccRS3QwvVSSDRD M/HyyaN4U4h7fjIXooOuiIu6xB/JL6isP3UWZuHGzrPqwFb1fx+ptSyeVd88vG5LxiNv HfgUxESXpPY8+j44EHSqLVJGzu+H+l8wqI1/kdVQOmnlY6VOBEaLLCRgxRoI+zgKbqBX gmkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=irWkqJcM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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. [23.128.96.36]) by mx.google.com with ESMTPS id a23-20020a63e417000000b005b8f24e6525si4877331pgi.81.2023.12.02.04.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 04:40:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=irWkqJcM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 2933580238A0; Sat, 2 Dec 2023 04:40:38 -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 S232655AbjLBMkX (ORCPT + 99 others); Sat, 2 Dec 2023 07:40:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbjLBMkW (ORCPT ); Sat, 2 Dec 2023 07:40:22 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 800FA9C; Sat, 2 Dec 2023 04:40:28 -0800 (PST) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B2CEWoG022474; Sat, 2 Dec 2023 12:36:44 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=W4ch+tubTZYeKnDC5ALhax4ioIC042gEkXsU4YqWJig=; b=irWkqJcMgYCngemhDndf0HTvWhZ11nc6A0D2Fzkc1bue0xwsOESxaYTSjdsc0MfQux8s c0PqxamZPRJ1uX+C4wf9a6vzTNMXy8RO1YXDE9qv8VHq8msQkB4CPa3kuthkdw5FuKTt RuypsoaNSxxedaToQaU/AaV8PqWvzB7v0ANhadRfX7E6qQUyfidKhDb/dyZtooDV1As1 bz2QlaYV/b5ppc9wOSSO2LthVHOPFsyN1XgStCL2vEE0W57IAngVEbljX7lbfPIEUNjX nGZnghSbgCBTlibwXFJL+ZQo52Rhb2toJaDerRwtyrAQsrls6opxnIpH49ARJXdiNY9Q zQ== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uquwt0ms0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 02 Dec 2023 12:36:44 +0000 Received: from pps.filterd (NASANPPMTA05.qualcomm.com [127.0.0.1]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 3B2CagLh011417; Sat, 2 Dec 2023 12:36:42 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NASANPPMTA05.qualcomm.com (PPS) with ESMTP id 3uqwnkbdb6-1; Sat, 02 Dec 2023 12:36:42 +0000 Received: from NASANPPMTA05.qualcomm.com (NASANPPMTA05.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B2Cag8V011409; Sat, 2 Dec 2023 12:36:42 GMT Received: from stor-dylan.qualcomm.com (stor-dylan.qualcomm.com [192.168.140.207]) by NASANPPMTA05.qualcomm.com (PPS) with ESMTP id 3B2CagLN011408; Sat, 02 Dec 2023 12:36:42 +0000 Received: by stor-dylan.qualcomm.com (Postfix, from userid 359480) id ADD9A20A90; Sat, 2 Dec 2023 04:36:41 -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 v8 04/10] scsi: ufs: ufs-qcom: Allow the first init start with the maximum supported gear Date: Sat, 2 Dec 2023 04:36:10 -0800 Message-Id: <1701520577-31163-5-git-send-email-quic_cang@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1701520577-31163-1-git-send-email-quic_cang@quicinc.com> References: <1701520577-31163-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: SNrZdyvFkHz6kdsZ2TT4Qf4Hz4ENz7-t X-Proofpoint-ORIG-GUID: SNrZdyvFkHz6kdsZ2TT4Qf4Hz4ENz7-t 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-02_10,2023-11-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 clxscore=1015 impostorscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2312020094 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 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]); Sat, 02 Dec 2023 04:40:38 -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 Reviewed-by: Nitin Rawat 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