All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi/sd_zbc: Use READ(10)/WRITE(10) for zoned UFS devices
@ 2024-02-29 17:23 Bart Van Assche
  2024-02-29 17:29 ` Damien Le Moal
  2024-03-01 13:09 ` Christoph Hellwig
  0 siblings, 2 replies; 14+ messages in thread
From: Bart Van Assche @ 2024-02-29 17:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Damien Le Moal, Niklas Cassel,
	James E.J. Bottomley

READ(10) and WRITE(10) are sufficient for zoned UFS devices. UFS device
manufacturers prefer to minimize the size of their firmware and hence
also the number of SCSI commands that are supported. Hence this patch
that switches from READ(16)/WRITE(16)/SYNCHRONIZE CACHE(16) to READ(10)/
WRITE(10)/SYNCHRONIZE CACHE(10) for zoned UFS devices. The 16-byte
commands are still used for zoned devices with more than 2**32 logical
blocks because of the following code in sd_read_capacity():

	if (sdkp->capacity > 0xffffffff)
		sdp->use_16_for_rw = 1;

Cc: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/ata/libata-scsi.c | 10 ++++++++--
 drivers/scsi/sd_zbc.c     |  5 -----
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 0a0f483124c3..a196dce4bbc3 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -986,8 +986,14 @@ static void ata_gen_ata_sense(struct ata_queued_cmd *qc)
 
 void ata_scsi_sdev_config(struct scsi_device *sdev)
 {
-	sdev->use_10_for_rw = 1;
-	sdev->use_10_for_ms = 1;
+	if (sdev->type == TYPE_ZBC) {
+		/* READ16/WRITE16/SYNC16 is mandatory for ZBC devices */
+		sdev->use_16_for_rw = 1;
+		sdev->use_16_for_sync = 1;
+	} else {
+		sdev->use_10_for_rw = 1;
+		sdev->use_10_for_ms = 1;
+	}
 	sdev->no_write_same = 1;
 
 	/* Schedule policy is determined by ->qc_defer() callback and
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index 26af5ab7d7c1..bcdb21706d3f 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -924,11 +924,6 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE])
 		return 0;
 	}
 
-	/* READ16/WRITE16/SYNC16 is mandatory for ZBC devices */
-	sdkp->device->use_16_for_rw = 1;
-	sdkp->device->use_10_for_rw = 0;
-	sdkp->device->use_16_for_sync = 1;
-
 	/* Check zoned block device characteristics (unconstrained reads) */
 	ret = sd_zbc_check_zoned_characteristics(sdkp, buf);
 	if (ret)

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-03-01 13:09 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-29 17:23 [PATCH] scsi/sd_zbc: Use READ(10)/WRITE(10) for zoned UFS devices Bart Van Assche
2024-02-29 17:29 ` Damien Le Moal
2024-02-29 18:05   ` Bart Van Assche
2024-02-29 18:31     ` Damien Le Moal
2024-02-29 18:54       ` Bart Van Assche
2024-02-29 19:58         ` Damien Le Moal
2024-02-29 20:05           ` Bart Van Assche
2024-02-29 22:07             ` Bart Van Assche
2024-02-29 22:16               ` Damien Le Moal
2024-02-29 22:39                 ` Bart Van Assche
2024-02-29 22:45                   ` Damien Le Moal
2024-02-29 23:25                     ` Bart Van Assche
2024-02-29 23:53                       ` Damien Le Moal
2024-03-01 13:09 ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.