From patchwork Tue Sep 12 07:08:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huacai Chen X-Patchwork-Id: 9948475 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E723760360 for ; Tue, 12 Sep 2017 07:07:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8EFD28DA9 for ; Tue, 12 Sep 2017 07:07:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDC1F28E3F; Tue, 12 Sep 2017 07:07:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B4CA28DA9 for ; Tue, 12 Sep 2017 07:07:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751079AbdILHHN (ORCPT ); Tue, 12 Sep 2017 03:07:13 -0400 Received: from smtpbg65.qq.com ([103.7.28.233]:16436 "EHLO smtpbg65.qq.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750987AbdILHHN (ORCPT ); Tue, 12 Sep 2017 03:07:13 -0400 X-QQ-mid: bizesmtp13t1505200005twfyc0gh Received: from software.domain.org (unknown [222.92.8.142]) by esmtp4.qq.com (ESMTP) with id ; Tue, 12 Sep 2017 15:06:41 +0800 (CST) X-QQ-SSF: 01100000008000F0FMF0B00A0000000 X-QQ-FEAT: xn5z2wyGZrMnZd+lxXfoRpxvbv70gu5T2cCjz44olENGBRYbPYI6YOlayHDhi XafrFkaxdercF5Sq4dFPb1f1Lcg2WxclHVURf+nRSRQ6r4MxDY3H7QyfruPp7B5S4RfbVVI KTQDS5Ruh1bjWX5raSHR0IqdQLqLrjBYyo+/8WmjWA70sAL+FlHM+38KNI3OGMZsayCq3ti yTWLKJwJYtlYG7x7r4dvaWIMF8vZkGM7kf90a8zKW5OvgyLbc/qlWvWT6DGc3Jg09vQf9xF uIvgneKq/xL6HQ5tiIOSJt2c+XHnm/aNbeu7C/m6F/7QPNap2KPl9Iy+E= X-QQ-GoodBg: 0 From: Huacai Chen To: "James E . J . Bottomley" Cc: "Martin K . Petersen" , Fuxin Zhang , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Huacai Chen , stable@vger.kernel.org Subject: [PATCH V2 3/3] scsi: Align queue to ARCH_DMA_MINALIGN in non-coherent DMA mode Date: Tue, 12 Sep 2017 15:08:23 +0800 Message-Id: <1505200104-24667-1-git-send-email-chenhc@lemote.com> X-Mailer: git-send-email 2.7.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:lemote.com:qybgforeign:qybgforeign1 X-QQ-Bgrelay: 1 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Cc: stable@vger.kernel.org Signed-off-by: Huacai Chen --- drivers/scsi/scsi_lib.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 9cf6a80..79433ad 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2132,11 +2132,14 @@ 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); + if (plat_device_is_coherent(dev)) + blk_queue_dma_alignment(q, 0x04 - 1); + else + blk_queue_dma_alignment(q, dma_get_cache_alignment() - 1); } EXPORT_SYMBOL_GPL(__scsi_init_queue);