From patchwork Sat Oct 29 14:16:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 12723 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1371212wru; Sat, 29 Oct 2022 07:20:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Td02M5biue3iy1xjsRaZ4dgo6gtW+JX08XHazA2mk1t/9bJ84JkSnBkpvBlckXH9HihMn X-Received: by 2002:a17:902:9308:b0:182:b2ba:755 with SMTP id bc8-20020a170902930800b00182b2ba0755mr4594091plb.107.1667053213763; Sat, 29 Oct 2022 07:20:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667053213; cv=none; d=google.com; s=arc-20160816; b=UGUwjPGSekZsmKp8Zh539e6GgbmxHmaZWojO8ZZ8AOeupb+VEem/wvpcngGfzuH5FM grvz8YQa8YazX5l5Hr5ccvUhEg5PuyT8ZG1OnU+S7gWhwZOb0me/pMxiuvX6ORpl46iG oJVFp229rKH56ejCXI1wKsTOnhxtipJJh9WlGcDVCqHEZ0QBxnsI2Km1JH3v53TGPFJF pXQFvmMWwr+T2V8+G2Dd/MBKG/oYw6QDCoiJQuDItCeufF24ONkFM8FUaqYHPMgFFv2Z cKEwNIgNSFDebNVOEVfoJrbMm3iQndoQQLaJU9CNlR49nTv17IZQMs0tNEeM8/V7yV4W aHEQ== 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=v9w0057GHgoZKWtXZ1+4u/MPirSR8go5oWQPd2eE2mI=; b=pR+wE2GEklk/qNbObP2SxDuWfbgnaG9ur7+pTceYb7gCMfBWl0YrRAXzMO0FFeqfK0 LtZHp5NdiQQ1afSUR7+Vlkxf+Mr/MvCQ24jxuiy0NlYQX2Na0yihUkJ+LFJ2ds7j93Il XUQ3TtFgarBDxG/7ALcrqFr0GUiQZ6lbc8K0CpSA9LOaRHgg1EnChtAV8TsADoJgj3ZW v9CrfABa/MmTKJ/Qp6Se/wyob7/btTLmqEX+onUrhizTGKjbKVnhHt0uOOxd8fs34rht OFkD4WtkVhOrThgLycUduC99NutFExwfCM3sPGAUiYaTdW7kgeNBKYe8ExGGb3VPUTYu l1Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=encU76jK; 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 x1-20020a17090a530100b0020cedba54fcsi1862771pjh.55.2022.10.29.07.20.00; Sat, 29 Oct 2022 07:20:13 -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=encU76jK; 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 S230102AbiJ2OTe (ORCPT + 99 others); Sat, 29 Oct 2022 10:19:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230012AbiJ2OS4 (ORCPT ); Sat, 29 Oct 2022 10:18:56 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B6E25F7FE for ; Sat, 29 Oct 2022 07:17:53 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id io19so7191952plb.8 for ; Sat, 29 Oct 2022 07:17:53 -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=v9w0057GHgoZKWtXZ1+4u/MPirSR8go5oWQPd2eE2mI=; b=encU76jKBrg6lH2ISMpQ/N7b4auZ2VydelAwmgOx19RnLM1oiSnBRWcM11Xqmvc3Cg EKkic2nHjmIz1GFChzZ8WjMeqZLnln+gDPxjo1o547phYbrMlpKwBLEn5PgEEKr/FZdI 1kZP888PIFaxLbzbKFqLGoZgFlyCuvge17GdEAxRXwUPywc8a5Z6ILYxviKf2QD4qNnD UlFfrt1Kbu+I4MBrU6N2Bqian3JljYN9ydInPZj3ilaU1a+wDVzSqyJB8ICfyQja0ntX 1099u1qHn209NgN/wtUebb8DWjq1ilbpQpz7sxbSQqHAB3yUgmu8BuXmIIOh/h1hI0DF BRSQ== 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=v9w0057GHgoZKWtXZ1+4u/MPirSR8go5oWQPd2eE2mI=; b=AE1oGUY89kRvj8cg1UYbw5mbgJ9s01dAH6FArWo4yN7w+mSQ9ycEcyvwAwSjkSogyr M0JECdKXA8w6WcOrHfiwJeHQiP/ADnRvhLYR4fuI0V9Eg9ackdDpnG04JV/tevvkVWN2 ZvJm5tY4nxiBA6nHKC909/1jPM3gfL2ysk+8UYskWiMk05CJFzDhDJPk3DZYVzIqgUgI 0sV5AVR6UaJ7TlsSY8ln8MlXwg5nGVrN4/bpDa+uWmlEL5jOq/dp/IhoBM4HjSBcgAHw chUO+oi9sZUWh3+Te3Ke8Tdaj/mOc0DXs/pKcpZ9CblACI2dzRPy51GUVqqI0+wyLA0g le5Q== X-Gm-Message-State: ACrzQf3B8cuvgcNrLoFpxL2QAKUkSi+mRy4/S5xSWPSymG/F9//P7JNh Fn2gMc0AXRvhDuawcFEd4Stk X-Received: by 2002:a17:903:50b:b0:187:11e:5f1f with SMTP id jn11-20020a170903050b00b00187011e5f1fmr4643202plb.41.1667053072648; Sat, 29 Oct 2022 07:17:52 -0700 (PDT) Received: from localhost.localdomain ([117.193.208.18]) by smtp.gmail.com with ESMTPSA id u4-20020a170902e5c400b001866049ddb1sm1370157plf.161.2022.10.29.07.17.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 07:17:51 -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, Manivannan Sadhasivam Subject: [PATCH 13/15] scsi: ufs: ufs-qcom: Factor out the logic finding the HS Gear Date: Sat, 29 Oct 2022 19:46:31 +0530 Message-Id: <20221029141633.295650-14-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221029141633.295650-1-manivannan.sadhasivam@linaro.org> References: <20221029141633.295650-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?1748031990972150439?= X-GMAIL-MSGID: =?utf-8?q?1748031990972150439?= 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 28ac5f0ab2bc..f952cc76919f 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,