From patchwork Wed Nov 29 08:28:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 171157 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp196262vqn; Wed, 29 Nov 2023 00:30:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IFAX4W9lRUcFhY3A6GWLsXlHnvnghHNqKov+CFio1jByoy7M9Mr0p8SGB0IXOt71XwaEqUN X-Received: by 2002:a17:90b:38d2:b0:285:b687:b82b with SMTP id nn18-20020a17090b38d200b00285b687b82bmr15019188pjb.1.1701246602026; Wed, 29 Nov 2023 00:30:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701246602; cv=none; d=google.com; s=arc-20160816; b=QZlodo5OfYPo9CT+u0WvA3JQAUZ+oPdKiBvuOyB66WAzBYFgYqK+fggeJ+Fue5T7uB gFUhzw0Qg8sTkHHkex/T1CH7fV3EaUSOEWMRfyb/VC5nybtsDsNXcYcyHbgy4Q3I7U8m UlgeTmLxK+MDWJwqc5MNEDg2Ly91Y+EpxGMnQEfXdnJ6GOUzEeCuFwaLlZ5cN2LrKoAL bSRUXljfGDOEcrOkF6W47CLqzzfGS/arFdFPpO9/vyZj8oa/BxNh68GNof44ru293thO R+kQ8mtmrCv9f+4jmtr69E5gd3akRAbXQVt1bVH1AwZsHup7wNegB2xjo6OwfFnKwMJK yP2g== 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=B1stBXweFHGLo0FZ562PYkOASJIgvjARx2einm+rVNQ=; fh=phzbN5Ug7iMQWhcx3kQ1KsZT8h3bRi807SvZ3xgXd5U=; b=shP3IATcRtS1VX14o7OK2BTT21vlpJXJL8FOwa8ttYOhw0+OlSIhdJXEcZiokpP1BL J6FHm631vwA5ZjdPjzs90gxG2DMHf2IoH+//QKwK/D4aZb7ZJVxnaajLt9KDwALhMNI5 RG8QG5WOOu+kpMRICcFjYMGp7Fcq8ksw7CugZOp3vV/GhhJvfRK7c7glsdUQeYwi/vvS kR65NoqmA/dt/NQnLFWzu2kOhZT1VuKcdTKAyfHRFj2Ff+Dk+cwbuUdCDOOK6OwJ2uiN SbNidQug4BFTYLam5gACcMVCu0Qid4kXlwatvT8ucX5uZLb5VAjymM5QAlndV0KUtoMo p7PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=FdHIO0ch; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id a18-20020a17090a8c1200b002861f0ed8ddsi630255pjo.12.2023.11.29.00.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 00:30:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=FdHIO0ch; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id AF73480A9321; Wed, 29 Nov 2023 00:29:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232328AbjK2I3O (ORCPT + 99 others); Wed, 29 Nov 2023 03:29:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231572AbjK2I3J (ORCPT ); Wed, 29 Nov 2023 03:29:09 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CB7F1BCC; Wed, 29 Nov 2023 00:29:15 -0800 (PST) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AT0c1wP026202; Wed, 29 Nov 2023 08:28:56 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=B1stBXweFHGLo0FZ562PYkOASJIgvjARx2einm+rVNQ=; b=FdHIO0chEOw0EhLnLC8oXoMku4SAEwNZKIXVEPTYykYBQmPE/nkij9gvroEG9Opb+cUy 7WTTOtNAiZ2KkmUn6tfcfWPti0TWzEwg208nolR8mf2kI10Pt67rCq/NuwBSQ4HYXebn ocITqoU5gjlaENLjLl4ZqZ9es5J0cOMHbVvP4c2z5wmPPupQWQpQOyiCuk500nGHCxA6 VnjcGEB+733xtHNX++DPih0NZgvV3Ayj0aU9QNgxJujEYv7ZxNxIthf92AMGma+sI+Ku 8MQhuO2XLeXsKLivQ9NhraglyhT0r9WXS5RF6VQvOiT1mK4A3plj16vJLES8HJWVP+Sa qg== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3unnpesndy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Nov 2023 08:28:56 +0000 Received: from pps.filterd (NASANPPMTA03.qualcomm.com [127.0.0.1]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 3AT8H9ST023384; Wed, 29 Nov 2023 08:28:55 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NASANPPMTA03.qualcomm.com (PPS) with ESMTP id 3unmev6wy5-1; Wed, 29 Nov 2023 08:28:55 +0000 Received: from NASANPPMTA03.qualcomm.com (NASANPPMTA03.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AT8SsZO007540; Wed, 29 Nov 2023 08:28:55 GMT Received: from stor-dylan.qualcomm.com (stor-dylan.qualcomm.com [192.168.140.207]) by NASANPPMTA03.qualcomm.com (PPS) with ESMTP id 3AT8Ssse007534; Wed, 29 Nov 2023 08:28:54 +0000 Received: by stor-dylan.qualcomm.com (Postfix, from userid 359480) id 88EC120A5D; Wed, 29 Nov 2023 00:28:54 -0800 (PST) From: Can Guo To: quic_cang@quicinc.com, bvanassche@acm.org, mani@kernel.org, adrian.hunter@intel.com, cmd4@qualcomm.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 v6 03/10] scsi: ufs: ufs-qcom: Setup host power mode during init Date: Wed, 29 Nov 2023 00:28:28 -0800 Message-Id: <1701246516-11626-4-git-send-email-quic_cang@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1701246516-11626-1-git-send-email-quic_cang@quicinc.com> References: <1701246516-11626-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: Hjbt9V35o9NguTUgbfLrfnroWd7AMMeq X-Proofpoint-ORIG-GUID: Hjbt9V35o9NguTUgbfLrfnroWd7AMMeq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-29_06,2023-11-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 priorityscore=1501 adultscore=0 clxscore=1015 bulkscore=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311290062 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email 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 (howler.vger.email [0.0.0.0]); Wed, 29 Nov 2023 00:29:51 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783886356861286689 X-GMAIL-MSGID: 1783886356861286689 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 Reviewed-by: Nitin Rawat Reviewed-by: Manivannan Sadhasivam 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 c21ff2c..9a90019 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_params(&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_params(&host_params, dev_max_params, dev_req_params); + ret = ufshcd_negotiate_pwr_params(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_params(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;