From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934096AbdJQIFK (ORCPT ); Tue, 17 Oct 2017 04:05:10 -0400 Received: from smtpbg65.qq.com ([103.7.28.233]:6324 "EHLO smtpbg65.qq.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934077AbdJQIFA (ORCPT ); Tue, 17 Oct 2017 04:05:00 -0400 X-QQ-mid: bizesmtp2t1508227417tf34w8up2 X-QQ-SSF: 01100000008000F0FNF0B00A0000000 X-QQ-FEAT: QESExx3iCqL9u2lpxnvWMYUotZdUkoYRB8OB4g8OJSkhJOj6ssWiZlChJ2iBI NczQgjVr8LNVhRSca1Be42FocApNr4GLXh81Iy5xoCQ4gC3/MZe8/LOuS7e0wjUsLV0iuB9 w/0jhnH/+5i2P81/sBvo9TNrdC9IDLcpmeM7J7A6frMq5IoonE4EIJ1vWJyu/wuRP2cY1w/ cnAcA3UbE2ynbHkLpcMD/G4nPIihYl5J6rDfVZ2jV6Pt9fWvdG6nuiipetzOiT6gL7+cD2J rratIRzDRPIOwJyLggpfnMqsnG+af7OkGquEQ8chR36V8+ X-QQ-GoodBg: 0 From: Huacai Chen To: Christoph Hellwig Cc: Marek Szyprowski , Robin Murphy , Andrew Morton , Fuxin Zhang , linux-kernel@vger.kernel.org, Ralf Baechle , James Hogan , linux-mips@linux-mips.org, "James E . J . Bottomley" , "Martin K . Petersen" , linux-scsi@vger.kernel.org, Tejun Heo , linux-ide@vger.kernel.org, Huacai Chen , stable@vger.kernel.org Subject: [PATCH V8 3/5] scsi: Align block queue to dma_get_cache_alignment() Date: Tue, 17 Oct 2017 16:05:40 +0800 Message-Id: <1508227542-13165-3-git-send-email-chenhc@lemote.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1508227542-13165-1-git-send-email-chenhc@lemote.com> References: <1508227542-13165-1-git-send-email-chenhc@lemote.com> X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:lemote.com:qybgforeign:qybgforeign1 X-QQ-Bgrelay: 1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In non-coherent DMA mode, kernel uses cache flushing operations to maintain I/O coherency, so scsi's block queue should be aligned to ARCH_DMA_MINALIGN. 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. Cc: stable@vger.kernel.org Signed-off-by: Huacai Chen --- drivers/scsi/scsi_lib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 9cf6a80..19abc2e 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2132,11 +2132,11 @@ void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q) q->limits.cluster = 0; /* - * set a reasonable default alignment on word boundaries: the - * host and device may alter it using + * set a reasonable default alignment on word/cacheline boundaries: + * the host and device may alter it using * blk_queue_update_dma_alignment() later. */ - blk_queue_dma_alignment(q, 0x03); + blk_queue_dma_alignment(q, max(4, dma_get_cache_alignment(dev)) - 1); } EXPORT_SYMBOL_GPL(__scsi_init_queue); -- 2.7.0