mbox series

[v7,0/3] scsi: ufs: Allow RTT negotiation

Message ID 20240530142510.734-1-avri.altman@wdc.com
Headers show
Series scsi: ufs: Allow RTT negotiation | expand

Message

Avri Altman May 30, 2024, 2:25 p.m. UTC
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 appear 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.

v6 -> v7:
Some more comments to patches 2 & 3 (Bart)

v5 -> v6:
Use blk_mq_<un>freeze_queue to drain the queues (Bart)
Replace the rtt_set() vop by a max_num_rtt constant (Cristoph/Bart)

v4 -> v5:
Quiesce the queues before writing bMaxNumOfRTT (Bart)
Make bDeviceRTTCap available in ufshcd_device_params_init() (Bart)

v3 -> v4:
Allow bMaxNumOfRTT to be configured via sysfs (Bart)

v2 -> v3:
Allow platform vendors to take precedence having their own rtt
negotiation mechanism (Peter)

v1 -> v2:
bMaxNumOfRTT is a Persistent attribute - do not override if it was
written (Bean)

Avri Altman (3):
  scsi: ufs: Allow RTT negotiation
  scsi: ufs: Maximum RTT supported by the host driver
  scsi: ufs: sysfs: Make max_number_of_rtt read-write

 Documentation/ABI/testing/sysfs-driver-ufs | 14 +++--
 drivers/ufs/core/ufs-sysfs.c               | 73 +++++++++++++++++++++-
 drivers/ufs/core/ufshcd.c                  | 41 ++++++++++++
 drivers/ufs/host/ufs-mediatek.c            |  1 +
 drivers/ufs/host/ufs-mediatek.h            |  3 +
 include/ufs/ufs.h                          |  2 +
 include/ufs/ufshcd.h                       |  4 ++
 include/ufs/ufshci.h                       |  1 +
 8 files changed, 132 insertions(+), 7 deletions(-)

Comments

Bart Van Assche May 30, 2024, 6:26 p.m. UTC | #1
On 5/30/24 07:25, Avri Altman wrote:
> Allow platform vendors to take precedence having their own max rtt
> support.  This makes sense because the host controller's nortt
> characteristic may vary among vendors.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Martin K. Petersen May 31, 2024, 12:36 a.m. UTC | #2
Avri,

> 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.

Applied to 6.11/scsi-staging, thanks!
Martin K. Petersen June 5, 2024, 2:32 a.m. UTC | #3
On Thu, 30 May 2024 17:25:06 +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.
> 
> [...]

Applied to 6.11/scsi-queue, thanks!

[1/3] scsi: ufs: Allow RTT negotiation
      https://git.kernel.org/mkp/scsi/c/9ec54934ce85
[2/3] scsi: ufs: Maximum RTT supported by the host driver
      https://git.kernel.org/mkp/scsi/c/e75ff63300c5
[3/3] scsi: ufs: sysfs: Make max_number_of_rtt read-write
      https://git.kernel.org/mkp/scsi/c/600edc6620a4