Use SYNCHRONIZE CACHE instead of FUA for UFS devices
Subsystems (2)
Bart Van Assche
reviewerv2 cover Use SYNCHRONIZE CACHE instead of FUA for UFS devices
Hi Martin,
Measurements have shown that UFS devices perform better when using SYNCHRONIZE CACHE instead of FUA. Hence this patch series that makes the SCSI core submit a SYNCHRONIZE CACHE command instead of setting the FUA bit for UFS devices. Please consider this patch series for the next merge window.
Thanks,
Bart.
Changes compared to v1:
- Updated __BLIST_LAST_USED.
- Added #include <scsi/scsi_devinfo.h> to fix a build error reported by the kernel robot.
Asutosh Das (1):
scsi: ufs: Use SYNCHRONIZE CACHE instead of FUA
Bart Van Assche (1):
scsi: core: Introduce the BLIST_BROKEN_FUA flag
drivers/scsi/scsi_scan.c | 3 +++ drivers/ufs/core/ufshcd.c | 4 ++++ include/scsi/scsi_devinfo.h | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-)
Bart Van Assche
reviewerPATCH v2 1/2 scsi: core: Introduce the BLIST_BROKEN_FUA flag
UFS devices perform better when using SYNCHRONIZE CACHE command instead of the FUA flag. Introduce the BLIST_BROKEN_FUA flag for using SYNCHRONIZE CACHE instead of FUA.
The BLIST_BROKEN_FUA flag can be set by using one of the following approaches:
* From user space, by writing into /proc/scsi/device_info.
* From the kernel, by setting sdev_bflags from the slave_alloc callback.
For a prior version of this patch, see also
https://lore.kernel.org/lkml/[email protected]/T/
--- drivers/scsi/scsi_scan.c | 3 +++ include/scsi/scsi_devinfo.h | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/scsi/scsi_scan.c +3 -0
@@ -1020,6 +1020,9 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,if (*bflags &BLIST_NO_RSOC ) sdev->no_report_opcodes =1 ; +if (*bflags &BLIST_BROKEN_FUA ) + sdev->broken_fua =1 ; +/* set the device running here so that slave configure * may do I/O */ mutex_lock (&sdev->state_mutex);
include/scsi/scsi_devinfo.h +3 -1
@@ -68,8 +68,10 @@#define BLIST_RETRY_ITF ((__force blist_flags_t)(1ULL << 32))/* Always retry ABORTED_COMMAND with ASC 0xc1 */ #define BLIST_RETRY_ASC_C1 ((__force blist_flags_t)(1ULL << 33)) +/* Use SYNCHRONIZE CACHE instead of FUA */ +#define BLIST_BROKEN_FUA ((__force blist_flags_t)(1ULL << 34)) -#define __BLIST_LAST_USED BLIST_RETRY_ASC_C1 +#define __BLIST_LAST_USED BLIST_BROKEN_FUA#define __BLIST_HIGH_UNUSED (~(__BLIST_LAST_USED | \ (__force blist_flags_t) \
Bart Van Assche
reviewerRe: [PATCH v2 1/2] scsi: core: Introduce the BLIST_BROKEN_FUA flag
Quoted 40 lines · Bart Van Assche
UFS devices perform better when using SYNCHRONIZE CACHE command instead of the FUA flag. Introduce the
BLIST_BROKEN_FUAflag for using SYNCHRONIZE CACHE instead of FUA.The
BLIST_BROKEN_FUAflag can be set by using one of the following approaches:
* From user space, by writing into/proc/scsi/device_info.
* From the kernel, by settingsdev_bflagsfrom theslave_alloccallback.For a prior version of this patch, see also
https://lore.kernel.org/lkml/[email protected]/T/Cc Jaegeuk Kim <[email protected]>Cc Asutosh Das <[email protected]>Signed-off-by Bart Van Assche <[email protected]>--- drivers/scsi/scsi_scan.c | 3 +++ include/scsi/scsi_devinfo.h | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-)drivers/scsi/scsi_scan.c +3
-0@@ -1020,6 +1020,9 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,if (*bflags &BLIST_NO_RSOC ) sdev->no_report_opcodes =1 ; +if (*bflags &BLIST_BROKEN_FUA ) + sdev->broken_fua =1 ; +/* set the device running here so that slave configure * may do I/O */ mutex_lock (&sdev->state_mutex);include/scsi/scsi_devinfo.h +0
-0@@ -68,8 +68,10 @@#define BLIST_RETRY_ITF ((__force blist_flags_t)(1ULL << 32))
include/scsi/scsi_devinfo.h line 77
Quoted 10 lines
include/scsi/scsi_devinfo.h +3
-1/* Always retry ABORTED_COMMAND with ASC 0xc1 */ #define BLIST_RETRY_ASC_C1 ((__force blist_flags_t)(1ULL << 33)) +/* Use SYNCHRONIZE CACHE instead of FUA */ +#define BLIST_BROKEN_FUA ((__force blist_flags_t)(1ULL << 34)) -#define __BLIST_LAST_USED BLIST_RETRY_ASC_C1 +#define __BLIST_LAST_USED BLIST_BROKEN_FUA#define __BLIST_HIGH_UNUSED (~(__BLIST_LAST_USED | \ (__force blist_flags_t) \
(replying to an email from two months ago)
I plan to repost the above patch because this patch will allow us to set the broken_fua flag from user space. Please let me know if there are any objections or concerns.
Thanks,
Bart.
Bart Van Assche
reviewerPATCH v2 2/2 scsi: ufs: Use SYNCHRONIZE CACHE instead of FUA
In reply to Bart Van AsscheFrom: Asutosh Das <[email protected]>
UFS devices perform better when using SYNCHRONIZE CACHE command instead of the FUA flag. Hence this patch.
--- drivers/ufs/core/ufshcd.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/ufs/core/ufshcd.c +4 -0
@@ -24,6 +24,7 @@#include <linux/sched/clock.h> #include <scsi/scsi_cmnd.h> #include <scsi/scsi_dbg.h> +#include <scsi/scsi_devinfo.h> #include <scsi/scsi_driver.h> #include <scsi/scsi_eh.h> #include "ufshcd-priv.h"
@@ -5056,6 +5057,9 @@ static int ufshcd_slave_alloc(struct scsi_device *sdev)/* WRITE_SAME command is not supported */ sdev->no_write_same =1 ; +/* Use SYNCHRONIZE CACHE instead of FUA to improve performance */ + sdev->sdev_bflags =BLIST_BROKEN_FUA ; +ufshcd_lu_init (hba, sdev);ufshcd_setup_links (hba, sdev);
Quoted 6 lines · Bart Van Assche
Hi Martin,
Measurements have shown that UFS devices perform better when using SYNCHRONIZE CACHE instead of FUA. Hence this patch series that makes the SCSI core submit a SYNCHRONIZE CACHE command instead of setting the FUA bit for UFS devices. Please consider this patch series for the next merge window.
NAK. This is a policy decision that might make sense for current UFS devices. If you want to do it use the sysfs files from udev to quirk it up for them. But there is nothing inherent in the UFS transport that speaks against using FUA.
And please lobby your suppliers to either don't claim FUA support or implement it in a useful way in the future. Unlikely most of us you and your employer actually have that power in the market.
Bart Van Assche
reviewerQuoted 8 lines · Christoph Hellwig
Quoted 6 lines · Bart Van Assche
Hi Martin,
Measurements have shown that UFS devices perform better when using SYNCHRONIZE CACHE instead of FUA. Hence this patch series that makes the SCSI core submit a SYNCHRONIZE CACHE command instead of setting the FUA bit for UFS devices. Please consider this patch series for the next merge window.
Quoted 8 lines
NAK. This is a policy decision that might make sense for current UFS devices. If you want to do it use the sysfs files from udev to quirk it up for them. But there is nothing inherent in the UFS transport that speaks against using FUA.
And please lobby your suppliers to either don't claim FUA support or implement it in a useful way in the future. Unlikely most of us you and your employer actually have that power in the market.
Hi Christoph,
We can ask our suppliers politely to not claim FUA support in future devices. However we still need patch 1/2 for existing UFS devices.
Bart.
Quoted 2 lines · Bart Van Assche
We can ask our suppliers politely to not claim FUA support in future devices. However we still need patch 1/2 for existing UFS devices.
Please add quirks for the actually affected devices, and do not block fua for an entire transport.
Christoph,
Quoted 5 lines
Quoted 2 lines
We can ask our suppliers politely to not claim FUA support in future devices. However we still need patch 1/2 for existing UFS devices.
Please add quirks for the actually affected devices, and do not block fua for an entire transport.
Yeah, I agree. Let's not make assumptions about implementation deficiencies based on transport. If there are specific devices that perform better with SYNCHRONIZE CACHE, then we should quirk them.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering