Re: [PATCH] scsi: ufs: add a quirk to disable FUA support

From: Adrian Hunter
Date: Wed Jun 01 2022 - 01:24:48 EST


On 31/05/22 23:10, Jaegeuk Kim wrote:
> UFS stack shows very low performance of FUA comparing to write and cache_flush.
> Let's add a quirk to adjust it.
>
> E.g., average latency according to the chunk size of write
>
> Write(us/KB) 4 64 256 1024 2048
> FUA 873.792 754.604 995.624 1011.67 1067.99
> CACHE_FLUSH 824.703 712.98 800.307 1019.5 1037.37

Wouldn't it depend on how much data might be in the cache?
Do you have real-world use-cases where the difference is measurable?

>
> Signed-off-by: Jaegeuk Kim <jaegeuk@xxxxxxxxxx>
> ---
> drivers/scsi/ufs/ufshcd.c | 3 +++
> drivers/scsi/ufs/ufshcd.h | 5 +++++
> 2 files changed, 8 insertions(+)
>
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 3f9caafa91bf..811f3467879c 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -5035,6 +5035,9 @@ static int ufshcd_slave_configure(struct scsi_device *sdev)
> */
> sdev->silence_suspend = 1;
>
> + if (hba->quirks & UFSHCD_QUIRK_BROKEN_FUA)
> + sdev->broken_fua = 1;
> +
> ufshcd_crypto_register(hba, q);
>
> return 0;
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index 94f545be183a..6c480c6741d6 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -602,6 +602,11 @@ enum ufshcd_quirks {
> * support physical host configuration.
> */
> UFSHCD_QUIRK_SKIP_PH_CONFIGURATION = 1 << 16,
> +
> + /*
> + * This quirk disables FUA support.
> + */
> + UFSHCD_QUIRK_BROKEN_FUA = 1 << 17,

Wouldn't it be more appropriate to make it a UFS_DEVICE_QUIRK_
since it presumably depends on the UFS device not the host controller?

Also, as already commented by others, there needs to be a user of
the quirk

> };
>
> enum ufshcd_caps {