From patchwork Fri Sep 8 10:20:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lu Hongfei X-Patchwork-Id: 721413 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 7CC62EE57EF for ; Fri, 8 Sep 2023 10:24:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238873AbjIHKYi (ORCPT ); Fri, 8 Sep 2023 06:24:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229710AbjIHKYh (ORCPT ); Fri, 8 Sep 2023 06:24:37 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2101.outbound.protection.outlook.com [40.107.215.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 813482110; Fri, 8 Sep 2023 03:24:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EKjJuD45R3vmNSJRxMJ7cS6nkus0OZYV25cSo5/NFc3Q+vjz105BtG+T9jc9SRwLxCm+pqUuobKfyrcHPWgpoQSHv2P/m3G/Ih6U4uYk/NDIGGD64Pm9im8RY3USrWlR21LwF+VeedZrF7fzpbnRzda6NP5mYFM14GCFaRBIVOfnGBMdLBBkO9HCaBuixm0iUnbqYPTIxy4eaxpwjmBFBTFt+qn+p6gthBltWuLz/GviDJhFZsPkislMf7W0tOFdZGq/VENhltHUCR+fq3l2Y89CxyJbguF4jOe1VBLq+C3eAtT7eaOGWV08w6VwDOARAY5ucbo6HyIRiN2yEWlCNQ== 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=OPnlR08hbsoclGERdenfkrp/RinvaXl1VOr7NFSDndQ=; b=PvZJawnYdqvLhyal7j+n7FDEOOmYPL1Dj7u88z6NRkmTpLP19gYa37vCy0D9A3OJo0mXDlc5QUwjv7vqZ8QWaZsxffcx/+9/iaMUCznlL5MudbNPX0JAdd8UOrw7AS9Xu6YMIzNZL7vAy7KbR6Cqe/ypqBrXAR4hj1B1D/NNbkjmsBL3mSuHRi0L3UEkqcWlfm2DXHva0fnR9HKUcJswhFSo2oBnPNXubGdgdvcYYJBGoNZRN+VKJpeIlRxuu9hpi4Vjt495hX5x9eFlm5he/8+aznvbKF5++jdFYj0lVDjdp/qJh1hwKiVpkIovpvL7clmIYrzd8VvVLCYw9wnp2w== 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=OPnlR08hbsoclGERdenfkrp/RinvaXl1VOr7NFSDndQ=; b=BrAThSXCl55FbeeAecQASk+SgyvIcMhdUuLfqk4TuH3ZBKLm+iiMSztxBp68eiHASfUrzh8xfSMR8LtYk7ylL4Ak2iofqKk6os1gkoYVaxMpAu56ENSvjJXkT7bOxaExRK0vNLOcbxvykCLTbuCsx3tS78Vap2E1O98URpI+l3oBbrOJ1rWxtAJc6nXLL3EG9q+rh6oqWB7KmyDbT+usf6FK/XHqzt0OVwvi8518P47YlsZc9hOUaxk6qi5lnXnG8xP9ATIVTnlnhBgdB9ZU4VWkobvJ6/buemUNeZoo76WA5Oc3nyuXOTG0eg/EfGI8aZxfjPy9zTm8UQdJmvOYrA== 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:22:28 +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:22:28 +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 1/3] scsi: ufs: core: add wb buffer resize related attr_idn Date: Fri, 8 Sep 2023 18:20:16 +0800 Message-Id: <20230908102113.547-2-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: 9e3a5e46-fb2f-49fb-33b3-08dbb05580bf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Acy8Xc/SSg+ksDBFgzcb2uvvFGeVtkQ4EZ+GKXXYz0to6K1fXInnKlImRRFHKXH28Ya53ni/YX0LG8s46FSV/A54UcKUVCrq9qSHOdNTwVz75lDcgTXW+yLLZ1wikzJWswnSA1No0hk3j02DYjeEcU/srjqWCuJTNcBKib0DrHaCiRIxKE8YgldWv0anFVGLmOOo+WhbvRDD4UyQFvt8gmJeuMP2YTlLYq+jBqNVgqrX7Bod9NjnOjsi6d4274TLZiH1YLUOsy9+xJJN9z6qe0qP4yZJ8rYA0ZEjIN6pdXlDLv2aw/PpwCZJw6aLe2EfTKWitMj2H99ysaSKa0097QQXU0OjYyMoAF3HGSDn8riCDC5Y4qpXG4hF7gJMWod3sXf4akTpj94YKbtdyk2NRLDwQ/OEiWccXRk/n3s8XDd1CUEnGsjFlTW3t9r6ah7O1ECeOb/Xu91pQWDvinmx5i/8vZsGOAxJAZfuhMFRI2Sr2PB/8rw1BnYLCMVlZPMtCUGz2vIR8fh71/yGK9Yacv9mUeB/6R6tcvZwy+jLjZnXgPPl9lLPeEn0iI1IIeFpFV15eJGjiXWYdUhQ9OAlClhehw1m/JEtyDow036MV9c2N+/2TF5pwr8XQ1JYTSmtFuS88CRqZWRKM6QzUepCuw== 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)(4744005)(41300700001)(66556008)(2906002)(478600001)(52116002)(6666004)(110136005)(6512007)(26005)(1076003)(107886003)(2616005)(7416002)(83380400001)(921005)(38350700002)(38100700002)(86362001)(36756003); DIR:OUT; SFP:1102; X-MS-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GCRXGs4AQOy/Dc2aLofjZPyS3EHaueFt6co8MHcX0yISKUPr8tS8CVacBTfOI5GJpMe3PNPljKScXF35+cTgg9x9SuHQSWL98erxnbS2sit3uAQY5BKTiaEJEAAVIKxfz/2wSFJlGHcJ1HIYpbjJAv5ZXK4yP6TT5NT3sROeVo1Z1Hr+Rt1N3w9v6O4zKfTRPEv+Y/0PYs3Onfs8nTwWeBUtVstgmJmCBBsTYQp3zumdSz8O2BMPdPmQje9td6Q2m4MYWTJjPWKgJiVI8D4elYAuJvJ/58FWCjXjoAKtdFLHr+WRr4HiWeoucPTbhGUfBJEah7U/om2Bw8g8mlZZSEyeZd2jPHzBlQ5n4g1l55wxUR+vWC6Fi5Jr6B8aiKD7ct6/sUNHHaq4MfPD+sf6gehBxfH5fOstPe6RutI9It1/TDUzFIFenC0HZBTtiGHmqZJEHkKMFKgji1IG+G/RuLX2wHftoEWQXB1naHYaFPyUMVAeex1k4hFQE3r6YqKgEh1ASIKClu6kStbNlqhDh5xc8R0Lm8okce791/GA5gmMddDJnviMk7ESOQ1 X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9e3a5e46-fb2f-49fb-33b3-08dbb05580bf 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:22:28.3885 (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: tQbf8mb09yl6B48bAu5Rm4c9nw3R7YDFSMPUOla3JPEPYMdV+69jVmPBnw4QxrFAh02p4QoNz3YVEims280plg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB5110 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org UFS4.1 will support the WB buffer resize function, and UFS driver needs to add definitions for attr_idn related to this function to support this feature Signed-off-by: Lu Hongfei --- include/ufs/ufs.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/ufs/ufs.h b/include/ufs/ufs.h index 0cced88f4531..8016bf30c8c4 100644 --- a/include/ufs/ufs.h +++ b/include/ufs/ufs.h @@ -179,7 +179,10 @@ enum attr_idn { QUERY_ATTR_IDN_WB_BUFF_LIFE_TIME_EST = 0x1E, QUERY_ATTR_IDN_CURR_WB_BUFF_SIZE = 0x1F, QUERY_ATTR_IDN_EXT_IID_EN = 0x2A, - QUERY_ATTR_IDN_TIMESTAMP = 0x30 + QUERY_ATTR_IDN_TIMESTAMP = 0x30, + QUERY_ATTR_IDN_WB_BUF_RESIZE_HINT = 0x3C, + QUERY_ATTR_IDN_WB_BUF_RESIZE_EN = 0x3D, + QUERY_ATTR_IDN_WB_BUF_RESIZE_STATUS = 0x3E }; /* Descriptor idn for Query requests */ 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); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hZKLwxkeffrVuraReU//HcG5MFOxeRH7xD4oa0O9wO6lWdVnJY7F7zVvZynHSEy/FhC+5bKGKu6TjCEUypsarpXQq5spvGpTpsruxvEEva3ywpRPGW9k94PbJkn9D7uYkR895P0kxHF8v6cYfJ8cMPDwyRhQc4TRdP1XowVd/svbwHaIk+iFkI5+ZGkdWouaiFcYgYuUD/1xHbww9hfqQhAJBLr67AhDjYklMvjT05yvE0pgyUKp18cz8lAGRT65sX7yjG90GamRyaxHmCckdbEQ3KoOgI3+hqllouRpzvujH2zIVe5gIIJi5i2CGQGluyTyrlr+Fhf+o8AqHXIK0ii6Gj81C0/JkDtjfeBm4kE4dNmtia0iehEzU5u/i/IY5L3Yn58vIyQhx3LTAsJ4vjnPP5j/nUby2a2pqf7MZiW1Tm4Sr0DEPrC8SZ9SzDXs4Qxztkp/pt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pt5J5tLwtNh/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); From patchwork Fri Sep 8 10:20:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lu Hongfei X-Patchwork-Id: 721066 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 A69CCEE57F1 for ; Fri, 8 Sep 2023 10:25:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243092AbjIHKZG (ORCPT ); Fri, 8 Sep 2023 06:25:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242628AbjIHKZE (ORCPT ); Fri, 8 Sep 2023 06:25:04 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2101.outbound.protection.outlook.com [40.107.215.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06C532108; Fri, 8 Sep 2023 03:24:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nUzRPtPEoGpCiwn+qdtK9GogPJctvqPbDqiye06up61MaoGXzWKF6Lwd6OlDuQc4y6syaOQzFyLyv4TQe1MxQaWBm4e0xNfor9Hj3lHsYlGrW070VTOzG0kq3NcUXTW1SkBVSm4JTMRBVlktc2mz1wAQjZkugkCxCB7GOYAqGRSM6DNUclY1w21FmVIvVlY6RuymYYJbp0pFgWDBju+oIAOcqaiDIe0Az3PI8vYO2592XzBOqssXvTxvSCPU3/sEnlXFLNKlu5gTkwkl77OJG4kQKjqv5Mu1fPQc8RtoJKMkBnQisOdmnBaCcduSrqj0I8uKvDY6qz7pbjGs3VacZg== 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=9hKLMc5Znzg9iN1UL4p/j3XS0pY/BiB45SxpH2s3Q8g=; b=Yq9CXxWfZO4ww36S31QQ88KMJP+vOFl/JGQji0NJT1PAqvJfAbu5H3qjAgbn7qM3E6UokjMC9nQ0kquqstPSRVE7SjQKE+EFltv0ylbfGzwgtoPHS1+28pt85JXGQFNfHxCE6gfO6nUD4G0hnvmvm1lfdEOxzwGhyUgk8wr/u7cXiygFVAbUjACk3l9OJA++4BOlkW/ChkMjCBKBRJPTcWHkVJg4H8XHZFtB01Y55uMySn64vnbZJDnWLqyBSRgkrgAycMKZ+8jhsftrwW8JCEgQGnP/np8tMpuz1Crdu4DnhokwHWHyJQr0abodcJfKUnUfcIyXumyskqOsnci/hw== 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=9hKLMc5Znzg9iN1UL4p/j3XS0pY/BiB45SxpH2s3Q8g=; b=J1WlZx+xaOg9pLxSVOT/CM3LCii+/tA7b6S03Q3n1+31PWYtgL4qSnJdnsD4Gyi6cbGkskxSgzXPkhyKtTqGZR2ubgEP+bd8LEicgMzznsk/Z62TU2uz8rc65m0fPybkK/gmlOkSnpyLR/xMXiCxWzA+NA0VYi3rGwKtFQ6G6ODn1dB/Y2tF6f9JAiX+2dGiao/TYRNH2WOgRa2rqGI+cfBQMCliNoQcewrShik0A0osVpmMQCyY5JwNa0N2EPjMOdjWpEQZv14lpx6zUZ4seZs3FUVN3l7wEkvozbzDdK30HQyuCwXrbif/eTkqd4WeyHFyOpPYbRZF6Aszv3PweQ== 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:24:26 +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:24:26 +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 3/3] scsi: ufs: core: Add sysfs attributes to control WB buffer resize function Date: Fri, 8 Sep 2023 18:20:18 +0800 Message-Id: <20230908102113.547-4-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: d9e42a0a-51de-4dc5-87b2-08dbb055c759 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tTSlny69Qr0MY8uGpa03RWgnWk7d9RbYibYcvKO3T3k8r6tDSq8y1RHNVAmXjDhuhdcZ2n/Ex5p3ZR7apke+e/F3ZO/ex68fndFGAbhSGqnnAl6mQ8PYOPGcuEjZX7QrotDiR5buv+M7lvA/OQgiWsxrdOvu/8oQg8n+2hXYMxax9iz+Cee19g2qIvvptOC5RDjOT/p6gFkOypFsTsF29h3vWpS1E/n/NzKrn7mNJUQ2rdUXbUGnMJTTAG8ambF14pF69c5klcaZqWG1FUQrn4sXWaTovB5sbjo8BzCpLkNeTBA7oT3WsAXHVChgyKNbhyy5oilCbLNMpi10dFN3qUOgd1sBxnsPDmBcCjs6BYKqaulMFpQUHpRVdWojxvYKR68ypl+iFziRHuwR8s8HDw4XnkVdcy+g8Klxi2mrSHRS7ya5I0Qy7t95KayxXL1ChBfwUuaV2KgtVkNKCri7F6stYJK+Sz3BaeM3cTgDelutpGvfDyd37PWLjHKAfKv+pJWz/caQCXRln6VxSufe24IVgogUWerRqhqP9gbHypkikq8AkcQQCsWaEQbNMJB/lApV1GHPi47taVJxkNjANAZQEpiS2IdCmxappY/7ZfxsWlvtpdh991j/PIJzttiDd+zTACrFDM8F04rF11AAiA== 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); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YC43SchpM4mz09k4U64Ohsnack5AfaI4Y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6f1Ne1IDPB2EBH1Vs9ely94K2usFOLhZR7NYWGEutB2yBGx6ZjFQUITw8iOPJe9JgdFxInQp8tEDnpLTYFHWTwdO4Zy5WGjyNdA7HUqoRKfvCRvFYw2pEKoC5V3dAFjViXU6poRUx3JW2TZ/OnFwklQUb1whFZ3zWy7+5VvULlkxrH8DWmLrIUhZRkZ5slcXvd5w1ctcYcXj4Pv7MGf+U4gxrvBsFoUEdhm8IRDY/bx8A83pNsh25U3Agh2g6Xc7qxFEG5qmO2/GnINCTyfYdewmEEyNfAVAW1PmkxZQXpAK0k/l/Kh1OIr08/q7JFJv/mHAVTM5ArJIPaLWnN93QJTGaWHUjyM6MaA8ZH/gnW1odLV0VlVs0/XrNosgqMe4Hq4L+KUvleFFRL+sFb11eqLoSPbDaxHl7ZG9E5ugQbyP3Ge3LIcU+cKCZ0P1etEMK8nJTrDTqp8JdIi0GxZmLtOebds93OYgg9EU1+oPKG X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d9e42a0a-51de-4dc5-87b2-08dbb055c759 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:24:26.7906 (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: Y24Tj1JcUsNyK9U4v4oRWXS5112gtniOcxF8eZMv1SM7NfH26j/KAh94V8xnThq7m62quk0KEF9tNmhMMRlaRw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB5110 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The host can control the WB buffer resize through sysfs. To achieve this goal, three sysfs nodes have been added: 1. wb_buf_resize_hint 2. enable_wb_buf_resize 3. wb_buf_resize_status The host can read wb_buf_resize_hint, obtain the hint information about which type of resize for wb buffer, and write enable_wb_buf_resize to enable wb buffer resize based on the hint information. Considering that this process may take a long time, the host can confirm the resize status by reading wb_buf_resize_status. The detailed definition of the three nodes can be found in the sysfs documentation. Signed-off-by: Lu Hongfei --- Documentation/ABI/testing/sysfs-driver-ufs | 52 ++++++++++++++++ drivers/ufs/core/ufs-sysfs.c | 71 ++++++++++++++++++++++ 2 files changed, 123 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-driver-ufs b/Documentation/ABI/testing/sysfs-driver-ufs index 0c7efaf62de0..6e0ecf3a025d 100644 --- a/Documentation/ABI/testing/sysfs-driver-ufs +++ b/Documentation/ABI/testing/sysfs-driver-ufs @@ -1437,6 +1437,58 @@ Description: If avail_wb_buff < wb_flush_threshold, it indicates that WriteBooster buffer needs to be flushed, otherwise it is not necessary. +What: /sys/bus/platform/drivers/ufshcd/*/wb_buf_resize_hint +What: /sys/bus/platform/devices/*.ufs/wb_buf_resize_hint +Date: Sept 2023 +Contact: Lu Hongfei +Description: + wb_buf_resize_hint indicates hint information about which type of resize for + WriteBooster Buffer is recommended by the device. + + ====== ====================================== + 00h Recommend keep the buffer size + 01h Recommend to decrease the buffer size + 02h Recommend to increase the buffer size + Others: Reserved + ====== ====================================== + + The file is read only. + +What: /sys/bus/platform/drivers/ufshcd/*/enable_wb_buf_resize +What: /sys/bus/platform/devices/*.ufs/enable_wb_buf_resize +Date: Sept 2023 +Contact: Lu Hongfei +Description: + The host can decrease or increase the WriteBooster Buffer size by setting + this file. + + ====== ====================================== + 00h Idle (There is no resize operation) + 01h Decrease WriteBooster Buffer Size + 02h Increase WriteBooster Buffer Size + Others Reserved + ====== ====================================== + + The file is write only. + +What: /sys/bus/platform/drivers/ufshcd/*/wb_buf_resize_status +What: /sys/bus/platform/devices/*.ufs/wb_buf_resize_status +Date: Sept 2023 +Contact: Lu Hongfei +Description: + The host can check the Resize operation status of the WriteBooster Buffer + by reading this file. + + ====== ======================================== + 00h Idle (resize operation is not issued) + 01h Resize operation in progress + 02h Resize operation completed successfully + 03h Resize operation general failure + Others Reserved + ====== ======================================== + + The file is read only. + Contact: Daniil Lunev What: /sys/bus/platform/drivers/ufshcd/*/capabilities/ What: /sys/bus/platform/devices/*.ufs/capabilities/ diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c index c95906443d5f..2ecb1e08a5b8 100644 --- a/drivers/ufs/core/ufs-sysfs.c +++ b/drivers/ufs/core/ufs-sysfs.c @@ -329,6 +329,71 @@ static ssize_t wb_flush_threshold_store(struct device *dev, return count; } +static ssize_t wb_buf_resize_hint_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct ufs_hba *hba = dev_get_drvdata(dev); + u32 value; + u8 index = ufshcd_wb_get_query_index(hba); + + if (ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_READ_ATTR, + QUERY_ATTR_IDN_WB_BUF_RESIZE_HINT, index, 0, &value)) { + dev_err(hba->dev, "Read WB Buffer Resize Hint info failed\n"); + return -EINVAL; + } + + return sysfs_emit(buf, "%u\n", value); +} + +static ssize_t enable_wb_buf_resize_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct ufs_hba *hba = dev_get_drvdata(dev); + unsigned int wb_buf_resize_op; + + if (!ufshcd_is_wb_allowed(hba) || !hba->dev_info.wb_enabled) { + dev_err(dev, "The WB is not allowed or disabled!\n"); + return -EINVAL; + } + + if (hba->dev_info.wspecversion < 0x410 || + !hba->dev_info.b_presrv_uspc_en) { + dev_err(dev, "The WB buf resize is not allowed!\n"); + return -EINVAL; + } + + if (kstrtouint(buf, 0, &wb_buf_resize_op)) + return -EINVAL; + + if (wb_buf_resize_op != 0x01 && wb_buf_resize_op != 0x02) { + dev_err(dev, "The operation %u is invalid!\n", wb_buf_resize_op); + return -EINVAL; + } + + ufshcd_wb_buf_resize(hba, wb_buf_resize_op); + + return count; +} + +static ssize_t wb_buf_resize_status_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct ufs_hba *hba = dev_get_drvdata(dev); + u32 value; + u8 index = ufshcd_wb_get_query_index(hba); + + if (ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_READ_ATTR, + QUERY_ATTR_IDN_WB_BUF_RESIZE_STATUS, index, 0, &value)) { + dev_err(hba->dev, "Read WB Buffer Resize Status info failed\n"); + return -EINVAL; + } + + return sysfs_emit(buf, "%u\n", value); +} + static DEVICE_ATTR_RW(rpm_lvl); static DEVICE_ATTR_RO(rpm_target_dev_state); static DEVICE_ATTR_RO(rpm_target_link_state); @@ -339,6 +404,9 @@ static DEVICE_ATTR_RW(auto_hibern8); static DEVICE_ATTR_RW(wb_on); static DEVICE_ATTR_RW(enable_wb_buf_flush); static DEVICE_ATTR_RW(wb_flush_threshold); +static DEVICE_ATTR_RO(wb_buf_resize_hint); +static DEVICE_ATTR_WO(enable_wb_buf_resize); +static DEVICE_ATTR_RO(wb_buf_resize_status); static struct attribute *ufs_sysfs_ufshcd_attrs[] = { &dev_attr_rpm_lvl.attr, @@ -351,6 +419,9 @@ static struct attribute *ufs_sysfs_ufshcd_attrs[] = { &dev_attr_wb_on.attr, &dev_attr_enable_wb_buf_flush.attr, &dev_attr_wb_flush_threshold.attr, + &dev_attr_wb_buf_resize_hint.attr, + &dev_attr_enable_wb_buf_resize.attr, + &dev_attr_wb_buf_resize_status.attr, NULL };