Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2579654rdf; Mon, 6 Nov 2023 20:48:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IF2G/qlEPat1F+/F+Q0l7pxsUwTwgcjiS0V9gsJz6XqNJRBL4bv2HyqwzBJiuSvvHEMdWCl X-Received: by 2002:a05:6830:14ce:b0:6bd:b5f7:187a with SMTP id t14-20020a05683014ce00b006bdb5f7187amr32511375otq.20.1699332501905; Mon, 06 Nov 2023 20:48:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699332501; cv=none; d=google.com; s=arc-20160816; b=l2UPiyG5ye2i/J8tldKBqvq8TB0CzZusrPO9GmjrkhJ/A4KpCl2PYdMNmP7HTWeKw+ V+3HW+EliI6FAu3MrndaX9S8cxuyXxY5a4yP6wMBdb3mKupqoLIjDn6QPxrtrXHKMOcw 7tcFQ9T48WWtJupSICNSjMwqHXGiHxKU7thG0YZX4mWJXsqJD7K2tyigQGwZkB2omTm9 Lq/26CRES3A7qHShCsQpiKlkSncrz4Y7Y0mtC6wfnFxd9GO6PqVNtxcVPIYrzxPag9Va laEagwQ3Bfg7j79CMfajErxpMdwy3Z1emblyCQVyX8jDw0p5ykqN36X/A4Jwtq0aGUy6 dQNw== 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=BJOPFUlO8fR2yike4h6l0Q1+3cHf0Kj1rIEKZZHnmeo=; fh=mh8gTMTkbwQn5/wFi0jej/XBbS8oNeZmzceEh2Aacuo=; b=K8fro8sOUkbtkHROPyus1bpb7wZSUGF1AoLN5qdtujpc0IXdnBmQrsdlyLKSZV/iai PnTl5f073LmIQImmVhOYx2icDayqQDe73dSHW4MTW8t7GhckEUkVCOKO/Udw/OzFupQn 09OZdA+XxRVW2AsxnCnryvBvEJdb4SDyfg0I+5pgfSPfxzYBwslQRmN3SskVIgTArEe0 zdUrsr0hNFBrJZixm7i3HU6DU1UHs7u7aCn/pSfdDaoiTljsbzYPM/0Mys3jfKNB4Coa 3Z6EURTFyqI4J0HR9HZVclpXLQg905n3mDfRRthvP+8uMSEQQJcjaRC0nSry50OLsl0e vG9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@qualcomm.com header.s=qcppdkim1 header.b=ZaRX4HhJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=qti.qualcomm.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id h16-20020a056a00219000b0068780155ddbsi9744610pfi.131.2023.11.06.20.48.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 20:48:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@qualcomm.com header.s=qcppdkim1 header.b=ZaRX4HhJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=qti.qualcomm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 407EE803DCFE; Mon, 6 Nov 2023 20:48:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233501AbjKGErD (ORCPT + 99 others); Mon, 6 Nov 2023 23:47:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232973AbjKGErC (ORCPT ); Mon, 6 Nov 2023 23:47:02 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 167A5114; Mon, 6 Nov 2023 20:47:00 -0800 (PST) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A73xnER029768; Tue, 7 Nov 2023 04:46:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=qcppdkim1; bh=BJOPFUlO8fR2yike4h6l0Q1+3cHf0Kj1rIEKZZHnmeo=; b=ZaRX4HhJn7jNqVLL79CafjQT1vvsn8l7x1dVoOMz7sVMIqrY7UZDqs/9THcBA2wWGfD5 pDhadHTIA0c1s7Gi7LMADAEcCOBnRz2w7GELAotDLGwKbyXlzOmGT1NmElPHVV3KWCpJ VEkiSo9+m48nlHsvZXEsZxzLBxCx+WbR9YEH/LFvibqqxGoxb/XbpAJUjNurCfLGXaEC TTSxGu6TcktfOS9Y0FKRFSiDrTIixbJSeyuxttMhzw2FEg17nJSAHnHrwg3xJUafBYiu 7FGH/kQFBfm+qqpuXnPY01rRgjv+ePQKbaAVKUkNkvhxLP8X/XObKkpCsz+FgEFrKp7g Nw== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3u74v3159k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Nov 2023 04:46:46 +0000 Received: from pps.filterd (NASANPPMTA03.qualcomm.com [127.0.0.1]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 3A74eK3f001989; Tue, 7 Nov 2023 04:46:46 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NASANPPMTA03.qualcomm.com (PPS) with ESMTP id 3u73v7ndqn-1; Tue, 07 Nov 2023 04:46:46 +0000 Received: from NASANPPMTA03.qualcomm.com (NASANPPMTA03.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3A74ewV0003254; Tue, 7 Nov 2023 04:46:45 GMT Received: from stor-dylan.qualcomm.com (stor-dylan.qualcomm.com [192.168.140.207]) by NASANPPMTA03.qualcomm.com (PPS) with ESMTP id 3A74kjKg013071; Tue, 07 Nov 2023 04:46:45 +0000 Received: by stor-dylan.qualcomm.com (Postfix, from userid 359480) id 93B4720A78; Mon, 6 Nov 2023 20:46:45 -0800 (PST) From: Can Guo To: quic_cang@quicinc.com, bvanassche@acm.org, mani@kernel.org, stanley.chu@mediatek.com, adrian.hunter@intel.com, beanhuo@micron.com, avri.altman@wdc.com, junwoo80.lee@samsung.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, Andy Gross , Bjorn Andersson , Konrad Dybcio , "James E.J. Bottomley" , linux-arm-msm@vger.kernel.org (open list:ARM/QUALCOMM SUPPORT), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 3/7] scsi: ufs: ufs-qcom: Allow the first init start with the maximum supported gear Date: Mon, 6 Nov 2023 20:46:09 -0800 Message-Id: <1699332374-9324-4-git-send-email-cang@qti.qualcomm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1699332374-9324-1-git-send-email-cang@qti.qualcomm.com> References: <1699332374-9324-1-git-send-email-cang@qti.qualcomm.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: gHKYI1cw92_-pC9pMV9p3u_lriUKjZV- X-Proofpoint-ORIG-GUID: gHKYI1cw92_-pC9pMV9p3u_lriUKjZV- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 bulkscore=0 clxscore=1015 impostorscore=0 spamscore=0 priorityscore=1501 malwarescore=0 phishscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070038 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, 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 groat.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 (groat.vger.email [0.0.0.0]); Mon, 06 Nov 2023 20:48:16 -0800 (PST) From: Can Guo 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(). This change is a preparation patch for the next patches in the same series. 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 cc0eb37..60b35ca 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