Skip to contentSkip to conversation

scsi regression fixes

PATCH Applied Christoph Hellwig 3 participants 6 messages Oct 8, 2020 – Oct 13, 2020 SCSI

lore
Share & tools
lore
#0 lore raw

Hi Martin,

two regression fixes for my recently merged series, uncovered by libata.

#1 lore raw

PATCH 1/2 sr: initialize ->cmd_len

Ensure the command length is properly set. Previously the command code tried to find this out using the command opcode.

Fixes 2ceda20f0a99 ("scsi: core: Move command size detection out of the fast path")
---
 drivers/scsi/sr.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/sr.c +1 -0
index b74dfd8dc1165e..c20b4391837898 100644
@@ -503,6 +503,7 @@ static blk_status_t sr_init_command(struct scsi_cmnd *SCpnt)
 	SCpnt->transfersize = cd->device->sector_size;
 	SCpnt->underflow = this_count << 9;
 	SCpnt->allowed = MAX_RETRIES;
+	SCpnt->cmd_len = 10;
 
 	/*
 	 * This indicates that the command is ready from our end to be queued.
Signature · 1 line
2.28.0
Tested-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] sr: initialize ->cmd_len

Quoted 3 lines · Christoph Hellwig

Ensure the command length is properly set. Previously the command code tried to find this out using the command opcode.

The reported problem [1] is fixed by applying this set of two patches on top of linux next 20201008 tag kernel and tested on arm64, arm and x86_64 and i386 devices and qemu.

Here is the two patches applied on linux next 20201008 tag [PATCH 1/2] sr: initialize ->cmd_len[PATCH 1/2] sr: initialize ->cmd_len [PATCH 2/2] scsi: set sc_data_direction to DMA_NONE for no-transfer commands

- Boot test PASS
- mkfs -t ext4 /dev/sda1 test PASS

Quoted 5 lines
Fixes 2ceda20f0a99 ("scsi: core: Move command size detection out of the fast path")
Quoted 17 lines
---
 drivers/scsi/sr.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/sr.c +1 -1
index b74dfd8dc1165e..c20b4391837898 100644
@@ -503,6 +503,7 @@ static blk_status_t sr_init_command(struct scsi_cmnd *SCpnt)
        SCpnt->transfersize = cd->device->sector_size;
        SCpnt->underflow = this_count << 9;
        SCpnt->allowed = MAX_RETRIES;
+       SCpnt->cmd_len = 10;
 
        /*
         * This indicates that the command is ready from our end to be queued.
--
Quoted 2 lines

2.28.0

[1] https://lore.kernel.org/linux-block/[email protected]/T/#m4fe8f4ccc1f54d93740f310ce80230a92929e94b

#3 lore raw

Re: [PATCH 1/2] sr: initialize ->cmd_len

In reply to Christoph Hellwig
Quoted 2 lines · Christoph Hellwig

Ensure the command length is properly set. Previously the command code tried to find this out using the command opcode.

Applied to 5.10/scsi-queue, thanks!

[1/2] scsi: sr: Initialize ->cmd_len

      https://git.kernel.org/mkp/scsi/c/9120ac54cce6
[2/2] scsi: core: Set sc_data_direction to DMA_NONE for no-transfer commands
      https://git.kernel.org/mkp/scsi/c/b6ba9b0e201a
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#4 lore raw

PATCH 2/2 scsi: set sc_data_direction to DMA_NONE for no-transfer commands

In reply to Christoph Hellwig

No having the special DMA_NONE logic makes libata rather unhappy.

Fixes 40b93836a136 ("scsi: core: Use rq_dma_dir in scsi_setup_cmnd()")
---
 drivers/scsi/scsi_lib.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/scsi/scsi_lib.c +4 -1
index 6b0fccda9af2ee..1a2e9bab42efab 100644
@@ -1545,7 +1545,10 @@ static blk_status_t scsi_prepare_cmd(struct request *req)
 	cmd->request = req;
 	cmd->tag = req->tag;
 	cmd->prot_op = SCSI_PROT_NORMAL;
-	cmd->sc_data_direction = rq_dma_dir(req);
+	if (blk_rq_bytes(req))
+		cmd->sc_data_direction = rq_dma_dir(req);
+	else
+		cmd->sc_data_direction = DMA_NONE;
 
 	sg = (void *)cmd + sizeof(struct scsi_cmnd) + shost->hostt->cmd_size;
 	cmd->sdb.table.sgl = sg;
Signature · 1 line
2.28.0
#5 lore raw
In reply to Christoph Hellwig

Christoph,

Quoted 2 lines

two regression fixes for my recently merged series, uncovered by libata.

Applied to 5.10/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering