From patchwork Tue Oct 17 08:05:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huacai Chen X-Patchwork-Id: 10011079 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 93324600CC for ; Tue, 17 Oct 2017 08:07:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 842B022376 for ; Tue, 17 Oct 2017 08:07:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78EA3287C7; Tue, 17 Oct 2017 08:07:12 +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 6DDFF22376 for ; Tue, 17 Oct 2017 08:07:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934157AbdJQIHI (ORCPT ); Tue, 17 Oct 2017 04:07:08 -0400 Received: from smtpbg65.qq.com ([103.7.28.233]:20192 "EHLO smtpbg65.qq.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932812AbdJQIHH (ORCPT ); Tue, 17 Oct 2017 04:07:07 -0400 X-QQ-mid: bizesmtp2t1508227413tj4mjummd Received: from software.domain.org (unknown [222.92.8.142]) by esmtp4.qq.com (ESMTP) with id ; Tue, 17 Oct 2017 16:03:31 +0800 (CST) X-QQ-SSF: 01100000008000F0FNF0B00A0000000 X-QQ-FEAT: 5gms5Di3ODjvj+IIXY8gezhdvoNvTpPnCjwf6NtcA+2PLkvszR52M4VjQa+w+ 7GQUSIY2p8X4gQ+eYptR4xCMyEHepWmGpsgOBxsUG01nA4XOYO5l2EGQTepU3Nq8TRzoIut Y7X5QhU7hUEp3GU5pxnvZTHQ1EfeX1q+A1BaPzIi8zP3FafcbRG0J666GuHD8bySVjbl+gn k/ANXn0Sx/ZnPUdnci6jHE1Ln9F0g5x7NVXk4XOHgTnrpOWjqxZBhZfrdOLph9VwfTxmjwH lF+vN1DunY2gfwdFluAsWoeg0uVNoCc0w9mZvtriXZOTvRTSNhys9aRSU= 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 2/5] MIPS: Implement dma_map_ops::get_cache_alignment() Date: Tue, 17 Oct 2017 16:05:39 +0800 Message-Id: <1508227542-13165-2-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-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, MIPS is an architecture which support coherent & noncoherent devices co-exist. So implement get_cache_alignment() function pointer in 'struct dma_map_ops' to return different dma alignments. Cc: stable@vger.kernel.org Signed-off-by: Huacai Chen --- arch/mips/cavium-octeon/dma-octeon.c | 3 ++- arch/mips/include/asm/dma-coherence.h | 2 ++ arch/mips/loongson64/common/dma-swiotlb.c | 1 + arch/mips/mm/dma-default.c | 11 ++++++++++- arch/mips/netlogic/common/nlm-dma.c | 3 ++- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/arch/mips/cavium-octeon/dma-octeon.c b/arch/mips/cavium-octeon/dma-octeon.c index c64bd87..41c29a85 100644 --- a/arch/mips/cavium-octeon/dma-octeon.c +++ b/arch/mips/cavium-octeon/dma-octeon.c @@ -324,7 +324,8 @@ static struct octeon_dma_map_ops _octeon_pci_dma_map_ops = { .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, .sync_sg_for_device = octeon_dma_sync_sg_for_device, .mapping_error = swiotlb_dma_mapping_error, - .dma_supported = swiotlb_dma_supported + .dma_supported = swiotlb_dma_supported, + .get_cache_alignment = mips_dma_get_cache_alignment }, }; diff --git a/arch/mips/include/asm/dma-coherence.h b/arch/mips/include/asm/dma-coherence.h index 72d0eab..5f7a9fc 100644 --- a/arch/mips/include/asm/dma-coherence.h +++ b/arch/mips/include/asm/dma-coherence.h @@ -29,4 +29,6 @@ extern int hw_coherentio; #define hw_coherentio 0 #endif /* CONFIG_DMA_MAYBE_COHERENT */ +int mips_dma_get_cache_alignment(struct device *dev); + #endif diff --git a/arch/mips/loongson64/common/dma-swiotlb.c b/arch/mips/loongson64/common/dma-swiotlb.c index 34486c1..17b9897 100644 --- a/arch/mips/loongson64/common/dma-swiotlb.c +++ b/arch/mips/loongson64/common/dma-swiotlb.c @@ -119,6 +119,7 @@ static const struct dma_map_ops loongson_dma_map_ops = { .sync_sg_for_device = loongson_dma_sync_sg_for_device, .mapping_error = swiotlb_dma_mapping_error, .dma_supported = loongson_dma_supported, + .get_cache_alignment = mips_dma_get_cache_alignment }; void __init plat_swiotlb_setup(void) diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c index c01bd20..e8f0659 100644 --- a/arch/mips/mm/dma-default.c +++ b/arch/mips/mm/dma-default.c @@ -394,6 +394,14 @@ void dma_cache_sync(struct device *dev, void *vaddr, size_t size, EXPORT_SYMBOL(dma_cache_sync); +int mips_dma_get_cache_alignment(struct device *dev) +{ + if (plat_device_is_coherent(dev)) + return 1; + else + return ARCH_DMA_MINALIGN; +} + static const struct dma_map_ops mips_default_dma_map_ops = { .alloc = mips_dma_alloc_coherent, .free = mips_dma_free_coherent, @@ -407,7 +415,8 @@ static const struct dma_map_ops mips_default_dma_map_ops = { .sync_sg_for_cpu = mips_dma_sync_sg_for_cpu, .sync_sg_for_device = mips_dma_sync_sg_for_device, .mapping_error = mips_dma_mapping_error, - .dma_supported = mips_dma_supported + .dma_supported = mips_dma_supported, + .get_cache_alignment = mips_dma_get_cache_alignment }; const struct dma_map_ops *mips_dma_map_ops = &mips_default_dma_map_ops; diff --git a/arch/mips/netlogic/common/nlm-dma.c b/arch/mips/netlogic/common/nlm-dma.c index 0ec9d9d..e9a9ddc 100644 --- a/arch/mips/netlogic/common/nlm-dma.c +++ b/arch/mips/netlogic/common/nlm-dma.c @@ -79,7 +79,8 @@ const struct dma_map_ops nlm_swiotlb_dma_ops = { .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, .sync_sg_for_device = swiotlb_sync_sg_for_device, .mapping_error = swiotlb_dma_mapping_error, - .dma_supported = swiotlb_dma_supported + .dma_supported = swiotlb_dma_supported, + .get_cache_alignment = mips_dma_get_cache_alignment }; void __init plat_swiotlb_setup(void)