|
Lee Duncan |
a34cc5 |
From: Jolly Shah <jollys@google.com>
|
|
Lee Duncan |
a34cc5 |
Date: Thu, 18 Mar 2021 15:56:32 -0700
|
|
Lee Duncan |
a34cc5 |
Subject: scsi: libsas: Reset num_scatter if libata marks qc as NODATA
|
|
Lee Duncan |
a34cc5 |
Git-commit: 176ddd89171ddcf661862d90c5d257877f7326d6
|
|
Lee Duncan |
a34cc5 |
Patch-mainline: v5.12-rc8
|
|
Lee Duncan |
a34cc5 |
References: bsc#1187068
|
|
Lee Duncan |
a34cc5 |
|
|
Lee Duncan |
a34cc5 |
When the cache_type for the SCSI device is changed, the SCSI layer issues a
|
|
Lee Duncan |
a34cc5 |
MODE_SELECT command. The caching mode details are communicated via a
|
|
Lee Duncan |
a34cc5 |
request buffer associated with the SCSI command with data direction set as
|
|
Lee Duncan |
a34cc5 |
DMA_TO_DEVICE (scsi_mode_select()). When this command reaches the libata
|
|
Lee Duncan |
a34cc5 |
layer, as a part of generic initial setup, libata layer sets up the
|
|
Lee Duncan |
a34cc5 |
scatterlist for the command using the SCSI command (ata_scsi_qc_new()).
|
|
Lee Duncan |
a34cc5 |
This command is then translated by the libata layer into
|
|
Lee Duncan |
a34cc5 |
ATA_CMD_SET_FEATURES (ata_scsi_mode_select_xlat()). The libata layer treats
|
|
Lee Duncan |
a34cc5 |
this as a non-data command (ata_mselect_caching()), since it only needs an
|
|
Lee Duncan |
a34cc5 |
ATA taskfile to pass the caching on/off information to the device. It does
|
|
Lee Duncan |
a34cc5 |
not need the scatterlist that has been setup, so it does not perform
|
|
Lee Duncan |
a34cc5 |
dma_map_sg() on the scatterlist (ata_qc_issue()). Unfortunately, when this
|
|
Lee Duncan |
a34cc5 |
command reaches the libsas layer (sas_ata_qc_issue()), libsas layer sees it
|
|
Lee Duncan |
a34cc5 |
as a non-data command with a scatterlist. It cannot extract the correct DMA
|
|
Lee Duncan |
a34cc5 |
length since the scatterlist has not been mapped with dma_map_sg() for a
|
|
Lee Duncan |
a34cc5 |
DMA operation. When this partially constructed SAS task reaches pm80xx
|
|
Lee Duncan |
a34cc5 |
LLDD, it results in the following warning:
|
|
Lee Duncan |
a34cc5 |
|
|
Lee Duncan |
a34cc5 |
"pm80xx_chip_sata_req 6058: The sg list address
|
|
Lee Duncan |
a34cc5 |
start_addr=0x0000000000000000 data_len=0x0end_addr_high=0xffffffff
|
|
Lee Duncan |
a34cc5 |
end_addr_low=0xffffffff has crossed 4G boundary"
|
|
Lee Duncan |
a34cc5 |
|
|
Lee Duncan |
a34cc5 |
Update libsas to handle ATA non-data commands separately so num_scatter and
|
|
Lee Duncan |
a34cc5 |
total_xfer_len remain 0.
|
|
Lee Duncan |
a34cc5 |
|
|
Lee Duncan |
a34cc5 |
Link: https://lore.kernel.org/r/20210318225632.2481291-1-jollys@google.com
|
|
Lee Duncan |
a34cc5 |
Fixes: 53de092f47ff ("scsi: libsas: Set data_dir as DMA_NONE if libata marks qc as NODATA")
|
|
Lee Duncan |
a34cc5 |
Tested-by: Luo Jiaxing <luojiaxing@huawei.com>
|
|
Lee Duncan |
a34cc5 |
Reviewed-by: John Garry <john.garry@huawei.com>
|
|
Lee Duncan |
a34cc5 |
Signed-off-by: Jolly Shah <jollys@google.com>
|
|
Lee Duncan |
a34cc5 |
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
|
|
Lee Duncan |
a34cc5 |
Acked-by: Lee Duncan <lduncan@suse.com>
|
|
Lee Duncan |
a34cc5 |
---
|
|
Lee Duncan |
a34cc5 |
drivers/scsi/libsas/sas_ata.c | 9 ++++-----
|
|
Lee Duncan |
a34cc5 |
1 file changed, 4 insertions(+), 5 deletions(-)
|
|
Lee Duncan |
a34cc5 |
|
|
Lee Duncan |
a34cc5 |
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
|
|
Lee Duncan |
a34cc5 |
index 024e5a550759..8b9a39077dba 100644
|
|
Lee Duncan |
a34cc5 |
--- a/drivers/scsi/libsas/sas_ata.c
|
|
Lee Duncan |
a34cc5 |
+++ b/drivers/scsi/libsas/sas_ata.c
|
|
Lee Duncan |
a34cc5 |
@@ -201,18 +201,17 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc)
|
|
Lee Duncan |
a34cc5 |
memcpy(task->ata_task.atapi_packet, qc->cdb, qc->dev->cdb_len);
|
|
Lee Duncan |
a34cc5 |
task->total_xfer_len = qc->nbytes;
|
|
Lee Duncan |
a34cc5 |
task->num_scatter = qc->n_elem;
|
|
Lee Duncan |
a34cc5 |
+ task->data_dir = qc->dma_dir;
|
|
Lee Duncan |
a34cc5 |
+ } else if (qc->tf.protocol == ATA_PROT_NODATA) {
|
|
Lee Duncan |
a34cc5 |
+ task->data_dir = DMA_NONE;
|
|
Lee Duncan |
a34cc5 |
} else {
|
|
Lee Duncan |
a34cc5 |
for_each_sg(qc->sg, sg, qc->n_elem, si)
|
|
Lee Duncan |
a34cc5 |
xfer += sg_dma_len(sg);
|
|
Lee Duncan |
a34cc5 |
|
|
Lee Duncan |
a34cc5 |
task->total_xfer_len = xfer;
|
|
Lee Duncan |
a34cc5 |
task->num_scatter = si;
|
|
Lee Duncan |
a34cc5 |
- }
|
|
Lee Duncan |
a34cc5 |
-
|
|
Lee Duncan |
a34cc5 |
- if (qc->tf.protocol == ATA_PROT_NODATA)
|
|
Lee Duncan |
a34cc5 |
- task->data_dir = DMA_NONE;
|
|
Lee Duncan |
a34cc5 |
- else
|
|
Lee Duncan |
a34cc5 |
task->data_dir = qc->dma_dir;
|
|
Lee Duncan |
a34cc5 |
+ }
|
|
Lee Duncan |
a34cc5 |
task->scatter = qc->sg;
|
|
Lee Duncan |
a34cc5 |
task->ata_task.retry_count = 1;
|
|
Lee Duncan |
a34cc5 |
task->task_state_flags = SAS_TASK_STATE_PENDING;
|
|
Lee Duncan |
a34cc5 |
|