Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp594888rwd; Mon, 12 Jun 2023 19:32:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4cH+eRhnpNt6JfhuhYVwScXiTZl100Aj2bCdjxOKyqUl845/OD79NUCtR7jcNUAwfC0ZK8 X-Received: by 2002:a17:907:7f1e:b0:96f:f56a:e9be with SMTP id qf30-20020a1709077f1e00b0096ff56ae9bemr12218971ejc.8.1686623575170; Mon, 12 Jun 2023 19:32:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686623575; cv=pass; d=google.com; s=arc-20160816; b=O9Nm6R7tHHYJ90gR2y2S7bydbTyOZeQtbrANpmAAaUaHYmFWJYOjVHNQLbAh0ZEOzY cb5kYavPAk2ugqIR92OvtGcC4BhjTpJ2K35EyI2WaEoFrhrc7m7yFzvSJFM7JnyExR5K C+xKiKxmF4SfxMS3rLU2LnNcCIDEFYdKcZoWvOOlyJNdmj7Pp1S6NXxLX4ArYDMyJOAz T0hTVG65E0OKKyZE3UjK6lIFvaNXtXItwzRZq123H2hlM05+v4WZbaCeP8KxmS33WBtQ Be8BeeSUNCgL/5YErbkuj45hg/dLv/tTShBAZGloQA82wk2ExJ/G3MKnBWHlAf0UnrvZ RwCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=T/sn6++dQJCq6vRVNKIIn3NDrKh5v7CV6wB08E/rxyo=; b=aEMH7AhfXylQ3IziGsCSgmYfkuPoC3jtz3kZ8Y81Qg6peJWnUTkUgLXFSXLXPsbYaC tE68LV65xIHxixwlNvdUIPGYumNpDzuRe8QDGpvZ2Z0Xog6FEZDLToUp4dLEFox/dtHH qMclnt/+i1KoZ9skB5EK0GkKuFoq5UV2/19vL0WYOujAqISLUTc9+QJPO9kc9aIO7qLr wovvSkE7miAKkgnrNvd1oa3Ate/1Us+5d1/rr6+sxTbyRzvTvBaxiYKSsWZ0j40pRgsf 2Wb0tVAR851N3FQ17JxbKpLm6QOnt14IP9tjRKVBA4EaOZJxA5dqbB05l7uUYDP76pb1 5WSw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=BnQHZ6bc; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h19-20020a1709062dd300b0097462bb9f3asi2614461eji.499.2023.06.12.19.32.31; Mon, 12 Jun 2023 19:32:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=BnQHZ6bc; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237485AbjFMCW5 (ORCPT + 99 others); Mon, 12 Jun 2023 22:22:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229807AbjFMCWy (ORCPT ); Mon, 12 Jun 2023 22:22:54 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2137.outbound.protection.outlook.com [40.107.215.137]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3E70AA; Mon, 12 Jun 2023 19:22:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GUUMo18Q3F2+zLET7lSSUZPC3IZpKtFvewU57vbrErUoTsjMa7e+iEqwkdMfcHuLk2FY8dcEsHUjv+7nPSBCiSOvKce3gklA4VTlAi+bDc698BVCgbPpmQg9DdySW720EUTLC+a5AQenm/p/qG/8zf5C+uYTXi5DJ5BwqRJx12SItwvSUrCN5RUcAg0A6cmQ8jKE9Kg0rsld6r6DxqPfFO28B6EwOOa5KKr3rFn5Dior7VAdIjcxuXj9r0Rmip+c7+bKupAPYYNHuITLfcVkTMvB8YxRA1lqXLVatGMPxExvdyV9RitSj3BQ3l2XTZVGsVO4yK8sdakKLxq73Odogw== 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=T/sn6++dQJCq6vRVNKIIn3NDrKh5v7CV6wB08E/rxyo=; b=nyYkZx0fvT1Y92J1TuL6ywb7imkKJsr0FsSySj9TgLGpi4S5pycUnUZuHThUu5gmaVxB1lbUIP6JmA3L6CL4wPEqP0qiKh+ujGq4cQf3FwmK6xKBl/v3QrrPXVPOfg4vyz3xQ49tv5c3Mwzr1cn2FrS7JN8F7JZo+mpdt3I1Xs/eLrRAG5XC+F05kzK05nbLyv+KdxLPb9Bz50NOAiAT7jVkOqXPuTkn67JBEjkEjznQwbcHjyKff927IoywBBpOcxbGjpwA0GIPYU6fcnrNX0MZ61xxs1tJcjyr5lKJlEccW9uxlvbnjK8bhrlwoDlp1I42SX1XYas96uzssjqC2A== 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=T/sn6++dQJCq6vRVNKIIn3NDrKh5v7CV6wB08E/rxyo=; b=BnQHZ6bcqZUhLTfR5aZsLd7qR0tSVH7zqdue9yrNnvA0cM1hQWFz6+bvNSiSdm6wUIZ3F2pt+zOeAd8G/uc5zV2j+X/8pmV70Ep5m0UCdc2i8uBIFhdw7R7lT93hKsWZzuZGa3vnTsk41/bD6oUeS6NntNJgoPfqK5hsZSRhiV+i8ehINX4oZ5f1+8l346jK41Wby7J8Y2NfgZAXkT9yEWIize6vveTait1BgD1tOvY7d+SMDjH8OcQeK9TCwSEN3ZmVHkS6jCkD1NrKTGdu2IsmuqSpD6uRUATzybVrb0lBITI52FYaODYDVRgDZhmYugNQxLlzlx2Nc/f4c5BiRw== 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 SI2PR06MB4426.apcprd06.prod.outlook.com (2603:1096:4:154::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.29; Tue, 13 Jun 2023 02:22:49 +0000 Received: from TYZPR06MB6697.apcprd06.prod.outlook.com ([fe80::f652:a96b:482:409e]) by TYZPR06MB6697.apcprd06.prod.outlook.com ([fe80::f652:a96b:482:409e%5]) with mapi id 15.20.6455.030; Tue, 13 Jun 2023 02:22:49 +0000 From: Lu Hongfei To: Alim Akhtar , Avri Altman , Bart Van Assche , "James E.J. Bottomley" , "Martin K. Petersen" , Jinyoung Choi , Daniil Lunev , Lu Hongfei , Bean Huo , Peter Wang , linux-kernel@vger.kernel.org (open list), linux-scsi@vger.kernel.org (open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER) Cc: opensource.kernel@vivo.com Subject: [PATCH v5] scsi: ufs: wb: Add explicit flush_threshold sysfs attribute Date: Tue, 13 Jun 2023 10:22:34 +0800 Message-Id: <20230613022240.16595-1-luhongfei@vivo.com> X-Mailer: git-send-email 2.39.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: TYWP286CA0007.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:178::15) To TYZPR06MB6697.apcprd06.prod.outlook.com (2603:1096:400:451::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB6697:EE_|SI2PR06MB4426:EE_ X-MS-Office365-Filtering-Correlation-Id: a0f24cc7-8087-43e7-bda3-08db6bb514f5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k2HEbVgxt6YgNGVGZnjB37+gYoq0H7dDMLW7ODP4JdPQeXIKYy5Q0iBaWEEreF3iwBrqalCKNLwIgKDF7K+GBWVuGof64v59X0d7vbKbbs5LAdAFSttGBa3lZIbCH433n+U/WDU8E18qOGMDsh20zhoMbJgsRYUCrs+q0rIOhIFJn+nAOkRAN2Ky3FgSL7ARTUiXdN2F71hg+8uOy8p79ENgJmGdbsnAuyH3zkZEiWWkxuWPflIpThcIFM60Y8JLx5BLIgoDKnYVfCASDzAJ8Tpzfknr3ZJQecskg9ZOY0+wlFGl0XRj2KhiEk/EVsAVZeXirU/H/cWU4RsL3JiCWvnNZeIM4tCFy4jvamtTBnDGFS0U2gFd9GSU+Sb7tNF1qfmxo9fcINt4DRB2WNUfcl4pA/8zTXeeeRMSi0ux+JMrySTiouffIrCylSr0D2MtXMkruNcoySby3NrW+fIHZ1LfNa+jSMcxT2/6Win0uK4rvsKuMWjlB7X7y/AN9fRfKYNcKIoHLDTc1z4GBFy14DMiTqnNsFFy/j5iU8en7I1DRyUuDm9ihdCI43bpUGejS8A7XFimoKouFSDCANCBcEVMne5GxH9Ir2S+K6pf6AENub+E2nFhP1YpdRtEGfs2b6EVvrCmazUbtWmf+CHKfg== 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:(13230028)(4636009)(346002)(136003)(39860400002)(396003)(376002)(366004)(451199021)(316002)(6486002)(52116002)(41300700001)(2616005)(86362001)(186003)(6512007)(1076003)(26005)(7416002)(107886003)(2906002)(6506007)(921005)(38100700002)(38350700002)(5660300002)(36756003)(8676002)(8936002)(66946007)(66556008)(110136005)(6666004)(478600001)(4326008)(66476007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?U3MUCIAoC6FdzKWeAMHt5pENr3P+hTOwV+RPsDA5wAFRJT2JilRwYksjcuhG?= =?us-ascii?Q?gPMRYQ+g4Bxl7dOMU5699f2BW01BMIc8rmQ4hT6T7CuTZPyMYSTbkyyekdn8?= =?us-ascii?Q?sfssGcznoLO3iJFR3ze5eGd4kPBYo5bN+uoHDddySzj5iC1aD3C0Pwo+Bgs9?= =?us-ascii?Q?8g8GvFmzyOXw4qseK56kRvVzY2dXGHVoFLgffXBl3To+97NXrlJM4Iy+N77z?= =?us-ascii?Q?ZhMsTVqkLpTd4Nz6BY33SgOB1Hbl8zKwUbRBfvDnVML0w6wyAwT5T6EMwygs?= =?us-ascii?Q?LdRevJyHKQ1WJanapPYQWR0K+vog1FqcSpU8LH4NQxZ3Oa4eA+psxtv5wqVx?= =?us-ascii?Q?B8wxYz405urLJ927H1lhLZDe4NAE+buAD2I77lbosBHKNK0GZzszy6agg400?= =?us-ascii?Q?nW5V1CYlrlMH9ACvijGfLCxmGv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Dzee84iBtOwunOnXfsVdBhbPf8FtYv1n3FB1hLVZzGL1Ocz9aQzqlvPVs+kc?= =?us-ascii?Q?zFgHaSMurIY35YRdJSRLmDMtnlRmw4oqGv1UkVwULcZqvrF8NVknGst6HuME?= =?us-ascii?Q?n2Q8fBTD6R9V4zzjneOsjMtGsmFWjaDJM9vhH8R0MtcufrP4bHx8y6YCg8Kd?= =?us-ascii?Q?DfvAM61YkaxAPPQQli0FcUgLtxCHklKlU5HtxCbbU56XTBG2wV89Jj1QmwnL?= =?us-ascii?Q?2g1V8sVE+Xmn3qwMfj8VhlI8ZbzpbuR/cCTnRdoI?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0f24cc7-8087-43e7-bda3-08db6bb514f5 X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB6697.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2023 02:22:48.9922 (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: bGWh3HcUemfo6D+nYRMmA9z6KhE2t1NxZKFwOMwS5axVpQNSnLVt5sCCIF9NehHa/wHGluniUz3U0+hzbBsluw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR06MB4426 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,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 There are three flags that control Write Booster Feature: 1. WB ON/OFF 2. WB Hibern Flush ON/OFF (implicitly) 3. WB Flush ON/OFF (explicit) In the case of "Hibern Flush", one of the conditions for flush WB buffer is that avail_wb_buff < wb_flush_threshold. As we know, different users have different requirements for power consumption and performance. Therefore, we need the ability to manually set wb_flush_threshold, so that users can easily and flexibly adjust the wb_flush_threshold value, thereby achieving a balance between power consumption and performance. So the sysfs attribute that controls this is necessary. wb_flush_threshold represents the threshold for flushing WB buffer, whose value expressed in unit of 10% granularity, such as '1' representing 10%, '2' representing 20%, and so on. Signed-off-by: Lu Hongfei --- The modifications made compared to the previous version are as follows: 1. Optimize the description of wb_flush_threshold in sysfs documentation to make the meaning clearer and more accurate Documentation/ABI/testing/sysfs-driver-ufs | 11 ++++++++ drivers/ufs/core/ufs-sysfs.c | 33 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-driver-ufs b/Documentation/ABI/testing/sysfs-driver-ufs index 228aa43e14ed..d5f44fc5b9dc --- a/Documentation/ABI/testing/sysfs-driver-ufs +++ b/Documentation/ABI/testing/sysfs-driver-ufs @@ -1426,6 +1426,17 @@ Description: This entry shows the status of WriteBooster buffer flushing If flushing is enabled, the device executes the flush operation when the command queue is empty. +What: /sys/bus/platform/drivers/ufshcd/*/wb_flush_threshold +What: /sys/bus/platform/devices/*.ufs/wb_flush_threshold +Date: June 2023 +Contact: Lu Hongfei +Description: + wb_flush_threshold represents the threshold for flushing WriteBooster buffer, + whose value expressed in unit of 10% granularity, such as '1' representing 10%, + '2' representing 20%, and so on. + 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/*/device_descriptor/hpb_version What: /sys/bus/platform/devices/*.ufs/device_descriptor/hpb_version Date: June 2021 diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c index cdf3d5f2b77b..347207f4e8ee 100644 --- a/drivers/ufs/core/ufs-sysfs.c +++ b/drivers/ufs/core/ufs-sysfs.c @@ -298,6 +298,37 @@ static ssize_t enable_wb_buf_flush_store(struct device *dev, return res < 0 ? res : count; } +static ssize_t wb_flush_threshold_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct ufs_hba *hba = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%u\n", hba->vps->wb_flush_threshold); +} + +static ssize_t wb_flush_threshold_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_flush_threshold; + + if (kstrtouint(buf, 0, &wb_flush_threshold)) + return -EINVAL; + + /* The range of values for wb_flush_threshold is (0,10] */ + if (wb_flush_threshold > UFS_WB_BUF_REMAIN_PERCENT(100) || + wb_flush_threshold == 0) { + dev_err(dev, "The value of wb_flush_threshold is invalid!\n"); + return -EINVAL; + } + + hba->vps->wb_flush_threshold = wb_flush_threshold; + + return count; +} + static DEVICE_ATTR_RW(rpm_lvl); static DEVICE_ATTR_RO(rpm_target_dev_state); static DEVICE_ATTR_RO(rpm_target_link_state); @@ -307,6 +338,7 @@ static DEVICE_ATTR_RO(spm_target_link_state); 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 struct attribute *ufs_sysfs_ufshcd_attrs[] = { &dev_attr_rpm_lvl.attr, @@ -318,6 +350,7 @@ static struct attribute *ufs_sysfs_ufshcd_attrs[] = { &dev_attr_auto_hibern8.attr, &dev_attr_wb_on.attr, &dev_attr_enable_wb_buf_flush.attr, + &dev_attr_wb_flush_threshold.attr, NULL }; -- 2.39.0