Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp188140rdh; Thu, 23 Nov 2023 00:37:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSzeRKB9Tr5sMIwbsklHhZ7p9xQCz+mhDE0Tv8GY8F86MzkXmEw+myU6uXCuh6d3l7wkik X-Received: by 2002:a17:90a:de98:b0:283:2652:3d20 with SMTP id n24-20020a17090ade9800b0028326523d20mr2712580pjv.9.1700728674911; Thu, 23 Nov 2023 00:37:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700728674; cv=none; d=google.com; s=arc-20160816; b=kO/mR77soKvqUFNrgaqWeqcr3Q9wS+PYLSo4c2k2PnjQHnhioUKCqGif6TSAHG/CIm iDDNiCAUW/3aajWhZ6gePn9IZfRZtsmkm5lm2DiRyDqnOUyn2sV4sLFLWCw5GIVyIGBF 0kLiWgesLHNY01CM825IfNK3XWQJ/K0vJJbwjpPaRnalNJqqS1tQ+Qvrsq2srlcDwC2g NAzNCj1DgGSlLMtdrAlDelS75voZgG9nQeM4N7kGogPYIEnIeS0OHbFR0Bh68fHB0t5k denRmuxekNaIRSGyxY6CRIEO5fl6+YyIB/SN7htvxrRQj8km5VoySbdKK7u0DdPr7Lea pZnQ== 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=Ji2W3bo2wis/cyNCK9qvvxsJUaiVTUQTXUa+SYPuFWY=; b=KLbzSTLyoGr0ob50t3ovQwBAD6JViWgPE1C2JfgP5nFm5WvbAs07IMrAFc25uVl9gz TeYbyyu+wdcgqTwnfdKAb9MaYiAducMv/fdGzokB3wf6OF236w+dCTfAW1cDrOqGl1qM 9P9BjNt1kCT1DBJZDqrpezLxO/Y9T0wJFVqG1My4o9qT2IwT6FTXYJSzZ8khBmyWY2Aj 0UMwGP/kffwBB9jh/OCGGi6SYFAW2BeqgK32AqurId6tvUCbeBqmZN2o266+hduMg5zV a8+WiqDEpkW2oWm+HPEu1ukPdoJQiL187IkEECP4pKcqPNl/833OLqa5czyvl1B3uMQx cULA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Mw643bC7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id h13-20020a17090adb8d00b002764fc15dd3si920565pjv.37.2023.11.23.00.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 00:37:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Mw643bC7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id A81A681DDD01; Thu, 23 Nov 2023 00:37:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344953AbjKWIgq (ORCPT + 99 others); Thu, 23 Nov 2023 03:36:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232012AbjKWIgk (ORCPT ); Thu, 23 Nov 2023 03:36:40 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98196A3; Thu, 23 Nov 2023 00:36:46 -0800 (PST) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AN5uFXC001324; Thu, 23 Nov 2023 08:36:33 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=Mw643bC7jWc0RyFq8R6xqdq6epMXhAiiqj3zyzpSYOZub9dVMT8XCi47b1+QPEe0mpGM e67CxL259DL0mHF6M6bpzQspm645cM75m4LxHW8m4BwUR07eFTnl3rf6vmqQmizb91l3 NgvvRvczvWCIE4UFgs61S4kmwX9japHfAsXcmBix3X2kW8xyrZJSmIN8vYPn7WUGlYH8 Og6vukbZjrJnzV/xXhcvLUtdFmRFvzA95S1e9PepKKd36n84l7PBnmQOJYs6/XGxQ8s8 wWfv6+8p31yjBFlDDWHUFQJeSt9xoymw8mveY1VFZ6GWQYHhYJ8cqn0CTWdSvt835TOD jw== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uhey5atf5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 08:36:33 +0000 Received: from pps.filterd (NASANPPMTA02.qualcomm.com [127.0.0.1]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 3AN8aWq3025956; Thu, 23 Nov 2023 08:36:32 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NASANPPMTA02.qualcomm.com (PPS) with ESMTP id 3uj1yvrv6a-1; Thu, 23 Nov 2023 08:36:32 +0000 Received: from NASANPPMTA02.qualcomm.com (NASANPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AN8a9gJ025729; Thu, 23 Nov 2023 08:36:32 GMT Received: from stor-dylan.qualcomm.com (stor-dylan.qualcomm.com [192.168.140.207]) by NASANPPMTA02.qualcomm.com (PPS) with ESMTP id 3AN8aVVk025948; Thu, 23 Nov 2023 08:36:31 +0000 Received: by stor-dylan.qualcomm.com (Postfix, from userid 359480) id BC2E420A68; Thu, 23 Nov 2023 00:36:31 -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, "Bao D . Nguyen" , Andy Gross , Bjorn Andersson , Konrad Dybcio , "James E.J. Bottomley" , linux-arm-msm@vger.kernel.org (open list:ARM/QUALCOMM SUPPORT), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 03/10] scsi: ufs: ufs-qcom: Setup host power mode during init Date: Thu, 23 Nov 2023 00:36:09 -0800 Message-Id: <1700728577-14729-4-git-send-email-quic_cang@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1700728577-14729-1-git-send-email-quic_cang@quicinc.com> References: <1700728577-14729-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-ORIG-GUID: 6JpbLIXCXbAgLJ_UFi4KUfk8QugduQmf X-Proofpoint-GUID: 6JpbLIXCXbAgLJ_UFi4KUfk8QugduQmf 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 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 clxscore=1015 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311230060 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 23 Nov 2023 00:37:31 -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