Re: [PATCH v2] scsi: ufs: Allow RTT negotiation
From: Peter Wang (王信友)
Date: Mon May 13 2024 - 05:33:00 EST
On Fri, 2024-05-03 at 14:34 +0300, Avri Altman wrote:
> The rtt-upiu packets precede any data-out upiu packets, thus
> synchronizing the data input to the device: this mostly applies to
> write
> operations, but there are other operations that requires rtt as well.
>
> There are several rules binding this rtt - data-out dialog,
> specifically
> There can be at most outstanding bMaxNumOfRTT such packets. This
> might
> have an effect on write performance (sequential write in particular),
> as
> each data-out upiu must wait for its rtt sibling.
>
> UFSHCI expects bMaxNumOfRTT to be min(bDeviceRTTCap, NORTT). However,
> as of today, there does not appears to be no-one who sets it: not the
> host controller nor the driver. It wasn't an issue up to now:
> bMaxNumOfRTT is set to 2 after manufacturing, and wasn't limiting the
> write performance.
>
> UFS4.0, and specifically gear 5 changes this, and requires the device
> to
> be more attentive. This doesn't come free - the device has to
> allocate
> more resources to that end, but the sequential write performance
> improvement is significant. Early measurements shows 25% gain when
> moving from rtt 2 to 9. Therefore, set bMaxNumOfRTT to be
> min(bDeviceRTTCap, NORTT) as UFSHCI expects.
>
> Signed-off-by: Avri Altman <avri.altman@xxxxxxx>
> Reviewed-by: Bean Huo <beanhuo@xxxxxxxxxx>
> ---
> Changes since v1:
> - bMaxNumOfRTT is a Persistent attribute - do not override if it was
> written (Bean)
> ---
> drivers/ufs/core/ufshcd.c | 36 ++++++++++++++++++++++++++++++++++++
> include/ufs/ufshcd.h | 2 ++
> include/ufs/ufshci.h | 1 +
> 3 files changed, 39 insertions(+)
>
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 0819ddafe7a6..c472bfdf071e 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -102,6 +102,9 @@
> /* Default RTC update every 10 seconds */
> #define UFS_RTC_UPDATE_INTERVAL_MS (10 * MSEC_PER_SEC)
>
> +/* bMaxNumOfRTT is equal to two after device manufacturing */
> +#define DEFAULT_MAX_NUM_RTT 2
> +
> /* UFSHC 4.0 compliant HC support this mode. */
> static bool use_mcq_mode = true;
>
> @@ -2405,6 +2408,8 @@ static inline int
> ufshcd_hba_capabilities(struct ufs_hba *hba)
> ((hba->capabilities & MASK_TASK_MANAGEMENT_REQUEST_SLOTS) >>
> 16) + 1;
> hba->reserved_slot = hba->nutrs - 1;
>
> + hba->nortt = FIELD_GET(MASK_NUMBER_OUTSTANDING_RTT, hba-
> >capabilities) + 1;
>
Hi Arvi.
Get nortt from NUTRS will have problem in mediatek platform.
The NUTRS in medatek platfrom is 32 or 64, but actually
host rtt support is only 2.
Please add new vops for host the set real rtt support.
Thanks.
Peter