Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6107167yba; Wed, 1 May 2019 06:15:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqyesycMQAL6A/KiCbb6RsnGSFltYQ6hgt1nbV3uidaJtakPaGbpzcJfKFXpvrzBvk4q84ze X-Received: by 2002:a65:6644:: with SMTP id z4mr41204859pgv.300.1556716535141; Wed, 01 May 2019 06:15:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556716535; cv=none; d=google.com; s=arc-20160816; b=Jt5bfYp2MyQtDXHAnYo4W8fKFKc8Uo8KI1KYmA5Be4hIYUXgLEqKH4HsUPpe1n9Cky +qzWeIEu9+4UBTkWcbU1BGgKLGVWpctTpzZwHC8hccd+RXV+zyb/6ZRS1BkwsOhWtDF0 j7vqu0eik6J5fdbDehJgPNssut/o4YI+ru1sVtVSL1HbBh4JJ1ZW7SODgGR1HDk3SEBB 27yDE5oq8dvWZx2Yj0xNsn2kiroewnaVi4kUJmSfT6D8sn9Lvbqo7lPtn0pXzuPUL5/A DOdIVpsT2ObAUvInGtPG58wCh4iI/3JhJpmrdspFKj+85+PEo+vCfwmPN6Ojid3fp87D 7Hyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=C3es3ktyY6lUVNDHMGAR/lQ6eNDtSK0UdflhR42fa9Q=; b=zPvHCFGALL7CIjI26h6QVB4CPOiM0pLcM9KL1w6lvxjA3AZFiyx1+uxAdj3NYWXIj8 G3m6mIolW5LelYPY9Y/7+LDObx2eXPQOD0LyP8FMCELEK7twce59cfx8TEbSAdARsvs9 xoL5vOJFgFydtQ6jcpe21QNYY5AOC0rcM0t089Ev0DFs+USHz5u6kr/vnNR7gZ3LMqgz 3qLt465dI7uGe6SBMBR9z9qIZowkPzpKao2x3hvjTgkh4P41KxPV+1ZnBaeRykNKPNrO iNSYUwPNrvy0O8zv+abSZh2Zbu6vZnTpsCkUyBdq4ZU8HPvpvvGmwS+IV/0dHx3S39Hp 7+EQ== ARC-Authentication-Results: i=1; mx.google.com; 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 r8si26902583pgg.345.2019.05.01.06.15.18; Wed, 01 May 2019 06:15:35 -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; 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 S1726543AbfEANN6 (ORCPT + 99 others); Wed, 1 May 2019 09:13:58 -0400 Received: from verein.lst.de ([213.95.11.211]:52884 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbfEANN6 (ORCPT ); Wed, 1 May 2019 09:13:58 -0400 Received: by newverein.lst.de (Postfix, from userid 2407) id 6CF0168AFE; Wed, 1 May 2019 15:13:39 +0200 (CEST) Date: Wed, 1 May 2019 15:13:39 +0200 From: Christoph Hellwig To: Paul Burton Cc: Christoph Hellwig , Ralf Baechle , James Hogan , Ley Foon Tan , Michal Simek , Bartlomiej Zolnierkiewicz , "linux-mips@vger.kernel.org" , "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "linux-fbdev@vger.kernel.org" Subject: [PATCH 5/7 v2] MIPS: use the generic uncached segment support in dma-direct Message-ID: <20190501131339.GA890@lst.de> References: <20190430110032.25301-1-hch@lst.de> <20190430110032.25301-6-hch@lst.de> <20190430201041.536amvinrcvd2wua@pburton-laptop> <20190430202947.GA30262@lst.de> <20190430211105.ielntedm46uqamca@pburton-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190430211105.ielntedm46uqamca@pburton-laptop> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Stop providing our arch alloc/free hooks and just expose the segment offset instead. Signed-off-by: Christoph Hellwig --- arch/mips/Kconfig | 1 + arch/mips/include/asm/page.h | 3 --- arch/mips/jazz/jazzdma.c | 6 ------ arch/mips/mm/dma-noncoherent.c | 26 +++++++++----------------- 4 files changed, 10 insertions(+), 26 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 4a5f5b0ee9a9..cde4b490f3c7 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -9,6 +9,7 @@ config MIPS select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_HAS_UBSAN_SANITIZE_ALL + select ARCH_HAS_UNCACHED_SEGMENT select ARCH_SUPPORTS_UPROBES select ARCH_USE_BUILTIN_BSWAP select ARCH_USE_CMPXCHG_LOCKREF if 64BIT diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h index 6b31c93b5eaa..23e0f1386e04 100644 --- a/arch/mips/include/asm/page.h +++ b/arch/mips/include/asm/page.h @@ -258,9 +258,6 @@ extern int __virt_addr_valid(const volatile void *kaddr); ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \ VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) -#define UNCAC_ADDR(addr) (UNCAC_BASE + __pa(addr)) -#define CAC_ADDR(addr) ((unsigned long)__va((addr) - UNCAC_BASE)) - #include #include diff --git a/arch/mips/jazz/jazzdma.c b/arch/mips/jazz/jazzdma.c index bedb5047aff3..1804dc9d8136 100644 --- a/arch/mips/jazz/jazzdma.c +++ b/arch/mips/jazz/jazzdma.c @@ -575,10 +575,6 @@ static void *jazz_dma_alloc(struct device *dev, size_t size, return NULL; } - if (!(attrs & DMA_ATTR_NON_CONSISTENT)) { - dma_cache_wback_inv((unsigned long)ret, size); - ret = (void *)UNCAC_ADDR(ret); - } return ret; } @@ -586,8 +582,6 @@ static void jazz_dma_free(struct device *dev, size_t size, void *vaddr, dma_addr_t dma_handle, unsigned long attrs) { vdma_free(dma_handle); - if (!(attrs & DMA_ATTR_NON_CONSISTENT)) - vaddr = (void *)CAC_ADDR((unsigned long)vaddr); dma_direct_free_pages(dev, size, vaddr, dma_handle, attrs); } diff --git a/arch/mips/mm/dma-noncoherent.c b/arch/mips/mm/dma-noncoherent.c index f9549d2fbea3..ed56c6fa7be2 100644 --- a/arch/mips/mm/dma-noncoherent.c +++ b/arch/mips/mm/dma-noncoherent.c @@ -44,33 +44,25 @@ static inline bool cpu_needs_post_dma_flush(struct device *dev) } } -void *arch_dma_alloc(struct device *dev, size_t size, - dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs) +void arch_dma_prep_coherent(struct page *page, size_t size) { - void *ret; - - ret = dma_direct_alloc_pages(dev, size, dma_handle, gfp, attrs); - if (ret && !(attrs & DMA_ATTR_NON_CONSISTENT)) { - dma_cache_wback_inv((unsigned long) ret, size); - ret = (void *)UNCAC_ADDR(ret); - } + dma_cache_wback_inv((unsigned long)page_address(page), size); +} - return ret; +void *uncached_kernel_address(void *addr) +{ + return (void *)(__pa(addr) + UNCAC_BASE); } -void arch_dma_free(struct device *dev, size_t size, void *cpu_addr, - dma_addr_t dma_addr, unsigned long attrs) +void *cached_kernel_address(void *addr) { - if (!(attrs & DMA_ATTR_NON_CONSISTENT)) - cpu_addr = (void *)CAC_ADDR((unsigned long)cpu_addr); - dma_direct_free_pages(dev, size, cpu_addr, dma_addr, attrs); + return __va(addr) - UNCAC_BASE; } long arch_dma_coherent_to_pfn(struct device *dev, void *cpu_addr, dma_addr_t dma_addr) { - unsigned long addr = CAC_ADDR((unsigned long)cpu_addr); - return page_to_pfn(virt_to_page((void *)addr)); + return page_to_pfn(virt_to_page(cached_kernel_address(cpu_addr))); } pgprot_t arch_dma_mmap_pgprot(struct device *dev, pgprot_t prot, -- 2.20.1