Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp591929imm; Wed, 25 Jul 2018 02:42:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe/JQJt3MfMQvmeLwAcaEjLJzdLgDLBdMLwo7xFtK8uYmofD4Q4pzIkGPtZgJu52JAzOTjJ X-Received: by 2002:a17:902:900b:: with SMTP id a11-v6mr20445149plp.143.1532511739235; Wed, 25 Jul 2018 02:42:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532511739; cv=none; d=google.com; s=arc-20160816; b=sN0xJRV2rGGoS8/MsSGDMn3Wh80+nScp1hYhLZ/opYTZbCLNjZ/KCe/yQLAwpNWb4b jB2fKJSA/0LlMngODdpvjjhS439dyjfMTvxxLbbjDAtSpLLYbtHwvbQf2h5Ru+emjZam mzO2bXIItaBIDbrchoqLX7MgbdBTLZzDgUU/oU37x8brTQW1he3V0lTc/gd2mA3WdaM6 VDUHavKwZO6+iZbcWZUzO6GokARzTy/Vm/nBdPJjV8Qdaadi5JQAaDIMCKVZMSRqJulP XE4rCCfSFq0foZ8w/LZ8SizHLwBItEVWCxyYiGdD9d1fiECBCzoY/8N7STp/Nq3J7Xqy HidQ== 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=FPXJJaekBAymrTkUyqWKwaHMF+HZlDv7s7AgwhqhsaLxNdmNQsYTgPs9KFyxhHW6LE diCzApFlWWbpBKFRWCIfF/LueFYGbudqHZi1ZwLcOCG2RvebAE6iUNAqd6AbSeLbbxF5 HHckn7FlPWc6ecIJC5Zen3hmO+Oqja4VGmVk+EgAgcvPjrLJF0ekbytqFOSNyHyAq2wv egilhwLQ2r8zWIFdDLXGKJWm9iN7p8ScyUmtHPxvU1DKUBOvBPKTcxsOxCssmcL20vqH U73hOL90LRwFKaau1zJ5ck8oVKr/NxyI5awssVtPLmFHnZ6nEzQ5S3BkhJD0O8Om0Jx2 XAdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Yd2thoiF; 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 l26-v6si14405478pgu.191.2018.07.25.02.42.04; Wed, 25 Jul 2018 02:42: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=Yd2thoiF; 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 S1728786AbeGYKv7 (ORCPT + 99 others); Wed, 25 Jul 2018 06:51:59 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:43532 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728694AbeGYKv6 (ORCPT ); Wed, 25 Jul 2018 06:51:58 -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=Yd2thoiFbV4sECZZdVw7xHJWx YVoQIZbyd/gRKnidfAARDO58L3HGcjYT13kLS43WM4wVc3XZC72Tt53sR9z8aV2zd9aMTI7qwnbX2 rFHzE2Ces97cs90V23xlizpd+f38GgSgxsX4bHIKeFqbXEzaRGQwvmEjVN6dI6n47WAN+CT8gogja pJMpgaFXN9W833UoYpsWekYm8nr+Y4sf3mOu2lxZr7Xam/agTlYaNgjHg0MQrLxsYH96Lbkdgf5S5 OEA3TbxdBruXfysDVFUHNK4j8vYYnUb3V8rCwWtcAVyhwPGb5jZvkahcOiQj19Ulu0/sIIWzF8te1 bQzpaCJ0Q==; Received: from [91.112.108.175] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fiGHv-0007T5-6o; Wed, 25 Jul 2018 09:40:55 +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: Wed, 25 Jul 2018 11:40:41 +0200 Message-Id: <20180725094043.32443-4-hch@lst.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180725094043.32443-1-hch@lst.de> References: <20180725094043.32443-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