On Wed, Jun 29, 2022 at 3:16 AM Michael Schmitz <schmitzmic@xxxxxxxxx> wrote: > > Use dma_map_single() for a2091 driver (leave bounce buffer > logic unchanged). > > Use dma_set_mask_and_coherent() to avoid explicit cache > flushes. > > Compile-tested only. > > CC: linux-scsi@xxxxxxxxxxxxxxx > Link: https://lore.kernel.org/r/6d1d88ee-1cf6-c735-1e6d-bafd2096e322@xxxxxxxxx > Signed-off-by: Michael Schmitz <schmitzmic@xxxxxxxxx> Reviewed-by: Arnd Bergmann <arnd@xxxxxxxx> > + > + addr = dma_map_single(hdata->dev, scsi_pointer->ptr, > + len, DMA_DIR(dir_in)); > + if (dma_mapping_error(hdata->dev, addr)) { > + dev_warn(hdata->dev, "cannot map SCSI data block %p\n", > + scsi_pointer->ptr); > + return 1; > + } > + scsi_pointer->dma_handle = addr; > > /* don't allow DMA if the physical address is bad */ > if (addr & A2091_XFER_MASK) { > + /* drop useless mapping */ > + dma_unmap_single(hdata->dev, scsi_pointer->dma_handle, > + scsi_pointer->this_residual, > + DMA_DIR(dir_in)); I think you could save the extra map/unmap here if you wanted, but that would risk introducing bugs since it requires a larger rework. > + scsi_pointer->dma_handle = (dma_addr_t) NULL; > + > wh->dma_bounce_len = (scsi_pointer->this_residual + 511) & ~0x1ff; > wh->dma_bounce_buffer = kmalloc(wh->dma_bounce_len, > GFP_KERNEL); Not your bug, but if there is memory above the A2091_XFER_MASK limit, this would need to use GFP_DMA instead of GFP_KERNEL. Arnd