From patchwork Thu Sep 7 08:48:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huacai Chen X-Patchwork-Id: 9941815 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 AC1E96038C for ; Thu, 7 Sep 2017 08:50:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DD1C28573 for ; Thu, 7 Sep 2017 08:50:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 926CE28581; Thu, 7 Sep 2017 08:50:48 +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 8033928573 for ; Thu, 7 Sep 2017 08:50:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754887AbdIGIuq (ORCPT ); Thu, 7 Sep 2017 04:50:46 -0400 Received: from smtpbgau1.qq.com ([54.206.16.166]:60864 "EHLO smtpbgau1.qq.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754860AbdIGIup (ORCPT ); Thu, 7 Sep 2017 04:50:45 -0400 X-QQ-mid: bizesmtp3t1504774044te54vxn7c Received: from software.domain.org (unknown [222.92.8.142]) by esmtp4.qq.com (ESMTP) with id ; Thu, 07 Sep 2017 16:47:19 +0800 (CST) X-QQ-SSF: 01100000002000F0FMF0B00A0000000 X-QQ-FEAT: lbfA5hRlhlbvx6fWm04Ehp762Nsb9hug5qegltdhRWKKeLcOA9TjrC+mnyEgu 5J9WOazEdP2D/Qln1a1ctex0eR+M5+xykNWfO4E/3wxedWtpPwg/CZOkKmP8W/2CA4tQ8EN cILmDaJPGjno7MPwBRzX/4xwrds/N+NAj7vO1hkJ212pch+fkg8e302Xdp1EriydkjqZ3lN zQmSKSdyRvCJvnbbPduj33SWqEEpiZAKHbfvhY3os3fk78VgL++ZU7oBK5U7a9FAeQUV2bF mxarcsyomz/qOrcOa53xB7tcEaMGsygKSE8ihPeG1lwhvg 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 2/2] scsi: Align queue to ARCH_DMA_MINALIGN in non-coherent DMA mode Date: Thu, 7 Sep 2017 16:48:51 +0800 Message-Id: <1504774131-11691-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:qybgforeign2 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 f6097b8..800bf2a 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2096,11 +2096,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);