scsi: use dma_get_cache_alignment() as minimum DMA alignment
authorHuacai Chen <chenhc@lemote.com>
Tue, 21 Nov 2017 13:23:38 +0000 (14:23 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 3 Mar 2018 15:50:38 +0000 (15:50 +0000)
commitd8c8a1a737d61e2e9b152564591f62ea8e62a434
tree5abf659cfcb21303305e78b74ca4ffe4d7c7983e
parent0d3385ab636b47a61f12798b3205cec4548a8547
scsi: use dma_get_cache_alignment() as minimum DMA alignment

commit 90addc6b3c9cda0146fbd62a08e234c2b224a80c upstream.

In non-coherent DMA mode, kernel uses cache flushing operations to
maintain I/O coherency, so scsi's block queue should be aligned to the
value returned by dma_get_cache_alignment().  Otherwise, If a DMA buffer
and a kernel structure share a same cache line, and if the kernel
structure has dirty data, cache_invalidate (no writeback) will cause
data corruption.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
[hch: rebased and updated the comment and changelog]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/scsi/scsi_lib.c