From patchwork Wed Nov 23 07:48:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 24775 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2649442wrr; Tue, 22 Nov 2022 23:54:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf5/YZGWcHkzo0iPE2gvfwm1lxk23QvXGuYOQIXbPcxSlW6r1v0A24dkegCw+c7ZlUMKCNPS X-Received: by 2002:a17:90a:e512:b0:218:9685:81fe with SMTP id t18-20020a17090ae51200b00218968581femr20725601pjy.190.1669190048875; Tue, 22 Nov 2022 23:54:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669190048; cv=none; d=google.com; s=arc-20160816; b=BNbodNc3j7I+wdV/YqltDZmqCNtL6+7s/m6VdqDxJodr+OuTaS8edLT8+Z5pkC3c4F swClnfn240TvcbCN/GYJiR+95aLaE/2nTh/g1vTzjLSNGxlXFPyQ1rVHR5yI1pDFLigA qmIBBOYidL300345jMRKYRGIRhHiUOQX1Kn0p9P8+9ko/rlXjLUn75WiN85KuPGMfQp6 jF/KZwMepabdZ8Y2+6k9XP8JtGQVPkM1Lk/3a3zFnjNKC7X8LZFwi9Ead7zTxc7CS0Ew oSChRHvdShkAKiEFgloiw3Y4vOKLsJILkfm4Y+2+AJh+JIRxLpFKbWRJschzg6Z5nBka Injw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jQW21UMpMMT39kQGkUZ44Bi2KAiI76Uffz4R9s7ZIY4=; b=myfjgH0dbyTfI3eziQheSDrwn2AlEO8EWFQGAQwLildOBjEufE/vmI2K+WEtamT/76 qoBDeV8WiMB9MHxHx24iYIS9JGVhlP89nKF/SR4lNbrCAF7QpcUsJ9r4fhRKeA9ls2CJ CZ05oP+o6HVxyRSLRDajhrukDUOP/0xILre5pvzz4GLj7xjuaZOdSH7JFPpnrChssOyX c/qGr6ltreSJ9DmQrTgSUZ8Jj5aZxdvxgvv2fnNjw0UVDvGH3kGeVK6r9sioewmOvkk7 esw4+YuIUqwqR5YfDdrVXwsUYi7pfrdDTRFtZ77TlRyuzEYMUeFZs775m0Rq6gxw6/H+ PYrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q4uifVNU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ij7-20020a170902ab4700b001893efd3e00si1323328plb.49.2022.11.22.23.53.56; Tue, 22 Nov 2022 23:54:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q4uifVNU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236398AbiKWHwH (ORCPT + 99 others); Wed, 23 Nov 2022 02:52:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236373AbiKWHvX (ORCPT ); Wed, 23 Nov 2022 02:51:23 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B6AAFAE90 for ; Tue, 22 Nov 2022 23:50:16 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id io19so15926490plb.8 for ; Tue, 22 Nov 2022 23:50:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jQW21UMpMMT39kQGkUZ44Bi2KAiI76Uffz4R9s7ZIY4=; b=Q4uifVNUG8xLZiw0nKZzqWhlsFQVjN7R7zmwgdRS/fTSn0Pz18mv37YJD39o+JlZ+U YX50U9RmFIiBE5gaK+qWmu8dehcTfKoU1BOe+NxgY/P8qv4PehJ3qfZDfW4HwQ/uSNLF SO5irDbKFTLjuwkrCMMdtgUjo/xb1StQ14ri1Bxv1UkA/bIwjVqyt+gMUVpvegQ+Peff qG4EAibX1FxdFxy8A92f6uSiv92YFS5FM3PH+5SGqa7OLIVqu/yGOPBW3106ZA1Dj0nN or6T2UMyGk7jCA89uhNo+9K4YwS8Q70+I2BoLGhEhoS19d02r0QG25cSU+dfJA25+76c lyFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jQW21UMpMMT39kQGkUZ44Bi2KAiI76Uffz4R9s7ZIY4=; b=XawdXNDNiiIuX+ymI08p49Quae3LrqBEpi+0xzqrXWHD4BuMxnL2hdOWumuGEbN1tn yFGCgV+L88JDQIJRq/wZofa6hfKN9XrYdj7Mj1ujLUn26yr1yRWYhScPe9idg2I0CRiU fnJJ3Y7mpY9eW7lmRm5HUaYKYfB3esGlioyVPQfqxt1axwa555MIFbRqycBLnvt6ICE6 xgytyCv6NwwyVAsDDa/gAvVYpw7OCuwhvoOGXHHozKgrGnayKToa36Asorw5CxYgjU9v dvKZ3o5xkxr+aV15WjZfnrWKE0BN2moUReTVm7PjkPFqZMIiVtLp2Wbgr2EY6EtJZWT6 fgpA== X-Gm-Message-State: ANoB5plDxj6R0rIP0SCKQWI5DKaSeXDyRuxSPiWIKJ/zkcul+3ERHK4G SsHylPh/KcBlI+cLhVyt73an X-Received: by 2002:a17:90a:d811:b0:213:aa8:dda with SMTP id a17-20020a17090ad81100b002130aa80ddamr30077911pjv.111.1669189815878; Tue, 22 Nov 2022 23:50:15 -0800 (PST) Received: from localhost.localdomain ([117.202.191.0]) by smtp.gmail.com with ESMTPSA id s16-20020a170902a51000b001869f2120a5sm13334059plq.34.2022.11.22.23.50.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 23:50:15 -0800 (PST) From: Manivannan Sadhasivam To: martin.petersen@oracle.com, jejb@linux.ibm.com, andersson@kernel.org, vkoul@kernel.org Cc: quic_cang@quicinc.com, quic_asutoshd@quicinc.com, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, linux-scsi@vger.kernel.org, dmitry.baryshkov@linaro.org, ahalaney@redhat.com, abel.vesa@linaro.org, Manivannan Sadhasivam Subject: [PATCH v3 17/20] scsi: ufs: ufs-qcom: Factor out the logic finding the HS Gear Date: Wed, 23 Nov 2022 13:18:23 +0530 Message-Id: <20221123074826.95369-18-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221123074826.95369-1-manivannan.sadhasivam@linaro.org> References: <20221123074826.95369-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750272624685074560?= X-GMAIL-MSGID: =?utf-8?q?1750272624685074560?= In the preparation of adding support for new gears, let's move the logic that finds the gear for each platform to a new function. This helps with code readability and also allows the logic to be used in other places of the driver in future. While at it, let's make it clear that this driver only supports symmetric gear setting (hs_tx_gear == hs_rx_gear). Reviewed-by: Andrew Halaney Signed-off-by: Manivannan Sadhasivam --- drivers/ufs/host/ufs-qcom.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 38e2ed749d75..919b6eae439d 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -278,6 +278,25 @@ static int ufs_qcom_host_reset(struct ufs_hba *hba) return 0; } +static u32 ufs_qcom_get_hs_gear(struct ufs_hba *hba) +{ + struct ufs_qcom_host *host = ufshcd_get_variant(hba); + + if (host->hw_ver.major == 0x1) { + /* + * HS-G3 operations may not reliably work on legacy QCOM + * UFS host controller hardware even though capability + * exchange during link startup phase may end up + * negotiating maximum supported gear as G3. + * Hence downgrade the maximum supported gear to HS-G2. + */ + return UFS_HS_G2; + } + + /* Default is HS-G3 */ + return UFS_HS_G3; +} + static int ufs_qcom_power_up_sequence(struct ufs_hba *hba) { struct ufs_qcom_host *host = ufshcd_get_variant(hba); @@ -692,19 +711,8 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba, ufshcd_init_pwr_dev_param(&ufs_qcom_cap); ufs_qcom_cap.hs_rate = UFS_QCOM_LIMIT_HS_RATE; - if (host->hw_ver.major == 0x1) { - /* - * HS-G3 operations may not reliably work on legacy QCOM - * UFS host controller hardware even though capability - * exchange during link startup phase may end up - * negotiating maximum supported gear as G3. - * Hence downgrade the maximum supported gear to HS-G2. - */ - if (ufs_qcom_cap.hs_tx_gear > UFS_HS_G2) - ufs_qcom_cap.hs_tx_gear = UFS_HS_G2; - if (ufs_qcom_cap.hs_rx_gear > UFS_HS_G2) - ufs_qcom_cap.hs_rx_gear = UFS_HS_G2; - } + /* This driver only supports symmetic gear setting i.e., hs_tx_gear == hs_rx_gear */ + ufs_qcom_cap.hs_tx_gear = ufs_qcom_cap.hs_rx_gear = ufs_qcom_get_hs_gear(hba); ret = ufshcd_get_pwr_dev_param(&ufs_qcom_cap, dev_max_params,