Hi Avri, On Sun, 2020-05-03 at 08:00 +0000, Avri Altman wrote: > > > - 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. Thanks for noticing this. I will fix it in next version. > > > + 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. Always appreciate your review and always not being too late : ) The spec does not mention clearly that the Query Request shall fail for Read or Write. Although I think it shall fail for Write only, i.e., fail during configuration only, it is better to let fail being skipped and check d_lu_wb_buf_alloc only anyway. I will fix this as well in next version. Thanks, Stanley Chu > > 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 > > _______________________________________________ > Linux-mediatek mailing list > Linux-mediatek@xxxxxxxxxxxxxxxxxxx > http://lists.infradead.org/mailman/listinfo/linux-mediatek