Received: by 2002:a05:622a:1442:b0:3a5:28ea:c4b9 with SMTP id v2csp689611qtx; Mon, 31 Oct 2022 11:28:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6oJMQT7wU96kLfZfY4mhGJ3VW9OnmC+mcBv+Ou2yKt1vkY4hDnIsQlCVIqTVvttdp9Z2th X-Received: by 2002:a05:6a00:c8f:b0:56d:70ca:fec3 with SMTP id a15-20020a056a000c8f00b0056d70cafec3mr7113336pfv.50.1667240897931; Mon, 31 Oct 2022 11:28:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667240897; cv=none; d=google.com; s=arc-20160816; b=KrOrlbMn43c7lwq5LvebUFbp85kid1qwIQe1SWStiVx2uUOavjMoIOxRvzpCMwMUFC rcFX8OR08JYkEky79F2ARxtsL21fBRUQQTMrWTYDX0BGiGTGOQZA1K1QGtpFM0BO4kNj HLYOsH2i2+Y4ZU/jp86bBVUtZ0KNixCmkuYN1YQX21XFiJsreAdAVMrQ6u8lDhz3se6i GZkhhyD9KZjQwNtEQe3xHdOviJd6X0uqVCpLoj4LARK0YMGBArgMgw1LWg6ku7JUjyP5 GozE2Fj6oZDiT1Nd9r9uKW6P8mFW9VQTjrbkDUUi0BURSxdQfX6C9BjkehvY4RnARD8e LDrg== 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=n09A1w395FEb8CFGE5mj23N+JsxXbyTWGm1Z2TTn0mM=; b=Id3EESkuo/v5iOoGskvaRrwc2YIeQ0ReE3+vTkpk/ZaATGKEVmUa2Q/n/J2Kg1j8SQ 5yCDrUbZ/D2WKtNogBrnVFnsQyFZHDtnFw0+Ro/iItZrPNFTcbCvCjqvEuOi6434detn o84arqy/E3oq6zvNH+AvZ3qNVkZsYHpl+jBK/8dP4EIJDPAb29gwWTNh7I7kGCyQSQGG PAhZ5Qnp7uvni2OSFWVYtYJbqQAMou/0Dhv2pGpNPZhBGeXayX3qWRn5Fd+0wUc5/dCS vGcSYfv/n3nQkY3D6byXlh1SIb+L3pdAX5FXk2QZpxyzpzecPxUNV6smkRj9DEH3w41h 9IQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GS8oQJDD; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 207-20020a6301d8000000b0046f9f498732si8384379pgb.303.2022.10.31.11.28.04; Mon, 31 Oct 2022 11:28:17 -0700 (PDT) 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=GS8oQJDD; 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 S230018AbiJaSFY (ORCPT + 98 others); Mon, 31 Oct 2022 14:05:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230036AbiJaSEP (ORCPT ); Mon, 31 Oct 2022 14:04:15 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E58ED13DCC for ; Mon, 31 Oct 2022 11:04:11 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id h193so2661499pgc.10 for ; Mon, 31 Oct 2022 11:04:11 -0700 (PDT) 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=n09A1w395FEb8CFGE5mj23N+JsxXbyTWGm1Z2TTn0mM=; b=GS8oQJDD8gziLB3T6WUk5TbqFCYkzq8n49LYkyJ+Eq+mA1nyAmGsKjbf6xVjwj8bdy XocrDFfUr1eGr0a31uzd20iFSjCtGOZjOYqAPw8501lWH9xTFfJEg1NFkOStwrEoLsSV iCKPKf5st2Bjc6Aj1BGkVvaHCPyIHVT67bl0HLtbbrZfj4Q6Wy/PKDCbXDx2nX4JQ1y+ o/XkuII+bdxqrvmv9aXP+yIqqKiesoZeR2Z/sci8gJltFT09BT7MS0IAlG9NHcRgNXP9 6POsfU70sxDcG5QvrkFmDTvKpeVBuP6kbg4GQVGAOnJ7+IGUj66m2+o5ePi6C5yJ+h5k dJ6Q== 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=n09A1w395FEb8CFGE5mj23N+JsxXbyTWGm1Z2TTn0mM=; b=jHbJQkRzvIOKFLpDqL7G/4cwYyU5NjlwRqZ/4s+PSN3pl2ujAIAIkZ8u25CtgByZZf gB/4LgkzL66vUNko4BfN4hpyulSWgTvEUQfsxLfAmwySbtfXn+WZKw/MKeV46qceIue0 3Ttg6Wh5cLaGdhvnXH7QIxXcR4vLlOQ9/o/YBMpe0HEeeaDCygABDFPeWaoGT1sF4Tj1 3Ub5Dot7590Y7tUuCCypLKkHj7t/NBrn3XtyFu9z99qar/T7bE/nlGZ6DrjSA7/FRPev LnXHleYOSRm5ZoonowWniDYH6HWX7ACEgdDNdvFNHhNosF8Q6zeiGqKp3T+fmBvLTlfh mjkw== X-Gm-Message-State: ACrzQf22XpzW4cq1ejUgO2D18lwHfmdXfVpVbVsBwC1Sl54lHaGQJjHU +sv6AFtPO092e5BfZbfXfVjO X-Received: by 2002:a63:de46:0:b0:46e:c3bd:e47d with SMTP id y6-20020a63de46000000b0046ec3bde47dmr13398495pgi.609.1667239451578; Mon, 31 Oct 2022 11:04:11 -0700 (PDT) Received: from localhost.localdomain ([117.193.209.221]) by smtp.gmail.com with ESMTPSA id q14-20020a170902a3ce00b00186c6d2e7e3sm4742224plb.26.2022.10.31.11.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Oct 2022 11:04:10 -0700 (PDT) From: Manivannan Sadhasivam To: martin.petersen@oracle.com, jejb@linux.ibm.com, andersson@kernel.org, vkoul@kernel.org, krzysztof.kozlowski+dt@linaro.org Cc: konrad.dybcio@somainline.org, robh+dt@kernel.org, quic_cang@quicinc.com, linux-arm-msm@vger.kernel.org, devicetree@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, Manivannan Sadhasivam Subject: [PATCH v2 13/15] scsi: ufs: ufs-qcom: Factor out the logic finding the HS Gear Date: Mon, 31 Oct 2022 23:32:15 +0530 Message-Id: <20221031180217.32512-14-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221031180217.32512-1-manivannan.sadhasivam@linaro.org> References: <20221031180217.32512-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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=ham 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 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). Signed-off-by: Manivannan Sadhasivam --- drivers/ufs/host/ufs-qcom.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 38e2ed749d75..c93d2d38b43e 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -278,6 +278,26 @@ static int ufs_qcom_host_reset(struct ufs_hba *hba) return 0; } +static u32 ufs_qcom_get_hs_gear(struct ufs_hba *hba, u32 hs_gear) +{ + 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. + */ + if (hs_gear > UFS_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 +712,9 @@ 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, + ufs_qcom_cap.hs_tx_gear); ret = ufshcd_get_pwr_dev_param(&ufs_qcom_cap, dev_max_params, -- 2.25.1