RE: [PATCH v4 6/8] scsi: ufs: add LU Dedicated buffer mode support for WriteBooster
From: Avri Altman
Date: Sun May 03 2020 - 04:03:45 EST
> - 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++) {
max_lu_supported is determined according to bMaxNumberLU in the geometry descriptor,
which can be 32. WB buffer however, is only valid only for LU 0, ..., LU7.
Better to add this new limit to ufs.h.
> + 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;
I think you should just continue here, as it is ok for the query to fail.
The spec says:
The WriteBooster Buffer is available only for the logical units from 0 to 7 which are configured as
"normal memory type" (bMemoryType = 00h) and "not Boot well known logical unit" (bBootLunID =
00h), otherwise the Query Request shall fail and the Query Response field shall be set to "General
Failure".
Sorry for not noticing this earlier.
Thanks,
Avri
> + if (d_lu_wb_buf_alloc) {
> + hba->dev_info.wb_dedicated_lu = lun;
> + break;
> + }
> + }
>
> + if (!d_lu_wb_buf_alloc)
> + goto wb_disabled;
> + }
> return;
>
> wb_disabled:
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index 898883058e3a..f232a67fd9b3 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -861,6 +861,13 @@ static inline bool
> ufshcd_keep_autobkops_enabled_except_suspend(
> return hba->caps &
> UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND;
> }
>
> +static inline u8 ufshcd_wb_get_flag_index(struct ufs_hba *hba)
> +{
> + if (hba->dev_info.b_wb_buffer_type ==
> WB_BUF_MODE_LU_DEDICATED)
> + return hba->dev_info.wb_dedicated_lu;
> + return 0;
> +}
> +
> extern int ufshcd_runtime_suspend(struct ufs_hba *hba);
> extern int ufshcd_runtime_resume(struct ufs_hba *hba);
> extern int ufshcd_runtime_idle(struct ufs_hba *hba);
> --
> 2.18.0