From patchwork Fri Sep 8 10:20:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lu Hongfei X-Patchwork-Id: 721412 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F38B6EE57F1 for ; Fri, 8 Sep 2023 10:25:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234322AbjIHKZ5 (ORCPT ); Fri, 8 Sep 2023 06:25:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229623AbjIHKZ4 (ORCPT ); Fri, 8 Sep 2023 06:25:56 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2113.outbound.protection.outlook.com [40.107.215.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFD051FCC; Fri, 8 Sep 2023 03:25:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lhyQkz5XUamlyH0YrFVgIaDXNuxUI+iZSTGyLKNaQA8rRlR2LbJnIOLUvrayf1H2RRnzEcRjixc2VLIXLju6ZSbP3RvpEjQDBcFEqraFbvzEyuCH8vnOmuky3x5VqJ/09vKui82Yu2G1gf5B5QSMr3DHm7bFQN9u/5WqlDTwNFgfgmcwo1EFQD39SYDa79t0JLEmHp6Qw2bgfAAVPn3RzgHjSxpY6eqfVCyUVa7WVCLtDmsAyumkAwVvs/jrDCCi3bKQwCZGNzhBdsy7q7x5ks76IC5iMvFlL6EtWItE5lnX/DOFmvSRTKYitIg8RVSDWIEsEdecxzR/S7KTPH2eBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=v8wJkl/B8/0BAZqNu7T2OFqreM8vBhZdkclN98SU32U=; b=TmvvFF+4Y0PU2VEE152s0mnRP5yWB97Oc4G6x0zv5KUDaCpvNyVtn0MB4Shx8GS0ld3bzVLEOjHCziHYCYdtFYWJCHgle/JuoOfTf/61sSSkAJCkpyB1B1d16wLW7O0UsgeTls3hgX2SjXyvLB0wEGUTKLcy1njFRDEAxDMFUMZa3rjz7ww/mzpN4gvTSWKTlJfRYggw5VAwaNxODILMhMBrzFk17gZeW+iAeUijGBFFtl3q0dlV6HyDCIe3Y4355zSq/I1fs2Tw8Bqcz3RA1+B0qqS5RYIjbokpEjxrd3JCSxnckpn7pQqdrxMd8P1afnTjVUMCX+QB1f7KzcO1wg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v8wJkl/B8/0BAZqNu7T2OFqreM8vBhZdkclN98SU32U=; b=Q00EJCqnCT928P9jJJwlVKONUz4TCm9LW+4DxLtWe2dafW9JWJi3Kb8akYm0Q1jvSPWLnWolwZf4HoRgCeiCqvaiWbnlynkLXNuf1Gg41btA6ZDCfZwoe0nBFwOq6NnC6ZEC1pjeeHNE32kg1ns55UU1yriFcbQNlJcg2WC+RP4Vh1/rzgRZBNm8Rhr/qxyNIIREw/EMGL/UfuDMJMMvg2xQQUrSE92FUdA4JRrkF1PJXm+uSHBvGwVr/z2zRcVKaIns/BrJbY6UNurEAgvXLdkWPRZafxmchOTAQf8Nl1uXuXyIek7Xt/hjAlXOGRS33CRqjGK411ycxQt5rw6IfQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from TYZPR06MB6697.apcprd06.prod.outlook.com (2603:1096:400:451::6) by SEYPR06MB5110.apcprd06.prod.outlook.com (2603:1096:101:56::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.38; Fri, 8 Sep 2023 10:23:27 +0000 Received: from TYZPR06MB6697.apcprd06.prod.outlook.com ([fe80::5bef:53ac:2a7c:6f4e]) by TYZPR06MB6697.apcprd06.prod.outlook.com ([fe80::5bef:53ac:2a7c:6f4e%3]) with mapi id 15.20.6745.034; Fri, 8 Sep 2023 10:23:27 +0000 From: Lu Hongfei To: Alim Akhtar , Avri Altman , Bart Van Assche , "James E.J. Bottomley" , "Martin K. Petersen" , Lu Hongfei , Can Guo , Bean Huo , Arthur Simchaev , Stanley Chu , Manivannan Sadhasivam , Asutosh Das , "Bao D. Nguyen" , zhanghui , Po-Wen Kao , Eric Biggers , Keoseong Park , linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org Cc: opensource.kernel@vivo.com Subject: [PATCH v2 2/3] scsi: ufs: core: Add ufshcd_wb_buf_resize function to enable WB buffer resize Date: Fri, 8 Sep 2023 18:20:17 +0800 Message-Id: <20230908102113.547-3-luhongfei@vivo.com> X-Mailer: git-send-email 2.27.0.windows.1 In-Reply-To: <20230908102113.547-1-luhongfei@vivo.com> References: <20230908102113.547-1-luhongfei@vivo.com> X-ClientProxiedBy: SG2PR01CA0196.apcprd01.prod.exchangelabs.com (2603:1096:4:189::23) To TYZPR06MB6697.apcprd06.prod.outlook.com (2603:1096:400:451::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB6697:EE_|SEYPR06MB5110:EE_ X-MS-Office365-Filtering-Correlation-Id: 204bae92-e45d-4244-3666-08dbb055a405 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RRCQk+6gpBhmdl3kmMW6dYva0kaS8SMRVR3Xt2GvctJf3F+DHu4Oc5RKmCYr7gofEbJOC8+27BzxpApV04oSO2Yv/Szt4J0lwnwP3h9ZHvqQZIBFQuQ/eZUoELdrbAwsTshE/dYfQhCAy9ndFkFKFOJC8vWUEQOtNwrf0mmNv7XEzaB1LhZ4sRm4CoYUBLDXl4OJ0f0KVwSHdH5yt2SIJTNgduJY1ueEsydmP+OSrOBo/33qCjPyCeVPgcWjn+zSuSFivcx2JNWODJbCQmgkRP9+IK6dv7o4ZnF0g919eh24JkSvEARP3Q5a566VneVdF+V3dgBAmhgdYEk15G1/IWPKcsw+4QI5wPVIp2jkXA3ytA2fmX46U7fabb5WlMgrZX1XMcI24HuiWgWTxrg8j7q80sKVTdtWBfEs7cUxm+nIl5GRGwhqh61o4jnrL95ji2jMQioA1BKZhic54lQKzg5oMR+uz3u4yzYdW/3FA3LuHTMT7w9A8BfhXfKpZZBFMLC0Te8ATsE3TJTCdlquVICSgXyatufXuXEDDtyNGdvflmpvA0Byiy+rX4K5gb1/tnxauqEvMiqZkcLEzl3rCNrIWVn47BR6EPT3v2ZNDLY+6kVbSPNmdZoIYoGVqPuZuUX6NvDtVrybpnDsiQJ6uA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TYZPR06MB6697.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(376002)(346002)(39860400002)(396003)(366004)(451199024)(186009)(1800799009)(5660300002)(4326008)(8936002)(6486002)(6506007)(8676002)(66476007)(316002)(66946007)(41300700001)(66556008)(2906002)(478600001)(52116002)(6666004)(110136005)(6512007)(26005)(1076003)(107886003)(2616005)(7416002)(83380400001)(921005)(38350700002)(38100700002)(86362001)(36756003); D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/lsAQmhA7wvWV9VYcgTK956w/4ne0fs07o/yQh9txNxB42tuCC71DDr90D0grMPXB1Fg914BVNs55sHHe+fJPKleHsZfLeiVdx09c4hIdDjKyvOLE7FjHa4tCnXw5es0wNPrT3SlURrbtjG0ybDMerFaizzHU765WAbiGHX1ExxMbzb2tQwJmBhPGbWkrWSaAdHx4k2DtVJYIE4pmABIeaQzDLcJNX6rtHBfQLakjT3V+LHL/hir1rwDCV5bbFh4RBHUtvQ1Xm6oJW6QGpzdmrzUvPSRNolOZmURF9NnolAcIMniLUP5823jsO7DhpOnANFH8+wi+AbkOyUY5frS4zKPCzIpW8aRaz+S0SRii4t5HiTa3bUZvfgF9RudUuoZHbMkUOcFTGy4r8IaR3FAX0iH4eSu/j3sxrXnkw8m5vhvxCEz9lBHPk7SOAygzZBnMCl7CkQyHTUQOUyeFyPeFFrcFYe2XdczU2A58OLEsT4gA8PslzQaO+ENE2Oh6fxOlr3Mbd/7dLMibR8MAkXrpqo7pt5J5tLwtNh/G8Sn19YjS+FGv4swma/hEugCO1nYu3DssuHvSWEwlSZN X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 204bae92-e45d-4244-3666-08dbb055a405 X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB6697.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2023 10:23:27.5115 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dYm96bUAJfCZGIxkkMR4R+UU8kImv6AD9dFDaoC627Jmcwg8K3+FV3V0Xvbh4gEXiGrbe7NMYpxHm7dVp+iFog== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB5110 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org ufshcd_wb_buf_resize is used to enable WB buffer resize. It first blocks the upper layer from issuing reqs, then waits for the cmd queue to be empty, and then issues the command to enable WB buffer resize. It may be called anywhere, such as ufs-sysfs.c, so it needs to be declared in the header files. Signed-off-by: Lu Hongfei --- drivers/ufs/core/ufshcd-priv.h | 1 + drivers/ufs/core/ufshcd.c | 21 +++++++++++++++++++++ include/ufs/ufshcd.h | 1 + 3 files changed, 23 insertions(+) diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h index f42d99ce5bf1..85caefa421f7 100644 --- a/drivers/ufs/core/ufshcd-priv.h +++ b/drivers/ufs/core/ufshcd-priv.h @@ -98,6 +98,7 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba, enum query_opcode desc_op); int ufshcd_wb_toggle(struct ufs_hba *hba, bool enable); +int ufshcd_wb_buf_resize(struct ufs_hba *hba, u32 resize_op); /* Wrapper functions for safely calling variant operations */ static inline const char *ufshcd_get_var_name(struct ufs_hba *hba) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 93417518c04d..7e4461360cbd 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -6045,6 +6045,27 @@ static bool ufshcd_wb_need_flush(struct ufs_hba *hba) return ufshcd_wb_presrv_usrspc_keep_vcc_on(hba, avail_buf); } +int ufshcd_wb_buf_resize(struct ufs_hba *hba, u32 resize_op) +{ + int ret; + u8 index; + + ufshcd_scsi_block_requests(hba); + if (ufshcd_wait_for_doorbell_clr(hba, 1 * USEC_PER_SEC)) + goto out; + + index = ufshcd_wb_get_query_index(hba); + ret = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_WRITE_ATTR, + QUERY_ATTR_IDN_WB_BUF_RESIZE_EN, index, 0, &resize_op); + if (ret) + dev_err(hba->dev, + "%s: Enable WB buf resize operation failed %d\n", + __func__, ret); +out: + ufshcd_scsi_unblock_requests(hba); + return ret; +} + static void ufshcd_rpm_dev_flush_recheck_work(struct work_struct *work) { struct ufs_hba *hba = container_of(to_delayed_work(work), diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index 7d07b256e906..7dd560dc22c6 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -1381,6 +1381,7 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r struct ufs_ehs *ehs_rsp, int sg_cnt, struct scatterlist *sg_list, enum dma_data_direction dir); int ufshcd_wb_toggle(struct ufs_hba *hba, bool enable); +int ufshcd_wb_buf_resize(struct ufs_hba *hba, u32 resize_op); int ufshcd_wb_toggle_buf_flush(struct ufs_hba *hba, bool enable); int ufshcd_suspend_prepare(struct device *dev); int __ufshcd_suspend_prepare(struct device *dev, bool rpm_ok_for_spm);