scsi: lpfc: Use sg_dma_address() and sg_dma_len() macros for NVMe I/O
authorJames Smart <jsmart2021@gmail.com>
Fri, 6 May 2022 03:55:18 +0000 (20:55 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 11 May 2022 02:12:04 +0000 (22:12 -0400)
commita14396b6d139ff9335b4be25ba30ffa67cadd2e9
tree11f7ffebcbe88a91d13f2cbff696443612414915
parente6f51041450282a8668af3a8fc5c7744e81a447c
scsi: lpfc: Use sg_dma_address() and sg_dma_len() macros for NVMe I/O

NVMe I/O problems may be seen on IOMMU enabled platforms. Adapter I/Os
failing with transfer length mismatches.

The sg list processing routine for NVMe I/O is accessing the sg entry
directly for the length and address fields. On some IOMMU platforms,
contigous mappings are compressed to the first sg entry with the sum of the
lengths set to the sg entry dma_length field. The length fields are left
for later use by the unmap call. As such, the driver didn't see the actual
dma_length value, just the first entries length value.  Drivers are to use
the sg_dma_length() and sg_dma_address() macros to reference the sg
entry. The macros select the proper length field (dma_length or length) to
reference.

Fix the offending code to use the sg_dma_xxx macros.

Link: https://lore.kernel.org/r/20220506035519.50908-12-jsmart2021@gmail.com
Tested-by: Jerry Snitselaar <jsnitsel@redhat.com>
Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>
Co-developed-by: Nigel Kirkland <nkirkland2304@gmail.com>
Signed-off-by: Nigel Kirkland <nkirkland2304@gmail.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/lpfc/lpfc_nvme.c