Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp191549rdh; Thu, 23 Nov 2023 00:47:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIafgcqIU9s/EXtCV11fzDUiz/saqX7ZndJUhiT+OoggQgl6K1x3toyWdm7D4ju/nxGMmM X-Received: by 2002:a17:902:e88b:b0:1cf:7cfc:c39b with SMTP id w11-20020a170902e88b00b001cf7cfcc39bmr3142293plg.7.1700729266652; Thu, 23 Nov 2023 00:47:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700729266; cv=none; d=google.com; s=arc-20160816; b=dkYd5TTjOU3uv3ruFeTtN/BbHnDMqyKJIT6vO8KSmCov/W5z/tz/6xzTgVS3848Nm3 0lC/IBNePu82wSG6Y2cY/YZyz5lcnkR8HXJ89Gq1/8bay3b1JF9g/fXTOhzvxfMoCv2l gl0QRdPwrs+xpXhMDismE7rxEpkdyt5W0nLqAHNZ/4sM77qdw++42LP6md7X9nAyn5gS Kn66Xv8E62GduZ4+1kCldhNChn+FQAOM9uvCPVsZCQamDqK9s5xqSwfvOunqQVwobEeb icGHM2uFho7npAa4Ic4rHg03ZgHTNdHwqgzZzPlmAWt55wrSFtBv3RhB9expUmAe+9Gz 37Kg== 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=Bo886srp5MIVH1wCxiVYC/PHqeZIjQZkwCjvvESOKhI=; fh=v3WNAOsdDjKrPdvI+YfvazMKUjHMUeIEo+mnrPz2+wM=; b=pI4Aer/e2XZrNIdD7EuxwAaraaYLr5Rfn2P1lFOzMUgaNBCkasFa0+F36eXlnxyu/n Tvuf9FU+ur3JQF+mYm/2FRcPqcg/sRTk7nPniNLgb37WEMJAbJiauRETW+xad+RagVLh aT0Iwj1A7WxjxzugrRE4w1weP2Pc49/s4e8QwhBuMyIEeg0n5hlipeMk8ZnKF9vYrMel biGioec8JlDJHZ0rGZJP+1bsySFxbJZUikiIhkdCqOmk8lKgZYClTC5ppOkdVhirk6EQ xUQSy0xyC0h3W3WkpUBmAKOt6JsXSzQ1QmfkdNgWlHfftWHHoLhQmoeXe9nGYCpTMDm2 Jg3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=geSJdQJz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id b6-20020a170902ed0600b001cf59df025csi712577pld.459.2023.11.23.00.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 00:47:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=geSJdQJz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 308AD804755A; Thu, 23 Nov 2023 00:47:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232006AbjKWIrM (ORCPT + 99 others); Thu, 23 Nov 2023 03:47:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233978AbjKWIrK (ORCPT ); Thu, 23 Nov 2023 03:47:10 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE8E2D42; Thu, 23 Nov 2023 00:47:16 -0800 (PST) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AN5b0Yf020304; Thu, 23 Nov 2023 08:47:05 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=Bo886srp5MIVH1wCxiVYC/PHqeZIjQZkwCjvvESOKhI=; b=geSJdQJzcP9MmCZcX8vOwa6kwntUKseAWwpyXZ9zK4+F4ELaDnMtuH5+bgLHy6ng2HCS H+bYQ8J3I7GMeHSGtZWkszw9cAnVTO2hE9MQ6iCrREYWXGIuDww2Q5P5eqqDz1BHX8hX KUzWaXjo3dPe2p/iJGbDEOqy66QS17VAFGaWmpbEDU8lRU6DaXkH7jlfNFAqb+KAH/PW u9sZ5tpCGZbcwoMInWI+0bpHaRv5S8DxjgXpqW7rnDliiAJi/Lxr9+m2In/32YGVCfz0 UGcba/vG6ls/ID9QQmysE4VaBLa6ZoFBs260vzSMc3qNeyvnVAQ9febGjNe+U3r+XE4t 4g== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uhr5psdeq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 08:47:05 +0000 Received: from pps.filterd (NASANPPMTA01.qualcomm.com [127.0.0.1]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 3AN8l4FG031218; Thu, 23 Nov 2023 08:47:04 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NASANPPMTA01.qualcomm.com (PPS) with ESMTP id 3ughrmny4f-1; Thu, 23 Nov 2023 08:47:04 +0000 Received: from NASANPPMTA01.qualcomm.com (NASANPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AN8l4XY031209; Thu, 23 Nov 2023 08:47:04 GMT Received: from stor-dylan.qualcomm.com (stor-dylan.qualcomm.com [192.168.140.207]) by NASANPPMTA01.qualcomm.com (PPS) with ESMTP id 3AN8l36x031202; Thu, 23 Nov 2023 08:47:04 +0000 Received: by stor-dylan.qualcomm.com (Postfix, from userid 359480) id 7263420A68; Thu, 23 Nov 2023 00:47:03 -0800 (PST) From: Can Guo To: quic_cang@quicinc.com, bvanassche@acm.org, mani@kernel.org, adrian.hunter@intel.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, "Bao D . Nguyen" , Andy Gross , Bjorn Andersson , Konrad Dybcio , "James E.J. Bottomley" , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 03/10] scsi: ufs: ufs-qcom: Setup host power mode during init Date: Thu, 23 Nov 2023 00:46:23 -0800 Message-Id: <1700729190-17268-4-git-send-email-quic_cang@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1700729190-17268-1-git-send-email-quic_cang@quicinc.com> References: <1700729190-17268-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-GUID: vt3znQUMD1AOLFAte8yg94WYKzHc4B6K X-Proofpoint-ORIG-GUID: vt3znQUMD1AOLFAte8yg94WYKzHc4B6K X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-23_06,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 phishscore=0 mlxscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 adultscore=0 clxscore=1015 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311230062 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 23 Nov 2023 00:47:27 -0800 (PST) Setup host power mode and its limitations during UFS host driver init to avoid repetitive work during every power mode change. Acked-by: Andrew Halaney Co-developed-by: Bao D. Nguyen Signed-off-by: Bao D. Nguyen Signed-off-by: Can Guo --- drivers/ufs/host/ufs-qcom.c | 21 ++++++++++++++------- drivers/ufs/host/ufs-qcom.h | 1 + 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index cc30ad9..cc0eb37 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -898,7 +898,7 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba, struct ufs_pa_layer_attr *dev_req_params) { struct ufs_qcom_host *host = ufshcd_get_variant(hba); - struct ufs_host_params host_params; + struct ufs_host_params *host_params = &host->host_params; int ret = 0; if (!dev_req_params) { @@ -908,12 +908,7 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba, switch (status) { case PRE_CHANGE: - ufshcd_init_host_param(&host_params); - - /* This driver only supports symmetic gear setting i.e., hs_tx_gear == hs_rx_gear */ - host_params.hs_tx_gear = host_params.hs_rx_gear = ufs_qcom_get_hs_gear(hba); - - ret = ufshcd_negotiate_pwr_param(&host_params, dev_max_params, dev_req_params); + ret = ufshcd_negotiate_pwr_param(host_params, dev_max_params, dev_req_params); if (ret) { dev_err(hba->dev, "%s: failed to determine capabilities\n", __func__); @@ -1048,6 +1043,17 @@ static void ufs_qcom_advertise_quirks(struct ufs_hba *hba) hba->quirks |= UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH; } +static void ufs_qcom_set_host_params(struct ufs_hba *hba) +{ + struct ufs_qcom_host *host = ufshcd_get_variant(hba); + struct ufs_host_params *host_params = &host->host_params; + + ufshcd_init_host_param(host_params); + + /* This driver only supports symmetic gear setting i.e., hs_tx_gear == hs_rx_gear */ + host_params->hs_tx_gear = host_params->hs_rx_gear = ufs_qcom_get_hs_gear(hba); +} + static void ufs_qcom_set_caps(struct ufs_hba *hba) { struct ufs_qcom_host *host = ufshcd_get_variant(hba); @@ -1272,6 +1278,7 @@ static int ufs_qcom_init(struct ufs_hba *hba) ufs_qcom_set_caps(hba); ufs_qcom_advertise_quirks(hba); + ufs_qcom_set_host_params(hba); err = ufs_qcom_ice_init(host); if (err) diff --git a/drivers/ufs/host/ufs-qcom.h b/drivers/ufs/host/ufs-qcom.h index 82cd143..11419eb 100644 --- a/drivers/ufs/host/ufs-qcom.h +++ b/drivers/ufs/host/ufs-qcom.h @@ -238,6 +238,7 @@ struct ufs_qcom_host { struct gpio_desc *device_reset; + struct ufs_host_params host_params; u32 phy_gear; bool esi_enabled; -- 2.7.4