* [PATCH] scsi: ufs: Add checking lifetime attribute for WriteBooster
[not found] <CGME20220126104125epcms2p50afb250190ffc3f2dc7b16df31757c94@epcms2p6>
@ 2022-01-26 11:25 ` Jinyoung CHOI
2022-01-26 23:58 ` kernel test robot
0 siblings, 1 reply; 3+ messages in thread
From: Jinyoung CHOI @ 2022-01-26 11:25 UTC (permalink / raw)
To: ALIM AKHTAR, avri.altman@wdc.com, jejb@linux.ibm.com,
martin.petersen@oracle.com, bvanassche@acm.org,
beanhuo@micron.com, cang@codeaurora.org, adrian.hunter@intel.com,
asutoshd@codeaurora.org, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org
Because WB performs write in SLC mode, it is difficult to use WB
infinitely.
Vendors can set the Lifetime limit value to the device.
If Lifetime exceeds the limit value, the device itself can disable the
WB feature.
WB feature supports "bWriteBoosterBufferLifeTimeEst (IDN = 1E)" attribute.
With Lifetime exceeding the limit value,
the current driver continuously performs the following query.
- Write Flag: WB_ENABLE / DISABLE
- Read attr: Available Buffer Size
- Read attr: Current Buffer Size
This patch recognizes that WriteBooster is no longer supported by the device,
and prevent unnecessary query issues.
Signed-off-by: Jinyoung Choi <j-young.choi@samsung.com>
---
drivers/scsi/ufs/ufs.h | 6 +++++
drivers/scsi/ufs/ufshcd.c | 52 +++++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+)
diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h
index 0bfdca3e648e..4a00c24a3209 100644
--- a/drivers/scsi/ufs/ufs.h
+++ b/drivers/scsi/ufs/ufs.h
@@ -43,6 +43,12 @@
/* WriteBooster buffer is available only for the logical unit from 0 to 7 */
#define UFS_UPIU_MAX_WB_LUN_ID 8
+/*
+ * WriteBooster buffer lifetime has a limit setted by vendor.
+ * If it is over the limit, WriteBooster feature will be disabled.
+ */
+#define UFS_WB_EXCEED_LIFETIME 0x0B
+
/* Well known logical unit id in LUN field of UPIU */
enum {
UFS_UPIU_REPORT_LUNS_WLUN = 0x81,
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 460d2b440d2e..6088af45633b 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -5778,6 +5778,47 @@ static bool ufshcd_wb_presrv_usrspc_keep_vcc_on(struct ufs_hba *hba,
return false;
}
+static void ufshcd_wb_force_disable(struct ufs_hba *hba)
+{
+ if (!(hba->quirks & UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL))
+ ufshcd_wb_toggle_flush(hba, false);
+
+ ufshcd_wb_toggle_flush_during_h8(hba, false);
+ ufshcd_wb_toggle(hba, false);
+ hba->caps &= ~UFSHCD_CAP_WB_EN;
+
+ dev_info(hba->dev, "%s: WB force disabled\n", __func__);
+}
+
+static bool ufshcd_is_wb_buf_lifetime_available(struct ufs_hba *hba)
+{
+ u32 lifetime;
+ int ret;
+ u8 index;
+
+ index = ufshcd_wb_get_query_index(hba);
+ ret = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_READ_ATTR,
+ QUERY_ATTR_IDN_WB_BUFF_LIFE_TIME_EST,
+ index, 0, &lifetime);
+ if (ret) {
+ dev_err(hba->dev,
+ "%s: bWriteBoosterBufferLifeTimeEst read failed %d\n",
+ __func__, ret);
+ return false;
+ }
+
+ if (lifetime == UFS_WB_EXCEED_LIFETIME) {
+ dev_err(hba->dev, "%s: WB buf lifetime is exhausted 0x%0.2X\n",
+ __func__, lifetime);
+ return false;
+ }
+
+ dev_dbg(hba->dev, "%s: WB buf lifetime is 0x%0.2X\n",
+ __func__, lifetime);
+
+ return true;
+}
+
static bool ufshcd_wb_need_flush(struct ufs_hba *hba)
{
int ret;
@@ -5786,6 +5827,12 @@ static bool ufshcd_wb_need_flush(struct ufs_hba *hba)
if (!ufshcd_is_wb_allowed(hba))
return false;
+
+ if (!ufshcd_is_wb_buf_lifetime_available(hba)) {
+ ufshcd_wb_force_disable(hba);
+ return false;
+ }
+
/*
* The ufs device needs the vcc to be ON to flush.
* With user-space reduction enabled, it's enough to enable flush
@@ -7486,6 +7533,7 @@ static void ufshcd_wb_probe(struct ufs_hba *hba, u8 *desc_buf)
if (!ufshcd_is_wb_allowed(hba))
return;
+
/*
* Probe WB only for UFS-2.2 and UFS-3.1 (and later) devices or
* UFS devices with quirk UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES
@@ -7537,6 +7585,10 @@ static void ufshcd_wb_probe(struct ufs_hba *hba, u8 *desc_buf)
if (!d_lu_wb_buf_alloc)
goto wb_disabled;
}
+
+ if (!ufshcd_is_wb_buf_lifetime_available(hba))
+ goto wb_disabled;
+
return;
wb_disabled:
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: ufs: Add checking lifetime attribute for WriteBooster
2022-01-26 11:25 ` [PATCH] scsi: ufs: Add checking lifetime attribute for WriteBooster Jinyoung CHOI
@ 2022-01-26 23:58 ` kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-01-26 23:58 UTC (permalink / raw)
To: Jinyoung CHOI, ALIM AKHTAR, avri.altman@wdc.com,
jejb@linux.ibm.com, martin.petersen@oracle.com,
bvanassche@acm.org, beanhuo@micron.com, cang@codeaurora.org,
adrian.hunter@intel.com, asutoshd@codeaurora.org,
linux-scsi@vger.kernel.org
Cc: kbuild-all
Hi Jinyoung,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on mkp-scsi/for-next]
[also build test WARNING on jejb-scsi/for-next v5.17-rc1 next-20220125]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Jinyoung-CHOI/scsi-ufs-Add-checking-lifetime-attribute-for-WriteBooster/20220127-064945
base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
config: alpha-allmodconfig (https://download.01.org/0day-ci/archive/20220127/202201270725.pB39Qr9M-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/119120165af15780b5bdb5bf4bf59cfd8a2826ba
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jinyoung-CHOI/scsi-ufs-Add-checking-lifetime-attribute-for-WriteBooster/20220127-064945
git checkout 119120165af15780b5bdb5bf4bf59cfd8a2826ba
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=alpha SHELL=/bin/bash drivers/scsi/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
In file included from include/linux/device.h:15,
from include/linux/async.h:14,
from drivers/scsi/ufs/ufshcd.c:12:
drivers/scsi/ufs/ufshcd.c: In function 'ufshcd_is_wb_buf_lifetime_available':
>> drivers/scsi/ufs/ufshcd.c:5811:35: warning: '0' flag ignored with precision and '%X' gnu_printf format [-Wformat=]
5811 | dev_err(hba->dev, "%s: WB buf lifetime is exhausted 0x%0.2X\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
110 | _p_func(dev, fmt, ##__VA_ARGS__); \
| ^~~
include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt'
144 | dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~
drivers/scsi/ufs/ufshcd.c:5811:17: note: in expansion of macro 'dev_err'
5811 | dev_err(hba->dev, "%s: WB buf lifetime is exhausted 0x%0.2X\n",
| ^~~~~~~
In file included from include/linux/printk.h:555,
from include/asm-generic/bug.h:22,
from arch/alpha/include/asm/bug.h:23,
from include/linux/bug.h:5,
from include/linux/thread_info.h:13,
from include/asm-generic/current.h:5,
from ./arch/alpha/include/generated/asm/current.h:1,
from include/linux/sched.h:12,
from include/linux/ratelimit.h:6,
from include/linux/dev_printk.h:16,
from include/linux/device.h:15,
from include/linux/async.h:14,
from drivers/scsi/ufs/ufshcd.c:12:
drivers/scsi/ufs/ufshcd.c:5816:27: warning: '0' flag ignored with precision and '%X' gnu_printf format [-Wformat=]
5816 | dev_dbg(hba->dev, "%s: WB buf lifetime is 0x%0.2X\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dynamic_debug.h:134:29: note: in definition of macro '__dynamic_func_call'
134 | func(&id, ##__VA_ARGS__); \
| ^~~~~~~~~~~
include/linux/dynamic_debug.h:166:9: note: in expansion of macro '_dynamic_func_call'
166 | _dynamic_func_call(fmt,__dynamic_dev_dbg, \
| ^~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:155:9: note: in expansion of macro 'dynamic_dev_dbg'
155 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~~~~~~~~
include/linux/dev_printk.h:155:30: note: in expansion of macro 'dev_fmt'
155 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~
drivers/scsi/ufs/ufshcd.c:5816:9: note: in expansion of macro 'dev_dbg'
5816 | dev_dbg(hba->dev, "%s: WB buf lifetime is 0x%0.2X\n",
| ^~~~~~~
vim +5811 drivers/scsi/ufs/ufshcd.c
5792
5793 static bool ufshcd_is_wb_buf_lifetime_available(struct ufs_hba *hba)
5794 {
5795 u32 lifetime;
5796 int ret;
5797 u8 index;
5798
5799 index = ufshcd_wb_get_query_index(hba);
5800 ret = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_READ_ATTR,
5801 QUERY_ATTR_IDN_WB_BUFF_LIFE_TIME_EST,
5802 index, 0, &lifetime);
5803 if (ret) {
5804 dev_err(hba->dev,
5805 "%s: bWriteBoosterBufferLifeTimeEst read failed %d\n",
5806 __func__, ret);
5807 return false;
5808 }
5809
5810 if (lifetime == UFS_WB_EXCEED_LIFETIME) {
> 5811 dev_err(hba->dev, "%s: WB buf lifetime is exhausted 0x%0.2X\n",
5812 __func__, lifetime);
5813 return false;
5814 }
5815
5816 dev_dbg(hba->dev, "%s: WB buf lifetime is 0x%0.2X\n",
5817 __func__, lifetime);
5818
5819 return true;
5820 }
5821
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: ufs: Add checking lifetime attribute for WriteBooster
@ 2022-01-26 23:58 ` kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-01-26 23:58 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 5940 bytes --]
Hi Jinyoung,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on mkp-scsi/for-next]
[also build test WARNING on jejb-scsi/for-next v5.17-rc1 next-20220125]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Jinyoung-CHOI/scsi-ufs-Add-checking-lifetime-attribute-for-WriteBooster/20220127-064945
base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
config: alpha-allmodconfig (https://download.01.org/0day-ci/archive/20220127/202201270725.pB39Qr9M-lkp(a)intel.com/config)
compiler: alpha-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/119120165af15780b5bdb5bf4bf59cfd8a2826ba
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jinyoung-CHOI/scsi-ufs-Add-checking-lifetime-attribute-for-WriteBooster/20220127-064945
git checkout 119120165af15780b5bdb5bf4bf59cfd8a2826ba
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=alpha SHELL=/bin/bash drivers/scsi/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
In file included from include/linux/device.h:15,
from include/linux/async.h:14,
from drivers/scsi/ufs/ufshcd.c:12:
drivers/scsi/ufs/ufshcd.c: In function 'ufshcd_is_wb_buf_lifetime_available':
>> drivers/scsi/ufs/ufshcd.c:5811:35: warning: '0' flag ignored with precision and '%X' gnu_printf format [-Wformat=]
5811 | dev_err(hba->dev, "%s: WB buf lifetime is exhausted 0x%0.2X\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
110 | _p_func(dev, fmt, ##__VA_ARGS__); \
| ^~~
include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt'
144 | dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~
drivers/scsi/ufs/ufshcd.c:5811:17: note: in expansion of macro 'dev_err'
5811 | dev_err(hba->dev, "%s: WB buf lifetime is exhausted 0x%0.2X\n",
| ^~~~~~~
In file included from include/linux/printk.h:555,
from include/asm-generic/bug.h:22,
from arch/alpha/include/asm/bug.h:23,
from include/linux/bug.h:5,
from include/linux/thread_info.h:13,
from include/asm-generic/current.h:5,
from ./arch/alpha/include/generated/asm/current.h:1,
from include/linux/sched.h:12,
from include/linux/ratelimit.h:6,
from include/linux/dev_printk.h:16,
from include/linux/device.h:15,
from include/linux/async.h:14,
from drivers/scsi/ufs/ufshcd.c:12:
drivers/scsi/ufs/ufshcd.c:5816:27: warning: '0' flag ignored with precision and '%X' gnu_printf format [-Wformat=]
5816 | dev_dbg(hba->dev, "%s: WB buf lifetime is 0x%0.2X\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dynamic_debug.h:134:29: note: in definition of macro '__dynamic_func_call'
134 | func(&id, ##__VA_ARGS__); \
| ^~~~~~~~~~~
include/linux/dynamic_debug.h:166:9: note: in expansion of macro '_dynamic_func_call'
166 | _dynamic_func_call(fmt,__dynamic_dev_dbg, \
| ^~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:155:9: note: in expansion of macro 'dynamic_dev_dbg'
155 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~~~~~~~~
include/linux/dev_printk.h:155:30: note: in expansion of macro 'dev_fmt'
155 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~
drivers/scsi/ufs/ufshcd.c:5816:9: note: in expansion of macro 'dev_dbg'
5816 | dev_dbg(hba->dev, "%s: WB buf lifetime is 0x%0.2X\n",
| ^~~~~~~
vim +5811 drivers/scsi/ufs/ufshcd.c
5792
5793 static bool ufshcd_is_wb_buf_lifetime_available(struct ufs_hba *hba)
5794 {
5795 u32 lifetime;
5796 int ret;
5797 u8 index;
5798
5799 index = ufshcd_wb_get_query_index(hba);
5800 ret = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_READ_ATTR,
5801 QUERY_ATTR_IDN_WB_BUFF_LIFE_TIME_EST,
5802 index, 0, &lifetime);
5803 if (ret) {
5804 dev_err(hba->dev,
5805 "%s: bWriteBoosterBufferLifeTimeEst read failed %d\n",
5806 __func__, ret);
5807 return false;
5808 }
5809
5810 if (lifetime == UFS_WB_EXCEED_LIFETIME) {
> 5811 dev_err(hba->dev, "%s: WB buf lifetime is exhausted 0x%0.2X\n",
5812 __func__, lifetime);
5813 return false;
5814 }
5815
5816 dev_dbg(hba->dev, "%s: WB buf lifetime is 0x%0.2X\n",
5817 __func__, lifetime);
5818
5819 return true;
5820 }
5821
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-26 23:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20220126104125epcms2p50afb250190ffc3f2dc7b16df31757c94@epcms2p6>
2022-01-26 11:25 ` [PATCH] scsi: ufs: Add checking lifetime attribute for WriteBooster Jinyoung CHOI
2022-01-26 23:58 ` kernel test robot
2022-01-26 23:58 ` kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.