Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1675728imm; Thu, 19 Jul 2018 06:07:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeOicoUBtjq3n8chZtGhf0XKlIp6O1dX6qRtbf4KwmbbbPE5XJelCgcl0z/ZBCEZgYH04br X-Received: by 2002:a17:902:1007:: with SMTP id b7-v6mr9935421pla.277.1532005624577; Thu, 19 Jul 2018 06:07:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532005624; cv=none; d=google.com; s=arc-20160816; b=jJ6L1x3QboSP1vOzhZ5Eyq/8X6XHgYSES4OdHJGJRDqxPYsq4BVqEhiZWZiKkzSd7T 6vLOj+kOpK2bBFNONzfOrGtleclD9bNwIZy0LK59H4DVqUCWizDYoOgJ//rCy63eZ2xq CYzTOYU9FkfQcWodqorxrSj5W76HcKUow0iDykq7N8Qt4Ss/SiD0JCmkht88nz2leetG qam0QXa3krzvfA4S4l/KTZUwAcuWe5FQD0M64cl31zvtOJmg9f1WfnRL7c3WSgSTD8TO +DUkSThbd5d62MpQcdt9mHNGP+54+qg34BeUIoZBVDUkQ3yC5mNGswNAsocoHf5WojUI nlRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=2FHW8tlV9m6Ju/msvKWhKqlWN3IbIeXGAjZfRycPqw0=; b=Nt0JkbNV7smteVFmEzN6uJ4d+WVGhoiBF47+n+7JZax2AEjyRE5Cy8EZLAGiJRjKam +r3NtahzDc0H4Kh++G5qme8OBlSOfwHpz05Po1MoMNjxf3XUxGikynJkaWwfXmcsGR/f DfcXRbZNyMQ8iajQ3yuvupMrwCbnSriHsGlW3mrqi3D87QCPi9y9u1Jn8DzTqMbaCsa8 v3S7Kcqv+h43fSsda7UAYF7TFgK7Ym0JIsUWWrRTkuGPAhByOHvtsrkXbrI/wGZvADkk qEVEe0FWKDceA0ufw/vpU/PBR3Jt3PiKKksvMSvBAYnpr+NlaWcSoP6o7l06eAxdoqkP HH7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="J/ZQxUoA"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s15-v6si5850604pgr.269.2018.07.19.06.06.49; Thu, 19 Jul 2018 06:07:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="J/ZQxUoA"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731686AbeGSNsb (ORCPT + 99 others); Thu, 19 Jul 2018 09:48:31 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38826 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731646AbeGSNsa (ORCPT ); Thu, 19 Jul 2018 09:48:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=2FHW8tlV9m6Ju/msvKWhKqlWN3IbIeXGAjZfRycPqw0=; b=J/ZQxUoAYavUtOT2xpYuTKIqU ioCe+9TiqxQEloROFeYLJkBX2TfM6t/3aax1hip88NPq+/CLn0SjnsCcaxHWCFnWWOY2iibldoY4b g6FwrKnJE94R+uhh9dWjWOJ2lFQMMjCNUtaWPSX5v4ntl4vAIBzjtWL8J0Tpv6R+HBFDVLow0EInt R9FnWFr7vCIcMMRU6m97OU7GN+hmeDjIyLmPEHEm3hXc+NiyqxI3FVFSxbOWlkvKhJ/bGh3nsNiwi s/Bug0FT823sgAQyaj8mwssuemTNOG+5PgczAfGCegF2zKHcW7i/L8iIyy7fg306Da221pwV7wXJ6 gRqpvJoug==; Received: from [96.72.186.57] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fg8cQ-0001gW-J2; Thu, 19 Jul 2018 13:05:18 +0000 From: Christoph Hellwig To: Yoshinori Sato , Rich Felker Cc: Jacopo Mondi , Thomas Petazzoni , linux-sh@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/5] sh: use dma_direct_ops for the CONFIG_DMA_COHERENT case Date: Thu, 19 Jul 2018 06:05:14 -0700 Message-Id: <20180719130516.1989-4-hch@lst.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180719130516.1989-1-hch@lst.de> References: <20180719130516.1989-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a slight change in behavior as we avoid the detour through the virtual mapping for the coherent allocator, but if this CPU really is coherent that should be the right thing to do. Signed-off-by: Christoph Hellwig --- arch/sh/Kconfig | 1 + arch/sh/include/asm/dma-mapping.h | 4 ++++ arch/sh/kernel/Makefile | 4 ++-- arch/sh/kernel/dma-nommu.c | 4 ---- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index dd4f3d3e644f..c9993a0cdc7e 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -159,6 +159,7 @@ config SWAP_IO_SPACE bool config DMA_COHERENT + select DMA_DIRECT_OPS bool config DMA_NONCOHERENT diff --git a/arch/sh/include/asm/dma-mapping.h b/arch/sh/include/asm/dma-mapping.h index 149e71f95be7..1ebc6a4eb1c5 100644 --- a/arch/sh/include/asm/dma-mapping.h +++ b/arch/sh/include/asm/dma-mapping.h @@ -6,7 +6,11 @@ extern const struct dma_map_ops nommu_dma_ops; static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) { +#ifdef CONFIG_DMA_NONCOHERENT return &nommu_dma_ops; +#else + return &dma_direct_ops; +#endif } extern void *dma_generic_alloc_coherent(struct device *dev, size_t size, diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile index dc80041f7363..cb5f1bfb52de 100644 --- a/arch/sh/kernel/Makefile +++ b/arch/sh/kernel/Makefile @@ -12,7 +12,7 @@ endif CFLAGS_REMOVE_return_address.o = -pg -obj-y := debugtraps.o dma-nommu.o dumpstack.o \ +obj-y := debugtraps.o dumpstack.o \ idle.o io.o irq.o irq_$(BITS).o kdebugfs.o \ machvec.o nmi_debug.o process.o \ process_$(BITS).o ptrace.o ptrace_$(BITS).o \ @@ -45,7 +45,7 @@ obj-$(CONFIG_DUMP_CODE) += disassemble.o obj-$(CONFIG_HIBERNATION) += swsusp.o obj-$(CONFIG_DWARF_UNWINDER) += dwarf.o obj-$(CONFIG_PERF_EVENTS) += perf_event.o perf_callchain.o - +obj-$(CONFIG_DMA_NONCOHERENT) += dma-nommu.o obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o ccflags-y := -Werror diff --git a/arch/sh/kernel/dma-nommu.c b/arch/sh/kernel/dma-nommu.c index 79a9edafa5b0..d8689b1cb743 100644 --- a/arch/sh/kernel/dma-nommu.c +++ b/arch/sh/kernel/dma-nommu.c @@ -51,7 +51,6 @@ static int nommu_map_sg(struct device *dev, struct scatterlist *sg, return nents; } -#ifdef CONFIG_DMA_NONCOHERENT static void nommu_sync_single_for_device(struct device *dev, dma_addr_t addr, size_t size, enum dma_data_direction dir) { @@ -67,16 +66,13 @@ static void nommu_sync_sg_for_device(struct device *dev, struct scatterlist *sg, for_each_sg(sg, s, nelems, i) sh_sync_dma_for_device(sg_virt(s), s->length, dir); } -#endif const struct dma_map_ops nommu_dma_ops = { .alloc = dma_generic_alloc_coherent, .free = dma_generic_free_coherent, .map_page = nommu_map_page, .map_sg = nommu_map_sg, -#ifdef CONFIG_DMA_NONCOHERENT .sync_single_for_device = nommu_sync_single_for_device, .sync_sg_for_device = nommu_sync_sg_for_device, -#endif }; EXPORT_SYMBOL(nommu_dma_ops); -- 2.18.0