From patchwork Thu Dec 22 14:09:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 35790 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp349726wrn; Thu, 22 Dec 2022 06:16:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXt0zp8q2D0eGaWwiDSEz2gg3ddWTJ6ym67tLEzIlx/rQ1cpa6QJUboUYfMoxMzCx78spGF8 X-Received: by 2002:a50:eacc:0:b0:46c:ec6f:43d7 with SMTP id u12-20020a50eacc000000b0046cec6f43d7mr6346845edp.19.1671718607506; Thu, 22 Dec 2022 06:16:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671718607; cv=none; d=google.com; s=arc-20160816; b=VsmQmSUM2liUpJzs/sdf5lJb9m3uB/587MJILYfwbD1RALaudTxD49MPNCXbZ/lpU6 taRIRJLpgEhF7Fls1bvGbqxyVZcBEjtvH++kxEK6ZoMTt4VwEtT2TTRouq4yMniWvqlv K+9GmtVjsy51GIhG1jaV3pl9r8fsIVUzd5YOAvecQVaDZ4WwMgpVrTXLl9qtd06qldzJ pthpqSTN/dciaLQM9ATw7NaaX1EE+sQYLuG9aEMDylPzydOeApUY3RTZ403K8G80Kkeo iePGw9CkcmiWZbyJuRzpKflTIModt0L73XNJU1KOQ/y0Ok0bwS0tkYxN+jRlnhkaZWrR yFOQ== 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=SPN6MvsLleyjqtpg7glkpxk2Wcr9bYRBKaDcXVrkxao=; b=cxapq/N/+b+K2e/JtwD12vrVqIEQqjIypPMiZ8TG9ej2p2Gz0W/pBlnVFhIZsr8u0S dkNzPYjlMwGBQGa98x9Rl1S4Y/aTRa/hBEzkbMxC3rV42qBXXiqw6Cdtr7qMEnF6W9wF jCjfdC0K3S2wiZG6i3iDrgOV9ElUTVIRx7+2yrq5FSJ10PDB9lb3ofQgTfOmO+6IjYkz n+Wkx6LuxjWfD7/Ltc0vopwV0bxXLsXXR6MTmt23P5KFf3oKmvp7n2QxUmrx9Rel/sXt 3qb83yx2K0puWSxgs39g3dhSXLKZSS5mNGI+9DEp0AWA78ETsP8ph8h0pK54x2QapHM5 G2VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vSlLDPBk; 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 d4-20020a05640208c400b0046d25b746a6si676692edz.632.2022.12.22.06.16.24; Thu, 22 Dec 2022 06:16:47 -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=vSlLDPBk; 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 S235610AbiLVOPg (ORCPT + 99 others); Thu, 22 Dec 2022 09:15:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235492AbiLVOOf (ORCPT ); Thu, 22 Dec 2022 09:14:35 -0500 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 134C531350 for ; Thu, 22 Dec 2022 06:12:40 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id b2so2118608pld.7 for ; Thu, 22 Dec 2022 06:12:39 -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=SPN6MvsLleyjqtpg7glkpxk2Wcr9bYRBKaDcXVrkxao=; b=vSlLDPBkg+X0ZBxJOz0DTSh8gbGqwFDw8UyYr/ADDQaA8R0hwaZRRaMpkOy6O4o0sp JGqUgdcaT1m6ws2nPfO2XNoFBQ14GrEDWqdYaVwKauZGyoTePtC/skYEx0T71dwuCFi2 Hnr3gUVFPrG8fdACGv8bvmF3Oap3mjD8CIvt/XZM7TWFXQnszK3IDSrDHj6NIZ7XZDJh +rNo8mmnfwme1AQ+x7iJanAPi2bj/RikfdCgKVauk+geNc3jTLWTfH0Znkhi/yoGkg2K sHahEJ0OTclZuxC6X6J46uAV8ATkrebW6Qw2QQnUFLCWkP+gG8NF4vEtRYtVWNs1UKpK 4DQw== 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=SPN6MvsLleyjqtpg7glkpxk2Wcr9bYRBKaDcXVrkxao=; b=vBVlkMb8iXPtb5Cj3qiS3MUap45/Knp1fcw1IgroFfYn6hAPWLqkluj8EJAMfBgtEH 1wme8M4Ff7r2LMWxjvGmfP+2Bx9a5d/aO2wZk02bn7oRytfhNj/bUK8+RUkFtke2c9Uh LEQkDWH110xprni0ct5Xf0+1mEPx9dYcOqmqHRCk7UQh1njNq3mk5ljzRz9uv7eOJhod 0AhuZcq8geJZ7ivbnzPNEpKyvZiZpkLbyZlGf5TFXagV/AYMzLqL4tGZgKfjeejg35AW SHpb4V7PhH9JLOKOSzGtxd12LyygIHLhbnAW7xwht2+cmZQnQkeUwJTVxnICFUx3l/YW o2LA== X-Gm-Message-State: AFqh2kpaWuUKA1CkKkyr/5V/ogvoSXR5u20EpgwZQL/f/GayQNIPL5l5 lozw9HH4vwkWJY3CuT3Tyocy X-Received: by 2002:a05:6a20:d695:b0:a2:c1f4:3c70 with SMTP id it21-20020a056a20d69500b000a2c1f43c70mr7254391pzb.8.1671718359483; Thu, 22 Dec 2022 06:12:39 -0800 (PST) Received: from localhost.localdomain ([117.217.177.177]) by smtp.gmail.com with ESMTPSA id f8-20020a655908000000b0047829d1b8eesm832031pgu.31.2022.12.22.06.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Dec 2022 06:12:38 -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, alim.akhtar@samsung.com, avri.altman@wdc.com, bvanassche@acm.org, Manivannan Sadhasivam Subject: [PATCH v5 20/23] scsi: ufs: ufs-qcom: Factor out the logic finding the HS Gear Date: Thu, 22 Dec 2022 19:39:58 +0530 Message-Id: <20221222141001.54849-21-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221222141001.54849-1-manivannan.sadhasivam@linaro.org> References: <20221222141001.54849-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?1752924010444834111?= X-GMAIL-MSGID: =?utf-8?q?1752924010444834111?= 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 Tested-by: Andrew Halaney # Qdrive3/sa8540p-ride 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,