scsi: ufs: core: Allow RTT negotiation
authorAvri Altman <avri.altman@wdc.com>
Thu, 30 May 2024 14:25:07 +0000 (17:25 +0300)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 31 May 2024 00:34:38 +0000 (20:34 -0400)
commit9ec54934ce857065e38523a2010e20182e76f515
treec2895352ebdb62596722f0aaaf7f8a84027a88bb
parent1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0
scsi: ufs: core: Allow RTT negotiation

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@wdc.com>
Link: https://lore.kernel.org/r/20240530142510.734-2-avri.altman@wdc.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ufs/core/ufshcd.c
include/ufs/ufs.h
include/ufs/ufshcd.h
include/ufs/ufshci.h