From: Michael Kelley <mhklinux@xxxxxxxxxxx> Extend the SCSI DMA mapping interfaces by adding the "_attrs" variant of scsi_dma_map(). This variant allows passing DMA_ATTR_* values, such as is needed to support swiotlb throttling. The existing scsi_dma_map() interface is unchanged, so no incompatibilities are introduced. Signed-off-by: Michael Kelley <mhklinux@xxxxxxxxxxx> --- drivers/scsi/scsi_lib_dma.c | 13 +++++++------ include/scsi/scsi_cmnd.h | 7 +++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/scsi_lib_dma.c b/drivers/scsi/scsi_lib_dma.c index 5723915275ad..34453a79be97 100644 --- a/drivers/scsi/scsi_lib_dma.c +++ b/drivers/scsi/scsi_lib_dma.c @@ -14,30 +14,31 @@ #include <scsi/scsi_host.h> /** - * scsi_dma_map - perform DMA mapping against command's sg lists + * scsi_dma_map_attrs - perform DMA mapping against command's sg lists * @cmd: scsi command + * @attrs: DMA attribute flags * * Returns the number of sg lists actually used, zero if the sg lists * is NULL, or -ENOMEM if the mapping failed. */ -int scsi_dma_map(struct scsi_cmnd *cmd) +int scsi_dma_map_attrs(struct scsi_cmnd *cmd, unsigned long attrs) { int nseg = 0; if (scsi_sg_count(cmd)) { struct device *dev = cmd->device->host->dma_dev; - nseg = dma_map_sg(dev, scsi_sglist(cmd), scsi_sg_count(cmd), - cmd->sc_data_direction); + nseg = dma_map_sg_attrs(dev, scsi_sglist(cmd), + scsi_sg_count(cmd), cmd->sc_data_direction, attrs); if (unlikely(!nseg)) return -ENOMEM; } return nseg; } -EXPORT_SYMBOL(scsi_dma_map); +EXPORT_SYMBOL(scsi_dma_map_attrs); /** - * scsi_dma_unmap - unmap command's sg lists mapped by scsi_dma_map + * scsi_dma_unmap - unmap command's sg lists mapped by scsi_dma_map_attrs * @cmd: scsi command */ void scsi_dma_unmap(struct scsi_cmnd *cmd) diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 45c40d200154..6603003bc588 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -170,11 +170,14 @@ extern void scsi_kunmap_atomic_sg(void *virt); blk_status_t scsi_alloc_sgtables(struct scsi_cmnd *cmd); void scsi_free_sgtables(struct scsi_cmnd *cmd); +#define scsi_dma_map(cmd) scsi_dma_map_attrs(cmd, 0) + #ifdef CONFIG_SCSI_DMA -extern int scsi_dma_map(struct scsi_cmnd *cmd); +extern int scsi_dma_map_attrs(struct scsi_cmnd *cmd, unsigned long attrs); extern void scsi_dma_unmap(struct scsi_cmnd *cmd); #else /* !CONFIG_SCSI_DMA */ -static inline int scsi_dma_map(struct scsi_cmnd *cmd) { return -ENOSYS; } +static inline int scsi_dma_map_attrs(struct scsi_cmnd *cmd, unsigned long attrs) + { return -ENOSYS; } static inline void scsi_dma_unmap(struct scsi_cmnd *cmd) { } #endif /* !CONFIG_SCSI_DMA */ -- 2.25.1