RE: [PATCH v22 4/4] scsi: ufs: Add HPB 2.0 support
From: Avri Altman
Date: Mon Feb 22 2021 - 14:32:48 EST
> @@ -7447,8 +7452,14 @@ static int ufs_get_device_desc(struct ufs_hba *hba)
>
> if (dev_info->wspecversion >= UFS_DEV_HPB_SUPPORT_VERSION &&
> (b_ufs_feature_sup & UFS_DEV_HPB_SUPPORT)) {
> - dev_info->hpb_enabled = true;
> - ufshpb_get_dev_info(hba, desc_buf);
> + bool hpb_en = false;
> +
> + err = ufshcd_query_flag_retry(hba,
> UPIU_QUERY_OPCODE_READ_FLAG,
> + QUERY_FLAG_IDN_HPB_EN, 0, &hpb_en);
> + if (!err && hpb_en) {
> + dev_info->hpb_enabled = true;
> + ufshpb_get_dev_info(hba, desc_buf);
QUERY_FLAG_IDN_HPB_EN only apply to HPB2.0
> + }
> }
>
> +
> +/*
> + * WRITE_BUFFER CMD support 36K (len=9) ~ 512K (len=128) default.
> + * it is possible to change range of transfer_len through sysfs.
> + */
Actually the transfer length is limited by its (and read id) single byte.
Fixing MAX_HPB_READ_ID = 128 is IMO a reasonable choice,
But not limited by spec. Maybe make note of that ?
> +static inline bool ufshpb_is_required_wb(struct ufshpb_lu *hpb, int len)
> +{
> + return (len >= hpb->pre_req_min_tr_len &&
> + len <= hpb->pre_req_max_tr_len);
> }
Maybe also check HPB2.0 as well?
> -void ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
> +int ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
> {
> struct ufshpb_lu *hpb;
> struct ufshpb_region *rgn;
> @@ -282,26 +546,27 @@ void ufshpb_prep(struct ufs_hba *hba, struct
> ufshcd_lrb *lrbp)
> u64 ppn;
> unsigned long flags;
> int transfer_len, rgn_idx, srgn_idx, srgn_offset;
> + int read_id = MAX_HPB_READ_ID;
Should be 0 if wb is not used?
> +
> + hpb->pre_req = kcalloc(qd, sizeof(struct ufshpb_req), GFP_KERNEL);
> + hpb->throttle_pre_req = qd;
What is the point in throttling if you are allowing 32 simultaneous commands?
There can't be more than qd/2 anyway?
On the contrary, it makes much more sense to control the inflight map requests, instead?
> + hpb->num_inflight_pre_req = 0;
> +
> -#define HPB_SUPPORT_VERSION 0x100
> +#define HPB_SUPPORT_VERSION 0x200
In ufshpb_get_dev_info you are bailing out if version != HPB_SUPPORT_VERSION
Meaning you are no longer backward supporting HPB1.0?
Maybe it would be more constructive to allow a day or 2 for more people to comment this new patch?
After all, it is a lot of code.
Thanks,
Avri