RE: [PATCH v2 3/5] scsi: ufs: add LU Dedicated buffer mode support for WriteBooster

Avri Altman
2020-04-30T08:30:22Z

>
> static void ufshcd_wb_probe(struct ufs_hba *hba, u8 *desc_buf)
> {
> + int ret;
> + u8 lun;
> + u32 d_lu_wb_buf_alloc = 0;
> +
> if (hba->desc_size.dev_desc <=
> DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP)
> goto wb_disabled;
>
> @@ -6821,15 +6842,35 @@ static void ufshcd_wb_probe(struct ufs_hba
> *hba, u8 *desc_buf)
> hba->dev_info.b_wb_buffer_type =
> desc_buf[DEVICE_DESC_PARAM_WB_TYPE];
>
> - hba->dev_info.d_wb_alloc_units =
> - get_unaligned_be32(desc_buf +
> - DEVICE_DESC_PARAM_WB_SHARED_ALLOC_UNITS);
> hba->dev_info.b_presrv_uspc_en =
> desc_buf[DEVICE_DESC_PARAM_WB_PRESRV_USRSPC_EN];
>
> - if (!(hba->dev_info.b_wb_buffer_type &&
> - hba->dev_info.d_wb_alloc_units))
> - goto wb_disabled;
> + if (hba->dev_info.b_wb_buffer_type == WB_BUF_MODE_SHARED) {
> + hba->dev_info.d_wb_alloc_units =
> + get_unaligned_be32(desc_buf +
> + DEVICE_DESC_PARAM_WB_SHARED_ALLOC_UNITS);
> + if (!hba->dev_info.d_wb_alloc_units)
> + goto wb_disabled;
> + } else {
> + for (lun = 0; lun < hba->dev_info.max_lu_supported; lun++) {
> + ret = ufshcd_read_unit_desc_param(hba,
> + lun,
> + UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS,
> + (u8 *)&d_lu_wb_buf_alloc,
> + sizeof(d_lu_wb_buf_alloc));
> + if (ret)
> + goto wb_disabled;
> + if (d_lu_wb_buf_alloc) {
> + hba->dev_info.wb_dedicated_lu = lun;
> + break;
Why are you allowing only a single WB lun?
You should allow those buffers for lun0..lun7