Received: by 10.192.165.148 with SMTP id m20csp412489imm; Fri, 20 Apr 2018 01:07:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+O+sk3M4/uR8Ig64F1xZCGr9BQCbOQT0B2lrDd3NI6qHODIfOGb52TlPI20fXUJzQO6LbM X-Received: by 2002:a17:902:9886:: with SMTP id s6-v6mr9156201plp.380.1524211639974; Fri, 20 Apr 2018 01:07:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524211639; cv=none; d=google.com; s=arc-20160816; b=vQ1E6SVXM33NnneOkqMviIk8Mo9XIPpgiuTa25hHJIVUQYV8nB8nHs48x1ik1xiNKc UCPpuOg1Vnr1ZawqsF4ZWe/xiScnKPSFOBv9jTF7q84vf2Y7jCfO7Uqv4dKpVF4CnhIn HR5ZvWb/5srqrx+xShy9XTLbtFa3q0BXlTrkUbHBlJeGlna5wRL4U33gm0Wk8GqszM2V nBW8aBfvbHCBWVZV4M/c4/eUWoegGCjY6BRuEBlBcxv86XClFyv9wgoD9OSnqFcBBdSj zIUoBMkjiVthFBTq26XrnlyltrD1FnKb6UwVM3w5uoE62Zj9VGbi3rj7uXZgQ0YRiM5T fiTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:in-reply-to:message-id:date :subject:cc:from:dkim-signature:arc-authentication-results; bh=2gN12JbbJmvniAHRYRrZVRCOJSQNCwIoEqrVIlJwiv4=; b=ttBmASbUYl1Qa51oodb12/FQCQ5rldvdLwK6DnpaQSumzad/WDqFUAkBX/BmKNSHk2 Z5P/w5oRkRvODvdEj6T68sUUjocOwAYFAY7csPCIo03YzsVnltGV0c7h5dvjhPVIN+DL LdEcp53L+mt//KR44eOYLt7NBEu/HCsaFQsC6uaB6sktBYmTBOGGGsYyg8+rLAX2JTXL 7x3ym9xxZhaxmICJ5yNgGIVjzmFak12EhT+A7U1DLa79BhNSErMbQShUmVEoxWf6rs1d CIADl29IIR2nZoywDk8LC0Ubnkpg29Tg4XAC4oOVejFMrS+Nq8K9GHk4vJ3GBcr2N/+X LTcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=DYBlj48G; 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 a17-v6si5590997plm.151.2018.04.20.01.07.05; Fri, 20 Apr 2018 01:07:19 -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=DYBlj48G; 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 S1754355AbeDTIEz (ORCPT + 99 others); Fri, 20 Apr 2018 04:04:55 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:40638 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754078AbeDTIEr (ORCPT ); Fri, 20 Apr 2018 04:04:47 -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=2gN12JbbJmvniAHRYRrZVRCOJSQNCwIoEqrVIlJwiv4=; b=DYBlj48GpMpb8u2aHq4mptRgD 5sfUiJdCxOCUQhH9sIWQ6TE7cI1qqoOVy+nsXY4YeS3GJcVoOZoH1635VfNJ4+k5pJnZNBc1tMFD5 ypUxaTIJXBPLU6zFkLuaRtFzmJLhHDaL+gek/lQYDo+465HYdzEXpaRRlHMbptG0hrbIciikoP0mZ Avdpdd42h586kqbmRDssKvQwyb8sC5s1wA1r93Rvl5pnBlG0Jo8TkRcOIdIZlGk4RL2ZuBdZ1Us26 e+8V0G0RzWo8qM1vEfjs5TwUjNGYaooO9YT4wHmMPtV+WdrHs9cEhLyKRhzGUPcOsaTntQcyUjhqW jaCsTOZvg==; Received: from static-242-42-24-46.ipcom.comunitel.net ([46.24.42.242] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9R1n-0007mJ-GP; Fri, 20 Apr 2018 08:04:19 +0000 From: Christoph Hellwig Cc: linux-arch@vger.kernel.org, Michal Simek , Greentime Hu , Vincent Chen , linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, nios2-dev@lists.rocketboards.org, openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-kernel@vger.kernel.org Subject: [PATCH 18/22] sh: use dma_direct_ops for the CONFIG_DMA_COHERENT case Date: Fri, 20 Apr 2018 10:03:09 +0200 Message-Id: <20180420080313.18796-19-hch@lst.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180420080313.18796-1-hch@lst.de> References: <20180420080313.18796-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html To: unlisted-recipients:; (no To-header on input) 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 9417f70e008e..23e7432302b0 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -158,6 +158,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 c0fff676e2e4..442922a9f8c0 100644 --- a/arch/sh/kernel/dma-nommu.c +++ b/arch/sh/kernel/dma-nommu.c @@ -48,7 +48,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) { @@ -64,16 +63,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.17.0