Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4421170rdh; Wed, 29 Nov 2023 00:32:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdEe3dQOWW41xODWRrY3V4BiexwJ++JPjwnJeswx2hIwx4tV6diMzXyu0QfaiJFyFrf/Pi X-Received: by 2002:a05:6a00:2d27:b0:6cb:d24b:8c2e with SMTP id fa39-20020a056a002d2700b006cbd24b8c2emr21664745pfb.13.1701246750478; Wed, 29 Nov 2023 00:32:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701246750; cv=none; d=google.com; s=arc-20160816; b=dfpa4VtYqus3IiUmsBVLSMzvb27oSMdvMnIizWPnmvxmZXXcjZ5s6FY2HGPf73elk6 9Phue6cwVfbbtEuCqRZIJ0GJbADHU2aWf/4xzwhbVCYnUrplSxGvKOdVoF+fUTMeeZvD k59JpvDn0qzNiBRL5hJfrE1eYflIRShAmAUniATtmfeQy6oF0TcXoJalRCDlXVFpih4Y CbW35ZrQiDqa01nIIY2CZfc6aCkio/Bs7+g6xKTrZ3Ec0sld7P+4QYXWbz4cYaJ/UJkh ZKzzpWVkwoEtutPhu1LJu9ElbEoz9JjkLKSmSMRme5N4VHt96yEnmSIHw8eNsBjvQnMP BXUQ== 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=/t4gc5j9UEoMHfbDfgzJBzMFpYLemKsT1fmy50U6WNg=; fh=GfW6IokojBSM2WalA9WiQDdU1UuM8RK2I83+Pwj1klU=; b=I8ZhjdvVas+N893EutD2R2p/uE6p5dv6B/0b6yE04wRX2Fy+nrb85WwP6iZqz0aLc7 KL+FNUCoRlvFztOG1LCP1jt0gYbKa/pika5uBC+igydTiLWesmE2f8AHQ5wxD5AO/yBn i3OYRnwkwgxCplk/I6Uv3pOlxi7uAVosOq6EZRvY/D/eB1S6UCdaqXqBb4X714LDNk8I fMIsArSkRY7cf6G+YBJA7OQ+4wc1IHbl++ePpWGxGMgW2cKX4vOAh90DMhB5HKQB3Xf4 GYdBOkeCUAQLXrCKuxP/05A9mgvkv0PeYN+2pWM8mv1cbmaDnzgXnLbJtjQI6ac87SNt qBUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=JhvOYyyv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id f12-20020a631f0c000000b005b21d089aabsi14155333pgf.519.2023.11.29.00.32.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 00:32:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=JhvOYyyv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 548ED807FCD0; Wed, 29 Nov 2023 00:32:26 -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 S230103AbjK2IcJ (ORCPT + 99 others); Wed, 29 Nov 2023 03:32:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232547AbjK2Ibw (ORCPT ); Wed, 29 Nov 2023 03:31:52 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2A6519BA; Wed, 29 Nov 2023 00:30:49 -0800 (PST) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AT5n8JS031359; Wed, 29 Nov 2023 08:28:57 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=/t4gc5j9UEoMHfbDfgzJBzMFpYLemKsT1fmy50U6WNg=; b=JhvOYyyvJiILf3JFLooegaNSZjWofjOwWtNs4jXmqdXfMapmJyA+pNHyJA5D9dBZLOhZ 7eFVDYNKS0hzUumq0hsE3f59JilG7G2pJ8nu4gj3EUvGa0SizQsMxQKms+m7OQUgzPBt +o5leANqoU1XJ3oYiSOa+C/o+n2rY7vX1RoyxrRGHG+BSwHSK2v8cGfWBfiJQshLCWxT FTPXMjoHG4Utm5ub09XKt8oWQ1x/FINAA4lQl8v6Y985hnjhNliXZKewwyEZ0Jr2jX3u U1+39EGefMgPXnHuoOuXjCF4k8f3ZN+tEI7kVas9OU9Jaa2mrVnXfTNjXGYXJ+z/CZw9 IA== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3unfn4txy2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Nov 2023 08:28:57 +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 3AT8JhR4007425; Wed, 29 Nov 2023 08:28:56 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NASANPPMTA04.qualcomm.com (PPS) with ESMTP id 3unmew6x70-1; Wed, 29 Nov 2023 08:28:56 +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 3AT8Stx6020794; Wed, 29 Nov 2023 08:28:55 GMT Received: from stor-dylan.qualcomm.com (stor-dylan.qualcomm.com [192.168.140.207]) by NASANPPMTA04.qualcomm.com (PPS) with ESMTP id 3AT8StZh020789; Wed, 29 Nov 2023 08:28:55 +0000 Received: by stor-dylan.qualcomm.com (Postfix, from userid 359480) id E4B3520A5D; Wed, 29 Nov 2023 00:28:55 -0800 (PST) From: Can Guo To: quic_cang@quicinc.com, bvanassche@acm.org, mani@kernel.org, adrian.hunter@intel.com, cmd4@qualcomm.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 v6 04/10] scsi: ufs: ufs-qcom: Allow the first init start with the maximum supported gear Date: Wed, 29 Nov 2023 00:28:29 -0800 Message-Id: <1701246516-11626-5-git-send-email-quic_cang@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1701246516-11626-1-git-send-email-quic_cang@quicinc.com> References: <1701246516-11626-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-ORIG-GUID: atI3-P2PoFF9OQ-Ccz9jbhHRKNmAShp6 X-Proofpoint-GUID: atI3-P2PoFF9OQ-Ccz9jbhHRKNmAShp6 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-11-29_06,2023-11-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 impostorscore=0 adultscore=0 clxscore=1015 suspectscore=0 priorityscore=1501 mlxscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311290062 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]); Wed, 29 Nov 2023 00:32:26 -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(). 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 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