From patchwork Thu Nov 23 08:46:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 168793 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp304578vqx; Thu, 23 Nov 2023 00:48:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqyQC+fAhnQUVQYwG1nkTLITOr1mQIRCvDbrEr4xFoYKC+so1/OEZmq9chf28mGvyZUVuY X-Received: by 2002:a05:6871:554:b0:1f9:9980:7a0a with SMTP id t20-20020a056871055400b001f999807a0amr4327633oal.54.1700729334921; Thu, 23 Nov 2023 00:48:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700729334; cv=none; d=google.com; s=arc-20160816; b=oh/vI972wwQzFgaV7+q92H3EwHVIy/Q8tzLySLV6S7n3WW0VYwsPssCYHMXYBr3bWP /dEKI7Il/jZ4a7s4CYZaUO6XpUgCP+A+EZYprbCEaIJYPx5Wp5r05091m6a+hmMEobuL VbyDh4FuZyRK0pBg4jfafNz1hKF/at5meK8tWirSf/wXpqPMNf/1+9x0vjj8tx1ifSxV IIsX/YviITwR98LcXBIIcPcqGza6xu+k2lBNc1yKW6rS5XSMtPd572HvSW25zmlygaks WCED82QNtN2k0X528rLD/pbN8q1CeYavc2htFsyaG+HpHmBQqrye4vQzrRH8NdPOtKvY 4iIQ== 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=ZhwV3737hVFopoyIktTqMRJOFfXUF17oXq/72ZAucXQ=; fh=Mo6TxgGzGLrlS+5dVlNWdqd+fZYn09cU+8+JAb6EqZk=; b=oTpuGpkQ9kTEwgtf621Nx9+vBSmABLfglNMY+59e0Tn+CDcdrYDoxMBjDMIDu9/AOX 0AxttRtxJ7V1obPCkHJjTA6ZAo6X43pCRhi35OedjtSJfHNg/VFA2ZeJhIHkdQwV9nJ8 4nMD7p2v2KDmvmNmMtsPTcLPEqPua5Fl0TopkmvEvdKvfF0s12RYiMnn/pHvJLc2FvSm uwh+QiYBp5OZsN/EKJ6v9dGI6BoIAa3q/vZGW29HT3b8SES3I7dfqL3JgaqIZIq1voyN 46Qli/n3vlVimlT5mWnyfOUpit0mcUPtVXHF4w4CrhBd9Kt6wLwOfKqDVImMr/HgeawV pFRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=RCkvUgEF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id z6-20020aa79e46000000b006bf53365ac4si839161pfq.139.2023.11.23.00.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 00:48:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=RCkvUgEF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id BEB29823C814; Thu, 23 Nov 2023 00:48:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235282AbjKWIsZ (ORCPT + 99 others); Thu, 23 Nov 2023 03:48:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345086AbjKWIsD (ORCPT ); Thu, 23 Nov 2023 03:48:03 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A74741736; Thu, 23 Nov 2023 00:47:52 -0800 (PST) Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AN5e46G006678; Thu, 23 Nov 2023 08:47:08 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=ZhwV3737hVFopoyIktTqMRJOFfXUF17oXq/72ZAucXQ=; b=RCkvUgEFR7ppvb709LyXT7pLU9AJrO4HWFbFhHlDXw5hn5qubs+J5wngsX0xquSL5WsJ 1soq3KOCLlmkDx0eCv//KoW4klcBjuA8DjgcQkzIvl7hItny/O5Mwv5V9qRiaOPNTEPF OIgL8+9HdXR5Y3y1JkalqEsU8qkFSIS3ed7YsdY7tVCnEHXy9/tx15W0906qeT47IFUo 9lpza6Lc6hMIkAl+ixS4DmRyiYsWU8t2VcRQHrNiwRkiXVF2XPuu2SGUhnK5WnnL84+9 jfFyw6dndRzlYAOEIr52G7mZoxN7AN1DGPMtJGWJdAFbFzZF8dBO3NwXxXN0Zlpb1hpw cg== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uhvm0rxgs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 08:47:07 +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 3AN8OCkc013812; Thu, 23 Nov 2023 08:47:07 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NASANPPMTA03.qualcomm.com (PPS) with ESMTP id 3uhwcrkkaw-1; Thu, 23 Nov 2023 08:47:07 +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 3AN8l6xG012011; Thu, 23 Nov 2023 08:47:06 GMT Received: from stor-dylan.qualcomm.com (stor-dylan.qualcomm.com [192.168.140.207]) by NASANPPMTA03.qualcomm.com (PPS) with ESMTP id 3AN8l67L012009; Thu, 23 Nov 2023 08:47:06 +0000 Received: by stor-dylan.qualcomm.com (Postfix, from userid 359480) id A3AD520A68; Thu, 23 Nov 2023 00:47:06 -0800 (PST) From: Can Guo To: quic_cang@quicinc.com, bvanassche@acm.org, mani@kernel.org, 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, 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 v5 05/10] scsi: ufs: ufs-qcom: Allow the first init start with the maximum supported gear Date: Thu, 23 Nov 2023 00:46:25 -0800 Message-Id: <1700729190-17268-6-git-send-email-quic_cang@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1700729190-17268-1-git-send-email-quic_cang@quicinc.com> References: <1700729190-17268-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: SUlQtFEj9bFG-gQ-59wby7AElcO8hLUC X-Proofpoint-ORIG-GUID: SUlQtFEj9bFG-gQ-59wby7AElcO8hLUC 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-23_06,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 clxscore=1015 priorityscore=1501 spamscore=0 impostorscore=0 lowpriorityscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311230062 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 agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 23 Nov 2023 00:48:47 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783343963281600850 X-GMAIL-MSGID: 1783343963281600850 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 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index d4edf58..9613ad9 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -916,16 +916,19 @@ 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) { u32 old_phy_gear = host->phy_gear; host->phy_gear = dev_req_params->gear_tx; - dev_req_params->gear_tx = old_phy_gear; - dev_req_params->gear_rx = old_phy_gear; + if (dev_req_params->gear_tx > old_phy_gear) { + dev_req_params->gear_tx = old_phy_gear; + dev_req_params->gear_rx = old_phy_gear; + } } /* enable the device ref clock before changing to HS mode */