From patchwork Tue Oct 9 13:24:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632517 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B5DD13AA for ; Tue, 9 Oct 2018 13:25:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A159286A1 for ; Tue, 9 Oct 2018 13:25:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DD7F289C4; Tue, 9 Oct 2018 13:25:33 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53D86286A1 for ; Tue, 9 Oct 2018 13:25:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB1496B0005; Tue, 9 Oct 2018 09:25:28 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D3AEF6B000A; Tue, 9 Oct 2018 09:25:28 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8C256B000C; Tue, 9 Oct 2018 09:25:28 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 6C00A6B0005 for ; Tue, 9 Oct 2018 09:25:28 -0400 (EDT) Received: by mail-pl1-f197.google.com with SMTP id v7-v6so954310plo.23 for ; Tue, 09 Oct 2018 06:25:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=t4111eWUggvDPhD1JmlTBkHpP8cYIAKt6u/lP2eJRkM=; b=KhvZ42NSwy9OqSJmC3VkjY4FfQnY9GYHsBhWnMID7G4lL2O9Ax9u4ZjoiVcVBybebL 5DndiUbg4vMT2AVxJT2A1cDQ+N15qcpEvuNbIKp01R2y3xgjHRpk1UIfHhDz9CeOz6IZ Q2/cDnXeWxop0PYXe0HvQO9fyOLm3ouktBLrAP8P4npsPqXE6qOY7ANimgtdh4114wpH gZqLAjtXmv2ulUfJJnmSjk6eZ1UeDcYbK/6/4hGB3ux6+aHjWQkHE7qn3dhGL2ltldAj BIJRFM9Y4QGPUCz4iNfHAWz0Mkz139XDFalvkt9onuqjx+yTxO9eyJbJBziez5KETFrV WMqA== X-Gm-Message-State: ABuFfogBpFyWGWiRRJROgJpkjVB/ey2f4TyxAz2sgnJvGeXRWt6KhHuk 6tw8n5NMHVCDaP8Gr8Yyn7Z+eX4+2o8vN54l//mh0YrGgo0/5togawayK6R1Ulx3R4yIg8zjrel UIFRYIdFuYGRm+P12Z+rlTYqtS/VkjbB0XnA36kCVL7t9rg7H050Le9+L7kdZPmQ= X-Received: by 2002:a17:902:3041:: with SMTP id u59-v6mr28119195plb.99.1539091528074; Tue, 09 Oct 2018 06:25:28 -0700 (PDT) X-Google-Smtp-Source: ACcGV63CxDVAzD3mypfSBMW3oFswjBm76E3uDihNY9wm0OttFfQZKwl/bbalFB8Zqv+FEYx5AjhS X-Received: by 2002:a17:902:3041:: with SMTP id u59-v6mr28119125plb.99.1539091526763; Tue, 09 Oct 2018 06:25:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091526; cv=none; d=google.com; s=arc-20160816; b=tyH0bCY8QzVHLfzjEc7sABHNSkaA4Jc+pqfP0tYVZ96HmWrEvK9qqqv72ByaodTvI1 FINKbwVhlrEnzajDvhA9B8Cz4/h0pE9JmKTeUyrDMQ3I2H+xUnjQM+c2Ih+H0LhB0aqN 9hJ2M8cDqsrC5Rm2fg1GsThAcRWMxBLYkqrnbbzLGYOxqyplajPvwDhaDP80pZhHOHgO NG43+d8NTeXl3Cul1r3HGYQ8170/Q/8WxZ2oqHBe/rMKJPdLzKSmxKhjHFeHYUOYQZ/H IAe7Ng4ntLf9B6boudd89Od2j2BQRbMxR57Wj/2xX6mgS/6itR/SNSMHl8UxNs+OTqMU R7Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=t4111eWUggvDPhD1JmlTBkHpP8cYIAKt6u/lP2eJRkM=; b=Q5ZmJL70H9Sx4sywQuBFkG9MRxLdLvk2VTYjrPlEJO2JROKuPjAyCdUOJMBChab7vd cHxK0GRbNHA++h5L/PN/0dpdcno73mwzwUudNaXxKLkydplsFV01JbCQ445y6o5juvD3 h9188WVBUbcvZ/Agn6w4VnPmi/Pn3vSf8Np2EVo63+moRjwUOL3gBZMQgq1HY4U9CFeR ef6wJmSD0qkury9EioLdM7eZ6xQsg83VCevo0vVZtNPvY8/KOVsxC6J5XL2/sfJ7xrNY RwDKoKXzdbaHTS+ivTTpHC1ciQtAwTFkDi5bmQ2PvuIOAEKFfvBkGspdDvOpecjFR8qk e6bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b="Rx8ORDO/"; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id g5-v6si20814694pgf.565.2018.10.09.06.25.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:25:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b="Rx8ORDO/"; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=t4111eWUggvDPhD1JmlTBkHpP8cYIAKt6u/lP2eJRkM=; b=Rx8ORDO/Vl2daZDQb4J0rqJloG GcESEP+TeojH/eEJSqgVzgxRcZGymVI9smAysM0mUdhQJ7Dw0Hnbo1cuhRknivHTry0gkbfn0ZO8D KxG4CB0m02b2y0S7wseMbQF16JtwTPGG3PbfkfJGKxNt8Xl24WnbPXyoIK2VnKzQJsv0cdKatS0zR +PpZa9kqWlmj3DG3RCp4mWMYQtvDyBYPEdYX3ngPZZ/gEbbPGv/tH4bwsUS6S6JzlUc93Bc/Du2ac aMJNqP0lMUeVGaqie7/eqPoPgdppkJeXL7fTCVVuMkWcJXdUF9yXpwPoB/BmATJPFKX5F/o0maJ3i TfLAq52A==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s0W-0008Kf-PH; Tue, 09 Oct 2018 13:25:05 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/33] powerpc: use mm zones more sensibly Date: Tue, 9 Oct 2018 15:24:28 +0200 Message-Id: <20181009132500.17643-2-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Powerpc has somewhat odd usage where ZONE_DMA is used for all memory on common 64-bit configfs, and ZONE_DMA32 is used for 31-bit schemes. Move to a scheme closer to what other architectures use (and I dare to say the intent of the system): - ZONE_DMA: optionally for memory < 31-bit - ZONE_NORMAL: everything addressable by the kernel - ZONE_HIGHMEM: memory > 32-bit for 32-bit kernels Also provide information on how ZONE_DMA is used by defining ARCH_ZONE_DMA_BITS. Contains various fixes from Benjamin Herrenschmidt. Signed-off-by: Christoph Hellwig --- arch/powerpc/Kconfig | 6 +-- arch/powerpc/include/asm/page.h | 2 + arch/powerpc/include/asm/pgtable.h | 1 - arch/powerpc/kernel/dma-swiotlb.c | 6 +-- arch/powerpc/kernel/dma.c | 7 +-- arch/powerpc/mm/mem.c | 50 +++++++------------ arch/powerpc/platforms/85xx/corenet_generic.c | 10 ---- arch/powerpc/platforms/85xx/qemu_e500.c | 9 ---- include/linux/mmzone.h | 2 +- 9 files changed, 24 insertions(+), 69 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index a80669209155..06996df07cad 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -380,7 +380,7 @@ config PPC_ADV_DEBUG_DAC_RANGE depends on PPC_ADV_DEBUG_REGS && 44x default y -config ZONE_DMA32 +config ZONE_DMA bool default y if PPC64 @@ -879,10 +879,6 @@ config ISA have an IBM RS/6000 or pSeries machine, say Y. If you have an embedded board, consult your board documentation. -config ZONE_DMA - bool - default y - config GENERIC_ISA_DMA bool depends on ISA_DMA_API diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h index f6a1265face2..fc8c9ac0c6be 100644 --- a/arch/powerpc/include/asm/page.h +++ b/arch/powerpc/include/asm/page.h @@ -354,4 +354,6 @@ typedef struct page *pgtable_t; #endif /* __ASSEMBLY__ */ #include +#define ARCH_ZONE_DMA_BITS 31 + #endif /* _ASM_POWERPC_PAGE_H */ diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 14c79a7dc855..9bafb38e959e 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -37,7 +37,6 @@ extern unsigned long empty_zero_page[]; extern pgd_t swapper_pg_dir[]; -void limit_zone_pfn(enum zone_type zone, unsigned long max_pfn); int dma_pfn_limit_to_zone(u64 pfn_limit); extern void paging_init(void); diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c index 88f3963ca30f..93a4622563c6 100644 --- a/arch/powerpc/kernel/dma-swiotlb.c +++ b/arch/powerpc/kernel/dma-swiotlb.c @@ -108,12 +108,8 @@ int __init swiotlb_setup_bus_notifier(void) void __init swiotlb_detect_4g(void) { - if ((memblock_end_of_DRAM() - 1) > 0xffffffff) { + if ((memblock_end_of_DRAM() - 1) > 0xffffffff) ppc_swiotlb_enable = 1; -#ifdef CONFIG_ZONE_DMA32 - limit_zone_pfn(ZONE_DMA32, (1ULL << 32) >> PAGE_SHIFT); -#endif - } } static int __init check_swiotlb_enabled(void) diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index dbfc7056d7df..6551685a4ed0 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c @@ -50,7 +50,7 @@ static int dma_nommu_dma_supported(struct device *dev, u64 mask) return 1; #ifdef CONFIG_FSL_SOC - /* Freescale gets another chance via ZONE_DMA/ZONE_DMA32, however + /* Freescale gets another chance via ZONE_DMA, however * that will have to be refined if/when they support iommus */ return 1; @@ -94,13 +94,10 @@ void *__dma_nommu_alloc_coherent(struct device *dev, size_t size, } switch (zone) { +#ifdef CONFIG_ZONE_DMA case ZONE_DMA: flag |= GFP_DMA; break; -#ifdef CONFIG_ZONE_DMA32 - case ZONE_DMA32: - flag |= GFP_DMA32; - break; #endif }; #endif /* CONFIG_FSL_SOC */ diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 5c8530d0c611..8bff7e893bde 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -69,15 +69,12 @@ pte_t *kmap_pte; EXPORT_SYMBOL(kmap_pte); pgprot_t kmap_prot; EXPORT_SYMBOL(kmap_prot); -#define TOP_ZONE ZONE_HIGHMEM static inline pte_t *virt_to_kpte(unsigned long vaddr) { return pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr), vaddr), vaddr), vaddr); } -#else -#define TOP_ZONE ZONE_NORMAL #endif int page_is_ram(unsigned long pfn) @@ -246,35 +243,19 @@ static int __init mark_nonram_nosave(void) } #endif -static bool zone_limits_final; - -/* - * The memory zones past TOP_ZONE are managed by generic mm code. - * These should be set to zero since that's what every other - * architecture does. - */ -static unsigned long max_zone_pfns[MAX_NR_ZONES] = { - [0 ... TOP_ZONE ] = ~0UL, - [TOP_ZONE + 1 ... MAX_NR_ZONES - 1] = 0 -}; - /* - * Restrict the specified zone and all more restrictive zones - * to be below the specified pfn. May not be called after - * paging_init(). + * Zones usage: + * + * We setup ZONE_DMA to be 31-bits on all platforms and ZONE_NORMAL to be + * everything else. GFP_DMA32 page allocations automatically fall back to + * ZONE_DMA. + * + * By using 31-bit unconditionally, we can exploit ARCH_ZONE_DMA_BITS to + * inform the generic DMA mapping code. 32-bit only devices (if not handled + * by an IOMMU anyway) will take a first dip into ZONE_NORMAL and get + * otherwise served by ZONE_DMA. */ -void __init limit_zone_pfn(enum zone_type zone, unsigned long pfn_limit) -{ - int i; - - if (WARN_ON(zone_limits_final)) - return; - - for (i = zone; i >= 0; i--) { - if (max_zone_pfns[i] > pfn_limit) - max_zone_pfns[i] = pfn_limit; - } -} +static unsigned long max_zone_pfns[MAX_NR_ZONES]; /* * Find the least restrictive zone that is entirely below the @@ -324,11 +305,14 @@ void __init paging_init(void) printk(KERN_DEBUG "Memory hole size: %ldMB\n", (long int)((top_of_ram - total_ram) >> 20)); +#ifdef CONFIG_ZONE_DMA + max_zone_pfns[ZONE_DMA] = min(max_low_pfn, 0x7fffffffUL >> PAGE_SHIFT); +#endif + max_zone_pfns[ZONE_NORMAL] = max_low_pfn; #ifdef CONFIG_HIGHMEM - limit_zone_pfn(ZONE_NORMAL, lowmem_end_addr >> PAGE_SHIFT); + max_zone_pfns[ZONE_HIGHMEM] = max_pfn #endif - limit_zone_pfn(TOP_ZONE, top_of_ram >> PAGE_SHIFT); - zone_limits_final = true; + free_area_init_nodes(max_zone_pfns); mark_nonram_nosave(); diff --git a/arch/powerpc/platforms/85xx/corenet_generic.c b/arch/powerpc/platforms/85xx/corenet_generic.c index ac191a7a1337..b0dac307bebf 100644 --- a/arch/powerpc/platforms/85xx/corenet_generic.c +++ b/arch/powerpc/platforms/85xx/corenet_generic.c @@ -68,16 +68,6 @@ void __init corenet_gen_setup_arch(void) swiotlb_detect_4g(); -#if defined(CONFIG_FSL_PCI) && defined(CONFIG_ZONE_DMA32) - /* - * Inbound windows don't cover the full lower 4 GiB - * due to conflicts with PCICSRBAR and outbound windows, - * so limit the DMA32 zone to 2 GiB, to allow consistent - * allocations to succeed. - */ - limit_zone_pfn(ZONE_DMA32, 1UL << (31 - PAGE_SHIFT)); -#endif - pr_info("%s board\n", ppc_md.name); mpc85xx_qe_init(); diff --git a/arch/powerpc/platforms/85xx/qemu_e500.c b/arch/powerpc/platforms/85xx/qemu_e500.c index b63a8548366f..27631c607f3d 100644 --- a/arch/powerpc/platforms/85xx/qemu_e500.c +++ b/arch/powerpc/platforms/85xx/qemu_e500.c @@ -45,15 +45,6 @@ static void __init qemu_e500_setup_arch(void) fsl_pci_assign_primary(); swiotlb_detect_4g(); -#if defined(CONFIG_FSL_PCI) && defined(CONFIG_ZONE_DMA32) - /* - * Inbound windows don't cover the full lower 4 GiB - * due to conflicts with PCICSRBAR and outbound windows, - * so limit the DMA32 zone to 2 GiB, to allow consistent - * allocations to succeed. - */ - limit_zone_pfn(ZONE_DMA32, 1UL << (31 - PAGE_SHIFT)); -#endif mpc85xx_smp_init(); } diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 1e22d96734e0..68970340df1c 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -312,7 +312,7 @@ enum zone_type { * Architecture Limit * --------------------------- * parisc, ia64, sparc <4G - * s390 <2G + * s390, powerpc <2G * arm Various * alpha Unlimited or 0-16MB. * From patchwork Tue Oct 9 13:24:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632515 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA9D013AA for ; Tue, 9 Oct 2018 13:25:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A575286A1 for ; Tue, 9 Oct 2018 13:25:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E6F9289C4; Tue, 9 Oct 2018 13:25:30 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A4AF286A1 for ; Tue, 9 Oct 2018 13:25:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D1536B0006; Tue, 9 Oct 2018 09:25:28 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 830F76B000C; Tue, 9 Oct 2018 09:25:28 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C0876B000A; Tue, 9 Oct 2018 09:25:28 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 1FCC96B0005 for ; Tue, 9 Oct 2018 09:25:28 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id 87-v6so1083499pfq.8 for ; Tue, 09 Oct 2018 06:25:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=g770qJx2ODC0LvNyFrLPq9WG2MTi98G0QMTJr1eeeBQ=; b=L2zjtPVhB9p22mP8LPLW5FXAkuPE6/pV/wl8avCTFV3vtN7zAh9G2H+xjplSBCULsV sceFJbc6LTEiYtNLBGyn3aHkonAjdAwxJQrxiwspZ51Aro0pA+TAPnBdBtlTYwIM1WJS +ntryR+zFUZRIGEByB2gXAca7Oxz7D9i0jC0vxT1CaKV1pltI+b/MKGJfureP+8uNJHx cIjk7rdjWyM4pu4YuyoTbNC2LzKFR7cYPciExG8pWJb4SZoHuobP9RQHeaK2Z/42lqSh AG8n4q5OydXfPHYgL9vxFZT756ILOly8U7tX0ET8zksyTG5A6dTKYzNUgX10SQ9t/TTd 6IKQ== X-Gm-Message-State: ABuFfohyn7scEkbMBlJnJedOlfTUpq6z6q9CbS5uxOK9EGFpwVDTyYrA mr36QvLHmzGNjQWjN1WOYm+SBUjV38KfPieFiIB3pIF89MNgEJHCaLVLx/eOmGqbPzIJEgcFDH8 CoUKXSsvpiWrbFeyiKzX5mXJPQZnYdTIyXo69fOD5jx2OjRnI++TWkEMPj4AH8hQ= X-Received: by 2002:a65:41c6:: with SMTP id b6-v6mr26139965pgq.421.1539091527806; Tue, 09 Oct 2018 06:25:27 -0700 (PDT) X-Google-Smtp-Source: ACcGV603FsaH0rH987HeC9zcvGUW6GfZ9cPqw7uTkyiip+Cp/xRWC8KZVmenGTwDWIiSVtqb9bxA X-Received: by 2002:a65:41c6:: with SMTP id b6-v6mr26139916pgq.421.1539091527059; Tue, 09 Oct 2018 06:25:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091527; cv=none; d=google.com; s=arc-20160816; b=qAlk02pTFnmp+H6RVZPuQ5IDIapXtr7skoDYOV/PI8hnw/uJtzpsMABxHmoBFckE/1 uD0ksaqx7/xD3F0G4QijxUwavh3Mu7qHRK/cNZLUytBWMhN0S1S2j3GhJAU8XDtLHQZ4 1YHHa7Gs5PU2+IjHz8oA+dDGRYNjIlanG6DLf5jJ/C+2Yq4cH5mesBkyuyEBx9qiLTiT SH8vIBLbStIckYU0SGqMteIh0KpUG9UkrxZuirQV7i3uUwkflAFAuU1vMbcC9X5OO5CY BQNsSERlWsfhcy3Lw4iKQMeESQIX4GqHziK7SixSC311TqXQ9H7gyS0VI9OJZ0WNdoY6 opcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=g770qJx2ODC0LvNyFrLPq9WG2MTi98G0QMTJr1eeeBQ=; b=Q87b5fejaBAoJpW02/MHuS5jbhIXYmwrH7LpdYu8t1cc/5wdbOMdetF8NJ+URG5ptx XnPsKKex1oEAy1VqvwVlTWsnKeBZdmSVVYe8n1KKX+jqlkVkc8aT3R3Fe3r7+jJ72pCS XJfy35MHaXClIZ02saRe8GIU51+4WvQdsJg+Fr5GaWRa4WYNnumd0WRx4hALS/AihrMn 0eebde/jeYnYc2iC3NR5HzyX7MnmELp+9JM4lShSGRwX9X+Vg0M5rLvbrhRGOu309nKc L0huL4J3WJ7gCSHg5aQuOKD8BuB4d+hhXc0JQEp5tmUh4l5jTqkOOz3oJtCrPJYh7/vu UEog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=JGxUQllD; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id i5-v6si15477402pgc.289.2018.10.09.06.25.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:25:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=JGxUQllD; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=g770qJx2ODC0LvNyFrLPq9WG2MTi98G0QMTJr1eeeBQ=; b=JGxUQllD35wUfXqxSHIwA+orRm CFPVkpS9mbPtjCUVc+9xbf6+ffv6ajEaphZmcNYH+4561W/eLs6Bvr1kQ47JCpqZhsdap1G2P+QyH UAiMMeoEZw/rJbAErzE7+tfeY27A66dokl7X6QarLzlbjZkStu6PHxkZ9dY1bZNff2o+PHErllu0x fBtyCrd4JuCo3KRLAK6nNjfH503TErYCh+P77wzsu53Hz3NjnL3W/RO5N43Yk4IyxbiEGEFu5YB0Y IcAyZehRvryfZtzgAhDKTqakysayk/d01KqBe8rNIA7KVZYKHAGxAWuSi4qqdBTTMQ6UITGJ73s9x nOB1f6LQ==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s0Z-0008V7-4A; Tue, 09 Oct 2018 13:25:07 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/33] powerpc/dma: remove the unused ARCH_HAS_DMA_MMAP_COHERENT define Date: Tue, 9 Oct 2018 15:24:29 +0200 Message-Id: <20181009132500.17643-3-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Christoph Hellwig Acked-by: Benjamin Herrenschmidt --- arch/powerpc/include/asm/dma-mapping.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index 8fa394520af6..f2a4a7142b1e 100644 --- a/arch/powerpc/include/asm/dma-mapping.h +++ b/arch/powerpc/include/asm/dma-mapping.h @@ -112,7 +112,5 @@ extern int dma_set_mask(struct device *dev, u64 dma_mask); extern u64 __dma_get_required_mask(struct device *dev); -#define ARCH_HAS_DMA_MMAP_COHERENT - #endif /* __KERNEL__ */ #endif /* _ASM_DMA_MAPPING_H */ From patchwork Tue Oct 9 13:24:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632519 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 43B47112B for ; Tue, 9 Oct 2018 13:25:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3564C286A1 for ; Tue, 9 Oct 2018 13:25:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 294D9289DF; Tue, 9 Oct 2018 13:25:36 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D85A286A1 for ; Tue, 9 Oct 2018 13:25:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2055E6B000E; Tue, 9 Oct 2018 09:25:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 097E56B0266; Tue, 9 Oct 2018 09:25:30 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CCDCE6B026D; Tue, 9 Oct 2018 09:25:30 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 7EA336B000D for ; Tue, 9 Oct 2018 09:25:30 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id n81-v6so1068888pfi.20 for ; Tue, 09 Oct 2018 06:25:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Hv7ijMJqJ3bUGXdkPGBbQ1t8YTTHtf1Gbw38l9E+/Sc=; b=mxodS0N61n9BZAUhdoNwJA2/tlE3lQZ/71ulGNoI6gqgGqWVsINARw/7TJ1xt9Ajt6 WBXdwgYKIKc9S1ZsXPFlpkxY4FTdb+za6MeFkyA1qFapxBr0xFKqjOm1OyEPc8Dph92b AiVIw0bw0349MbcYqGYjAd2VD5m9/5OGl0c8id7vWjj0bk1EikILKPTriZlGTD+VJCGB 2gidpYeiQKErZDBrnnNvELyvGCzaF3TmFfSW5No3iluzWak6ibUN8dQ+iriFgOWNm7Hy hzyDsIfS5cCBzBLhXlO9KdkdzNvZbrBrKWSeeyYw36ZtUXyuBBBKVQQ2Cg6Ct7JbpVip 9/DQ== X-Gm-Message-State: ABuFfogjNGDmJRf4tSgNRiqzyTzXcc16KS3X4rJZRlIPjXse/cPnQcqY 6l/+8nf/g0lI0waE5N8fATKk0/ivx4KKWGBQcKnLjRYk9miIwK8gy6Q2oCQ6Y43ns+NbVrHfr0A ro7w2hA5Csl/Fqq0uKpBt08GrTu8y2Mq4PfFfSHG5mrmDiaxPH6jwIsM0RCCF1X0= X-Received: by 2002:a63:1066:: with SMTP id 38-v6mr22196689pgq.254.1539091530214; Tue, 09 Oct 2018 06:25:30 -0700 (PDT) X-Google-Smtp-Source: ACcGV61o/GRPENUhN2wjvpYzmVvkdkkcObBgAJQCNJ5XhiTAARhmywUEi9wswDlPsp5xRSB2WZTm X-Received: by 2002:a63:1066:: with SMTP id 38-v6mr22196643pgq.254.1539091529465; Tue, 09 Oct 2018 06:25:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091529; cv=none; d=google.com; s=arc-20160816; b=h4QGfXsLqxI3h6izPWJxPgeRWJwvII050NL+OLU14OsubIzdptpdshWVA9BXB55ZC9 j9pBj/NiLaoZ/za71VSLMzfkEZQxne1VFUPNvpcO2G6hMjh390YcnA3M3Cao9M4cfvw7 zo+HEEfYOrRmQCJ3fwx7hk2FTlhAs1IoC85XwfVkQc/0EIq7YFxXnG8EAIE226iwcuwx 1GXcGC7eerUGB3dQ73aanKv/UpXPULmx612F9FTMdCD/KwmOTXXiqEgLqtmwMWktJ9Dd Kq+5vuLCuNZdyKBFAdX/LaULz5gSi0pRn7fUZuvuwDDoR4OjHWVg4V8yvzbilbRSd8PZ md4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Hv7ijMJqJ3bUGXdkPGBbQ1t8YTTHtf1Gbw38l9E+/Sc=; b=lJ7d9R2s/LvggI0t4WkWEH1zgGwA8uChQmI17q7PRzvlZt4ztq1AxNDjl3SD5JrEWM GMi4mcetAqCrekDxGxON3W71Z1awJsEmv/v4OZx8MEynop7lfoLLRL1r9E+xFhkqq+x7 xWHtm9/J+jJ8wDVZ4AC+bLNe2/mXR8+JssAHUZECarWYfZ4tlnsg5CvKMN60QZBi5oQG qVJsW1hN/WSrPV9mnOWicFYOJheSPek/0qonPMEyX0RO+wtSTRp7RGDyBuAcIaDUyKkU tITs7kAL0mDfWZTB538PGa2wfb8Tx8hoE8Ex0rcx3CEd/zDKzBQOesSq+4EJ+Av+pUv/ CxDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=quIYxs9k; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id n3-v6si22310503plb.435.2018.10.09.06.25.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:25:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=quIYxs9k; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=Hv7ijMJqJ3bUGXdkPGBbQ1t8YTTHtf1Gbw38l9E+/Sc=; b=quIYxs9k5GXEKXAccZoYth95PI VLSPT3ACv248Cy0Wr442JZoyMBQlt1OPwlCXe3f1ty0RaNb0mYXW75MllbBe9zvBHccFfSzdCNbSc Bu2vkBliX9TNfs+0ruYaAuLtKuhE5gy1apLz7R6LJD/3yqqs88N11tLTv6yr+fov/V4/KoV0SjIfS dJ1H7g0INc3VAAFFBHIfwHLmKQBJ6DONxnohXDF4Z4TfTgkY5X/cEpX2uh1UUHrNXramtu5K4b47K djn6yVx+sZwni0l3vk7tU1JTl2kbZrkyoFkNz+is8V8HbCrMRVvYsdhqPcpy682AHcGmZ0GPbcj4J MhF0NrEw==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s0b-0000Dp-G4; Tue, 09 Oct 2018 13:25:09 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/33] powerpc/dma: remove the unused ISA_DMA_THRESHOLD export Date: Tue, 9 Oct 2018 15:24:30 +0200 Message-Id: <20181009132500.17643-4-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Christoph Hellwig Acked-by: Benjamin Herrenschmidt --- arch/powerpc/kernel/setup_32.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index 8c507be12c3c..3cc2e449594c 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c @@ -59,7 +59,6 @@ unsigned long ISA_DMA_THRESHOLD; unsigned int DMA_MODE_READ; unsigned int DMA_MODE_WRITE; -EXPORT_SYMBOL(ISA_DMA_THRESHOLD); EXPORT_SYMBOL(DMA_MODE_READ); EXPORT_SYMBOL(DMA_MODE_WRITE); From patchwork Tue Oct 9 13:24:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632539 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C180613AA for ; Tue, 9 Oct 2018 13:26:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B523A286A1 for ; Tue, 9 Oct 2018 13:26:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7A1F289C4; Tue, 9 Oct 2018 13:26:20 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C3D3286A1 for ; Tue, 9 Oct 2018 13:26:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 493B26B027A; Tue, 9 Oct 2018 09:26:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3EE576B027C; Tue, 9 Oct 2018 09:26:03 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 28FF86B027D; Tue, 9 Oct 2018 09:26:03 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id C333A6B027A for ; Tue, 9 Oct 2018 09:26:02 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id z8-v6so822472pgp.20 for ; Tue, 09 Oct 2018 06:26:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=E3ytBO+xFPS/hUghGpPtRZVZDlLd3ymijaT0fBZBTd4=; b=JWS9dK/A/8oUiREdpSojY+1BAVh+zWkdOccI1fZyPazfeIM8CrSb0BsFLdLi/Vbt4v P8jOZgr8SnHnV8r3CPhCo7hqPluaTSShDl+YW2rqRcwonJVEHPHLWIinQkXUWK64sxA/ mbW17oCv9zmGGnqemVCn9YyiJ+irg/qDDBt/EmqS+MWpUR5yowC/iICf1GEoJijlDbPT Sq9mElo4t9Pc2uTED44hiqHm+gol2yy8+12pmEIu0Jpre4k40eXJI4/uiNtZhm1U1DE/ KY5FbSU4m4JZqedinE22Bt24QS0tbE53sizU1lJ8MkVQosKO3PRGy2RjLfP8BDWgiZd8 zCTg== X-Gm-Message-State: ABuFfojRFPAcZy2g1IxmNfulM/YleJyR8z3kJXxClecVQH95sko05VrX PXYyxq4GbmRN/iWg2r7s189AURlqEC4j+a9ac/qtm4adhevTpcc/ddywRmgZx+V7MjscgntxZT+ DZ9VTxEqpDqmbKQ9gp6k7smG1/z2GEw9ec4N7heC6o0+GdsZ1EJElxrt+CAITcGw= X-Received: by 2002:a63:bd01:: with SMTP id a1-v6mr8906816pgf.58.1539091562468; Tue, 09 Oct 2018 06:26:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV62qQtCWbeS4vH82y71Tb8hlvRSOpf/X+ybbHim6FQ/RMmuLqA4GoylPVBO8nivaBVbruQ0R X-Received: by 2002:a63:bd01:: with SMTP id a1-v6mr8906777pgf.58.1539091561855; Tue, 09 Oct 2018 06:26:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091561; cv=none; d=google.com; s=arc-20160816; b=cuhToeI027yLUsjSM2sn3TApOWLOa38rER7tjAWlSUlNrvdL8u2TgM4/jewVyuWZg/ H3K982rpSo1zllyESNX4Sd8osQmlVeyK6Fs+DZlmy5KAQfxaiLnDElBzcaJaDNuOYGLv KRIj0BuCHvuQ5AKJCioja6lJL/UVTcGSu9jd+RsscpayM0A6QF0ZZHqQxOsNMO9+4HoW XdGMdgEeYOZ+i7Ztp2Y4zOwDB0cFmB9SMzkXgt4tatHdf0G1Xl05Docpuj487K9seLBp gr2Hw72I4/j7DFVowT4tfcRald30gHMK2NO7rOw/pLJhUMzcNFjAXjmgZNwl/ez/KN/b g7VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=E3ytBO+xFPS/hUghGpPtRZVZDlLd3ymijaT0fBZBTd4=; b=qp6OzcDvPF/UyW6i7w92FbxfY6p99xiZ3pIJhuq3rwzdMLW5hXxgE4fScJKWh2kHZo d+9/sFU5LxpiSslhTi+JEnU2s1fBIhi0pmFrkpF8POW5xb42ClG8yecdUy6q18g04jkn h1o/iWYrjMudVWl5IcPmB7hWA9LDRBpYdEVncVWPNfFLqeSsoNfSmUA9dwhsxuA0mJWs xZiUebTZogI8LoPrQnmTvxAiwHZlivlbhDQMvn/sYCCFe5DQ/Bxb3+xuo3TC68iQuCZE opQdfNyG7WPpMXdMdlU1bMkbqXaQFMJnhiVuhSd9wSTJndpg+W9T0koJxMP2kxncJ6na hnjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=bNAFJJ+l; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id q61-v6si21259025plb.231.2018.10.09.06.26.01 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=bNAFJJ+l; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=E3ytBO+xFPS/hUghGpPtRZVZDlLd3ymijaT0fBZBTd4=; b=bNAFJJ+l95sWYb3WWNZl6tR87A 3wdy6yRK2Pp0eigWUJ8bDkxZyEBRZk6WxWzo7wd+nNirzECt0zxbWW55KtgCfR2t2ljGUwo7Ssaio GE4jr2E01ug3o0sMZb/qGtfQ3g8TL+jRFjNu0hPd0tZndAhl5mA2XkYy5oR8oVTq0BF/CkX+FVxE+ 8bn0AISCfr02diRl1gHufsbR4ArdrIV3GN43rY7T6PQd9krAzba4DsaTKkSgkyxShUiwd1f9/pyj2 aZyxI4NSV1eqcmaEwOadLzb+FVDQfLdeQJuuyc2LkPb9tkBJMOrk8jybS7FYwY1sgUteADoomaVTT 6TIIpLwQ==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s0d-0000PQ-R5; Tue, 09 Oct 2018 13:25:12 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/33] powerpc/dma: remove the unused dma_iommu_ops export Date: Tue, 9 Oct 2018 15:24:31 +0200 Message-Id: <20181009132500.17643-5-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Christoph Hellwig --- arch/powerpc/kernel/dma-iommu.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c index f9fe2080ceb9..2ca6cfaebf65 100644 --- a/arch/powerpc/kernel/dma-iommu.c +++ b/arch/powerpc/kernel/dma-iommu.c @@ -6,7 +6,6 @@ * busses using the iommu infrastructure */ -#include #include /* @@ -123,4 +122,3 @@ struct dma_map_ops dma_iommu_ops = { .get_required_mask = dma_iommu_get_required_mask, .mapping_error = dma_iommu_mapping_error, }; -EXPORT_SYMBOL(dma_iommu_ops); From patchwork Tue Oct 9 13:24:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632523 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2DD9B13AA for ; Tue, 9 Oct 2018 13:25:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C880286A1 for ; Tue, 9 Oct 2018 13:25:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10B00289C4; Tue, 9 Oct 2018 13:25:43 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 582B2286A1 for ; Tue, 9 Oct 2018 13:25:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 448526B0266; Tue, 9 Oct 2018 09:25:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 37EE16B026D; Tue, 9 Oct 2018 09:25:35 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 132666B026E; Tue, 9 Oct 2018 09:25:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id BC1D36B0266 for ; Tue, 9 Oct 2018 09:25:34 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id l1-v6so1086679pfb.7 for ; Tue, 09 Oct 2018 06:25:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=I7FfW7oRTGYeYQGt1279WjcZzqsAXR7/MagLXB6mh8E=; b=pgB1YvfV1pBLKjNVxr6XL4BbsMR2cbPVMZT03ZghfsH7mxe708JzXpjQtahJMXxsb1 sYjoBeR9rqrCFNqwoz6UPX/16eSDcZzYtL7YBlrm5Lr3OM5N4kkXCHCMW8Tn5T5j4/oM VI5Bk13TtzLADjJopndAByjwhg21C5aphPTqPsZY5MzW5UH4BLDw2NmA2OHcqQXhnrP7 uX9mqB/CLmVKN4jA9+1rDW1b/DDvuCVx62qTAd8TbJof93bZijVGTRlt2uwAX1bVcTLg nPQ05s4Ssmbigz5kAsyY0yPIttTvFK+f6fcn94GYCwon1HSiMvbqgdtsdfUltpdRERRE 1ffQ== X-Gm-Message-State: ABuFfojav1+pcEErdQycPjNNPT/8ysovq6GdSQbBrGNdTzteWgg9PHgm gd2miJD4TssBJfJGSz0j5JDUu9IeGDPkPTj3ZPNxUdzgDnULl5MP3Oo1OgfKk+Xn+dMU+YQirtT xile4vQXBGMrNhl3P3FzanMNCYiXJeWUq9fR8WMPZqhKUogtEjJ0WSTgqX4nOPTM= X-Received: by 2002:a63:991a:: with SMTP id d26-v6mr25753877pge.434.1539091534416; Tue, 09 Oct 2018 06:25:34 -0700 (PDT) X-Google-Smtp-Source: ACcGV636GdH+mIR2uiox4Qi0SanDSjmd+gtOAKeKxwGSN0Vzk/A5iBCKBfhlvUagJKZiRfx5luTo X-Received: by 2002:a63:991a:: with SMTP id d26-v6mr25753817pge.434.1539091533487; Tue, 09 Oct 2018 06:25:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091533; cv=none; d=google.com; s=arc-20160816; b=q+EXk1YUVLYttxnDXwxvb1b+LSqgh3PvEJYx1DcXPXg0usz78O6aiwau16Jd1dsUP2 4Grs/KNdwFMnqWYw49aurh/FHHwHJVOUdbublyIJODzlAMzBmU9frmmRjXX8iacXZDzA JGN6ebavQzJoyhQBw6jv0xIu4O2mPF7X1n/9c74TeZefQ0aEVP4D9B5DQhNpK08Ny0/C Cdf8MzPdZG8eeLZerJGpP41c7KkFHKWIqfSmwc6UPj8OEh7ulLkBdXxfSll35TcJVLhW OICocTCSjojxlneesiVV+yjAF6VQF0XPOkldji4i5iXRXAEOaLAwF/eiySODh9zvyVci YWdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=I7FfW7oRTGYeYQGt1279WjcZzqsAXR7/MagLXB6mh8E=; b=BveIcifN1ycfy+XsnJh9xebS+pcezBikFULb0mEjqI8dRV3vHOAr+0z20VbN1fAdyi 9T7NHNka+N+/t30tZEkLJN1S6eCWYtrQm5N5YUV7zrRs9LkcdjlIOhRKTSK00D+nj0Yo 4aL4ZmLB/S2fIiB/EmCXTouM1KecHAA1PtFwAmW+txwt/TTa7hzsFqb+h+LlEwOwCH0c HLJQmmvquKFftuXrlUGHIiWIQg6rdQ01hLFhtpL7hdQpxj2OZjTDkKtGbcUsWmyDSrFb 5Ht5S3FjRAKlEpmAN+gyw9xkEANpdLYq6WpdaQXI+Evdf4wRuyh3nDzuAEWYtpkVE1gI +Ltg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=HAgXDdsW; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id a3-v6si19859478pld.351.2018.10.09.06.25.33 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:25:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=HAgXDdsW; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=I7FfW7oRTGYeYQGt1279WjcZzqsAXR7/MagLXB6mh8E=; b=HAgXDdsWfPTSakz4RKjH42SE52 Kp9hbB43mjlHCBjWa/AE9LVhwdeH0V7avIrhCmxbYBZb3zBdgdzJNtVqoCoaDThn6DZ/vYRJNleT2 JwbpyfInrqVp992hkY74bgGXS8gpPi1jxNj1CkM8SYq5JlKb99x0xmQ6DKow8IUoF1h0SkujD1pVf vpmy8de8/0gjbugKEX3cQB49zZlSCi4wYaeh6blkM1Mq2XEV2qKeIRMMYQFea2SS7c0d74mxOnEBW AZAj49oIZEk6sdLOmCNgxZMIsOMzZ+9Rday3tIhUSN298pZ+jyiOvfzqtRv2St5MVWtEGKTUlNh0g K++K9ing==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s0g-0000mE-6Y; Tue, 09 Oct 2018 13:25:14 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/33] powerpc/dma: split the two __dma_alloc_coherent implementations Date: Tue, 9 Oct 2018 15:24:32 +0200 Message-Id: <20181009132500.17643-6-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The implemementation for the CONFIG_NOT_COHERENT_CACHE case doesn't share any code with the one for systems with coherent caches. Split it off and merge it with the helpers in dma-noncoherent.c that have no other callers. Signed-off-by: Christoph Hellwig Acked-by: Benjamin Herrenschmidt --- arch/powerpc/include/asm/dma-mapping.h | 5 ----- arch/powerpc/kernel/dma.c | 14 ++------------ arch/powerpc/mm/dma-noncoherent.c | 15 +++++++-------- arch/powerpc/platforms/44x/warp.c | 2 +- 4 files changed, 10 insertions(+), 26 deletions(-) diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index f2a4a7142b1e..dacd0f93f2b2 100644 --- a/arch/powerpc/include/asm/dma-mapping.h +++ b/arch/powerpc/include/asm/dma-mapping.h @@ -39,9 +39,6 @@ extern int dma_nommu_mmap_coherent(struct device *dev, * to ensure it is consistent. */ struct device; -extern void *__dma_alloc_coherent(struct device *dev, size_t size, - dma_addr_t *handle, gfp_t gfp); -extern void __dma_free_coherent(size_t size, void *vaddr); extern void __dma_sync(void *vaddr, size_t size, int direction); extern void __dma_sync_page(struct page *page, unsigned long offset, size_t size, int direction); @@ -52,8 +49,6 @@ extern unsigned long __dma_get_coherent_pfn(unsigned long cpu_addr); * Cache coherent cores. */ -#define __dma_alloc_coherent(dev, gfp, size, handle) NULL -#define __dma_free_coherent(size, addr) ((void)0) #define __dma_sync(addr, size, rw) ((void)0) #define __dma_sync_page(pg, off, sz, rw) ((void)0) diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index 6551685a4ed0..d6deb458bb91 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c @@ -62,18 +62,12 @@ static int dma_nommu_dma_supported(struct device *dev, u64 mask) #endif } +#ifndef CONFIG_NOT_COHERENT_CACHE void *__dma_nommu_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flag, unsigned long attrs) { void *ret; -#ifdef CONFIG_NOT_COHERENT_CACHE - ret = __dma_alloc_coherent(dev, size, dma_handle, flag); - if (ret == NULL) - return NULL; - *dma_handle += get_dma_offset(dev); - return ret; -#else struct page *page; int node = dev_to_node(dev); #ifdef CONFIG_FSL_SOC @@ -110,19 +104,15 @@ void *__dma_nommu_alloc_coherent(struct device *dev, size_t size, *dma_handle = __pa(ret) + get_dma_offset(dev); return ret; -#endif } void __dma_nommu_free_coherent(struct device *dev, size_t size, void *vaddr, dma_addr_t dma_handle, unsigned long attrs) { -#ifdef CONFIG_NOT_COHERENT_CACHE - __dma_free_coherent(size, vaddr); -#else free_pages((unsigned long)vaddr, get_order(size)); -#endif } +#endif /* !CONFIG_NOT_COHERENT_CACHE */ static void *dma_nommu_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flag, diff --git a/arch/powerpc/mm/dma-noncoherent.c b/arch/powerpc/mm/dma-noncoherent.c index 382528475433..965ce3d19f5a 100644 --- a/arch/powerpc/mm/dma-noncoherent.c +++ b/arch/powerpc/mm/dma-noncoherent.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include @@ -151,8 +151,8 @@ static struct ppc_vm_region *ppc_vm_region_find(struct ppc_vm_region *head, unsi * Allocate DMA-coherent memory space and return both the kernel remapped * virtual and bus address for that space. */ -void * -__dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp) +void *__dma_nommu_alloc_coherent(struct device *dev, size_t size, + dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs) { struct page *page; struct ppc_vm_region *c; @@ -223,7 +223,7 @@ __dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t /* * Set the "dma handle" */ - *handle = page_to_phys(page); + *dma_handle = phys_to_dma(dev, page_to_phys(page)); do { SetPageReserved(page); @@ -249,12 +249,12 @@ __dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t no_page: return NULL; } -EXPORT_SYMBOL(__dma_alloc_coherent); /* * free a page as defined by the above mapping. */ -void __dma_free_coherent(size_t size, void *vaddr) +void __dma_nommu_free_coherent(struct device *dev, size_t size, void *vaddr, + dma_addr_t dma_handle, unsigned long attrs) { struct ppc_vm_region *c; unsigned long flags, addr; @@ -309,7 +309,6 @@ void __dma_free_coherent(size_t size, void *vaddr) __func__, vaddr); dump_stack(); } -EXPORT_SYMBOL(__dma_free_coherent); /* * make an area consistent. @@ -401,7 +400,7 @@ EXPORT_SYMBOL(__dma_sync_page); /* * Return the PFN for a given cpu virtual address returned by - * __dma_alloc_coherent. This is used by dma_mmap_coherent() + * __dma_nommu_alloc_coherent. This is used by dma_mmap_coherent() */ unsigned long __dma_get_coherent_pfn(unsigned long cpu_addr) { diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c index a886c2c22097..7e4f8ca19ce8 100644 --- a/arch/powerpc/platforms/44x/warp.c +++ b/arch/powerpc/platforms/44x/warp.c @@ -47,7 +47,7 @@ static int __init warp_probe(void) if (!of_machine_is_compatible("pika,warp")) return 0; - /* For __dma_alloc_coherent */ + /* For __dma_nommu_alloc_coherent */ ISA_DMA_THRESHOLD = ~0L; return 1; From patchwork Tue Oct 9 13:24:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632525 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EFD01112B for ; Tue, 9 Oct 2018 13:25:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1532286A1 for ; Tue, 9 Oct 2018 13:25:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5CA2289C4; Tue, 9 Oct 2018 13:25:46 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DD85286A1 for ; Tue, 9 Oct 2018 13:25:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E524B6B026E; Tue, 9 Oct 2018 09:25:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DB2306B026F; Tue, 9 Oct 2018 09:25:36 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB9666B0270; Tue, 9 Oct 2018 09:25:36 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 6145C6B026E for ; Tue, 9 Oct 2018 09:25:36 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id n23-v6so1059848pfk.23 for ; Tue, 09 Oct 2018 06:25:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=sm64G9zOzLTVHztS2JfrA+dPUB2AqgJ3QVy7QL6eQdU=; b=N+tdOATfaIV0/jn07zW11HrAtmIBPiN/RXgufXunb4VUSYyF4AdfN5FIHIBDieKSDx gAKqRV6lAD9zJONKvDMcdFgry9USpX/2ASAfhUP++OxFQvdtVWmvJTpcjSdZgGipM6Zt o08Zr5h9l1jfldryrLYNk1KHs+xmkGNQFjKyhx8yrK3bQ4SIrAFoisAVsWB4OQcNSyXY kBXp8ZYE07xOLSRdgpPKC1UimWk2dcwf3DJ8aTAO+YqORyLMSApOyjfTBId0L3iCk8ZP otQp39tbr4LZYxK9qLzb2pv4jrPCfPeLCAL58XFUcXCGjzdOuxmMC5jTphXaTP9twucY MSIQ== X-Gm-Message-State: ABuFfogyFeJe5fqTrKkTME8PEQXmWQfEUdAaCCR7j5NJa1HQpct1dwUX ELIgBecuFyb3q6sshveXUctGKsa9SbKgVfcoNe2nKgX/+BIX5NZhfDsq4uog+gognrPbodn7f30 HH8AdqzojKomuOQRDnXo1D+lEFj+L5YN0v8QopqRoAWSlqv7DIVBHNOho/AFLY8A= X-Received: by 2002:a17:902:d694:: with SMTP id v20-v6mr16580500ply.146.1539091536081; Tue, 09 Oct 2018 06:25:36 -0700 (PDT) X-Google-Smtp-Source: ACcGV62FN2vZRdJ5SKwCoJBZ21pfkmqetA+YaI74S51d+6g10qqx3LMqkc0fCtlFqe8r3F9yMfSL X-Received: by 2002:a17:902:d694:: with SMTP id v20-v6mr16580459ply.146.1539091535454; Tue, 09 Oct 2018 06:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091535; cv=none; d=google.com; s=arc-20160816; b=b0UXhPzJO4kF/7EcKiakE+CFQmH5UjO0uqk12BJjqnD8PdVXL+EfuBY9ULMcCWKWTS TmzDD83nEW4GRkWnnZ9GHjW6qlX3w0X8THbQB3qCOqo1bhheNdOEO3XEbad1zzKVovGc vf9tagsglJAhpZFKIVWSE0IZVK3RJFmMODWFfGozU94/7biClTM5jsYRjMgBq5uKMkqJ LChYcY5ucQjklIJgnirtnBUdFXMRKwQcUGSIK2paQaAulUK/JZVV/zOLEOlk9wVq6HcC mNLTWSfrEqRRcn1TtlqOewjJ+Y4xqJuqbKc0Xkh19315YAoAdrw1RZTjS51ELSE5/YFb XraQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=sm64G9zOzLTVHztS2JfrA+dPUB2AqgJ3QVy7QL6eQdU=; b=AX+LXlyHXWdDctw2PQgoEVFdedmXbU3A86+vJTi0iJCevMz1TW6eSQUMa4JmU11YWh RDeT6xQvLUkCrGqLS95unLtLrSNQPy5Rv3HMBMtAAQU9UXjjo4lPCYHLd8sjlnAuhYbV hrlOZ03OJa5MHNaaA6R983CVsE4ZzMNuIUgSk04KbRcAtCgslFwqDamm9cOfMYRHCsWN AdkmHoAlUSHjNeUWJEhT3i9WH5oA1BwijBlPTg2fZ271wGkfWUVKDB6hdrBlNP6T0g8z roZy7D6GbmE5aWySVkaNCCalwKt81ZtT02qKdILtuSxaW5I8+d2RqeKKaL5GLZHilIP2 /qEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=tbFfGJFn; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id w71-v6si20142718pgd.163.2018.10.09.06.25.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:25:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=tbFfGJFn; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=sm64G9zOzLTVHztS2JfrA+dPUB2AqgJ3QVy7QL6eQdU=; b=tbFfGJFnfB3JeKmr6eXyJMA2lS 3iSQtuWsqXxhhGFqjV7CQTDfEvCNa/5HApusniYRWiFIqdjdx54MWVo4zff2QbFa7xbe/NLgeV92g Mtkmgq+Oolp3YaJ1tQ3RgGayY64YWelr6rCDdmHceAqGZBrGAjWWBf+LdNsc1F9lL6OALqGwmpkm7 nCYbtK4S/lcNmsu3Ji/jzhfnbmVVqtGWP6e5mMrkSZkVz9Bhw69XDAz5w4QlGYlpg2y5Okc4c1Mwu 3OehE8L4l4Ju7IQMR1rzzoaCIPVtKFCjLKOqvrKeFdYSZ0En2BKvYgRoA152b2sgpMDzqumkMYOWT GKd+ybGQ==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s0i-000150-Hp; Tue, 09 Oct 2018 13:25:16 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/33] powerpc/dma: remove the no-op dma_nommu_unmap_{page,sg} routines Date: Tue, 9 Oct 2018 15:24:33 +0200 Message-Id: <20181009132500.17643-7-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP These methods are optional, no need to implement no-op versions. Signed-off-by: Christoph Hellwig Acked-by: Benjamin Herrenschmidt --- arch/powerpc/kernel/dma.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index d6deb458bb91..7078d72baec2 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c @@ -197,12 +197,6 @@ static int dma_nommu_map_sg(struct device *dev, struct scatterlist *sgl, return nents; } -static void dma_nommu_unmap_sg(struct device *dev, struct scatterlist *sg, - int nents, enum dma_data_direction direction, - unsigned long attrs) -{ -} - static u64 dma_nommu_get_required_mask(struct device *dev) { u64 end, mask; @@ -228,14 +222,6 @@ static inline dma_addr_t dma_nommu_map_page(struct device *dev, return page_to_phys(page) + offset + get_dma_offset(dev); } -static inline void dma_nommu_unmap_page(struct device *dev, - dma_addr_t dma_address, - size_t size, - enum dma_data_direction direction, - unsigned long attrs) -{ -} - #ifdef CONFIG_NOT_COHERENT_CACHE static inline void dma_nommu_sync_sg(struct device *dev, struct scatterlist *sgl, int nents, @@ -261,10 +247,8 @@ const struct dma_map_ops dma_nommu_ops = { .free = dma_nommu_free_coherent, .mmap = dma_nommu_mmap_coherent, .map_sg = dma_nommu_map_sg, - .unmap_sg = dma_nommu_unmap_sg, .dma_supported = dma_nommu_dma_supported, .map_page = dma_nommu_map_page, - .unmap_page = dma_nommu_unmap_page, .get_required_mask = dma_nommu_get_required_mask, #ifdef CONFIG_NOT_COHERENT_CACHE .sync_single_for_cpu = dma_nommu_sync_single, From patchwork Tue Oct 9 13:24:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632527 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3513213AA for ; Tue, 9 Oct 2018 13:25:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26453286A1 for ; Tue, 9 Oct 2018 13:25:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A947289C4; Tue, 9 Oct 2018 13:25:52 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 64565286A1 for ; Tue, 9 Oct 2018 13:25:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 85D8F6B026F; Tue, 9 Oct 2018 09:25:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 797476B0272; Tue, 9 Oct 2018 09:25:40 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 63F8A6B0273; Tue, 9 Oct 2018 09:25:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 10C8A6B026F for ; Tue, 9 Oct 2018 09:25:40 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id d22-v6so1105565pfn.3 for ; Tue, 09 Oct 2018 06:25:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=1Tr53rfJav7zdbLlOHDxxRmJt13SOgc6G8e+yA/ZzXg=; b=Zyq7kCGEdmWHeSGGnoru60m08GER6PEBJtukkZ1aWl7a9Fl0am/ED/y6dG9aF1jYjp aoxMBdRyehdkhva8ZRVrVZFmdtCaC2Pp99KQx6BS+3ZhHYQRxQ4DZO2cQ0FyialFCbYY bsWu+NX6H/DKLJTVWwBzD5VOwsjdOKANC16vZfvNDTw7qUESCW9OJJedrVT9Ws64LBb1 uoTOM1K26aXsXPu9tRNso3zesyjSVrKUb+amCpcQfAbSEuYQsC1y/4s5M76QOWb1OPTr ZtAbyo3yJM/dRdPQPziAnXN6fgj/oIizLzILJlKMhFDRW++vDsVAvQ3obagCU+1grdr3 LEIw== X-Gm-Message-State: ABuFfohzLN7+s9wbrWvhYj1KQN416OgP3VdkYWQ5nJJQbEwF3lM67Jq4 xsoj+i57wjLe1l3esnjG2FYVn119VS2arvDxsp9XgE5qb5KeYAmZlg6ptad9soG5S4P9UHGmByj a+lzSQLNsEOMsJ13PA49g81WzEsdQYjCYBzYk6t6wMk5Tb0FT2rk9lBvgrIWsAt8= X-Received: by 2002:a62:6c48:: with SMTP id h69-v6mr29982830pfc.61.1539091539724; Tue, 09 Oct 2018 06:25:39 -0700 (PDT) X-Google-Smtp-Source: ACcGV60mUYHia6LU2pHltKAUeQ7RjPTIKE4yBoxhZvKE3VMoTNrEfIIX7AVcOMtbWPtFngNLqlVy X-Received: by 2002:a62:6c48:: with SMTP id h69-v6mr29982770pfc.61.1539091538762; Tue, 09 Oct 2018 06:25:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091538; cv=none; d=google.com; s=arc-20160816; b=GOub4BibnGyA8w1GAnZcWwD2ARXaAGJlW8tnWaPyOI/HX6o68y3MqHZLM/JZuKp40x GFaRNdkT/kzbYdzkiWMOAcUFVWTDZ1Upg0hx0BKIBV3JFsdmqlOreMbc1iJiU/VHtK5M WV2KpmUE/+cZp7aypmkoRrcLNDWtcppiYJgXTpP64QuNKpv2Y0L2fL0WGQcysGPMpSqe iNTA4SjSZgB0LPFsvOEWfjwv8hOJLmPvcMBdWh580dumLt9BsLgdkXvuWGA2xbx+108o Bem+PrsTO0DG5+n3xpgHt6R0DBmJuZ9+GFCMOqC7yhFmWD9ezAQTmIf5RhyxyUL2aIzw FYhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=1Tr53rfJav7zdbLlOHDxxRmJt13SOgc6G8e+yA/ZzXg=; b=cvHUUJowoobKNktz09eI3wJDagGbJPkVrTPe5aAAzZPADeIIyECyf0HzQMH4yaq/vu 4a402hTDYBaMM6TUtziTkFfMPznNrh+ss9ZyKZh9E4EmCmdlx5ZUFml4QZTTVpvTrsts +XT9o74pHkp9qmB0kvXRnNEMAr72eZs0wELxLPJ4+sbMnRIXcdMeTKoy2M6fPgbfEVXt rwRscfZ/lQuPBAIdooV/I5lKGOLbfqJjhyB2SoRspE1l++CwaGDJHzZFpC3NmB9xgxa2 BMINIX3nwHfp+gU0VAlExEuaLaJsSd7R3fO0DSLa4h2miqo16IMLhX+hEvEZjhA+pmVF Q9qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=s9heitGh; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id d130-v6si19657838pgc.189.2018.10.09.06.25.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:25:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=s9heitGh; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=1Tr53rfJav7zdbLlOHDxxRmJt13SOgc6G8e+yA/ZzXg=; b=s9heitGhgfyQTY10/J4RDtoSTw m2mE5+9yvK9ZeVOtBbMrT4kUDD2Y/Fs9vKb5RYZOKvGec9wz7tYjR3YrjY+y0IqDDa6PBdSIqeNwP KlKxUp5zl8mfwGAa0r96pi+64gOmv6yt+jAl5aiMJUNqHEglg5vMondBQQm2qO29ibrAnNlyV/JaN EofNDQn2P9XjIlp+ijSoDOBs2Z16Y6dZ3zsF0nLjEo7Fc8+fo7ZJWqADH3MrMZDFCvVGIlHLpfh4R J7CfzS0+VnDe5VzO9RH2b5H8EIDBqGbeQ/6e3N8ydrOJjvOllpx8xcODugO2FjXyM73PMWzOYdaum a8Z7Z49g==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s0k-00018r-T9; Tue, 09 Oct 2018 13:25:19 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/33] powerpc/dma: untangle vio_dma_mapping_ops from dma_iommu_ops Date: Tue, 9 Oct 2018 15:24:34 +0200 Message-Id: <20181009132500.17643-8-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP vio_dma_mapping_ops currently does a lot of indirect calls through dma_iommu_ops, which not only make the code harder to follow but are also expensive in the post-spectre world. Unwind the indirect calls by calling the ppc_iommu_* or iommu_* APIs directly applicable, or just use the dma_iommu_* methods directly where we can. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/iommu.h | 1 + arch/powerpc/kernel/dma-iommu.c | 2 +- arch/powerpc/platforms/pseries/vio.c | 87 ++++++++++++---------------- 3 files changed, 38 insertions(+), 52 deletions(-) diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h index ab3a4fba38e3..26b7cc176a99 100644 --- a/arch/powerpc/include/asm/iommu.h +++ b/arch/powerpc/include/asm/iommu.h @@ -244,6 +244,7 @@ static inline int __init tce_iommu_bus_notifier_init(void) } #endif /* !CONFIG_IOMMU_API */ +u64 dma_iommu_get_required_mask(struct device *dev); int dma_iommu_mapping_error(struct device *dev, dma_addr_t dma_addr); #else diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c index 2ca6cfaebf65..0613278abf9f 100644 --- a/arch/powerpc/kernel/dma-iommu.c +++ b/arch/powerpc/kernel/dma-iommu.c @@ -92,7 +92,7 @@ int dma_iommu_dma_supported(struct device *dev, u64 mask) return 1; } -static u64 dma_iommu_get_required_mask(struct device *dev) +u64 dma_iommu_get_required_mask(struct device *dev) { struct iommu_table *tbl = get_iommu_table_base(dev); u64 mask; diff --git a/arch/powerpc/platforms/pseries/vio.c b/arch/powerpc/platforms/pseries/vio.c index 49e04ec19238..1dfff53ebd7f 100644 --- a/arch/powerpc/platforms/pseries/vio.c +++ b/arch/powerpc/platforms/pseries/vio.c @@ -492,7 +492,9 @@ static void *vio_dma_iommu_alloc_coherent(struct device *dev, size_t size, return NULL; } - ret = dma_iommu_ops.alloc(dev, size, dma_handle, flag, attrs); + ret = iommu_alloc_coherent(dev, get_iommu_table_base(dev), size, + dma_handle, dev->coherent_dma_mask, flag, + dev_to_node(dev)); if (unlikely(ret == NULL)) { vio_cmo_dealloc(viodev, roundup(size, PAGE_SIZE)); atomic_inc(&viodev->cmo.allocs_failed); @@ -507,8 +509,7 @@ static void vio_dma_iommu_free_coherent(struct device *dev, size_t size, { struct vio_dev *viodev = to_vio_dev(dev); - dma_iommu_ops.free(dev, size, vaddr, dma_handle, attrs); - + iommu_free_coherent(get_iommu_table_base(dev), size, vaddr, dma_handle); vio_cmo_dealloc(viodev, roundup(size, PAGE_SIZE)); } @@ -518,22 +519,22 @@ static dma_addr_t vio_dma_iommu_map_page(struct device *dev, struct page *page, unsigned long attrs) { struct vio_dev *viodev = to_vio_dev(dev); - struct iommu_table *tbl; + struct iommu_table *tbl = get_iommu_table_base(dev); dma_addr_t ret = IOMMU_MAPPING_ERROR; - tbl = get_iommu_table_base(dev); - if (vio_cmo_alloc(viodev, roundup(size, IOMMU_PAGE_SIZE(tbl)))) { - atomic_inc(&viodev->cmo.allocs_failed); - return ret; - } - - ret = dma_iommu_ops.map_page(dev, page, offset, size, direction, attrs); - if (unlikely(dma_mapping_error(dev, ret))) { - vio_cmo_dealloc(viodev, roundup(size, IOMMU_PAGE_SIZE(tbl))); - atomic_inc(&viodev->cmo.allocs_failed); - } - + if (vio_cmo_alloc(viodev, roundup(size, IOMMU_PAGE_SIZE(tbl)))) + goto out_fail; + ret = iommu_map_page(dev, tbl, page, offset, size, device_to_mask(dev), + direction, attrs); + if (unlikely(ret == IOMMU_MAPPING_ERROR)) + goto out_deallocate; return ret; + +out_deallocate: + vio_cmo_dealloc(viodev, roundup(size, IOMMU_PAGE_SIZE(tbl))); +out_fail: + atomic_inc(&viodev->cmo.allocs_failed); + return IOMMU_MAPPING_ERROR; } static void vio_dma_iommu_unmap_page(struct device *dev, dma_addr_t dma_handle, @@ -542,11 +543,9 @@ static void vio_dma_iommu_unmap_page(struct device *dev, dma_addr_t dma_handle, unsigned long attrs) { struct vio_dev *viodev = to_vio_dev(dev); - struct iommu_table *tbl; - - tbl = get_iommu_table_base(dev); - dma_iommu_ops.unmap_page(dev, dma_handle, size, direction, attrs); + struct iommu_table *tbl = get_iommu_table_base(dev); + iommu_unmap_page(tbl, dma_handle, size, direction, attrs); vio_cmo_dealloc(viodev, roundup(size, IOMMU_PAGE_SIZE(tbl))); } @@ -555,34 +554,32 @@ static int vio_dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist, unsigned long attrs) { struct vio_dev *viodev = to_vio_dev(dev); - struct iommu_table *tbl; + struct iommu_table *tbl = get_iommu_table_base(dev); struct scatterlist *sgl; int ret, count; size_t alloc_size = 0; - tbl = get_iommu_table_base(dev); for_each_sg(sglist, sgl, nelems, count) alloc_size += roundup(sgl->length, IOMMU_PAGE_SIZE(tbl)); - if (vio_cmo_alloc(viodev, alloc_size)) { - atomic_inc(&viodev->cmo.allocs_failed); - return 0; - } - - ret = dma_iommu_ops.map_sg(dev, sglist, nelems, direction, attrs); - - if (unlikely(!ret)) { - vio_cmo_dealloc(viodev, alloc_size); - atomic_inc(&viodev->cmo.allocs_failed); - return ret; - } + if (vio_cmo_alloc(viodev, alloc_size)) + goto out_fail; + ret = ppc_iommu_map_sg(dev, tbl, sglist, nelems, device_to_mask(dev), + direction, attrs); + if (unlikely(!ret)) + goto out_deallocate; for_each_sg(sglist, sgl, ret, count) alloc_size -= roundup(sgl->dma_length, IOMMU_PAGE_SIZE(tbl)); if (alloc_size) vio_cmo_dealloc(viodev, alloc_size); - return ret; + +out_deallocate: + vio_cmo_dealloc(viodev, alloc_size); +out_fail: + atomic_inc(&viodev->cmo.allocs_failed); + return 0; } static void vio_dma_iommu_unmap_sg(struct device *dev, @@ -591,30 +588,18 @@ static void vio_dma_iommu_unmap_sg(struct device *dev, unsigned long attrs) { struct vio_dev *viodev = to_vio_dev(dev); - struct iommu_table *tbl; + struct iommu_table *tbl = get_iommu_table_base(dev); struct scatterlist *sgl; size_t alloc_size = 0; int count; - tbl = get_iommu_table_base(dev); for_each_sg(sglist, sgl, nelems, count) alloc_size += roundup(sgl->dma_length, IOMMU_PAGE_SIZE(tbl)); - dma_iommu_ops.unmap_sg(dev, sglist, nelems, direction, attrs); - + ppc_iommu_unmap_sg(tbl, sglist, nelems, direction, attrs); vio_cmo_dealloc(viodev, alloc_size); } -static int vio_dma_iommu_dma_supported(struct device *dev, u64 mask) -{ - return dma_iommu_ops.dma_supported(dev, mask); -} - -static u64 vio_dma_get_required_mask(struct device *dev) -{ - return dma_iommu_ops.get_required_mask(dev); -} - static const struct dma_map_ops vio_dma_mapping_ops = { .alloc = vio_dma_iommu_alloc_coherent, .free = vio_dma_iommu_free_coherent, @@ -623,8 +608,8 @@ static const struct dma_map_ops vio_dma_mapping_ops = { .unmap_sg = vio_dma_iommu_unmap_sg, .map_page = vio_dma_iommu_map_page, .unmap_page = vio_dma_iommu_unmap_page, - .dma_supported = vio_dma_iommu_dma_supported, - .get_required_mask = vio_dma_get_required_mask, + .dma_supported = dma_iommu_mapping_error, + .get_required_mask = dma_iommu_get_required_mask, .mapping_error = dma_iommu_mapping_error, }; From patchwork Tue Oct 9 13:24:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632537 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 76530112B for ; Tue, 9 Oct 2018 13:26:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6863A286A1 for ; Tue, 9 Oct 2018 13:26:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5CAEE289C4; Tue, 9 Oct 2018 13:26:16 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9193B28988 for ; Tue, 9 Oct 2018 13:26:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E538F6B027B; Tue, 9 Oct 2018 09:26:02 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DDA286B027D; Tue, 9 Oct 2018 09:26:02 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C288C6B027C; Tue, 9 Oct 2018 09:26:02 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 7BBA06B027A for ; Tue, 9 Oct 2018 09:26:02 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id 11-v6so851992pgd.1 for ; Tue, 09 Oct 2018 06:26:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=JhfAI7+Q5zQfe4nU3Z7X/NaCUXxeqE67+vUNnRaT5wk=; b=lbm0DOvF6gkEfwq4L/AEWZbsWD+EgWZe82tsBs1DksaWUi01Yzqkf61+Bx8aPwdYrL VrGvbkK+/Cx849sjByHBWNO0MTNGlmZJLFEMm7t2efyr2j/dDMARoWjRhoikoUuq/nBn GwgL8uvboVzo1MPg30hCtAkmgB1jB66NAOFa+XIdop8EaOzU0+wRQESZz5Yf3Qyg7Sc0 eoffkBlySZQHZU+PGVWlvrJh3AISOxQJL5YIOchfqAPESkGupZtm57I4WQLMpSpbuiGw Lu32CLX7T6o3lwGdzWzbg7CVbkePxpbW+xE2pVkQHfcZH2wGXz51AleTFHG8jczo9ZmU al/w== X-Gm-Message-State: ABuFfogTjf96I58+I2nfYZYYHwnopLaPkbQH8rtZ1UcQzewOjzpIkTS7 Mj5EcqnEuLngJrE/kdkmwZ6ZmZ11DCvymdroXBjRK+/wfrueyuI5grtIussx5S78FvIBdGs/TzD UAaxOvwRXTYK4ApHDn5o3ZshhFWmv8nWoD/BNP5mKuhIipZ43jRX3J7jj8JXUxCc= X-Received: by 2002:a62:3185:: with SMTP id x127-v6mr30916548pfx.88.1539091562160; Tue, 09 Oct 2018 06:26:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV60cpMB3qZxyi3kxd/pD5eMsBWRTdJWC1sGLtgX576OFgEOjsK5U1vNyL8wGTgjdE0WMTUuA X-Received: by 2002:a62:3185:: with SMTP id x127-v6mr30916477pfx.88.1539091561042; Tue, 09 Oct 2018 06:26:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091561; cv=none; d=google.com; s=arc-20160816; b=NkdKxvKBsa43jOsQoFS3Qiv8MhdIdi/hvLlqLqcPt6gRm+La4nOzFe1DIVNkJpQ3xS qD2huPIMbbDgwwJsfeMk5qpqpVFArKMNuDE51rR9wgeyUC9yrJycvLyhqk6bHRD7kcO+ BV3oYUAd3RP5TLyvZOAzcRkhd0wS7RrTz6e7aoDY3eJ6fYnF79Td4kUsgL25jR61a9PT 4X+cixeXEjEzN4w1rEXTzQB1sw6A3xJEKA/4LQSzardotyQn1WfPk2feaJTkccladzTs sqapSt0Znh6dGxMGmBtcLu3x2HzKfKkjRWldlegr3UCJhQ4jwhb/0fHje9hq+u189gy0 TkeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=JhfAI7+Q5zQfe4nU3Z7X/NaCUXxeqE67+vUNnRaT5wk=; b=uSTC/feM0MvSKLZ2cTJYHGlih8d6yvsdwnpq7+EzWFrR3/zwW3TzEPBPukzB9I0EPi /1ellDSXkdkRIQXtiOSaD2UiiGQAPcZ8Ei5kOTXinI8gsVlEe9/8jpxEjrdAIgEnxHcx 7jjjoR3XjYgdP6U6UG8IQqOXISqHanDm45cbIH2roVAzno75V+fBbf7AInSDXf+28lhO 2vlA93sVhBZSsTYbgZa/j3HI/rHVYFUUrbn5ObJnGqzcCa/YJfiRuVC/3EH2UWBvyufJ 9y9eboZ18c7/QmOw5PEBLUSsWv4+A4gEt1IEDMEaujpwvfoBnEubLlB/pGQwoIBwyqbk KVlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=hoBvi551; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id o186-v6si24248187pfo.236.2018.10.09.06.26.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=hoBvi551; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=JhfAI7+Q5zQfe4nU3Z7X/NaCUXxeqE67+vUNnRaT5wk=; b=hoBvi551yWbQrBhyCC05HtCkxi 0nWk7SCLEUlZoNRoiHPAnHHlCGv0MBbCSF7B4q52VGHjc9n8s+FuDLVRLtgGi2OYIlzL5I4jW8tuy XVMc4bi5MyqVqSMBiAAVaqB9eMrTegx43PuaRDNSNdrX+nxNIjcbNlHfkWtR8ZOfpuiiXP1TeU4Kr S3cBTkZ5Ha/Hqvd47bftzt7+I+7btEQbq4BAWNec8VQme/LLDFm8npYph8wvZSWswFJy7SJPTN708 Y56MS5ir1qT+JfhqB7+sREezfC2Qi7EPwM94BANpbaY7yEAFdB0JDV4Qahv0QtlYHCtMQ33pDy9G6 9glo0dwQ==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s0n-000199-Ab; Tue, 09 Oct 2018 13:25:21 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/33] powerpc/dma: handle iommu bypass in dma_iommu_ops Date: Tue, 9 Oct 2018 15:24:35 +0200 Message-Id: <20181009132500.17643-9-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Add a new iommu_bypass flag to struct dev_archdata so that the dma_iommu implementation can handle the direct mapping transparently instead of switiching ops around. Setting of this flag is controlled by new pci_controller_ops method. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/device.h | 5 ++ arch/powerpc/include/asm/dma-mapping.h | 7 +++ arch/powerpc/include/asm/pci-bridge.h | 2 + arch/powerpc/kernel/dma-iommu.c | 70 +++++++++++++++++++++++--- arch/powerpc/kernel/dma.c | 17 +++---- 5 files changed, 85 insertions(+), 16 deletions(-) diff --git a/arch/powerpc/include/asm/device.h b/arch/powerpc/include/asm/device.h index 0245bfcaac32..1aa53318b4bc 100644 --- a/arch/powerpc/include/asm/device.h +++ b/arch/powerpc/include/asm/device.h @@ -19,6 +19,11 @@ struct iommu_table; * drivers/macintosh/macio_asic.c */ struct dev_archdata { + /* + * Set to %true if the dma_iommu_ops are requested to use a direct + * window instead of dynamically mapping memory. + */ + bool iommu_bypass : 1; /* * These two used to be a union. However, with the hybrid ops we need * both so here we store both a DMA offset for direct mappings and diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index dacd0f93f2b2..27283eb68c50 100644 --- a/arch/powerpc/include/asm/dma-mapping.h +++ b/arch/powerpc/include/asm/dma-mapping.h @@ -29,6 +29,13 @@ extern int dma_nommu_mmap_coherent(struct device *dev, struct vm_area_struct *vma, void *cpu_addr, dma_addr_t handle, size_t size, unsigned long attrs); +int dma_nommu_map_sg(struct device *dev, struct scatterlist *sgl, + int nents, enum dma_data_direction direction, + unsigned long attrs); +dma_addr_t dma_nommu_map_page(struct device *dev, struct page *page, + unsigned long offset, size_t size, + enum dma_data_direction dir, unsigned long attrs); +int dma_nommu_dma_supported(struct device *dev, u64 mask); #ifdef CONFIG_NOT_COHERENT_CACHE /* diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h index 94d449031b18..5c7a1e7ffc8a 100644 --- a/arch/powerpc/include/asm/pci-bridge.h +++ b/arch/powerpc/include/asm/pci-bridge.h @@ -19,6 +19,8 @@ struct device_node; struct pci_controller_ops { void (*dma_dev_setup)(struct pci_dev *pdev); void (*dma_bus_setup)(struct pci_bus *bus); + bool (*iommu_bypass_supported)(struct pci_dev *pdev, + u64 mask); int (*probe_mode)(struct pci_bus *bus); diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c index 0613278abf9f..c865e15ad024 100644 --- a/arch/powerpc/kernel/dma-iommu.c +++ b/arch/powerpc/kernel/dma-iommu.c @@ -6,12 +6,30 @@ * busses using the iommu infrastructure */ +#include +#include #include /* * Generic iommu implementation */ +/* + * The coherent mask may be smaller than the real mask, check if we can + * really use a direct window. + */ +static inline bool dma_iommu_alloc_bypass(struct device *dev) +{ + return dev->archdata.iommu_bypass && + dma_nommu_dma_supported(dev, dev->coherent_dma_mask); +} + +static inline bool dma_iommu_map_bypass(struct device *dev, + unsigned long attrs) +{ + return dev->archdata.iommu_bypass; +} + /* Allocates a contiguous real buffer and creates mappings over it. * Returns the virtual address of the buffer and sets dma_handle * to the dma address (mapping) of the first page. @@ -20,6 +38,9 @@ static void *dma_iommu_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flag, unsigned long attrs) { + if (dma_iommu_alloc_bypass(dev)) + return __dma_nommu_alloc_coherent(dev, size, dma_handle, flag, + attrs); return iommu_alloc_coherent(dev, get_iommu_table_base(dev), size, dma_handle, dev->coherent_dma_mask, flag, dev_to_node(dev)); @@ -29,7 +50,11 @@ static void dma_iommu_free_coherent(struct device *dev, size_t size, void *vaddr, dma_addr_t dma_handle, unsigned long attrs) { - iommu_free_coherent(get_iommu_table_base(dev), size, vaddr, dma_handle); + if (dma_iommu_alloc_bypass(dev)) + __dma_nommu_free_coherent(dev, size, vaddr, dma_handle, attrs); + else + iommu_free_coherent(get_iommu_table_base(dev), size, vaddr, + dma_handle); } /* Creates TCEs for a user provided buffer. The user buffer must be @@ -42,6 +67,9 @@ static dma_addr_t dma_iommu_map_page(struct device *dev, struct page *page, enum dma_data_direction direction, unsigned long attrs) { + if (dma_iommu_map_bypass(dev, attrs)) + return dma_nommu_map_page(dev, page, offset, size, direction, + attrs); return iommu_map_page(dev, get_iommu_table_base(dev), page, offset, size, device_to_mask(dev), direction, attrs); } @@ -51,8 +79,9 @@ static void dma_iommu_unmap_page(struct device *dev, dma_addr_t dma_handle, size_t size, enum dma_data_direction direction, unsigned long attrs) { - iommu_unmap_page(get_iommu_table_base(dev), dma_handle, size, direction, - attrs); + if (!dma_iommu_map_bypass(dev, attrs)) + iommu_unmap_page(get_iommu_table_base(dev), dma_handle, size, + direction, attrs); } @@ -60,6 +89,8 @@ static int dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist, int nelems, enum dma_data_direction direction, unsigned long attrs) { + if (dma_iommu_map_bypass(dev, attrs)) + return dma_nommu_map_sg(dev, sglist, nelems, direction, attrs); return ppc_iommu_map_sg(dev, get_iommu_table_base(dev), sglist, nelems, device_to_mask(dev), direction, attrs); } @@ -68,10 +99,20 @@ static void dma_iommu_unmap_sg(struct device *dev, struct scatterlist *sglist, int nelems, enum dma_data_direction direction, unsigned long attrs) { - ppc_iommu_unmap_sg(get_iommu_table_base(dev), sglist, nelems, + if (!dma_iommu_map_bypass(dev, attrs)) + ppc_iommu_unmap_sg(get_iommu_table_base(dev), sglist, nelems, direction, attrs); } +static bool dma_iommu_bypass_supported(struct device *dev, u64 mask) +{ + struct pci_dev *pdev = to_pci_dev(dev); + struct pci_controller *phb = pci_bus_to_host(pdev->bus); + + return phb->controller_ops.iommu_bypass_supported && + phb->controller_ops.iommu_bypass_supported(pdev, mask); +} + /* We support DMA to/from any memory page via the iommu */ int dma_iommu_dma_supported(struct device *dev, u64 mask) { @@ -83,22 +124,39 @@ int dma_iommu_dma_supported(struct device *dev, u64 mask) return 0; } + if (dev_is_pci(dev) && dma_iommu_bypass_supported(dev, mask)) { + dev->archdata.iommu_bypass = true; + dev_dbg(dev, "iommu: 64-bit OK, using fixed ops\n"); + return 1; + } + if (tbl->it_offset > (mask >> tbl->it_page_shift)) { dev_info(dev, "Warning: IOMMU offset too big for device mask\n"); dev_info(dev, "mask: 0x%08llx, table offset: 0x%08lx\n", mask, tbl->it_offset << tbl->it_page_shift); return 0; - } else - return 1; + } + + dev_dbg(dev, "iommu: not 64-bit, using default ops\n"); + dev->archdata.iommu_bypass = false; + return 1; } u64 dma_iommu_get_required_mask(struct device *dev) { struct iommu_table *tbl = get_iommu_table_base(dev); u64 mask; + if (!tbl) return 0; + if (dev_is_pci(dev)) { + u64 bypass_mask = dma_direct_get_required_mask(dev); + + if (dma_iommu_bypass_supported(dev, bypass_mask)) + return bypass_mask; + } + mask = 1ULL < (fls_long(tbl->it_offset + tbl->it_size) - 1); mask += mask - 1; diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index 7078d72baec2..716b7eab3ee7 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c @@ -40,7 +40,7 @@ static u64 __maybe_unused get_pfn_limit(struct device *dev) return pfn; } -static int dma_nommu_dma_supported(struct device *dev, u64 mask) +int dma_nommu_dma_supported(struct device *dev, u64 mask) { #ifdef CONFIG_PPC64 u64 limit = get_dma_offset(dev) + (memblock_end_of_DRAM() - 1); @@ -177,9 +177,9 @@ int dma_nommu_mmap_coherent(struct device *dev, struct vm_area_struct *vma, vma->vm_page_prot); } -static int dma_nommu_map_sg(struct device *dev, struct scatterlist *sgl, - int nents, enum dma_data_direction direction, - unsigned long attrs) +int dma_nommu_map_sg(struct device *dev, struct scatterlist *sgl, + int nents, enum dma_data_direction direction, + unsigned long attrs) { struct scatterlist *sg; int i; @@ -209,12 +209,9 @@ static u64 dma_nommu_get_required_mask(struct device *dev) return mask; } -static inline dma_addr_t dma_nommu_map_page(struct device *dev, - struct page *page, - unsigned long offset, - size_t size, - enum dma_data_direction dir, - unsigned long attrs) +dma_addr_t dma_nommu_map_page(struct device *dev, struct page *page, + unsigned long offset, size_t size, + enum dma_data_direction dir, unsigned long attrs) { if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC)) __dma_sync_page(page, offset, size, dir); From patchwork Tue Oct 9 13:24:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632535 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9FB2112B for ; Tue, 9 Oct 2018 13:26:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CFC2286A1 for ; Tue, 9 Oct 2018 13:26:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91168289C4; Tue, 9 Oct 2018 13:26:11 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3204D286A1 for ; Tue, 9 Oct 2018 13:26:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1EF956B0279; Tue, 9 Oct 2018 09:26:02 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 17B266B027A; Tue, 9 Oct 2018 09:26:02 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F126F6B027B; Tue, 9 Oct 2018 09:26:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id A9E406B0279 for ; Tue, 9 Oct 2018 09:26:01 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id d69-v6so815290pgc.22 for ; Tue, 09 Oct 2018 06:26:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=W5emNbizLCS7LiIqBqhMWXhuT26R9Ea9KCG0lszGb70=; b=hzgY8EqcIbgeFt5MqHHa/vbaT32yGJkeaoBoZLh3F4DZQ25YPm0lyOqnJfzIXUIezq ypWHJPE61nrVMTHFP8jEYfn4+9tj5f8hCQ+6TIgTfK9WjRpXVb6jikdJn64G/MwdW9hX yiscIcMw76XoOKGH94hgHH/wGy1VVJ5kr+YE6aTLVKqUflS6b+zkQh/A9QCOFaHUp5mk yJWq5pG5PqMt/1UfVFfSH5OcFhY5EgQlhzstFrR+7wzMtXRBWYm3sMzrhTywTCZ8Ea6N y131O/qV3B/9BdiRqVFms9TO8EMXAD3jlDepQWANQrJhYQibIVpgCE287bY0pAsP9HD3 um6g== X-Gm-Message-State: ABuFfojVqiZPqlkGBNbPVVD+5Ku067/IKmsY1UlZVVS9NH00Ygo5cWaW Ywd+UD8gVCIMnDJz5zchWjDIijEERAp4sGCJzEyvPWTrAQGEeXkHTZu8fEIPqCT+0tpbccWsDww hSVwQPUAbZeX6YHhfDg7Q3rbD3zrKsTzo/pi3DKyRFBQvHKtMUNY0ISOEDJEQCaQ= X-Received: by 2002:a63:fc46:: with SMTP id r6-v6mr25922358pgk.345.1539091561375; Tue, 09 Oct 2018 06:26:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV63Qvkas11EaBS+o+gP2Oe52lWiY+zrFHYuw2IJxtKRGphY6VffViAPEJ2M8TW8JIcCD6U9D X-Received: by 2002:a63:fc46:: with SMTP id r6-v6mr25922315pgk.345.1539091560736; Tue, 09 Oct 2018 06:26:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091560; cv=none; d=google.com; s=arc-20160816; b=Qo9la9QdOtaS3g760vhYQsTXnv8Rzj46cxDzLv3HS6/iZ6UPx7Q4fw3vOOABaiYK7q qtoy+zBXG9I8UvccUScurGm0CdI4ugwi3R3gh1ED1sPtMnScbL+QuBSTmqn/54sbpCf7 8SYR+NTMhEAJy/igUaVEzUWimGWdknRm7aWm3NpYbz7wzxa//s+bWX+lx5B3Z/fXeBRR HOHQ+pnuuwCNaA/tYy6dq7aqrHSMEM+TnUa/QspvQqaVy2mCTyI62NsYPLW4TfeYo7Cf QtG7AX/XMjJh+eDIWp3vGtoVkAhaIgbXkqyywVDDExVP8xrtZ20j0dIYtBc69KSU7zwX sYKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=W5emNbizLCS7LiIqBqhMWXhuT26R9Ea9KCG0lszGb70=; b=oWHje38ereAuUiX9u/pV93CT7pkI5PSbW3nk7jK4Wsjq3RIQgFWRO0W9ZU9DJRt7EZ VeuXjxLwXUzoE1Vrksji8fXXazTU4LunClsyLE6JWckZsT82J8MD+g1XC5UGL6ilHTdS gWQ5vuSmcd0ZbwCZYJYxEQ07bfWtgWUJ8ryZGylGirGO5QFb7C27mJJd/TP/6OL9rbgW nEuaAEAIh/9k+TtspB8MvMR0TndRkBxSiENOtKciXVoNK1k/ukzPr4dCA8mt5ZmTNwld CCbthOJ8Lt2soxkzk+XmWWDKzlxm6as5yRHQT6pCo5R7s0uHAF4ZiKBSINc5arZukX1N aMgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=QgSNcfnz; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id f76-v6si24554906pfa.73.2018.10.09.06.26.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=QgSNcfnz; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=W5emNbizLCS7LiIqBqhMWXhuT26R9Ea9KCG0lszGb70=; b=QgSNcfnzXP9eBaj/r33QO6P80a CuC5VHdQDRq5CC7d32eeb/gcMDBdTI60+ny9lSoPq9hURro6wCwGnBE/H3qPFKnhhmjI8EUzmzAws h2P31uXsK7jAk5NjJcWeVgBOOv/XWPUic0xwCCNMDEGxP0H5M6/XzyaK6W+QT3RG+vq/5DLaaohnz oFyHvTwPil3p7FPBh1A8iY9dEHiYhFxOfTi88UVrHfaPXeAaSZlHMiQb4sSdCEGrcHa1GGa1jwjb5 /5aG3Pk9tQr0weILhveZ+fu5Qb9/Igca3TOIAwFgpD38iu9tJvCt3yaj+1vRDCRgm+VV68EAAmCOX t/qVVwSg==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s0p-00019S-MI; Tue, 09 Oct 2018 13:25:24 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/33] powerpc/pseries: unwind dma_get_required_mask_pSeriesLP a bit Date: Tue, 9 Oct 2018 15:24:36 +0200 Message-Id: <20181009132500.17643-10-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Call dma_get_required_mask_pSeriesLP directly instead of dma_iommu_ops to simply the code a bit. Signed-off-by: Christoph Hellwig --- arch/powerpc/platforms/pseries/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 06f02960b439..da5716de7f4c 100644 --- a/arch/powerpc/platforms/pseries/iommu.c +++ b/arch/powerpc/platforms/pseries/iommu.c @@ -1273,7 +1273,7 @@ static u64 dma_get_required_mask_pSeriesLP(struct device *dev) return DMA_BIT_MASK(64); } - return dma_iommu_ops.get_required_mask(dev); + return dma_iommu_get_required_mask(dev); } static int iommu_mem_notifier(struct notifier_block *nb, unsigned long action, From patchwork Tue Oct 9 13:24:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632529 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD89B112B for ; Tue, 9 Oct 2018 13:25:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE0C0286A1 for ; Tue, 9 Oct 2018 13:25:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0B50289C4; Tue, 9 Oct 2018 13:25:57 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5DE59286A1 for ; Tue, 9 Oct 2018 13:25:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9BBA26B0273; Tue, 9 Oct 2018 09:25:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 943816B0274; Tue, 9 Oct 2018 09:25:48 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 798A96B0275; Tue, 9 Oct 2018 09:25:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 341776B0273 for ; Tue, 9 Oct 2018 09:25:48 -0400 (EDT) Received: by mail-pl1-f197.google.com with SMTP id c4-v6so965956plz.20 for ; Tue, 09 Oct 2018 06:25:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=xcMUgmz8fxZAX73L1Qt9UC9lj3gcizfN8j5e3xZ/twA=; b=NrUusNDV2rqQcIRBw1gVYD9Nh6POug5pqvRM+QmIuRc4pzKuFaqKX3LPUE0roWnEVX k6NJa6TU1hBO54OlMh/7e96e7CcLaJGwXw2ttlz8Oiaq6PI5zO77gizRCLTssAbYFsyG W55rmoj9brY6wlKaJ3sN1VjcVSXpiUGhsebGVsvdYhDkTYtcK0Yv5WAZyhQGNMLICP0U 47/gsC592UWWNbGE636IzcPmWUJXUAjRaZoELtZq19XnjTRW5VKYy8qjjsDUZErOBcfz 15HDtBZhiek4zkA1DvjGpyes98wuo1PQeV3Kw4bOIcyAkpnPrj8gqNYxO7K1/FaglsDk o6eQ== X-Gm-Message-State: ABuFfojZfckuR8IXjADpf6YYl1IfBgSvK6X5Hw9tVDGZj9yevMEuq1Jx Nwim0uinow7UrF6H1JwJNiKVvXj8i7RU++2B5ODBqmx1VzrhXRWED72gxkiSl/LBDqBt2AHTr4Q 7KeGZYTzc+lh2ftS/RQld4C8X3LC3bGfknCwHvtL5Kq6oTySPSZCSyzdtFw1pzX0= X-Received: by 2002:a62:7d8d:: with SMTP id y135-v6mr29919490pfc.245.1539091547884; Tue, 09 Oct 2018 06:25:47 -0700 (PDT) X-Google-Smtp-Source: ACcGV62nTV31BUsAJrzI5wW6XPeLiDE6L16mA8pasNgUxYXBU0zzA541etdAi4XIeTK6swpA/C03 X-Received: by 2002:a62:7d8d:: with SMTP id y135-v6mr29919436pfc.245.1539091547027; Tue, 09 Oct 2018 06:25:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091547; cv=none; d=google.com; s=arc-20160816; b=IlBn66zY/B7GDZQaY2oI7KOs+muqIFShDRfgLg6M065V32ts62qfwblzMEawajzX1c YSxXHChNPvNumcU87fsbhO0JzqpgPgy5gK495Eo/+uZExezhbZ7HsauF2hcfgvsVd4xx swvSyiqXbSdAgNjYhtgIqnWsieZILx0lFd6gS9VOET501cFm9bv0B/Wrz6JxwKaKZ6Ay YnmrqaVcdAIk7FmxcHcn9iAm3KQqVTXmgHPasqGweubYjE/EBUexoncnGmt9PS9qsI+G HYqKIFEYYvzBxTjwragyegeu+RaXSY0lrq1ao02y6gHkShuO0DQVGja8kI0Jqkc5wVIC tsQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=xcMUgmz8fxZAX73L1Qt9UC9lj3gcizfN8j5e3xZ/twA=; b=Jstn7F+zyeo4GV8kHrE7hhCqp/X0OHz5lRZyi8dm143qbVqwHlZniioOEK0MXGa2G2 AZ9inGVbj4JCi0xRYKB/L6znOSlajA9vIJiQgZSaoHUw7zpPvKW6FJxdroG6A7b+dzkq RHCq4IJjP4gO5V5cHvTrrY6X1jpHZGvEvql7/ifjt+WB0skISVOMxwmWnvZZ2gSFY08z xeY7+G/TyRrBWjwlZQ8sXmJ+J0WGca5esNqbIiqy8GJeUUVfXZG7haDyJnbXAuvurzv/ Nl+mPM2kYkPHDutKfW6KwxspJFGz7uRof5Mux1RVRGfUQ5xxJYZB23XxvtOGmrUi4BZx fkTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=WfqpTe9A; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id a16-v6si20159006pfi.34.2018.10.09.06.25.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:25:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=WfqpTe9A; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=xcMUgmz8fxZAX73L1Qt9UC9lj3gcizfN8j5e3xZ/twA=; b=WfqpTe9AfNPRK03J03E1TgWbUV lSW4aiCEpvTbqH0RGiKSSaQLPa5a70lIFkJ5FRqCvb5ASV5JGApWBXQrwPXof/ak6yitPRItVOvo/ 8x+/tAyMXomgDDj46R3T32xOxR25J1+BWqWaNCz0wP/NGVVnlhONtFX89Hik1I/eTHdIB6QdD7YEW V79m2iUZ0rWL6GW1EYDDvWtqGzF5C+eGTC3P8Ploojb95XoFGdxAH916+RQM3Po7OMw40PwEliqFP YAg7DfskVSGB3AMk03xzkprfh69gEB5OflazRrBDa2GXVoCfa1DeOB8QXCTvEeg/Blnk4OttNO63h +Lg7FPNA==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s0s-00019c-1E; Tue, 09 Oct 2018 13:25:26 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/33] powerpc/pseries: use the generic iommu bypass code Date: Tue, 9 Oct 2018 15:24:37 +0200 Message-Id: <20181009132500.17643-11-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Use the generic iommu bypass code instead of overriding set_dma_mask. Signed-off-by: Christoph Hellwig --- arch/powerpc/platforms/pseries/iommu.c | 100 +++++++------------------ 1 file changed, 27 insertions(+), 73 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index da5716de7f4c..8965d174c53b 100644 --- a/arch/powerpc/platforms/pseries/iommu.c +++ b/arch/powerpc/platforms/pseries/iommu.c @@ -973,7 +973,7 @@ static LIST_HEAD(failed_ddw_pdn_list); * pdn: the parent pe node with the ibm,dma_window property * Future: also check if we can remap the base window for our base page size * - * returns the dma offset for use by dma_set_mask + * returns the dma offset for use by the direct mapped DMA code. */ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn) { @@ -1193,87 +1193,40 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev) iommu_add_device(&dev->dev); } -static int dma_set_mask_pSeriesLP(struct device *dev, u64 dma_mask) +static bool iommu_bypass_supported_pSeriesLP(struct pci_dev *pdev, u64 dma_mask) { - bool ddw_enabled = false; - struct device_node *pdn, *dn; - struct pci_dev *pdev; + struct device_node *dn = pci_device_to_OF_node(pdev), *pdn; const __be32 *dma_window = NULL; u64 dma_offset; - if (!dev->dma_mask) - return -EIO; - - if (!dev_is_pci(dev)) - goto check_mask; - - pdev = to_pci_dev(dev); - /* only attempt to use a new window if 64-bit DMA is requested */ - if (!disable_ddw && dma_mask == DMA_BIT_MASK(64)) { - dn = pci_device_to_OF_node(pdev); - dev_dbg(dev, "node is %pOF\n", dn); + if (dma_mask < DMA_BIT_MASK(64)) + return false; - /* - * the device tree might contain the dma-window properties - * per-device and not necessarily for the bus. So we need to - * search upwards in the tree until we either hit a dma-window - * property, OR find a parent with a table already allocated. - */ - for (pdn = dn; pdn && PCI_DN(pdn) && !PCI_DN(pdn)->table_group; - pdn = pdn->parent) { - dma_window = of_get_property(pdn, "ibm,dma-window", NULL); - if (dma_window) - break; - } - if (pdn && PCI_DN(pdn)) { - dma_offset = enable_ddw(pdev, pdn); - if (dma_offset != 0) { - dev_info(dev, "Using 64-bit direct DMA at offset %llx\n", dma_offset); - set_dma_offset(dev, dma_offset); - set_dma_ops(dev, &dma_nommu_ops); - ddw_enabled = true; - } - } - } + dev_dbg(&pdev->dev, "node is %pOF\n", dn); - /* fall back on iommu ops */ - if (!ddw_enabled && get_dma_ops(dev) != &dma_iommu_ops) { - dev_info(dev, "Restoring 32-bit DMA via iommu\n"); - set_dma_ops(dev, &dma_iommu_ops); + /* + * the device tree might contain the dma-window properties + * per-device and not necessarily for the bus. So we need to + * search upwards in the tree until we either hit a dma-window + * property, OR find a parent with a table already allocated. + */ + for (pdn = dn; pdn && PCI_DN(pdn) && !PCI_DN(pdn)->table_group; + pdn = pdn->parent) { + dma_window = of_get_property(pdn, "ibm,dma-window", NULL); + if (dma_window) + break; } -check_mask: - if (!dma_supported(dev, dma_mask)) - return -EIO; - - *dev->dma_mask = dma_mask; - return 0; -} - -static u64 dma_get_required_mask_pSeriesLP(struct device *dev) -{ - if (!dev->dma_mask) - return 0; - - if (!disable_ddw && dev_is_pci(dev)) { - struct pci_dev *pdev = to_pci_dev(dev); - struct device_node *dn; - - dn = pci_device_to_OF_node(pdev); - - /* search upwards for ibm,dma-window */ - for (; dn && PCI_DN(dn) && !PCI_DN(dn)->table_group; - dn = dn->parent) - if (of_get_property(dn, "ibm,dma-window", NULL)) - break; - /* if there is a ibm,ddw-applicable property require 64 bits */ - if (dn && PCI_DN(dn) && - of_get_property(dn, "ibm,ddw-applicable", NULL)) - return DMA_BIT_MASK(64); + if (pdn && PCI_DN(pdn)) { + dma_offset = enable_ddw(pdev, pdn); + if (dma_offset != 0) { + set_dma_offset(&pdev->dev, dma_offset); + return true; + } } - return dma_iommu_get_required_mask(dev); + return false; } static int iommu_mem_notifier(struct notifier_block *nb, unsigned long action, @@ -1368,8 +1321,9 @@ void iommu_init_early_pSeries(void) if (firmware_has_feature(FW_FEATURE_LPAR)) { pseries_pci_controller_ops.dma_bus_setup = pci_dma_bus_setup_pSeriesLP; pseries_pci_controller_ops.dma_dev_setup = pci_dma_dev_setup_pSeriesLP; - ppc_md.dma_set_mask = dma_set_mask_pSeriesLP; - ppc_md.dma_get_required_mask = dma_get_required_mask_pSeriesLP; + if (!disable_ddw) + pseries_pci_controller_ops.iommu_bypass_supported = + iommu_bypass_supported_pSeriesLP; } else { pseries_pci_controller_ops.dma_bus_setup = pci_dma_bus_setup_pSeries; pseries_pci_controller_ops.dma_dev_setup = pci_dma_dev_setup_pSeries; From patchwork Tue Oct 9 13:24:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E927313AA for ; Tue, 9 Oct 2018 13:26:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC1A4286A1 for ; Tue, 9 Oct 2018 13:26:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0588289C4; Tue, 9 Oct 2018 13:26:01 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61A40286A1 for ; Tue, 9 Oct 2018 13:26:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D3F76B0274; Tue, 9 Oct 2018 09:25:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 831BB6B0275; Tue, 9 Oct 2018 09:25:50 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FCF96B0276; Tue, 9 Oct 2018 09:25:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 203006B0275 for ; Tue, 9 Oct 2018 09:25:50 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id b27-v6so1081804pfm.15 for ; Tue, 09 Oct 2018 06:25:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=pgdEXC/sHHUjWFtFn1VF7InKvXmUXueeyx2znGokKV8=; b=ZvYcEJLTH3j8HWQo7CHrKuw6HHD8UsaoztP+g5hMdNog9GkRZJMBAIqFV0d2M1gdbo ObM+Kut+8utTUDfwJfZfojUHjnsJdqGiRqcuwG/j8RZn8RpjRh7N6msGytHipL4jVBWZ Zy9EHQWw+Xg+z0ens+bXMA+isbknMShP6Rw/7I56ARgxyQmFWIFVMnVs3LUUGKOTjiEO Ych0d0ZHt/vhugDnaX/Lu30pjgb96yrpljJ1hgLAiSBLKRj9xzLCIrN1oxMKX/EQhmTx AlrT/cVt/fEPOvaNNEzpg/uHOkg0ErsS2+UTD++A3bpT3Pj1sxQrRfkia+ftnisoMej5 qLIA== X-Gm-Message-State: ABuFfohiG2A6nplFVVt+MbuTetfhlktoWn5egQzHtsQyl0omexe8GjAH 7obKW5qt13UN8ZnyRSMlJJlRJL3u4epvWnhDFHq7hx44QA4dObsMmN61cYRbfHik437BqHK2Jah QZOMLhYwVPNTro4S+Pd2cz94qvvihGhUox6v26Lkm3Kv7U2jLmjdZXQsS6CMfB0E= X-Received: by 2002:a17:902:30a3:: with SMTP id v32-v6mr28224000plb.277.1539091549803; Tue, 09 Oct 2018 06:25:49 -0700 (PDT) X-Google-Smtp-Source: ACcGV61QKFwOt6dkS8eHA5yAV+dS/XMlZY60F0iICNxOn5P6dTf84TArtvjUYuvEPtS/fn2kXx7G X-Received: by 2002:a17:902:30a3:: with SMTP id v32-v6mr28223970plb.277.1539091549151; Tue, 09 Oct 2018 06:25:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091549; cv=none; d=google.com; s=arc-20160816; b=QDmXbOjzAs0NifwR6DvWs7XCKYkSx5aOwzFQw3TU3HQDCrABSdLYWv0THLeBeIq0WZ uJIssS+SNCQ6Io3l8yGEK259iTjBQ+iDZVkd9JBOYobqtIrx6SOjskkumFKX+YA3ffoc iKC1DJDcqlKie2nTOL+EKc97p2QbhVyDLH/cWXXOlUQu9rVXUoElpNgIT3QjqSsd4qen y/5LlJQ4VqL9HFwDsTUzdem3FsiZLSKUoWQcfBrHeB0c3woBlo5xJHapeteTsKEa8n+P duZJZJqDlaqrGIgKF45M0er49mrwZmLjE1n/H8cwxCxdXhs4zmNo0TgQJvMvUv7xwH1i nZ+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=pgdEXC/sHHUjWFtFn1VF7InKvXmUXueeyx2znGokKV8=; b=XQ0hOYc04raW+lDKhiDnE8AmtWv7ViI4MfPbtTTdy8Kh1JciiIK+ARlouAdWKopZDB mFIWqFqbLHupIlPTDuLTqeN3kULhvCjfBZjb4OhPlCBapY3xeCaLJ+pvRY+zeXaK5LJR +RzlVtLwawkPGCgb0wd/Oj2HkgbUA7uYGbITNjQGWZ29Go7X5jfJ5DTbBlM0tKw6CJBT MJo1i+DBJHw8YVlXvzERr5FD4xOmN+F3UZYh+7PTuVBQ1y5pPuN8TKvEv50uDeGViulc KX7Q+eT4hN/a/zkA5XDwOhTRcK1tVOQjRN0ztexBbxFWuLmWgqlqS3wmanO8RCEWbh9N trsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Io5Mbc2M; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id o32-v6si7655942pld.284.2018.10.09.06.25.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:25:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Io5Mbc2M; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=pgdEXC/sHHUjWFtFn1VF7InKvXmUXueeyx2znGokKV8=; b=Io5Mbc2M9Xbt6IT198HDwBTfJs upqerTOm4EpX0USVYJgiDSzsVzlreExWfkJ+Ygi7qfp6CS4pMsqwelPzA4pzOvHLnJDod1pkNSwvV UGB8MBaqeDOkVhwqrsZXrQ0l889Sgl4l8oqtwJI5JWklfxA5TUECat72Emj/oJE++KPJSrJFplFlU r0Q7FQ74IvEqbMcR5xYD8YymdUNnqu9aKx0FzrkIzCnot1Wt1G2+oFiMRqR32zkiIKK+iFQ2ug3m2 cE61hN5wQmsF9NoWJGr9WrNkqYDYKAuv0/eIbXKYwM4mF9Ln5/fHdYYB6ycVbxU2Rt9++tnTozvoe +lgilGiQ==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s0u-00019t-Br; Tue, 09 Oct 2018 13:25:28 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/33] powerpc/cell: move dma direct window setup out of dma_configure Date: Tue, 9 Oct 2018 15:24:38 +0200 Message-Id: <20181009132500.17643-12-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Configure the dma settings at device setup time, and stop playing games with get_pci_dma_ops. This prepares for using the common dma_configure code later on. Signed-off-by: Christoph Hellwig --- arch/powerpc/platforms/cell/iommu.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c index 12352a58072a..cce5bf9515e5 100644 --- a/arch/powerpc/platforms/cell/iommu.c +++ b/arch/powerpc/platforms/cell/iommu.c @@ -657,14 +657,21 @@ static const struct dma_map_ops dma_iommu_fixed_ops = { .mapping_error = dma_iommu_mapping_error, }; +static u64 cell_iommu_get_fixed_address(struct device *dev); + static void cell_dma_dev_setup(struct device *dev) { - if (get_pci_dma_ops() == &dma_iommu_ops) + if (get_pci_dma_ops() == &dma_iommu_ops) { + u64 addr = cell_iommu_get_fixed_address(dev); + + if (addr != OF_BAD_ADDR) + set_dma_offset(dev, addr + dma_iommu_fixed_base); set_iommu_table_base(dev, cell_get_iommu_table(dev)); - else if (get_pci_dma_ops() == &dma_nommu_ops) + } else if (get_pci_dma_ops() == &dma_nommu_ops) { set_dma_offset(dev, cell_dma_nommu_offset); - else + } else { BUG(); + } } static void cell_pci_dma_dev_setup(struct pci_dev *dev) @@ -950,19 +957,14 @@ static int dma_suported_and_switch(struct device *dev, u64 dma_mask) { if (dma_mask == DMA_BIT_MASK(64) && cell_iommu_get_fixed_address(dev) != OF_BAD_ADDR) { - u64 addr = cell_iommu_get_fixed_address(dev) + - dma_iommu_fixed_base; dev_dbg(dev, "iommu: 64-bit OK, using fixed ops\n"); - dev_dbg(dev, "iommu: fixed addr = %llx\n", addr); set_dma_ops(dev, &dma_iommu_fixed_ops); - set_dma_offset(dev, addr); return 1; } if (dma_iommu_dma_supported(dev, dma_mask)) { dev_dbg(dev, "iommu: not 64-bit, using default ops\n"); - set_dma_ops(dev, get_pci_dma_ops()); - cell_dma_dev_setup(dev); + set_dma_ops(dev, &dma_iommu_ops); return 1; } From patchwork Tue Oct 9 13:24:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632533 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6AB7113AA for ; Tue, 9 Oct 2018 13:26:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B50A286A1 for ; Tue, 9 Oct 2018 13:26:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F42A289C4; Tue, 9 Oct 2018 13:26:07 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B9E6286A1 for ; Tue, 9 Oct 2018 13:26:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4FF076B0276; Tue, 9 Oct 2018 09:25:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 48A0D6B0277; Tue, 9 Oct 2018 09:25:55 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B9BF6B0278; Tue, 9 Oct 2018 09:25:55 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id D38F66B0276 for ; Tue, 9 Oct 2018 09:25:54 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id c5-v6so992926plo.2 for ; Tue, 09 Oct 2018 06:25:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=8XXesnZgyqra9gNm5NWYp3vrx3JH2lusaZA3YDbzupg=; b=c+T3TyMJYNSUZmzR/P3UiElCx9UJlQH18Zbq7ANzGiyHVz676+trW9qc/e8MGYVGKJ yK9AOlGv66DGZGWNo6vauROh15WadFdHtR1NqbD5eCGKh5if1e0LtIn5zGQU/kjDvAEu 6dgZNP25tv4QMapTrY6t5bqvhWvqueWF4vHu6trIQCF214QjQKh5m3DSPM/8vbN/Ep49 DX/SCr6b2D7x58Mdn+Qt5tuYXBOQ0hKCE2TRFNC1UuuxwJZnsggnpelR+D7OTebN4lCQ kj0rpsyy4AHvEdM3wCsH7ehCsqGAKyfbM8KZjK6649kpkBhCHHz4BG1R+B8pc6Giuo4P Xofg== X-Gm-Message-State: ABuFfoiSXDS3gloSloDpCqGHyeGS/UgGLv/m8cZXxLLjV99NqnGd7i7+ ITDbHiH3cY4LtQGW61yRCeu88zOK++w5VD2uywiHIncG6a3qvHw93df+JtZkZkwNCUUlPF3M1r4 Cta4ofaKe40swCowdPZAVgiGn4owFIW9XB7FLiN1DIiRDaOVTSaLKFh2u9AdtGdM= X-Received: by 2002:a17:902:7482:: with SMTP id h2-v6mr29378051pll.228.1539091554517; Tue, 09 Oct 2018 06:25:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV62YAgAh0Ed3nPrDgwA2Pc42gPDRy6+vO8CqdIveZSiOSSvmHxA/6tyyS4AKlvYvrhLMX3cy X-Received: by 2002:a17:902:7482:: with SMTP id h2-v6mr29377992pll.228.1539091553555; Tue, 09 Oct 2018 06:25:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091553; cv=none; d=google.com; s=arc-20160816; b=IpWYFeaHo6np/P+++f4rtVNpprKGw+PT5K+PBu6qrCNEe4aFuVwQxRCKgbmKsn8+aB kS2+By1k+AezzglFN+bft9AwKQ56tCSb3kxFgKgXiJafibEzAL6MzFnFw/FLicBGKlKw jAI0Inalwz6+0GW0SuXnB9JUTpSjl1k8YRHISiaucu/Lu6ymedKMYQqYB75iOsAFm5zD uu7oD98SPcraubRoO2xEqZ0phajZdyn6pcHSAriIGIjHlL9gJZi+cjl1hHH0YQhDCMRZ wtMEjTkA7nEkoqMO86y7aWwvNYEg0/vP52DHfQcxXKbOX8/Seq8IWB4rD4Cj6VgrU3hg Sm4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=8XXesnZgyqra9gNm5NWYp3vrx3JH2lusaZA3YDbzupg=; b=GC9RXyR6FRCvxc+TfLzmk/rKSKHorj5ItWYNai7UmSjHeInCwxjNLd2bMY1+0hSf09 R2WwtzGRqur+p1D2zwSQfirTP7AV/6of9F3I1MvJAzy7NMFle9530YJYczwwKSiaOS1D UZj2Wd1JuzmCoqvulE3PKR24AUYqO0nzWas9T0mBlFpaejgg99Yf34bl0N5Whsa52fFM kSNFhXZKiunej0CDYpAp/qpLgurFvyJBRn1M9pOgzr7lywQHWqSD6od/kFXlmLhnaLTk aCACvBu9zB2O9qcuQKJXJzVknx4golgc1rMAhOn40+RUNPUEO1zlYa3+vH//Phz/3sfr KcPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=qTOoNAR1; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id cc10-v6si25068060plb.97.2018.10.09.06.25.53 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:25:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=qTOoNAR1; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=8XXesnZgyqra9gNm5NWYp3vrx3JH2lusaZA3YDbzupg=; b=qTOoNAR18soyj1I+UmCdgEYnAo PcmXv00IVqlqFY2nzgm7VxvEW8nxkGexVaBpuGYofVYNk8VtILjIG+bmr9Y0Uk7uOjZ/KzYHi+dly BV8f97JT8WWHpTy4szWFK/7CLAJL/Vtl8fssej204XokIyDmNfHFXuUURTW0jdN27xNw9qvdP4fnK U814v+O3c+T6UfqtD9IeczbJ+PlMwpTg1yLIaBtAievxjPwuJIddOTBXXwSWuoxhLDbQrh7EZVo+u YSWxPHNGRpab8S0yUontLNtHWLxeACEq5y+OTAwag3bGzkFufH8Yrv1Y/qRMVet2l9q6sEFRyyRpi T40XhVsg==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s0w-0001AF-N9; Tue, 09 Oct 2018 13:25:31 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/33] powerpc/cell: use the generic iommu bypass code Date: Tue, 9 Oct 2018 15:24:39 +0200 Message-Id: <20181009132500.17643-13-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This gets rid of a lot of clumsy code and finally allows us to mark dma_iommu_ops const. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/dma-mapping.h | 2 +- arch/powerpc/include/asm/iommu.h | 6 ++ arch/powerpc/kernel/dma-iommu.c | 7 +- arch/powerpc/platforms/cell/iommu.c | 143 ++----------------------- 4 files changed, 22 insertions(+), 136 deletions(-) diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index 27283eb68c50..59c090b7eaac 100644 --- a/arch/powerpc/include/asm/dma-mapping.h +++ b/arch/powerpc/include/asm/dma-mapping.h @@ -73,7 +73,7 @@ static inline unsigned long device_to_mask(struct device *dev) * Available generic sets of operations */ #ifdef CONFIG_PPC64 -extern struct dma_map_ops dma_iommu_ops; +extern const struct dma_map_ops dma_iommu_ops; #endif extern const struct dma_map_ops dma_nommu_ops; diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h index 26b7cc176a99..264d04f1dcd1 100644 --- a/arch/powerpc/include/asm/iommu.h +++ b/arch/powerpc/include/asm/iommu.h @@ -328,5 +328,11 @@ extern void iommu_release_ownership(struct iommu_table *tbl); extern enum dma_data_direction iommu_tce_direction(unsigned long tce); extern unsigned long iommu_direction_to_tce_perm(enum dma_data_direction dir); +#ifdef CONFIG_PPC_CELL_NATIVE +extern bool iommu_fixed_is_weak; +#else +#define iommu_fixed_is_weak false +#endif + #endif /* __KERNEL__ */ #endif /* _ASM_IOMMU_H */ diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c index c865e15ad024..7fa3636636fa 100644 --- a/arch/powerpc/kernel/dma-iommu.c +++ b/arch/powerpc/kernel/dma-iommu.c @@ -20,14 +20,15 @@ */ static inline bool dma_iommu_alloc_bypass(struct device *dev) { - return dev->archdata.iommu_bypass && + return dev->archdata.iommu_bypass && !iommu_fixed_is_weak && dma_nommu_dma_supported(dev, dev->coherent_dma_mask); } static inline bool dma_iommu_map_bypass(struct device *dev, unsigned long attrs) { - return dev->archdata.iommu_bypass; + return dev->archdata.iommu_bypass && + (!iommu_fixed_is_weak || (attrs & DMA_ATTR_WEAK_ORDERING)); } /* Allocates a contiguous real buffer and creates mappings over it. @@ -168,7 +169,7 @@ int dma_iommu_mapping_error(struct device *dev, dma_addr_t dma_addr) return dma_addr == IOMMU_MAPPING_ERROR; } -struct dma_map_ops dma_iommu_ops = { +const struct dma_map_ops dma_iommu_ops = { .alloc = dma_iommu_alloc_coherent, .free = dma_iommu_free_coherent, .mmap = dma_nommu_mmap_coherent, diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c index cce5bf9515e5..fb51f78035ce 100644 --- a/arch/powerpc/platforms/cell/iommu.c +++ b/arch/powerpc/platforms/cell/iommu.c @@ -546,7 +546,7 @@ static unsigned long cell_dma_nommu_offset; static unsigned long dma_iommu_fixed_base; /* iommu_fixed_is_weak is set if booted with iommu_fixed=weak */ -static int iommu_fixed_is_weak; +bool iommu_fixed_is_weak; static struct iommu_table *cell_get_iommu_table(struct device *dev) { @@ -568,95 +568,6 @@ static struct iommu_table *cell_get_iommu_table(struct device *dev) return &window->table; } -/* A coherent allocation implies strong ordering */ - -static void *dma_fixed_alloc_coherent(struct device *dev, size_t size, - dma_addr_t *dma_handle, gfp_t flag, - unsigned long attrs) -{ - if (iommu_fixed_is_weak) - return iommu_alloc_coherent(dev, cell_get_iommu_table(dev), - size, dma_handle, - device_to_mask(dev), flag, - dev_to_node(dev)); - else - return dma_nommu_ops.alloc(dev, size, dma_handle, flag, - attrs); -} - -static void dma_fixed_free_coherent(struct device *dev, size_t size, - void *vaddr, dma_addr_t dma_handle, - unsigned long attrs) -{ - if (iommu_fixed_is_weak) - iommu_free_coherent(cell_get_iommu_table(dev), size, vaddr, - dma_handle); - else - dma_nommu_ops.free(dev, size, vaddr, dma_handle, attrs); -} - -static dma_addr_t dma_fixed_map_page(struct device *dev, struct page *page, - unsigned long offset, size_t size, - enum dma_data_direction direction, - unsigned long attrs) -{ - if (iommu_fixed_is_weak == (attrs & DMA_ATTR_WEAK_ORDERING)) - return dma_nommu_ops.map_page(dev, page, offset, size, - direction, attrs); - else - return iommu_map_page(dev, cell_get_iommu_table(dev), page, - offset, size, device_to_mask(dev), - direction, attrs); -} - -static void dma_fixed_unmap_page(struct device *dev, dma_addr_t dma_addr, - size_t size, enum dma_data_direction direction, - unsigned long attrs) -{ - if (iommu_fixed_is_weak == (attrs & DMA_ATTR_WEAK_ORDERING)) - dma_nommu_ops.unmap_page(dev, dma_addr, size, direction, - attrs); - else - iommu_unmap_page(cell_get_iommu_table(dev), dma_addr, size, - direction, attrs); -} - -static int dma_fixed_map_sg(struct device *dev, struct scatterlist *sg, - int nents, enum dma_data_direction direction, - unsigned long attrs) -{ - if (iommu_fixed_is_weak == (attrs & DMA_ATTR_WEAK_ORDERING)) - return dma_nommu_ops.map_sg(dev, sg, nents, direction, attrs); - else - return ppc_iommu_map_sg(dev, cell_get_iommu_table(dev), sg, - nents, device_to_mask(dev), - direction, attrs); -} - -static void dma_fixed_unmap_sg(struct device *dev, struct scatterlist *sg, - int nents, enum dma_data_direction direction, - unsigned long attrs) -{ - if (iommu_fixed_is_weak == (attrs & DMA_ATTR_WEAK_ORDERING)) - dma_nommu_ops.unmap_sg(dev, sg, nents, direction, attrs); - else - ppc_iommu_unmap_sg(cell_get_iommu_table(dev), sg, nents, - direction, attrs); -} - -static int dma_suported_and_switch(struct device *dev, u64 dma_mask); - -static const struct dma_map_ops dma_iommu_fixed_ops = { - .alloc = dma_fixed_alloc_coherent, - .free = dma_fixed_free_coherent, - .map_sg = dma_fixed_map_sg, - .unmap_sg = dma_fixed_unmap_sg, - .dma_supported = dma_suported_and_switch, - .map_page = dma_fixed_map_page, - .unmap_page = dma_fixed_unmap_page, - .mapping_error = dma_iommu_mapping_error, -}; - static u64 cell_iommu_get_fixed_address(struct device *dev); static void cell_dma_dev_setup(struct device *dev) @@ -953,22 +864,10 @@ static u64 cell_iommu_get_fixed_address(struct device *dev) return dev_addr; } -static int dma_suported_and_switch(struct device *dev, u64 dma_mask) +static bool cell_pci_iommu_bypass_supported(struct pci_dev *pdev, u64 mask) { - if (dma_mask == DMA_BIT_MASK(64) && - cell_iommu_get_fixed_address(dev) != OF_BAD_ADDR) { - dev_dbg(dev, "iommu: 64-bit OK, using fixed ops\n"); - set_dma_ops(dev, &dma_iommu_fixed_ops); - return 1; - } - - if (dma_iommu_dma_supported(dev, dma_mask)) { - dev_dbg(dev, "iommu: not 64-bit, using default ops\n"); - set_dma_ops(dev, &dma_iommu_ops); - return 1; - } - - return 0; + return mask == DMA_BIT_MASK(64) && + cell_iommu_get_fixed_address(&pdev->dev) != OF_BAD_ADDR; } static void insert_16M_pte(unsigned long addr, unsigned long *ptab, @@ -1122,9 +1021,6 @@ static int __init cell_iommu_fixed_mapping_init(void) cell_iommu_setup_window(iommu, np, dbase, dsize, 0); } - dma_iommu_ops.dma_supported = dma_suported_and_switch; - set_pci_dma_ops(&dma_iommu_ops); - return 0; } @@ -1145,7 +1041,7 @@ static int __init setup_iommu_fixed(char *str) pciep = of_find_node_by_type(NULL, "pcie-endpoint"); if (strcmp(str, "weak") == 0 || (pciep && strcmp(str, "strong") != 0)) - iommu_fixed_is_weak = DMA_ATTR_WEAK_ORDERING; + iommu_fixed_is_weak = true; of_node_put(pciep); @@ -1153,26 +1049,6 @@ static int __init setup_iommu_fixed(char *str) } __setup("iommu_fixed=", setup_iommu_fixed); -static u64 cell_dma_get_required_mask(struct device *dev) -{ - const struct dma_map_ops *dma_ops; - - if (!dev->dma_mask) - return 0; - - if (!iommu_fixed_disabled && - cell_iommu_get_fixed_address(dev) != OF_BAD_ADDR) - return DMA_BIT_MASK(64); - - dma_ops = get_dma_ops(dev); - if (dma_ops->get_required_mask) - return dma_ops->get_required_mask(dev); - - WARN_ONCE(1, "no get_required_mask in %p ops", dma_ops); - - return DMA_BIT_MASK(64); -} - static int __init cell_iommu_init(void) { struct device_node *np; @@ -1189,10 +1065,9 @@ static int __init cell_iommu_init(void) /* Setup various callbacks */ cell_pci_controller_ops.dma_dev_setup = cell_pci_dma_dev_setup; - ppc_md.dma_get_required_mask = cell_dma_get_required_mask; if (!iommu_fixed_disabled && cell_iommu_fixed_mapping_init() == 0) - goto bail; + goto done; /* Create an iommu for each /axon node. */ for_each_node_by_name(np, "axon") { @@ -1209,8 +1084,12 @@ static int __init cell_iommu_init(void) continue; cell_iommu_init_one(np, SPIDER_DMA_OFFSET); } - + done: /* Setup default PCI iommu ops */ + if (!iommu_fixed_disabled) { + cell_pci_controller_ops.iommu_bypass_supported = + cell_pci_iommu_bypass_supported; + } set_pci_dma_ops(&dma_iommu_ops); bail: From patchwork Tue Oct 9 13:24:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632541 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A1A2113AA for ; Tue, 9 Oct 2018 13:26:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94B0F286A1 for ; Tue, 9 Oct 2018 13:26:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 890A0289C4; Tue, 9 Oct 2018 13:26:25 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BAC3286A1 for ; Tue, 9 Oct 2018 13:26:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26C686B027E; Tue, 9 Oct 2018 09:26:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1F4546B0280; Tue, 9 Oct 2018 09:26:12 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01BE16B0281; Tue, 9 Oct 2018 09:26:11 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id AE5636B027E for ; Tue, 9 Oct 2018 09:26:11 -0400 (EDT) Received: by mail-pl1-f200.google.com with SMTP id f17-v6so993483plr.1 for ; Tue, 09 Oct 2018 06:26:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=FPvgBLtWHsWCoL0Sua1w8BYNtdVAHDwhlJY2AxROsgo=; b=Hpn0IBZl+L87BP5/+Mp0UAPe1wDrf1SrVte+E3m79uHE0OnedEbteMxG3OyP8lEBe4 9t/fbHCP2umItsEMoYTR/3dQbZO9p6RH1mePEH9CD3I43BSxA0+Apmz85jUlU0UsIAlA 2xdKNf2WA3lujkBG3U6cFcC30MTfT80UBpGD6f4J48QlM+IGnQIFj8dATSINd/Yd+NvO /Axp75AVOZ5IUHHzEGR9DU/xQohgfNHAsQ5NC+hAv5TFkzxfDYXVjnVCwiqCjNOoOWMx Bw2LIqp7pnq+xlKHdvMvkHfjfxrjriDGkxs4BYn8kGGPD6hCun2f8GHrmbGRcsq46bxB vlFw== X-Gm-Message-State: ABuFfohnKisjbW7oJq4f2YhrniHbxgdPgDJzXl5aqKyC0I9M+FX2XF/T Sy997TsJXgBlxUVxthou14FSi5hP2awLpH4g1oG4sEUhnJti1MYpTOadggA3L0h8CJLdIy6lseB ymF7dYKjjZD6clUXyWGiwvng5i6Vy/qi7xYH7z4m+gyKuoR1q8zQlQpSHm0/JN04= X-Received: by 2002:a65:4103:: with SMTP id w3-v6mr26043969pgp.284.1539091571396; Tue, 09 Oct 2018 06:26:11 -0700 (PDT) X-Google-Smtp-Source: ACcGV60aALdaHC9+6OwmPMtRzOZkp3gWa42yrA1QjQErx0qg2bU/DfpuWolP+Qk6N/ABi6Ygv/bV X-Received: by 2002:a65:4103:: with SMTP id w3-v6mr26043932pgp.284.1539091570786; Tue, 09 Oct 2018 06:26:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091570; cv=none; d=google.com; s=arc-20160816; b=DGd0Hh6ePkDciQkDvcb5GrUFUu79sjcSdhwlqPqFPLM3bDQ9IzEAV4D6LWOwQYB5Fh hoW1HPgaR6iC1kC1Zdig8Pt0ub0VgeSQZ+jZk4mbbCZiX/TozVRa1zq6UyeDerY5TeJN a9u3RyJ0Cuxc4aa3gWbP5eJxsDwlp25/aLJSyg/DPddTduG5g7+jRUph1EvZDNzdxkZt RJoubKWYFbnatEgN6peLF8LNkqcebhC3E2fnu7vIiZc4elT69gxX2/VWmKifmTrxwIXf 08TspKC/HeIL1hJm0WO8sZRfwZtm+2mRbuvB6Gr1otzHGq6FnlN4AM47JyZEJAJgeM6u 7FIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=FPvgBLtWHsWCoL0Sua1w8BYNtdVAHDwhlJY2AxROsgo=; b=hhAdP060AbsWJazzsHSPViS/ZdhHYtsZj9RswOhOgnQFfA1kVannK87X+x+jSZqJyc vb3icp8GJ2jKlimUCBdjxyulXsi9ZdKZuHY5wFjLVdi1rGBaY7VlEKlMvJsPCNGSFRC2 wn6T8KCTQINmXyh0lEXgnyI/ayLgmS4AR+O9L8xGzMMI/Nn2ydBeRqqZuPP/7MS0Dpra 6olzq95XPpG7mT72C7F54nykCCqOLmt5xctl2qmLu1qzk4/GCcT78Y4vozWz7m1Fnefs gdUT9m4wpm6QTW1YQ3qHf2o82aMRxQIe55RWN0IYZcTMhGLwQP941GvR3mzyAHo0BPea ibaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=L2TSSbb+; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id 12-v6si17418829pgd.191.2018.10.09.06.26.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=L2TSSbb+; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=FPvgBLtWHsWCoL0Sua1w8BYNtdVAHDwhlJY2AxROsgo=; b=L2TSSbb+lOD59zteiXYTwFQ7Ma Dw0zO+HHGGmLlMqchBHV+WbkXMLMJO/7Uy00wg+DENtwWf5uVx1VA2umOZNklgKsr997KxO4HmbAp vJS01fFgWXBkFFJWtjQuxMCPpTYV3kHMi71E5ZzLXUa4ewHl7g1nk3LTV4s0cdrzzgozaunGWeJr3 TzEqp9+1gsNa5OLDunqPjsZCc6j0iAqKJn7BAtLUSX0wXX+0FQs/ALqt+q/pJaGpwRqWRjEmbyVkm y4p2LOdeUzMtLQJDiqlj+jTgGRWfvttHeBMeN1Tff4eX1rpU4tmstM20qKALPd9WrbnL+4Fkv+XmK E4rYwf/A==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s0z-0001B1-3S; Tue, 09 Oct 2018 13:25:33 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/33] powerpc/dart: remove dead cleanup code in iommu_init_early_dart Date: Tue, 9 Oct 2018 15:24:40 +0200 Message-Id: <20181009132500.17643-14-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP If dart_init failed we didn't have a chance to setup dma or controller ops yet, so there is no point in resetting them. Signed-off-by: Christoph Hellwig --- arch/powerpc/sysdev/dart_iommu.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c index 5ca3e22d0512..ce5dd2048f57 100644 --- a/arch/powerpc/sysdev/dart_iommu.c +++ b/arch/powerpc/sysdev/dart_iommu.c @@ -428,7 +428,7 @@ void __init iommu_init_early_dart(struct pci_controller_ops *controller_ops) /* Initialize the DART HW */ if (dart_init(dn) != 0) - goto bail; + return; /* Setup bypass if supported */ if (dart_is_u4) @@ -439,15 +439,6 @@ void __init iommu_init_early_dart(struct pci_controller_ops *controller_ops) /* Setup pci_dma ops */ set_pci_dma_ops(&dma_iommu_ops); - return; - - bail: - /* If init failed, use direct iommu and null setup functions */ - controller_ops->dma_dev_setup = NULL; - controller_ops->dma_bus_setup = NULL; - - /* Setup pci_dma ops */ - set_pci_dma_ops(&dma_nommu_ops); } #ifdef CONFIG_PM From patchwork Tue Oct 9 13:24:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632545 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B53BB13AA for ; Tue, 9 Oct 2018 13:26:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8F18286A1 for ; Tue, 9 Oct 2018 13:26:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CA89289C4; Tue, 9 Oct 2018 13:26:34 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A1C5286A1 for ; Tue, 9 Oct 2018 13:26:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EE7F16B0280; Tue, 9 Oct 2018 09:26:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DD8856B027F; Tue, 9 Oct 2018 09:26:12 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE1376B0283; Tue, 9 Oct 2018 09:26:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 607776B027F for ; Tue, 9 Oct 2018 09:26:12 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id y86-v6so1096738pff.6 for ; Tue, 09 Oct 2018 06:26:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=hhwdg0p6cD+tBZ2LvXC+nRssqLc7D1MCrzZuVKtcd0k=; b=rp/8cvC47yHUcZ3svOop19KvdTGyY+1ax3tMdUjgaHTNP0ErNRWBh7oJTggM/k9P34 /CC1bKTJf74+e6bL7+iQtDkoezpnCXfHGbwGD0W1mV9th1dxNmFwqajWOD+MwfVzXSu6 +lh2952kpOxQrOPWziEbXoO5TBHtka1RcIiAx8/Su5+AcgPnATYyNoTzWVzcMhHV3d7o zcHrMPWQjY1lDt/uR9mlpOoXlxqqyR69PWxMQRxsiP6rOo2UtW0CrsOy8Oq2km5UBGni ZOE1eWhu71p9dcOSJIeLHbbm9sUESKX7YJbwnqHEKR7Yy9HIa2cwCMS1z2IKtJCNpyYf 98Xw== X-Gm-Message-State: ABuFfohpfdo94E/+2c3NH3WTMHYV471mbA2iL6LTCMUQGlQRH7LyG82k Q+0TNLBcq4N6vvMlNWnlvWhz7apda/WRoVOe+Jn5wkLkjxARXcAuT0smf5k84IeqCPQf5mEG6Jp 7yaOW4yuJhXeKF+EJvVVOJUEuOqe1IYS/QfTWmBkyJ3bGZbrppWoTdu7xRy4MIM0= X-Received: by 2002:a62:13cb:: with SMTP id 72-v6mr29608212pft.34.1539091572077; Tue, 09 Oct 2018 06:26:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV60xQSLtVbtfyrFmY5KPJGrqMyxc8JcrXLy3raeDTflAk8juYLYQ409EfioUY1F7u8usFOzm X-Received: by 2002:a62:13cb:: with SMTP id 72-v6mr29608151pft.34.1539091571247; Tue, 09 Oct 2018 06:26:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091571; cv=none; d=google.com; s=arc-20160816; b=FaB8NneU8aI1a6+j+axxMT5/rtnJ7z43aUKMeXW4Nwz+xwbADEYuckaXpe4r7MZ9KD Awfsbu+hwNCtLxuQ0cpSYwIe6dpkNJUlMRxvlmRdqUbMffGF/biak1nhywMt54uHfS7N 716/Rjgb3nIir3cVOgajDHu2IJ0rzYLfwX/fJlEv3ifM2OEEBhP+ap4SL+Tt4fvVoGEb tJaG4F5PNpPSKI3fViwlW6SrbSV9BQgNPgdmmm2TCyPhsFma8KjOw+XAa2m9LJfFPOwC 3IipbQufgPFF/e+w+nK5OdZccw2BLs24sJcbFtLAZMYRLNCcF4WP17qij26xLQrSjkFH C6yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=hhwdg0p6cD+tBZ2LvXC+nRssqLc7D1MCrzZuVKtcd0k=; b=gDdm/FMPSGv0UFnIZryakacdBWtDA1b7wHGk2GMshA9HK+SgNx++w76WJB06NvWtGX Om9iz3QlXN28DmiQFd5VAIKDqxLQsw0NBirnfPA0vmHQxYFHjfU4IzDtY5nODH0LbQ3t VuyfKSIEqK61ZNyE9y93y1qxjoyZli3Ws9kchp9FO9RGJCnAuPJD0SOTbffCLlITFyDr YoC8ehZR70N5x8Mjmm/n9ab03GcdMCWWoQRAoXK+hkprJoNLK31U1z40YiF7Q2vt4Rvn zdQFGI3DpuyT91Pz/9xSSbj10kSdktu+keQo7kRhjlXUDxQRX74hEbVjYm/5NIj1hYsU fiDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=L7giyn18; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id g4-v6si20769714plo.254.2018.10.09.06.26.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=L7giyn18; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=hhwdg0p6cD+tBZ2LvXC+nRssqLc7D1MCrzZuVKtcd0k=; b=L7giyn18J6TxYDQfxVkMj3gVH0 Ew5szJrxKfbV8637Zyd7t+IvyFu01/sTfwQoJXXPYHsjeVSN7AJVLrm78NpBozF9m95TIAg3rAHTG DMehxdVSNaIpP/YiAYToVnZif0ptzHQZOZUgDrsqtlskp3Ce6JvS4mGseSB8jxoe72IfS3MdzGye0 9yiMTmZdkZIos2z1Ldn5zJMstPlRJuGdlPjfLagCcNYC0i6dezrYl0iLUyXImOVMYC+pJbuFZnEyV IF4SegwaByNeKspz2z1zC6fAejtlQzyFPWjOjCAdT4IJLfjj2Iqd+6h96fed9QAkiieHe+TcliUab jOZlftXg==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s11-0001Bk-GY; Tue, 09 Oct 2018 13:25:35 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 14/33] powerpc/dart: use the generic iommu bypass code Date: Tue, 9 Oct 2018 15:24:41 +0200 Message-Id: <20181009132500.17643-15-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Use the generic iommu bypass code instead of overriding set_dma_mask. Signed-off-by: Christoph Hellwig --- arch/powerpc/sysdev/dart_iommu.c | 45 +++++++++++--------------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c index ce5dd2048f57..e7d1645a2d2e 100644 --- a/arch/powerpc/sysdev/dart_iommu.c +++ b/arch/powerpc/sysdev/dart_iommu.c @@ -360,13 +360,6 @@ static void iommu_table_dart_setup(void) set_bit(iommu_table_dart.it_size - 1, iommu_table_dart.it_map); } -static void pci_dma_dev_setup_dart(struct pci_dev *dev) -{ - if (dart_is_u4) - set_dma_offset(&dev->dev, DART_U4_BYPASS_BASE); - set_iommu_table_base(&dev->dev, &iommu_table_dart); -} - static void pci_dma_bus_setup_dart(struct pci_bus *bus) { if (!iommu_table_dart_inited) { @@ -390,27 +383,16 @@ static bool dart_device_on_pcie(struct device *dev) return false; } -static int dart_dma_set_mask(struct device *dev, u64 dma_mask) +static void pci_dma_dev_setup_dart(struct pci_dev *dev) { - if (!dev->dma_mask || !dma_supported(dev, dma_mask)) - return -EIO; - - /* U4 supports a DART bypass, we use it for 64-bit capable - * devices to improve performances. However, that only works - * for devices connected to U4 own PCIe interface, not bridged - * through hypertransport. We need the device to support at - * least 40 bits of addresses. - */ - if (dart_device_on_pcie(dev) && dma_mask >= DMA_BIT_MASK(40)) { - dev_info(dev, "Using 64-bit DMA iommu bypass\n"); - set_dma_ops(dev, &dma_nommu_ops); - } else { - dev_info(dev, "Using 32-bit DMA via iommu\n"); - set_dma_ops(dev, &dma_iommu_ops); - } + if (dart_is_u4 && dart_device_on_pcie(&dev->dev)) + set_dma_offset(&dev->dev, DART_U4_BYPASS_BASE); + set_iommu_table_base(&dev->dev, &iommu_table_dart); +} - *dev->dma_mask = dma_mask; - return 0; +static bool iommu_bypass_supported_dart(struct pci_dev *dev, u64 mask) +{ + return dart_is_u4 && dart_device_on_pcie(&dev->dev); } void __init iommu_init_early_dart(struct pci_controller_ops *controller_ops) @@ -430,12 +412,15 @@ void __init iommu_init_early_dart(struct pci_controller_ops *controller_ops) if (dart_init(dn) != 0) return; - /* Setup bypass if supported */ - if (dart_is_u4) - ppc_md.dma_set_mask = dart_dma_set_mask; - + /* + * U4 supports a DART bypass, we use it for 64-bit capable devices to + * improve performance. However, that only works for devices connected + * to the U4 own PCIe interface, not bridged through hypertransport. + * We need the device to support at least 40 bits of addresses. + */ controller_ops->dma_dev_setup = pci_dma_dev_setup_dart; controller_ops->dma_bus_setup = pci_dma_bus_setup_dart; + controller_ops->iommu_bypass_supported = iommu_bypass_supported_dart; /* Setup pci_dma ops */ set_pci_dma_ops(&dma_iommu_ops); From patchwork Tue Oct 9 13:24:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632555 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9DDB1112B for ; Tue, 9 Oct 2018 13:26:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9239E289C4 for ; Tue, 9 Oct 2018 13:26:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84301289F5; Tue, 9 Oct 2018 13:26:54 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14FCF289C4 for ; Tue, 9 Oct 2018 13:26:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D20C36B0286; Tue, 9 Oct 2018 09:26:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C9E426B0289; Tue, 9 Oct 2018 09:26:15 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B9FD6B0288; Tue, 9 Oct 2018 09:26:15 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 515336B0285 for ; Tue, 9 Oct 2018 09:26:15 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id x2-v6so834258pgr.8 for ; Tue, 09 Oct 2018 06:26:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=+X8AkMvhaCh2A6t5uXBVRn35aMYZZ+/hh9Cwb5Qv+ts=; b=hOLFgjetwQshjgKSAvyThYhXj5r7jjb7eaFhPUj3CvYPnT6qitlqzRBxoQpajRQYCA 2yHsdcpez4tCEOKWikJhj3egVgZXu2z/1mrR0w7j6x7LSkwehsbjOf7G8lpoHPMMFrQO qUPOhBpB7s3NswqlhHGm4ExpbL6cXgSq40uey8CLDR6iGNQJlLe16fRgbuXjp0On0cOT tgU2ESuT7v/ogMBJeU2iQtUeuvk3Or+PfWxku4tfLmPMKoKFRBiAso0WmSnJYhAbvzuV iFrgd3FnefmNvTKwZPsuUB3xyJ1E95dGZMtGXHpkPVKgC/ivHI1Ez4RyycxEzNlxwmbG qYiw== X-Gm-Message-State: ABuFfoiLTK30mEUrKaTPWlIWblbjhZE5JByCqT2ywMfYaU0toNR0yR1Q zIKazvajLRE6raREdcKriE86lLqgFnDls9R2QOQyUcZKYgsvyWGt5OVIIPqa1qaECKdBHYatqUG 2s+slsL2BV1k94BSqV+lnEV+9sZAvbFHr4xGQMfvjoam+wKcyM2OGt1oH+arYwps= X-Received: by 2002:a63:4cb:: with SMTP id 194-v6mr25777113pge.183.1539091575019; Tue, 09 Oct 2018 06:26:15 -0700 (PDT) X-Google-Smtp-Source: ACcGV632VVW+z+6Vt0M7hMlMua6xgB//oJvolxJsgFId8E3BklII9XJ5xo5DiiSiWpAIg4pEmqiP X-Received: by 2002:a63:4cb:: with SMTP id 194-v6mr25777061pge.183.1539091574191; Tue, 09 Oct 2018 06:26:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091574; cv=none; d=google.com; s=arc-20160816; b=EQfz2R5E1GUJcmaq+nLktkDyQ4Bl9JS98STQqJG178b7ysod9LG7NcU5eZy9GWIw1/ uV5M40aUynEx2MO8bTlTkVXOi+0IlZ2UVFRivKwiKuJRvxeoRiGE+9oyj+dv1Y61gtXU HwYRcd0uAGmkXH9+8skXwzKcQi1bqYSGp/ay+5ttGzCsMYxJFprpvnCpQd/syxYO6w3O jV0/1OayDl7Lum4U7KzM27niMWxYP9s1Cnokkmw3u+Nkd2NUsiDPtv6jof8tl53AMen+ Y5m1FWc2bsWLVjebPjfkFm6/jR2D7zN1J/L7jepJ8r06SPG2PxumAiK6N75xoVlzQDj/ +lnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=+X8AkMvhaCh2A6t5uXBVRn35aMYZZ+/hh9Cwb5Qv+ts=; b=AtHWEtJ78IKS3rsxYI+9QDcGajp+3n7vTt0smDVduvKNn7JjdXybzlGER8YYTXKczW M5znFi9rNQ2qZ0P5+i9MhPVnFjbsjOkkjxVKaulkqHhm5Oo3viFKAnkIIAe65HXUzFZV C/DhmMY7rPX5SaWt+DUYVzts5joZTA7ba0UEImyGPBL+mGc/emHcwleSZQj4ESfAwkVb onGfRUhREFV74iPIpWJGC3GTUsZydh6SbZvamWmDbuXKxVlib5s6jffDnhBrXMYsJvK+ KwLzkCT7IVZXPxZTYsgD0N1+QbTPUUpdWiSe7OWJsJN/uYx0sb/UPgiKcUQsFhe2SUID GOcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=rpyLZ6Yv; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id k123-v6si19250553pfc.150.2018.10.09.06.26.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=rpyLZ6Yv; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=+X8AkMvhaCh2A6t5uXBVRn35aMYZZ+/hh9Cwb5Qv+ts=; b=rpyLZ6YvZXHfiGUtIIrCY/qTI3 NbJFMlXogf9f9yqOcfRPbnZhcyu0MzTVOzBxq/9rnc7ArXxSu6Zjv07gqCTZS+pfOi3a5opVFMut5 R2HBm6b201wRWNUTC/xmvVRZLqZanoVvu5VbAmOgb8s2QERa9LBR0qTpEVBJmXTgNrXAQNae3/2tQ QUYwo68x4wPzlMOkbR4ukjwJN3SxuJTFdTQ1ocfY6d6tZW+P21kFrBQIGH1LyUXROGkqLNTpap1ga kZakTm2C41zhMHGd23oBHeyEWYzDYMFKao3HxrDenHxHyF0mXxB7f24YLHII5yKeTzYi96i2xHobh smXPsyoQ==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s13-0001CT-Uu; Tue, 09 Oct 2018 13:25:38 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/33] powerpc/powernv: remove pnv_pci_ioda_pe_single_vendor Date: Tue, 9 Oct 2018 15:24:42 +0200 Message-Id: <20181009132500.17643-16-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This function is completely bogus - the fact that two PCIe devices come from the same vendor has absolutely nothing to say about the DMA capabilities and characteristics. Signed-off-by: Christoph Hellwig --- arch/powerpc/platforms/powernv/pci-ioda.c | 28 ++--------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index cde710297a4e..913175ba1c10 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -1746,31 +1746,6 @@ static void pnv_pci_ioda_dma_dev_setup(struct pnv_phb *phb, struct pci_dev *pdev */ } -static bool pnv_pci_ioda_pe_single_vendor(struct pnv_ioda_pe *pe) -{ - unsigned short vendor = 0; - struct pci_dev *pdev; - - if (pe->device_count == 1) - return true; - - /* pe->pdev should be set if it's a single device, pe->pbus if not */ - if (!pe->pbus) - return true; - - list_for_each_entry(pdev, &pe->pbus->devices, bus_list) { - if (!vendor) { - vendor = pdev->vendor; - continue; - } - - if (pdev->vendor != vendor) - return false; - } - - return true; -} - /* * Reconfigure TVE#0 to be usable as 64-bit DMA space. * @@ -1871,7 +1846,8 @@ static int pnv_pci_ioda_dma_set_mask(struct pci_dev *pdev, u64 dma_mask) */ if (dma_mask >> 32 && dma_mask > (memory_hotplug_max() + (1ULL << 32)) && - pnv_pci_ioda_pe_single_vendor(pe) && + /* pe->pdev should be set if it's a single device, pe->pbus if not */ + (pe->device_count == 1 || !pe->pbus) && phb->model == PNV_PHB_MODEL_PHB3) { /* Configure the bypass mode */ rc = pnv_pci_ioda_dma_64bit_bypass(pe); From patchwork Tue Oct 9 13:24:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632549 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 76A43112B for ; Tue, 9 Oct 2018 13:26:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66E87289C4 for ; Tue, 9 Oct 2018 13:26:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5997B289F5; Tue, 9 Oct 2018 13:26:42 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3BFF289C4 for ; Tue, 9 Oct 2018 13:26:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2449E6B027F; Tue, 9 Oct 2018 09:26:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 12EEB6B0284; Tue, 9 Oct 2018 09:26:12 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9E096B0282; Tue, 9 Oct 2018 09:26:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 4E8246B0280 for ; Tue, 9 Oct 2018 09:26:12 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id s24-v6so973183plp.12 for ; Tue, 09 Oct 2018 06:26:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Q6k+kEvsXfJwdDEzA0ghsvUjT8+LCavww+qunoVnHHo=; b=sFqFMIbVshkQmyhA1oFFGP8UtDYSZ1dBu6qvh5Uh755ednqJ0n+G9EOcSskuq+G8TC UiPqfI8OBCLLXiNWz/+QaaR3k5DwZ4997agJhMC52nxYjliZSUn19KoMceir4e3Za5Wb oYLc3m3rmK56tyXMXk0DXaGjj2AZhZExG5VtCUxjwZehv3Kh/R8ZDk4ySQtPDFWEDrZw 36neE7CzzqKwa7cAlodU4prz4i04C2bQMm1EafGbJ0JhDH/g2syq5dcr1IlBLMFesVb1 3gTdVooEaZA6q+JkEo2waGc7uXhM+mmQ9Tt1FWzTxfYQUOQ7eHJz3wRILBNvjMtP1ulE Q6iw== X-Gm-Message-State: ABuFfogZPsIuc3Mv/sK9u/Yqlry89MbR/H3OgYnddDzmFLgsl9ZU8GYR 1Up2FW2XwmOdXyUkU5UxBaRJ2899sjlNA9InYFe1wUjRv7sq9tdoHOLPW6h+uHfWz2AENkWyyeg VeIoK5ACRd9FlU1+yoRq/wFKKTXV0iSeHh4ksvP9M8vExUJ0Q7XCNVbmy97jQ3c8= X-Received: by 2002:a62:449b:: with SMTP id m27-v6mr29991645pfi.82.1539091571839; Tue, 09 Oct 2018 06:26:11 -0700 (PDT) X-Google-Smtp-Source: ACcGV62NdGJVVg0tz5PXIkRbOlAS+WZ9zyL+0zbl/Dxnn5PypmKg8Qw+8iNfm7oBy1kW6wb+nQuu X-Received: by 2002:a62:449b:: with SMTP id m27-v6mr29991444pfi.82.1539091568698; Tue, 09 Oct 2018 06:26:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091568; cv=none; d=google.com; s=arc-20160816; b=B75FP1QIOwDrWd2Bq322yeyG6tqQ9rWbRmp/JU845OesFja7lBxPb9r1rkaknFFkxr mzUdM/zI7Um2kO8w4DyIBWfqu54p8Z5N/lYLbIT76NErAq6CFBGa0t+RRw1qkLR+weI/ 9SeIq3/TUTR9w4hoKmnt7rDglKqHdUezqeccLEfMXQR6GzUxQHNaMboUDN94I3mabhuC qEgV4fw6EZuJkKtTFHZUNAJLmVn/+v7EUrq7v12plzKAuLDDV9pGE/u08+xzQO696T0z fUGgTgDOAwdk27lCzqtATdujnvoZZyyporgtt7OL5wD72sq1JoX+ZjvH2Oje6o33lL73 mG3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Q6k+kEvsXfJwdDEzA0ghsvUjT8+LCavww+qunoVnHHo=; b=ZQ4RqJ24NqfcKct+q/PIQi86NBW+jzSDZdv2Jhnsz9Vs1riyymnmjO57FXCYzfo/rb pLsjLGRtWxM+Ng6LUOeUvC1+h2cauFqhFpzbOiN3sNEJOtbGtp/5QlqmQeC9Rvhd8YQx AbdKvBYO2JScSBjE9ndnTcHxNv1lGQ3BUFmvRqok0oVql3kMgFH4uXxeCECCZGp/pn2G 6II86wXwTfYf4JwFpwE/5AthxIQXsAqyLdP88pi43pT9dPS6z4m5T26q/JwAPGT+CQGn 6w22KWRok9/iPS+4eYMsaAX53rAmVIT/25Qfxi/dk15NJ9IBaSmWZAFqYXWPaeNmuzQZ CPHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=bfkmg0ib; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id i6-v6si20230336pgl.50.2018.10.09.06.26.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=bfkmg0ib; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=Q6k+kEvsXfJwdDEzA0ghsvUjT8+LCavww+qunoVnHHo=; b=bfkmg0ibPmr8vKrbkddkDXTNhB Eue7FzrlwsYpW7RqeknYlsPX8r9YthGamu/URHh+M4KbHw7FKvtorsJa4FRNexA2nKllFy/PjUc68 ak3EqZ6qiTLOmfqGmpv7Hia6/VITphwqcqy1oCNfTRMEOHeg6agijUh+uZ6CRmVZu0hDGGw4OtG7v NO/46Xcsm4G7krmyhckw/MES4ws++YptK/KZ8cCZgpdZTjgi9RKZK+Ci5IVbKGva5uJ5ep27RHV+C G+rOO//GHRpD3/TenmqNAipwTZf+++wdcqGNdQzD/i/l8M/jfkoHzYnzfcLXlJTnun1SBb0LhELbU Uc0V5AnA==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s16-0001DD-Fw; Tue, 09 Oct 2018 13:25:42 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 16/33] powerpc/powernv: remove dead npu-dma code Date: Tue, 9 Oct 2018 15:24:43 +0200 Message-Id: <20181009132500.17643-17-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This code has been unused since it was merged and is in the way of cleaning up the DMA code, thus remove it. This effectively reverts commit 5d2aa710 ("powerpc/powernv: Add support for Nvlink NPUs"). Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/pci.h | 3 - arch/powerpc/include/asm/powernv.h | 23 - arch/powerpc/platforms/powernv/Makefile | 2 +- arch/powerpc/platforms/powernv/npu-dma.c | 999 ---------------------- arch/powerpc/platforms/powernv/pci-ioda.c | 243 ------ arch/powerpc/platforms/powernv/pci.h | 11 - 6 files changed, 1 insertion(+), 1280 deletions(-) delete mode 100644 arch/powerpc/platforms/powernv/npu-dma.c diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h index 2af9ded80540..a01d2e3d6ff9 100644 --- a/arch/powerpc/include/asm/pci.h +++ b/arch/powerpc/include/asm/pci.h @@ -127,7 +127,4 @@ extern void pcibios_scan_phb(struct pci_controller *hose); #endif /* __KERNEL__ */ -extern struct pci_dev *pnv_pci_get_gpu_dev(struct pci_dev *npdev); -extern struct pci_dev *pnv_pci_get_npu_dev(struct pci_dev *gpdev, int index); - #endif /* __ASM_POWERPC_PCI_H */ diff --git a/arch/powerpc/include/asm/powernv.h b/arch/powerpc/include/asm/powernv.h index 2f3ff7a27881..4848a6b3c6b2 100644 --- a/arch/powerpc/include/asm/powernv.h +++ b/arch/powerpc/include/asm/powernv.h @@ -11,33 +11,10 @@ #define _ASM_POWERNV_H #ifdef CONFIG_PPC_POWERNV -#define NPU2_WRITE 1 extern void powernv_set_nmmu_ptcr(unsigned long ptcr); -extern struct npu_context *pnv_npu2_init_context(struct pci_dev *gpdev, - unsigned long flags, - void (*cb)(struct npu_context *, void *), - void *priv); -extern void pnv_npu2_destroy_context(struct npu_context *context, - struct pci_dev *gpdev); -extern int pnv_npu2_handle_fault(struct npu_context *context, uintptr_t *ea, - unsigned long *flags, unsigned long *status, - int count); - void pnv_tm_init(void); #else static inline void powernv_set_nmmu_ptcr(unsigned long ptcr) { } -static inline struct npu_context *pnv_npu2_init_context(struct pci_dev *gpdev, - unsigned long flags, - struct npu_context *(*cb)(struct npu_context *, void *), - void *priv) { return ERR_PTR(-ENODEV); } -static inline void pnv_npu2_destroy_context(struct npu_context *context, - struct pci_dev *gpdev) { } - -static inline int pnv_npu2_handle_fault(struct npu_context *context, - uintptr_t *ea, unsigned long *flags, - unsigned long *status, int count) { - return -ENODEV; -} static inline void pnv_tm_init(void) { } static inline void pnv_power9_force_smt4(void) { } diff --git a/arch/powerpc/platforms/powernv/Makefile b/arch/powerpc/platforms/powernv/Makefile index b540ce8eec55..2b13e9dd137c 100644 --- a/arch/powerpc/platforms/powernv/Makefile +++ b/arch/powerpc/platforms/powernv/Makefile @@ -6,7 +6,7 @@ obj-y += opal-msglog.o opal-hmi.o opal-power.o opal-irqchip.o obj-y += opal-kmsg.o opal-powercap.o opal-psr.o opal-sensor-groups.o obj-$(CONFIG_SMP) += smp.o subcore.o subcore-asm.o -obj-$(CONFIG_PCI) += pci.o pci-ioda.o npu-dma.o pci-ioda-tce.o +obj-$(CONFIG_PCI) += pci.o pci-ioda.o pci-ioda-tce.o obj-$(CONFIG_CXL_BASE) += pci-cxl.o obj-$(CONFIG_EEH) += eeh-powernv.o obj-$(CONFIG_PPC_SCOM) += opal-xscom.o diff --git a/arch/powerpc/platforms/powernv/npu-dma.c b/arch/powerpc/platforms/powernv/npu-dma.c deleted file mode 100644 index 8006c54a91e3..000000000000 --- a/arch/powerpc/platforms/powernv/npu-dma.c +++ /dev/null @@ -1,999 +0,0 @@ -/* - * This file implements the DMA operations for NVLink devices. The NPU - * devices all point to the same iommu table as the parent PCI device. - * - * Copyright Alistair Popple, IBM Corporation 2015. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "powernv.h" -#include "pci.h" - -#define npu_to_phb(x) container_of(x, struct pnv_phb, npu) - -/* - * spinlock to protect initialisation of an npu_context for a particular - * mm_struct. - */ -static DEFINE_SPINLOCK(npu_context_lock); - -/* - * When an address shootdown range exceeds this threshold we invalidate the - * entire TLB on the GPU for the given PID rather than each specific address in - * the range. - */ -static uint64_t atsd_threshold = 2 * 1024 * 1024; -static struct dentry *atsd_threshold_dentry; - -/* - * Other types of TCE cache invalidation are not functional in the - * hardware. - */ -static struct pci_dev *get_pci_dev(struct device_node *dn) -{ - struct pci_dn *pdn = PCI_DN(dn); - - return pci_get_domain_bus_and_slot(pci_domain_nr(pdn->phb->bus), - pdn->busno, pdn->devfn); -} - -/* Given a NPU device get the associated PCI device. */ -struct pci_dev *pnv_pci_get_gpu_dev(struct pci_dev *npdev) -{ - struct device_node *dn; - struct pci_dev *gpdev; - - if (WARN_ON(!npdev)) - return NULL; - - if (WARN_ON(!npdev->dev.of_node)) - return NULL; - - /* Get assoicated PCI device */ - dn = of_parse_phandle(npdev->dev.of_node, "ibm,gpu", 0); - if (!dn) - return NULL; - - gpdev = get_pci_dev(dn); - of_node_put(dn); - - return gpdev; -} -EXPORT_SYMBOL(pnv_pci_get_gpu_dev); - -/* Given the real PCI device get a linked NPU device. */ -struct pci_dev *pnv_pci_get_npu_dev(struct pci_dev *gpdev, int index) -{ - struct device_node *dn; - struct pci_dev *npdev; - - if (WARN_ON(!gpdev)) - return NULL; - - /* Not all PCI devices have device-tree nodes */ - if (!gpdev->dev.of_node) - return NULL; - - /* Get assoicated PCI device */ - dn = of_parse_phandle(gpdev->dev.of_node, "ibm,npu", index); - if (!dn) - return NULL; - - npdev = get_pci_dev(dn); - of_node_put(dn); - - return npdev; -} -EXPORT_SYMBOL(pnv_pci_get_npu_dev); - -#define NPU_DMA_OP_UNSUPPORTED() \ - dev_err_once(dev, "%s operation unsupported for NVLink devices\n", \ - __func__) - -static void *dma_npu_alloc(struct device *dev, size_t size, - dma_addr_t *dma_handle, gfp_t flag, - unsigned long attrs) -{ - NPU_DMA_OP_UNSUPPORTED(); - return NULL; -} - -static void dma_npu_free(struct device *dev, size_t size, - void *vaddr, dma_addr_t dma_handle, - unsigned long attrs) -{ - NPU_DMA_OP_UNSUPPORTED(); -} - -static dma_addr_t dma_npu_map_page(struct device *dev, struct page *page, - unsigned long offset, size_t size, - enum dma_data_direction direction, - unsigned long attrs) -{ - NPU_DMA_OP_UNSUPPORTED(); - return 0; -} - -static int dma_npu_map_sg(struct device *dev, struct scatterlist *sglist, - int nelems, enum dma_data_direction direction, - unsigned long attrs) -{ - NPU_DMA_OP_UNSUPPORTED(); - return 0; -} - -static int dma_npu_dma_supported(struct device *dev, u64 mask) -{ - NPU_DMA_OP_UNSUPPORTED(); - return 0; -} - -static u64 dma_npu_get_required_mask(struct device *dev) -{ - NPU_DMA_OP_UNSUPPORTED(); - return 0; -} - -static const struct dma_map_ops dma_npu_ops = { - .map_page = dma_npu_map_page, - .map_sg = dma_npu_map_sg, - .alloc = dma_npu_alloc, - .free = dma_npu_free, - .dma_supported = dma_npu_dma_supported, - .get_required_mask = dma_npu_get_required_mask, -}; - -/* - * Returns the PE assoicated with the PCI device of the given - * NPU. Returns the linked pci device if pci_dev != NULL. - */ -static struct pnv_ioda_pe *get_gpu_pci_dev_and_pe(struct pnv_ioda_pe *npe, - struct pci_dev **gpdev) -{ - struct pnv_phb *phb; - struct pci_controller *hose; - struct pci_dev *pdev; - struct pnv_ioda_pe *pe; - struct pci_dn *pdn; - - pdev = pnv_pci_get_gpu_dev(npe->pdev); - if (!pdev) - return NULL; - - pdn = pci_get_pdn(pdev); - if (WARN_ON(!pdn || pdn->pe_number == IODA_INVALID_PE)) - return NULL; - - hose = pci_bus_to_host(pdev->bus); - phb = hose->private_data; - pe = &phb->ioda.pe_array[pdn->pe_number]; - - if (gpdev) - *gpdev = pdev; - - return pe; -} - -long pnv_npu_set_window(struct pnv_ioda_pe *npe, int num, - struct iommu_table *tbl) -{ - struct pnv_phb *phb = npe->phb; - int64_t rc; - const unsigned long size = tbl->it_indirect_levels ? - tbl->it_level_size : tbl->it_size; - const __u64 start_addr = tbl->it_offset << tbl->it_page_shift; - const __u64 win_size = tbl->it_size << tbl->it_page_shift; - - pe_info(npe, "Setting up window %llx..%llx pg=%lx\n", - start_addr, start_addr + win_size - 1, - IOMMU_PAGE_SIZE(tbl)); - - rc = opal_pci_map_pe_dma_window(phb->opal_id, - npe->pe_number, - npe->pe_number, - tbl->it_indirect_levels + 1, - __pa(tbl->it_base), - size << 3, - IOMMU_PAGE_SIZE(tbl)); - if (rc) { - pe_err(npe, "Failed to configure TCE table, err %lld\n", rc); - return rc; - } - pnv_pci_ioda2_tce_invalidate_entire(phb, false); - - /* Add the table to the list so its TCE cache will get invalidated */ - pnv_pci_link_table_and_group(phb->hose->node, num, - tbl, &npe->table_group); - - return 0; -} - -long pnv_npu_unset_window(struct pnv_ioda_pe *npe, int num) -{ - struct pnv_phb *phb = npe->phb; - int64_t rc; - - pe_info(npe, "Removing DMA window\n"); - - rc = opal_pci_map_pe_dma_window(phb->opal_id, npe->pe_number, - npe->pe_number, - 0/* levels */, 0/* table address */, - 0/* table size */, 0/* page size */); - if (rc) { - pe_err(npe, "Unmapping failed, ret = %lld\n", rc); - return rc; - } - pnv_pci_ioda2_tce_invalidate_entire(phb, false); - - pnv_pci_unlink_table_and_group(npe->table_group.tables[num], - &npe->table_group); - - return 0; -} - -/* - * Enables 32 bit DMA on NPU. - */ -static void pnv_npu_dma_set_32(struct pnv_ioda_pe *npe) -{ - struct pci_dev *gpdev; - struct pnv_ioda_pe *gpe; - int64_t rc; - - /* - * Find the assoicated PCI devices and get the dma window - * information from there. - */ - if (!npe->pdev || !(npe->flags & PNV_IODA_PE_DEV)) - return; - - gpe = get_gpu_pci_dev_and_pe(npe, &gpdev); - if (!gpe) - return; - - rc = pnv_npu_set_window(npe, 0, gpe->table_group.tables[0]); - - /* - * We don't initialise npu_pe->tce32_table as we always use - * dma_npu_ops which are nops. - */ - set_dma_ops(&npe->pdev->dev, &dma_npu_ops); -} - -/* - * Enables bypass mode on the NPU. The NPU only supports one - * window per link, so bypass needs to be explicitly enabled or - * disabled. Unlike for a PHB3 bypass and non-bypass modes can't be - * active at the same time. - */ -static int pnv_npu_dma_set_bypass(struct pnv_ioda_pe *npe) -{ - struct pnv_phb *phb = npe->phb; - int64_t rc = 0; - phys_addr_t top = memblock_end_of_DRAM(); - - if (phb->type != PNV_PHB_NPU_NVLINK || !npe->pdev) - return -EINVAL; - - rc = pnv_npu_unset_window(npe, 0); - if (rc != OPAL_SUCCESS) - return rc; - - /* Enable the bypass window */ - - top = roundup_pow_of_two(top); - dev_info(&npe->pdev->dev, "Enabling bypass for PE %x\n", - npe->pe_number); - rc = opal_pci_map_pe_dma_window_real(phb->opal_id, - npe->pe_number, npe->pe_number, - 0 /* bypass base */, top); - - if (rc == OPAL_SUCCESS) - pnv_pci_ioda2_tce_invalidate_entire(phb, false); - - return rc; -} - -void pnv_npu_try_dma_set_bypass(struct pci_dev *gpdev, bool bypass) -{ - int i; - struct pnv_phb *phb; - struct pci_dn *pdn; - struct pnv_ioda_pe *npe; - struct pci_dev *npdev; - - for (i = 0; ; ++i) { - npdev = pnv_pci_get_npu_dev(gpdev, i); - - if (!npdev) - break; - - pdn = pci_get_pdn(npdev); - if (WARN_ON(!pdn || pdn->pe_number == IODA_INVALID_PE)) - return; - - phb = pci_bus_to_host(npdev->bus)->private_data; - - /* We only do bypass if it's enabled on the linked device */ - npe = &phb->ioda.pe_array[pdn->pe_number]; - - if (bypass) { - dev_info(&npdev->dev, - "Using 64-bit DMA iommu bypass\n"); - pnv_npu_dma_set_bypass(npe); - } else { - dev_info(&npdev->dev, "Using 32-bit DMA via iommu\n"); - pnv_npu_dma_set_32(npe); - } - } -} - -/* Switch ownership from platform code to external user (e.g. VFIO) */ -void pnv_npu_take_ownership(struct pnv_ioda_pe *npe) -{ - struct pnv_phb *phb = npe->phb; - int64_t rc; - - /* - * Note: NPU has just a single TVE in the hardware which means that - * while used by the kernel, it can have either 32bit window or - * DMA bypass but never both. So we deconfigure 32bit window only - * if it was enabled at the moment of ownership change. - */ - if (npe->table_group.tables[0]) { - pnv_npu_unset_window(npe, 0); - return; - } - - /* Disable bypass */ - rc = opal_pci_map_pe_dma_window_real(phb->opal_id, - npe->pe_number, npe->pe_number, - 0 /* bypass base */, 0); - if (rc) { - pe_err(npe, "Failed to disable bypass, err %lld\n", rc); - return; - } - pnv_pci_ioda2_tce_invalidate_entire(npe->phb, false); -} - -struct pnv_ioda_pe *pnv_pci_npu_setup_iommu(struct pnv_ioda_pe *npe) -{ - struct pnv_phb *phb = npe->phb; - struct pci_bus *pbus = phb->hose->bus; - struct pci_dev *npdev, *gpdev = NULL, *gptmp; - struct pnv_ioda_pe *gpe = get_gpu_pci_dev_and_pe(npe, &gpdev); - - if (!gpe || !gpdev) - return NULL; - - list_for_each_entry(npdev, &pbus->devices, bus_list) { - gptmp = pnv_pci_get_gpu_dev(npdev); - - if (gptmp != gpdev) - continue; - - pe_info(gpe, "Attached NPU %s\n", dev_name(&npdev->dev)); - iommu_group_add_device(gpe->table_group.group, &npdev->dev); - } - - return gpe; -} - -/* Maximum number of nvlinks per npu */ -#define NV_MAX_LINKS 6 - -/* Maximum index of npu2 hosts in the system. Always < NV_MAX_NPUS */ -static int max_npu2_index; - -struct npu_context { - struct mm_struct *mm; - struct pci_dev *npdev[NV_MAX_NPUS][NV_MAX_LINKS]; - struct mmu_notifier mn; - struct kref kref; - bool nmmu_flush; - - /* Callback to stop translation requests on a given GPU */ - void (*release_cb)(struct npu_context *context, void *priv); - - /* - * Private pointer passed to the above callback for usage by - * device drivers. - */ - void *priv; -}; - -struct mmio_atsd_reg { - struct npu *npu; - int reg; -}; - -/* - * Find a free MMIO ATSD register and mark it in use. Return -ENOSPC - * if none are available. - */ -static int get_mmio_atsd_reg(struct npu *npu) -{ - int i; - - for (i = 0; i < npu->mmio_atsd_count; i++) { - if (!test_bit(i, &npu->mmio_atsd_usage)) - if (!test_and_set_bit_lock(i, &npu->mmio_atsd_usage)) - return i; - } - - return -ENOSPC; -} - -static void put_mmio_atsd_reg(struct npu *npu, int reg) -{ - clear_bit_unlock(reg, &npu->mmio_atsd_usage); -} - -/* MMIO ATSD register offsets */ -#define XTS_ATSD_AVA 1 -#define XTS_ATSD_STAT 2 - -static void mmio_launch_invalidate(struct mmio_atsd_reg *mmio_atsd_reg, - unsigned long launch, unsigned long va) -{ - struct npu *npu = mmio_atsd_reg->npu; - int reg = mmio_atsd_reg->reg; - - __raw_writeq_be(va, npu->mmio_atsd_regs[reg] + XTS_ATSD_AVA); - eieio(); - __raw_writeq_be(launch, npu->mmio_atsd_regs[reg]); -} - -static void mmio_invalidate_pid(struct mmio_atsd_reg mmio_atsd_reg[NV_MAX_NPUS], - unsigned long pid, bool flush) -{ - int i; - unsigned long launch; - - for (i = 0; i <= max_npu2_index; i++) { - if (mmio_atsd_reg[i].reg < 0) - continue; - - /* IS set to invalidate matching PID */ - launch = PPC_BIT(12); - - /* PRS set to process-scoped */ - launch |= PPC_BIT(13); - - /* AP */ - launch |= (u64) - mmu_get_ap(mmu_virtual_psize) << PPC_BITLSHIFT(17); - - /* PID */ - launch |= pid << PPC_BITLSHIFT(38); - - /* No flush */ - launch |= !flush << PPC_BITLSHIFT(39); - - /* Invalidating the entire process doesn't use a va */ - mmio_launch_invalidate(&mmio_atsd_reg[i], launch, 0); - } -} - -static void mmio_invalidate_va(struct mmio_atsd_reg mmio_atsd_reg[NV_MAX_NPUS], - unsigned long va, unsigned long pid, bool flush) -{ - int i; - unsigned long launch; - - for (i = 0; i <= max_npu2_index; i++) { - if (mmio_atsd_reg[i].reg < 0) - continue; - - /* IS set to invalidate target VA */ - launch = 0; - - /* PRS set to process scoped */ - launch |= PPC_BIT(13); - - /* AP */ - launch |= (u64) - mmu_get_ap(mmu_virtual_psize) << PPC_BITLSHIFT(17); - - /* PID */ - launch |= pid << PPC_BITLSHIFT(38); - - /* No flush */ - launch |= !flush << PPC_BITLSHIFT(39); - - mmio_launch_invalidate(&mmio_atsd_reg[i], launch, va); - } -} - -#define mn_to_npu_context(x) container_of(x, struct npu_context, mn) - -static void mmio_invalidate_wait( - struct mmio_atsd_reg mmio_atsd_reg[NV_MAX_NPUS]) -{ - struct npu *npu; - int i, reg; - - /* Wait for all invalidations to complete */ - for (i = 0; i <= max_npu2_index; i++) { - if (mmio_atsd_reg[i].reg < 0) - continue; - - /* Wait for completion */ - npu = mmio_atsd_reg[i].npu; - reg = mmio_atsd_reg[i].reg; - while (__raw_readq(npu->mmio_atsd_regs[reg] + XTS_ATSD_STAT)) - cpu_relax(); - } -} - -/* - * Acquires all the address translation shootdown (ATSD) registers required to - * launch an ATSD on all links this npu_context is active on. - */ -static void acquire_atsd_reg(struct npu_context *npu_context, - struct mmio_atsd_reg mmio_atsd_reg[NV_MAX_NPUS]) -{ - int i, j; - struct npu *npu; - struct pci_dev *npdev; - struct pnv_phb *nphb; - - for (i = 0; i <= max_npu2_index; i++) { - mmio_atsd_reg[i].reg = -1; - for (j = 0; j < NV_MAX_LINKS; j++) { - /* - * There are no ordering requirements with respect to - * the setup of struct npu_context, but to ensure - * consistent behaviour we need to ensure npdev[][] is - * only read once. - */ - npdev = READ_ONCE(npu_context->npdev[i][j]); - if (!npdev) - continue; - - nphb = pci_bus_to_host(npdev->bus)->private_data; - npu = &nphb->npu; - mmio_atsd_reg[i].npu = npu; - mmio_atsd_reg[i].reg = get_mmio_atsd_reg(npu); - while (mmio_atsd_reg[i].reg < 0) { - mmio_atsd_reg[i].reg = get_mmio_atsd_reg(npu); - cpu_relax(); - } - break; - } - } -} - -/* - * Release previously acquired ATSD registers. To avoid deadlocks the registers - * must be released in the same order they were acquired above in - * acquire_atsd_reg. - */ -static void release_atsd_reg(struct mmio_atsd_reg mmio_atsd_reg[NV_MAX_NPUS]) -{ - int i; - - for (i = 0; i <= max_npu2_index; i++) { - /* - * We can't rely on npu_context->npdev[][] being the same here - * as when acquire_atsd_reg() was called, hence we use the - * values stored in mmio_atsd_reg during the acquire phase - * rather than re-reading npdev[][]. - */ - if (mmio_atsd_reg[i].reg < 0) - continue; - - put_mmio_atsd_reg(mmio_atsd_reg[i].npu, mmio_atsd_reg[i].reg); - } -} - -/* - * Invalidate either a single address or an entire PID depending on - * the value of va. - */ -static void mmio_invalidate(struct npu_context *npu_context, int va, - unsigned long address, bool flush) -{ - struct mmio_atsd_reg mmio_atsd_reg[NV_MAX_NPUS]; - unsigned long pid = npu_context->mm->context.id; - - if (npu_context->nmmu_flush) - /* - * Unfortunately the nest mmu does not support flushing specific - * addresses so we have to flush the whole mm once before - * shooting down the GPU translation. - */ - flush_all_mm(npu_context->mm); - - /* - * Loop over all the NPUs this process is active on and launch - * an invalidate. - */ - acquire_atsd_reg(npu_context, mmio_atsd_reg); - if (va) - mmio_invalidate_va(mmio_atsd_reg, address, pid, flush); - else - mmio_invalidate_pid(mmio_atsd_reg, pid, flush); - - mmio_invalidate_wait(mmio_atsd_reg); - if (flush) { - /* - * The GPU requires two flush ATSDs to ensure all entries have - * been flushed. We use PID 0 as it will never be used for a - * process on the GPU. - */ - mmio_invalidate_pid(mmio_atsd_reg, 0, true); - mmio_invalidate_wait(mmio_atsd_reg); - mmio_invalidate_pid(mmio_atsd_reg, 0, true); - mmio_invalidate_wait(mmio_atsd_reg); - } - release_atsd_reg(mmio_atsd_reg); -} - -static void pnv_npu2_mn_release(struct mmu_notifier *mn, - struct mm_struct *mm) -{ - struct npu_context *npu_context = mn_to_npu_context(mn); - - /* Call into device driver to stop requests to the NMMU */ - if (npu_context->release_cb) - npu_context->release_cb(npu_context, npu_context->priv); - - /* - * There should be no more translation requests for this PID, but we - * need to ensure any entries for it are removed from the TLB. - */ - mmio_invalidate(npu_context, 0, 0, true); -} - -static void pnv_npu2_mn_change_pte(struct mmu_notifier *mn, - struct mm_struct *mm, - unsigned long address, - pte_t pte) -{ - struct npu_context *npu_context = mn_to_npu_context(mn); - - mmio_invalidate(npu_context, 1, address, true); -} - -static void pnv_npu2_mn_invalidate_range(struct mmu_notifier *mn, - struct mm_struct *mm, - unsigned long start, unsigned long end) -{ - struct npu_context *npu_context = mn_to_npu_context(mn); - unsigned long address; - - if (end - start > atsd_threshold) { - /* - * Just invalidate the entire PID if the address range is too - * large. - */ - mmio_invalidate(npu_context, 0, 0, true); - } else { - for (address = start; address < end; address += PAGE_SIZE) - mmio_invalidate(npu_context, 1, address, false); - - /* Do the flush only on the final addess == end */ - mmio_invalidate(npu_context, 1, address, true); - } -} - -static const struct mmu_notifier_ops nv_nmmu_notifier_ops = { - .release = pnv_npu2_mn_release, - .change_pte = pnv_npu2_mn_change_pte, - .invalidate_range = pnv_npu2_mn_invalidate_range, -}; - -/* - * Call into OPAL to setup the nmmu context for the current task in - * the NPU. This must be called to setup the context tables before the - * GPU issues ATRs. pdev should be a pointed to PCIe GPU device. - * - * A release callback should be registered to allow a device driver to - * be notified that it should not launch any new translation requests - * as the final TLB invalidate is about to occur. - * - * Returns an error if there no contexts are currently available or a - * npu_context which should be passed to pnv_npu2_handle_fault(). - * - * mmap_sem must be held in write mode and must not be called from interrupt - * context. - */ -struct npu_context *pnv_npu2_init_context(struct pci_dev *gpdev, - unsigned long flags, - void (*cb)(struct npu_context *, void *), - void *priv) -{ - int rc; - u32 nvlink_index; - struct device_node *nvlink_dn; - struct mm_struct *mm = current->mm; - struct pnv_phb *nphb; - struct npu *npu; - struct npu_context *npu_context; - - /* - * At present we don't support GPUs connected to multiple NPUs and I'm - * not sure the hardware does either. - */ - struct pci_dev *npdev = pnv_pci_get_npu_dev(gpdev, 0); - - if (!firmware_has_feature(FW_FEATURE_OPAL)) - return ERR_PTR(-ENODEV); - - if (!npdev) - /* No nvlink associated with this GPU device */ - return ERR_PTR(-ENODEV); - - nvlink_dn = of_parse_phandle(npdev->dev.of_node, "ibm,nvlink", 0); - if (WARN_ON(of_property_read_u32(nvlink_dn, "ibm,npu-link-index", - &nvlink_index))) - return ERR_PTR(-ENODEV); - - if (!mm || mm->context.id == 0) { - /* - * Kernel thread contexts are not supported and context id 0 is - * reserved on the GPU. - */ - return ERR_PTR(-EINVAL); - } - - nphb = pci_bus_to_host(npdev->bus)->private_data; - npu = &nphb->npu; - - /* - * Setup the NPU context table for a particular GPU. These need to be - * per-GPU as we need the tables to filter ATSDs when there are no - * active contexts on a particular GPU. It is safe for these to be - * called concurrently with destroy as the OPAL call takes appropriate - * locks and refcounts on init/destroy. - */ - rc = opal_npu_init_context(nphb->opal_id, mm->context.id, flags, - PCI_DEVID(gpdev->bus->number, gpdev->devfn)); - if (rc < 0) - return ERR_PTR(-ENOSPC); - - /* - * We store the npu pci device so we can more easily get at the - * associated npus. - */ - spin_lock(&npu_context_lock); - npu_context = mm->context.npu_context; - if (npu_context) { - if (npu_context->release_cb != cb || - npu_context->priv != priv) { - spin_unlock(&npu_context_lock); - opal_npu_destroy_context(nphb->opal_id, mm->context.id, - PCI_DEVID(gpdev->bus->number, - gpdev->devfn)); - return ERR_PTR(-EINVAL); - } - - WARN_ON(!kref_get_unless_zero(&npu_context->kref)); - } - spin_unlock(&npu_context_lock); - - if (!npu_context) { - /* - * We can set up these fields without holding the - * npu_context_lock as the npu_context hasn't been returned to - * the caller meaning it can't be destroyed. Parallel allocation - * is protected against by mmap_sem. - */ - rc = -ENOMEM; - npu_context = kzalloc(sizeof(struct npu_context), GFP_KERNEL); - if (npu_context) { - kref_init(&npu_context->kref); - npu_context->mm = mm; - npu_context->mn.ops = &nv_nmmu_notifier_ops; - rc = __mmu_notifier_register(&npu_context->mn, mm); - } - - if (rc) { - kfree(npu_context); - opal_npu_destroy_context(nphb->opal_id, mm->context.id, - PCI_DEVID(gpdev->bus->number, - gpdev->devfn)); - return ERR_PTR(rc); - } - - mm->context.npu_context = npu_context; - } - - npu_context->release_cb = cb; - npu_context->priv = priv; - - /* - * npdev is a pci_dev pointer setup by the PCI code. We assign it to - * npdev[][] to indicate to the mmu notifiers that an invalidation - * should also be sent over this nvlink. The notifiers don't use any - * other fields in npu_context, so we just need to ensure that when they - * deference npu_context->npdev[][] it is either a valid pointer or - * NULL. - */ - WRITE_ONCE(npu_context->npdev[npu->index][nvlink_index], npdev); - - if (!nphb->npu.nmmu_flush) { - /* - * If we're not explicitly flushing ourselves we need to mark - * the thread for global flushes - */ - npu_context->nmmu_flush = false; - mm_context_add_copro(mm); - } else - npu_context->nmmu_flush = true; - - return npu_context; -} -EXPORT_SYMBOL(pnv_npu2_init_context); - -static void pnv_npu2_release_context(struct kref *kref) -{ - struct npu_context *npu_context = - container_of(kref, struct npu_context, kref); - - if (!npu_context->nmmu_flush) - mm_context_remove_copro(npu_context->mm); - - npu_context->mm->context.npu_context = NULL; -} - -/* - * Destroy a context on the given GPU. May free the npu_context if it is no - * longer active on any GPUs. Must not be called from interrupt context. - */ -void pnv_npu2_destroy_context(struct npu_context *npu_context, - struct pci_dev *gpdev) -{ - int removed; - struct pnv_phb *nphb; - struct npu *npu; - struct pci_dev *npdev = pnv_pci_get_npu_dev(gpdev, 0); - struct device_node *nvlink_dn; - u32 nvlink_index; - - if (WARN_ON(!npdev)) - return; - - if (!firmware_has_feature(FW_FEATURE_OPAL)) - return; - - nphb = pci_bus_to_host(npdev->bus)->private_data; - npu = &nphb->npu; - nvlink_dn = of_parse_phandle(npdev->dev.of_node, "ibm,nvlink", 0); - if (WARN_ON(of_property_read_u32(nvlink_dn, "ibm,npu-link-index", - &nvlink_index))) - return; - WRITE_ONCE(npu_context->npdev[npu->index][nvlink_index], NULL); - opal_npu_destroy_context(nphb->opal_id, npu_context->mm->context.id, - PCI_DEVID(gpdev->bus->number, gpdev->devfn)); - spin_lock(&npu_context_lock); - removed = kref_put(&npu_context->kref, pnv_npu2_release_context); - spin_unlock(&npu_context_lock); - - /* - * We need to do this outside of pnv_npu2_release_context so that it is - * outside the spinlock as mmu_notifier_destroy uses SRCU. - */ - if (removed) { - mmu_notifier_unregister(&npu_context->mn, - npu_context->mm); - - kfree(npu_context); - } - -} -EXPORT_SYMBOL(pnv_npu2_destroy_context); - -/* - * Assumes mmap_sem is held for the contexts associated mm. - */ -int pnv_npu2_handle_fault(struct npu_context *context, uintptr_t *ea, - unsigned long *flags, unsigned long *status, int count) -{ - u64 rc = 0, result = 0; - int i, is_write; - struct page *page[1]; - - /* mmap_sem should be held so the struct_mm must be present */ - struct mm_struct *mm = context->mm; - - if (!firmware_has_feature(FW_FEATURE_OPAL)) - return -ENODEV; - - WARN_ON(!rwsem_is_locked(&mm->mmap_sem)); - - for (i = 0; i < count; i++) { - is_write = flags[i] & NPU2_WRITE; - rc = get_user_pages_remote(NULL, mm, ea[i], 1, - is_write ? FOLL_WRITE : 0, - page, NULL, NULL); - - /* - * To support virtualised environments we will have to do an - * access to the page to ensure it gets faulted into the - * hypervisor. For the moment virtualisation is not supported in - * other areas so leave the access out. - */ - if (rc != 1) { - status[i] = rc; - result = -EFAULT; - continue; - } - - status[i] = 0; - put_page(page[0]); - } - - return result; -} -EXPORT_SYMBOL(pnv_npu2_handle_fault); - -int pnv_npu2_init(struct pnv_phb *phb) -{ - unsigned int i; - u64 mmio_atsd; - struct device_node *dn; - struct pci_dev *gpdev; - static int npu_index; - uint64_t rc = 0; - - if (!atsd_threshold_dentry) { - atsd_threshold_dentry = debugfs_create_x64("atsd_threshold", - 0600, powerpc_debugfs_root, &atsd_threshold); - } - - phb->npu.nmmu_flush = - of_property_read_bool(phb->hose->dn, "ibm,nmmu-flush"); - for_each_child_of_node(phb->hose->dn, dn) { - gpdev = pnv_pci_get_gpu_dev(get_pci_dev(dn)); - if (gpdev) { - rc = opal_npu_map_lpar(phb->opal_id, - PCI_DEVID(gpdev->bus->number, gpdev->devfn), - 0, 0); - if (rc) - dev_err(&gpdev->dev, - "Error %lld mapping device to LPAR\n", - rc); - } - } - - for (i = 0; !of_property_read_u64_index(phb->hose->dn, "ibm,mmio-atsd", - i, &mmio_atsd); i++) - phb->npu.mmio_atsd_regs[i] = ioremap(mmio_atsd, 32); - - pr_info("NPU%lld: Found %d MMIO ATSD registers", phb->opal_id, i); - phb->npu.mmio_atsd_count = i; - phb->npu.mmio_atsd_usage = 0; - npu_index++; - if (WARN_ON(npu_index >= NV_MAX_NPUS)) - return -ENOSPC; - max_npu2_index = npu_index; - phb->npu.index = npu_index; - - return 0; -} diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 913175ba1c10..b6db65917bb4 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -1203,75 +1203,6 @@ static struct pnv_ioda_pe *pnv_ioda_setup_bus_PE(struct pci_bus *bus, bool all) return pe; } -static struct pnv_ioda_pe *pnv_ioda_setup_npu_PE(struct pci_dev *npu_pdev) -{ - int pe_num, found_pe = false, rc; - long rid; - struct pnv_ioda_pe *pe; - struct pci_dev *gpu_pdev; - struct pci_dn *npu_pdn; - struct pci_controller *hose = pci_bus_to_host(npu_pdev->bus); - struct pnv_phb *phb = hose->private_data; - - /* - * Due to a hardware errata PE#0 on the NPU is reserved for - * error handling. This means we only have three PEs remaining - * which need to be assigned to four links, implying some - * links must share PEs. - * - * To achieve this we assign PEs such that NPUs linking the - * same GPU get assigned the same PE. - */ - gpu_pdev = pnv_pci_get_gpu_dev(npu_pdev); - for (pe_num = 0; pe_num < phb->ioda.total_pe_num; pe_num++) { - pe = &phb->ioda.pe_array[pe_num]; - if (!pe->pdev) - continue; - - if (pnv_pci_get_gpu_dev(pe->pdev) == gpu_pdev) { - /* - * This device has the same peer GPU so should - * be assigned the same PE as the existing - * peer NPU. - */ - dev_info(&npu_pdev->dev, - "Associating to existing PE %x\n", pe_num); - pci_dev_get(npu_pdev); - npu_pdn = pci_get_pdn(npu_pdev); - rid = npu_pdev->bus->number << 8 | npu_pdn->devfn; - npu_pdn->pe_number = pe_num; - phb->ioda.pe_rmap[rid] = pe->pe_number; - - /* Map the PE to this link */ - rc = opal_pci_set_pe(phb->opal_id, pe_num, rid, - OpalPciBusAll, - OPAL_COMPARE_RID_DEVICE_NUMBER, - OPAL_COMPARE_RID_FUNCTION_NUMBER, - OPAL_MAP_PE); - WARN_ON(rc != OPAL_SUCCESS); - found_pe = true; - break; - } - } - - if (!found_pe) - /* - * Could not find an existing PE so allocate a new - * one. - */ - return pnv_ioda_setup_dev_PE(npu_pdev); - else - return pe; -} - -static void pnv_ioda_setup_npu_PEs(struct pci_bus *bus) -{ - struct pci_dev *pdev; - - list_for_each_entry(pdev, &bus->devices, bus_list) - pnv_ioda_setup_npu_PE(pdev); -} - static void pnv_pci_ioda_setup_PEs(void) { struct pci_controller *hose, *tmp; @@ -1281,13 +1212,6 @@ static void pnv_pci_ioda_setup_PEs(void) list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { phb = hose->private_data; - if (phb->type == PNV_PHB_NPU_NVLINK) { - /* PE#0 is needed for error reporting */ - pnv_ioda_reserve_pe(phb, 0); - pnv_ioda_setup_npu_PEs(hose->bus); - if (phb->model == PNV_PHB_MODEL_NPU2) - pnv_npu2_init(phb); - } if (phb->type == PNV_PHB_NPU_OCAPI) { bus = hose->bus; list_for_each_entry(pdev, &bus->devices, bus_list) @@ -1871,9 +1795,6 @@ static int pnv_pci_ioda_dma_set_mask(struct pci_dev *pdev, u64 dma_mask) } *pdev->dev.dma_mask = dma_mask; - /* Update peer npu devices */ - pnv_npu_try_dma_set_bypass(pdev, bypass); - return 0; } @@ -2119,14 +2040,6 @@ static void pnv_pci_ioda2_tce_invalidate(struct iommu_table *tbl, } } -void pnv_pci_ioda2_tce_invalidate_entire(struct pnv_phb *phb, bool rm) -{ - if (phb->model == PNV_PHB_MODEL_NPU || phb->model == PNV_PHB_MODEL_PHB3) - pnv_pci_phb3_tce_invalidate_entire(phb, rm); - else - opal_pci_tce_kill(phb->opal_id, OPAL_PCI_TCE_KILL, 0, 0, 0, 0); -} - static int pnv_ioda2_tce_build(struct iommu_table *tbl, long index, long npages, unsigned long uaddr, enum dma_data_direction direction, @@ -2615,137 +2528,6 @@ static struct iommu_table_group_ops pnv_pci_ioda2_ops = { .take_ownership = pnv_ioda2_take_ownership, .release_ownership = pnv_ioda2_release_ownership, }; - -static int gpe_table_group_to_npe_cb(struct device *dev, void *opaque) -{ - struct pci_controller *hose; - struct pnv_phb *phb; - struct pnv_ioda_pe **ptmppe = opaque; - struct pci_dev *pdev = container_of(dev, struct pci_dev, dev); - struct pci_dn *pdn = pci_get_pdn(pdev); - - if (!pdn || pdn->pe_number == IODA_INVALID_PE) - return 0; - - hose = pci_bus_to_host(pdev->bus); - phb = hose->private_data; - if (phb->type != PNV_PHB_NPU_NVLINK) - return 0; - - *ptmppe = &phb->ioda.pe_array[pdn->pe_number]; - - return 1; -} - -/* - * This returns PE of associated NPU. - * This assumes that NPU is in the same IOMMU group with GPU and there is - * no other PEs. - */ -static struct pnv_ioda_pe *gpe_table_group_to_npe( - struct iommu_table_group *table_group) -{ - struct pnv_ioda_pe *npe = NULL; - int ret = iommu_group_for_each_dev(table_group->group, &npe, - gpe_table_group_to_npe_cb); - - BUG_ON(!ret || !npe); - - return npe; -} - -static long pnv_pci_ioda2_npu_set_window(struct iommu_table_group *table_group, - int num, struct iommu_table *tbl) -{ - struct pnv_ioda_pe *npe = gpe_table_group_to_npe(table_group); - int num2 = (num == 0) ? 1 : 0; - long ret = pnv_pci_ioda2_set_window(table_group, num, tbl); - - if (ret) - return ret; - - if (table_group->tables[num2]) - pnv_npu_unset_window(npe, num2); - - ret = pnv_npu_set_window(npe, num, tbl); - if (ret) { - pnv_pci_ioda2_unset_window(table_group, num); - if (table_group->tables[num2]) - pnv_npu_set_window(npe, num2, - table_group->tables[num2]); - } - - return ret; -} - -static long pnv_pci_ioda2_npu_unset_window( - struct iommu_table_group *table_group, - int num) -{ - struct pnv_ioda_pe *npe = gpe_table_group_to_npe(table_group); - int num2 = (num == 0) ? 1 : 0; - long ret = pnv_pci_ioda2_unset_window(table_group, num); - - if (ret) - return ret; - - if (!npe->table_group.tables[num]) - return 0; - - ret = pnv_npu_unset_window(npe, num); - if (ret) - return ret; - - if (table_group->tables[num2]) - ret = pnv_npu_set_window(npe, num2, table_group->tables[num2]); - - return ret; -} - -static void pnv_ioda2_npu_take_ownership(struct iommu_table_group *table_group) -{ - /* - * Detach NPU first as pnv_ioda2_take_ownership() will destroy - * the iommu_table if 32bit DMA is enabled. - */ - pnv_npu_take_ownership(gpe_table_group_to_npe(table_group)); - pnv_ioda2_take_ownership(table_group); -} - -static struct iommu_table_group_ops pnv_pci_ioda2_npu_ops = { - .get_table_size = pnv_pci_ioda2_get_table_size, - .create_table = pnv_pci_ioda2_create_table_userspace, - .set_window = pnv_pci_ioda2_npu_set_window, - .unset_window = pnv_pci_ioda2_npu_unset_window, - .take_ownership = pnv_ioda2_npu_take_ownership, - .release_ownership = pnv_ioda2_release_ownership, -}; - -static void pnv_pci_ioda_setup_iommu_api(void) -{ - struct pci_controller *hose, *tmp; - struct pnv_phb *phb; - struct pnv_ioda_pe *pe, *gpe; - - /* - * Now we have all PHBs discovered, time to add NPU devices to - * the corresponding IOMMU groups. - */ - list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { - phb = hose->private_data; - - if (phb->type != PNV_PHB_NPU_NVLINK) - continue; - - list_for_each_entry(pe, &phb->ioda.pe_list, list) { - gpe = pnv_pci_npu_setup_iommu(pe); - if (gpe) - gpe->table_group.ops = &pnv_pci_ioda2_npu_ops; - } - } -} -#else /* !CONFIG_IOMMU_API */ -static void pnv_pci_ioda_setup_iommu_api(void) { }; #endif static unsigned long pnv_ioda_parse_tce_sizes(struct pnv_phb *phb) @@ -3242,7 +3024,6 @@ static void pnv_pci_enable_bridges(void) static void pnv_pci_ioda_fixup(void) { pnv_pci_ioda_setup_PEs(); - pnv_pci_ioda_setup_iommu_api(); pnv_pci_ioda_create_dbgfs(); pnv_pci_enable_bridges(); @@ -3689,27 +3470,6 @@ static const struct pci_controller_ops pnv_pci_ioda_controller_ops = { .shutdown = pnv_pci_ioda_shutdown, }; -static int pnv_npu_dma_set_mask(struct pci_dev *npdev, u64 dma_mask) -{ - dev_err_once(&npdev->dev, - "%s operation unsupported for NVLink devices\n", - __func__); - return -EPERM; -} - -static const struct pci_controller_ops pnv_npu_ioda_controller_ops = { - .dma_dev_setup = pnv_pci_dma_dev_setup, -#ifdef CONFIG_PCI_MSI - .setup_msi_irqs = pnv_setup_msi_irqs, - .teardown_msi_irqs = pnv_teardown_msi_irqs, -#endif - .enable_device_hook = pnv_pci_enable_device_hook, - .window_alignment = pnv_pci_window_alignment, - .reset_secondary_bus = pnv_pci_reset_secondary_bus, - .dma_set_mask = pnv_npu_dma_set_mask, - .shutdown = pnv_pci_ioda_shutdown, -}; - static const struct pci_controller_ops pnv_npu_ocapi_ioda_controller_ops = { .enable_device_hook = pnv_pci_enable_device_hook, .window_alignment = pnv_pci_window_alignment, @@ -3931,9 +3691,6 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np, ppc_md.pcibios_fixup = pnv_pci_ioda_fixup; switch (phb->type) { - case PNV_PHB_NPU_NVLINK: - hose->controller_ops = pnv_npu_ioda_controller_ops; - break; case PNV_PHB_NPU_OCAPI: hose->controller_ops = pnv_npu_ocapi_ioda_controller_ops; break; diff --git a/arch/powerpc/platforms/powernv/pci.h b/arch/powerpc/platforms/powernv/pci.h index 8b37b28e3831..54f2935b7ac5 100644 --- a/arch/powerpc/platforms/powernv/pci.h +++ b/arch/powerpc/platforms/powernv/pci.h @@ -231,17 +231,6 @@ extern void pe_level_printk(const struct pnv_ioda_pe *pe, const char *level, #define pe_info(pe, fmt, ...) \ pe_level_printk(pe, KERN_INFO, fmt, ##__VA_ARGS__) -/* Nvlink functions */ -extern void pnv_npu_try_dma_set_bypass(struct pci_dev *gpdev, bool bypass); -extern void pnv_pci_ioda2_tce_invalidate_entire(struct pnv_phb *phb, bool rm); -extern struct pnv_ioda_pe *pnv_pci_npu_setup_iommu(struct pnv_ioda_pe *npe); -extern long pnv_npu_set_window(struct pnv_ioda_pe *npe, int num, - struct iommu_table *tbl); -extern long pnv_npu_unset_window(struct pnv_ioda_pe *npe, int num); -extern void pnv_npu_take_ownership(struct pnv_ioda_pe *npe); -extern void pnv_npu_release_ownership(struct pnv_ioda_pe *npe); -extern int pnv_npu2_init(struct pnv_phb *phb); - /* pci-ioda-tce.c */ #define POWERNV_IOMMU_DEFAULT_LEVELS 1 #define POWERNV_IOMMU_MAX_LEVELS 5 From patchwork Tue Oct 9 13:24:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632543 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0684C112B for ; Tue, 9 Oct 2018 13:26:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC44D286A1 for ; Tue, 9 Oct 2018 13:26:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF827289C4; Tue, 9 Oct 2018 13:26:29 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 494DC286A1 for ; Tue, 9 Oct 2018 13:26:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 901C76B0281; Tue, 9 Oct 2018 09:26:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 796C56B0283; Tue, 9 Oct 2018 09:26:12 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59CF16B0282; Tue, 9 Oct 2018 09:26:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id F04816B027F for ; Tue, 9 Oct 2018 09:26:11 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id q143-v6so831438pgq.12 for ; Tue, 09 Oct 2018 06:26:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=iBezZyCUYUHpLQ5Y3LKMHLLyBboeGujJBJLf+LkXLnA=; b=JWhSYUnCxxE/0ahW/NV2oXXfphUSL3CGLVsdhTB3ZkRqkaBUw++k5gw1sj8X14Tb5r cQEgo+p02iJBfBi59Kh5xSnwDLM1XhoKcbWBRAFRKASxNDAXT1R1EGX5K+dZv6H9DJRu JZHO6iInOTct0YhILTx52nwHwL35CulIeRZTc4FFo5NIoJJGrKn3izgcMrcyWXXiwfnB 6Htf0mlnpg3LBHAyBJDxWZ0MuG0NL3sVHX3SgP7fHwhqpSEnOR/lEcLygD0TAXSBMm7/ C1iD+ZO2X73dAIz0U8lIUTUbZ8ehdNill1Zyo1+0KbvueDlBk/BUXFEemvHBlBAIYpLv +aBA== X-Gm-Message-State: ABuFfohALGh3T78vHVm4rGQBrMDuluK5uH0sBrZKsQRNgScu7AMcqWPU lqQYBTzBHr05QO5svEul7z9QzvbF+3qUJdW2OAMRFfAsKnL2hQeAk0SqnK6OnOGCYW/kus+Ci3h LatTQGvi+mfz7O2HqIPQSfksvFgJWmUsG/PoHUAfd0w81MhS7qCbmWjffHXjDEdE= X-Received: by 2002:a63:b809:: with SMTP id p9-v6mr25078906pge.304.1539091571639; Tue, 09 Oct 2018 06:26:11 -0700 (PDT) X-Google-Smtp-Source: ACcGV604H83JymCqj6ickGxMe97jlLzLuF9qOBjqih6DUxyj1BHpfoReAppOBEoDss5qYVr3hmMM X-Received: by 2002:a63:b809:: with SMTP id p9-v6mr25078857pge.304.1539091570766; Tue, 09 Oct 2018 06:26:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091570; cv=none; d=google.com; s=arc-20160816; b=FOfOUW6M8YvCaZwAj2Y5rcdDljJiqCWkpy40bZD97Y+J1HWWs4aHP03qi0A8o1Ao5I dhG5eYXIqGhW0HO92awdcfAIxRgYH12eNrCTYji9ALs+2lM/5wJrwmGcH0gSFLy2pYox MgukG1y5EL1xFMEDIK85+0uHjEhkZjG1qMwNk8Q08/W3Jkr+HtJaLYkSSrH8+HuzUghg aXvC4xOFDQQVqT0Uwfkvq+nNzgzfUkaw/AZ+JxrM7zPop6bcf7ADBYXuWrlQac6e82LB pTs/P6JT+y2UoNR2HRKOgxftEqY1OAEhFZh8QIW6R2m9XBGvHVDmDt+Pb3+qTADgeNMw CDyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=iBezZyCUYUHpLQ5Y3LKMHLLyBboeGujJBJLf+LkXLnA=; b=wdixmU7VTuneCFHSOYoOl/onVi3ab9BihtMhb38R3akUGOe3tsUbQE2cHG8HlCFqmU b0M4IBd7MOKi+HCMsVB53KrPuru4w46BeDs/judI75fDGvYagpby5lGlQi3uiC6UCuXF 5gIPNJjuAvj5txDK0WouDcy5lh3y4595Qz7niGQE+LI3SiBU1ncQzHA4Sf1olGKXoQmj di0IZ+b9O6JzRwu29YIq/qdXfwTb6H+U9UydHSLAgkLot/reQp8hD8uXjdp2muY0/QVs BrB7RU7xP58FUNRw1K+Tc3FZsJfWqD7ubF0IMzKqxlbI6jALglvlG0fxfqrIApzzgwM4 tAnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=bUOPlX+g; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id 64-v6si20358169plk.257.2018.10.09.06.26.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=bUOPlX+g; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=iBezZyCUYUHpLQ5Y3LKMHLLyBboeGujJBJLf+LkXLnA=; b=bUOPlX+gR0aQqEckjE1Q7voPc7 eecdKM5E0BO906GDTzCM3rqqcTN6BOkXIAOMyKwQPyZbDLrgLyMGNse2JOecBVfX1HhaCcbNgRaIl QDuKmcTcS6M5lgAGvhULYVhYiprSq+CbYf9PwBIxpgTqKkjCplgda9p8uYkjUODiqhudnDExjCrIw jSfSAZlQ/wTzU4XpmHSPD0zD4zHNyz+LaUQPGwCmW31N2bd1ZmZ8jQoU+bpj7hDeal+5RFPDCdxp0 TgvkuIyayUdvtSsE5KEWaE1EbLHTmn6jrFt17PWtH//et0xf9DvCyppJPf22sAWbrtk/6dYFR4Iyh kdEcNwbA==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s1A-0001Fg-FM; Tue, 09 Oct 2018 13:25:44 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 17/33] powerpc/powernv: use the generic iommu bypass code Date: Tue, 9 Oct 2018 15:24:44 +0200 Message-Id: <20181009132500.17643-18-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Use the generic iommu bypass code instead of overriding set_dma_mask. Signed-off-by: Christoph Hellwig --- arch/powerpc/platforms/powernv/pci-ioda.c | 92 ++++++----------------- 1 file changed, 25 insertions(+), 67 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index b6db65917bb4..5748b62e2e86 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -1739,86 +1739,45 @@ static int pnv_pci_ioda_dma_64bit_bypass(struct pnv_ioda_pe *pe) return -EIO; } -static int pnv_pci_ioda_dma_set_mask(struct pci_dev *pdev, u64 dma_mask) +static bool pnv_pci_ioda_iommu_bypass_supported(struct pci_dev *pdev, + u64 dma_mask) { struct pci_controller *hose = pci_bus_to_host(pdev->bus); struct pnv_phb *phb = hose->private_data; struct pci_dn *pdn = pci_get_pdn(pdev); struct pnv_ioda_pe *pe; - uint64_t top; - bool bypass = false; - s64 rc; if (WARN_ON(!pdn || pdn->pe_number == IODA_INVALID_PE)) return -ENODEV; pe = &phb->ioda.pe_array[pdn->pe_number]; if (pe->tce_bypass_enabled) { - top = pe->tce_bypass_base + memblock_end_of_DRAM() - 1; - bypass = (dma_mask >= top); + u64 top = pe->tce_bypass_base + memblock_end_of_DRAM() - 1; + if (dma_mask >= top) + return true; } - if (bypass) { - dev_info(&pdev->dev, "Using 64-bit DMA iommu bypass\n"); - set_dma_ops(&pdev->dev, &dma_nommu_ops); - } else { - /* - * If the device can't set the TCE bypass bit but still wants - * to access 4GB or more, on PHB3 we can reconfigure TVE#0 to - * bypass the 32-bit region and be usable for 64-bit DMAs. - * The device needs to be able to address all of this space. - */ - if (dma_mask >> 32 && - dma_mask > (memory_hotplug_max() + (1ULL << 32)) && - /* pe->pdev should be set if it's a single device, pe->pbus if not */ - (pe->device_count == 1 || !pe->pbus) && - phb->model == PNV_PHB_MODEL_PHB3) { - /* Configure the bypass mode */ - rc = pnv_pci_ioda_dma_64bit_bypass(pe); - if (rc) - return rc; - /* 4GB offset bypasses 32-bit space */ - set_dma_offset(&pdev->dev, (1ULL << 32)); - set_dma_ops(&pdev->dev, &dma_nommu_ops); - } else if (dma_mask >> 32 && dma_mask != DMA_BIT_MASK(64)) { - /* - * Fail the request if a DMA mask between 32 and 64 bits - * was requested but couldn't be fulfilled. Ideally we - * would do this for 64-bits but historically we have - * always fallen back to 32-bits. - */ - return -ENOMEM; - } else { - dev_info(&pdev->dev, "Using 32-bit DMA via iommu\n"); - set_dma_ops(&pdev->dev, &dma_iommu_ops); - } + /* + * If the device can't set the TCE bypass bit but still wants + * to access 4GB or more, on PHB3 we can reconfigure TVE#0 to + * bypass the 32-bit region and be usable for 64-bit DMAs. + * The device needs to be able to address all of this space. + */ + if (dma_mask >> 32 && + dma_mask > (memory_hotplug_max() + (1ULL << 32)) && + /* pe->pdev should be set if it's a single device, pe->pbus if not */ + (pe->device_count == 1 || !pe->pbus) && + phb->model == PNV_PHB_MODEL_PHB3) { + /* Configure the bypass mode */ + s64 rc = pnv_pci_ioda_dma_64bit_bypass(pe); + if (rc) + return rc; + /* 4GB offset bypasses 32-bit space */ + set_dma_offset(&pdev->dev, (1ULL << 32)); + return true; } - *pdev->dev.dma_mask = dma_mask; - return 0; -} - -static u64 pnv_pci_ioda_dma_get_required_mask(struct pci_dev *pdev) -{ - struct pci_controller *hose = pci_bus_to_host(pdev->bus); - struct pnv_phb *phb = hose->private_data; - struct pci_dn *pdn = pci_get_pdn(pdev); - struct pnv_ioda_pe *pe; - u64 end, mask; - - if (WARN_ON(!pdn || pdn->pe_number == IODA_INVALID_PE)) - return 0; - - pe = &phb->ioda.pe_array[pdn->pe_number]; - if (!pe->tce_bypass_enabled) - return __dma_get_required_mask(&pdev->dev); - - - end = pe->tce_bypass_base + memblock_end_of_DRAM(); - mask = 1ULL << (fls64(end) - 1); - mask += mask - 1; - - return mask; + return false; } static void pnv_ioda_setup_bus_dma(struct pnv_ioda_pe *pe, @@ -3456,6 +3415,7 @@ static void pnv_pci_ioda_shutdown(struct pci_controller *hose) static const struct pci_controller_ops pnv_pci_ioda_controller_ops = { .dma_dev_setup = pnv_pci_dma_dev_setup, .dma_bus_setup = pnv_pci_dma_bus_setup, + .iommu_bypass_supported = pnv_pci_ioda_iommu_bypass_supported, #ifdef CONFIG_PCI_MSI .setup_msi_irqs = pnv_setup_msi_irqs, .teardown_msi_irqs = pnv_teardown_msi_irqs, @@ -3465,8 +3425,6 @@ static const struct pci_controller_ops pnv_pci_ioda_controller_ops = { .window_alignment = pnv_pci_window_alignment, .setup_bridge = pnv_pci_setup_bridge, .reset_secondary_bus = pnv_pci_reset_secondary_bus, - .dma_set_mask = pnv_pci_ioda_dma_set_mask, - .dma_get_required_mask = pnv_pci_ioda_dma_get_required_mask, .shutdown = pnv_pci_ioda_shutdown, }; From patchwork Tue Oct 9 13:24:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632551 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5C98815E8 for ; Tue, 9 Oct 2018 13:26:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50541289C4 for ; Tue, 9 Oct 2018 13:26:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44AA9289F5; Tue, 9 Oct 2018 13:26:46 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19C78289C4 for ; Tue, 9 Oct 2018 13:26:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DB9B6B0282; Tue, 9 Oct 2018 09:26:14 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 489036B0283; Tue, 9 Oct 2018 09:26:14 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 328FC6B0284; Tue, 9 Oct 2018 09:26:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by kanga.kvack.org (Postfix) with ESMTP id DC0EB6B0282 for ; Tue, 9 Oct 2018 09:26:13 -0400 (EDT) Received: by mail-pl1-f199.google.com with SMTP id f5-v6so974886plf.11 for ; Tue, 09 Oct 2018 06:26:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=qHIt8PU2ghlSSKLAslc/yyxBCNYkuCHyozLkBsIx2aI=; b=kNKtgiyjhcF8k4Fkghp+/46spxhpyQTUg5y1sGYBPojO61vi5fLFeTkDp6GNzUQdmY Wz3r8OWlbLu4+GcEn9OphYv5FmCmXRMakJu9CroeAYPS98cXcEHewdZhxjteMrVnWqHz CvL/NgQJlgEZ9YjzW8gzN/VLK8SkVg9+BK0QOAZWv77jkr/8DYK0iiHU+QFP2WnMPk6h A5dlA4cCq6TP+KE8LQj7WRNaZWVeUIjT99JyFIXJEtVNowlyYZRxx3A2enqXvWLgE9q/ zp3dF+drzn54ccpAHrqDiotRbUa+3NSmQRY2hMBrKU7HwASRqCAz9cgrsN2BGEa3mEky oSDg== X-Gm-Message-State: ABuFfoi8j4JIiR+RDxhbSwXZWEn0vyZNsGCDFeKDony3bZb5TawSwh7R fU2PR8QS0Y1qgAY09Yr8Dun5dITkU5bJqWzDVQOojo5MuainGhAGJnqhqAkYPSqD79y9KTMKkRl vf7hH4AthfXehNN4VhUxiWjLolyanyUy6uwR9v5+w0ZoFJp4BlK9qdCjqG69rbsE= X-Received: by 2002:a62:fb04:: with SMTP id x4-v6mr15653490pfm.210.1539091573574; Tue, 09 Oct 2018 06:26:13 -0700 (PDT) X-Google-Smtp-Source: ACcGV603bPbtCwjAfFCLjZsUmW9m9BbMGqYfUVpEBdbf9TGe3upk4oRWdVS+u//JBa+Je133u3vA X-Received: by 2002:a62:fb04:: with SMTP id x4-v6mr15653432pfm.210.1539091572674; Tue, 09 Oct 2018 06:26:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091572; cv=none; d=google.com; s=arc-20160816; b=IUvikTPTKyDs9de7jdtbBSh8IEmndsoR2qE7GeVs2ZhnDt3iky3BNUwLIgH62jKexp kHjzwcb48zIPwNcFM98oyfdGII0ecjYYtJ/3fWgD9IsOxrN4rYeeWyUw698WeEMmheBp hnKWtPiUapljQqdwN1T3Ho6u0vWFm1aoEO0k6Kb6Z1R38AEQk633KcyZUPNUSRqh7Sbj UV0hb+bsN9m59dxxoFkXZ7xIa3SmKVYqaxiaFeJPSMrXzlkmVC9NZEwvyU1psXk8a2tS aQpmAnRGXZVVI1pedoxt0u4tzB4CNrep4T87inlOwBO2iwRX2+6LfI29K0TANnIpL72g tLiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=qHIt8PU2ghlSSKLAslc/yyxBCNYkuCHyozLkBsIx2aI=; b=kpZ55r6B152zw8WS+AzUFwgfQu6zOXNl3DAOvL2jPpFKmwYp8DFbaP2zgHcQIVd+pb tItDoy++O3Rr6IggHUzHwG+qZ5JgPBp2curzwCsPoHUcYfoL3s3vhM1dW3bOAFNzlV1t Et8zscBWura3QYIZMaqQttXXTLjbPDUFF6wxTUgljpQYniRNl0TxJpVgbqWkqyH2omav gUNNgfXIFnJmSGZUJfg/qpsmx7w1j/Ipfstw0rIu2MyqtqSH3qjwk+CuxMyhs4z5DTr1 DIEAjrcVAQv5FNHfZPxqoeSuWTWNwm/tl+t6fq/Q+TAGlLzygI6F8BtxHSdyIajEni8V q4rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=OUQ35khO; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id q5-v6si18371942pgp.332.2018.10.09.06.26.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=OUQ35khO; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=qHIt8PU2ghlSSKLAslc/yyxBCNYkuCHyozLkBsIx2aI=; b=OUQ35khO0MRVkmARK+EPAPDiio UoKONGmkCbN4iVRt5myckpSTUi0gQSvXp7mBkf00cd+z8ObfihkHZtg9jkfOgSCUPvU5wOhduYRZS irqK3vMa2JbeXOE6li3QBYDfaRtv7dBvJHizrG5fAMwIEOvDCw+bbi5f3eCkTPuR7k0iA+XGPdOeP Oer1TgzuziP8S0iKDsxBVoAHn2fZJAWlJjBVHSQVraQUziWNRLVp6TgzLKze3AH3XUT/w16MG5MWj PqqJqoFK1HHkkOs73F2DLekxrbWK9j8gl04lyWUvh7LBzBPjFSPuZeBOHoDlL2FHxOqSr5I6gC6AS 3MewVvGA==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s1D-0001HQ-5k; Tue, 09 Oct 2018 13:25:47 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 18/33] powerpc/dma: stop overriding dma_get_required_mask Date: Tue, 9 Oct 2018 15:24:45 +0200 Message-Id: <20181009132500.17643-19-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The ppc_md and pci_controller_ops methods are unused now and can be removed. The dma_nommu implementation is generic to the generic one except for using max_pfn instead of calling into the memblock API, and all other dma_map_ops instances implement a method of their own. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/device.h | 2 -- arch/powerpc/include/asm/dma-mapping.h | 2 -- arch/powerpc/include/asm/machdep.h | 2 -- arch/powerpc/include/asm/pci-bridge.h | 1 - arch/powerpc/kernel/dma.c | 42 -------------------------- drivers/base/platform.c | 2 -- 6 files changed, 51 deletions(-) diff --git a/arch/powerpc/include/asm/device.h b/arch/powerpc/include/asm/device.h index 1aa53318b4bc..3814e1c2d4bc 100644 --- a/arch/powerpc/include/asm/device.h +++ b/arch/powerpc/include/asm/device.h @@ -59,6 +59,4 @@ struct pdev_archdata { u64 dma_mask; }; -#define ARCH_HAS_DMA_GET_REQUIRED_MASK - #endif /* _ASM_POWERPC_DEVICE_H */ diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index 59c090b7eaac..b1999880fc61 100644 --- a/arch/powerpc/include/asm/dma-mapping.h +++ b/arch/powerpc/include/asm/dma-mapping.h @@ -112,7 +112,5 @@ static inline void set_dma_offset(struct device *dev, dma_addr_t off) #define HAVE_ARCH_DMA_SET_MASK 1 extern int dma_set_mask(struct device *dev, u64 dma_mask); -extern u64 __dma_get_required_mask(struct device *dev); - #endif /* __KERNEL__ */ #endif /* _ASM_DMA_MAPPING_H */ diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h index a47de82fb8e2..99f06102474e 100644 --- a/arch/powerpc/include/asm/machdep.h +++ b/arch/powerpc/include/asm/machdep.h @@ -47,9 +47,7 @@ struct machdep_calls { #endif #endif /* CONFIG_PPC64 */ - /* Platform set_dma_mask and dma_get_required_mask overrides */ int (*dma_set_mask)(struct device *dev, u64 dma_mask); - u64 (*dma_get_required_mask)(struct device *dev); int (*probe)(void); void (*setup_arch)(void); /* Optional, may be NULL */ diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h index 5c7a1e7ffc8a..aace7033fa02 100644 --- a/arch/powerpc/include/asm/pci-bridge.h +++ b/arch/powerpc/include/asm/pci-bridge.h @@ -46,7 +46,6 @@ struct pci_controller_ops { #endif int (*dma_set_mask)(struct pci_dev *pdev, u64 dma_mask); - u64 (*dma_get_required_mask)(struct pci_dev *pdev); void (*shutdown)(struct pci_controller *hose); }; diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index 716b7eab3ee7..9ca9d2cec4ed 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c @@ -197,18 +197,6 @@ int dma_nommu_map_sg(struct device *dev, struct scatterlist *sgl, return nents; } -static u64 dma_nommu_get_required_mask(struct device *dev) -{ - u64 end, mask; - - end = memblock_end_of_DRAM() + get_dma_offset(dev); - - mask = 1ULL << (fls64(end) - 1); - mask += mask - 1; - - return mask; -} - dma_addr_t dma_nommu_map_page(struct device *dev, struct page *page, unsigned long offset, size_t size, enum dma_data_direction dir, unsigned long attrs) @@ -246,7 +234,6 @@ const struct dma_map_ops dma_nommu_ops = { .map_sg = dma_nommu_map_sg, .dma_supported = dma_nommu_dma_supported, .map_page = dma_nommu_map_page, - .get_required_mask = dma_nommu_get_required_mask, #ifdef CONFIG_NOT_COHERENT_CACHE .sync_single_for_cpu = dma_nommu_sync_single, .sync_single_for_device = dma_nommu_sync_single, @@ -294,35 +281,6 @@ int dma_set_mask(struct device *dev, u64 dma_mask) } EXPORT_SYMBOL(dma_set_mask); -u64 __dma_get_required_mask(struct device *dev) -{ - const struct dma_map_ops *dma_ops = get_dma_ops(dev); - - if (unlikely(dma_ops == NULL)) - return 0; - - if (dma_ops->get_required_mask) - return dma_ops->get_required_mask(dev); - - return DMA_BIT_MASK(8 * sizeof(dma_addr_t)); -} - -u64 dma_get_required_mask(struct device *dev) -{ - if (ppc_md.dma_get_required_mask) - return ppc_md.dma_get_required_mask(dev); - - if (dev_is_pci(dev)) { - struct pci_dev *pdev = to_pci_dev(dev); - struct pci_controller *phb = pci_bus_to_host(pdev->bus); - if (phb->controller_ops.dma_get_required_mask) - return phb->controller_ops.dma_get_required_mask(pdev); - } - - return __dma_get_required_mask(dev); -} -EXPORT_SYMBOL_GPL(dma_get_required_mask); - static int __init dma_init(void) { #ifdef CONFIG_IBMVIO diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 23cf4427f425..057357521561 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -1179,7 +1179,6 @@ int __init platform_bus_init(void) return error; } -#ifndef ARCH_HAS_DMA_GET_REQUIRED_MASK static u64 dma_default_get_required_mask(struct device *dev) { u32 low_totalram = ((max_pfn - 1) << PAGE_SHIFT); @@ -1208,7 +1207,6 @@ u64 dma_get_required_mask(struct device *dev) return dma_default_get_required_mask(dev); } EXPORT_SYMBOL_GPL(dma_get_required_mask); -#endif static __initdata LIST_HEAD(early_platform_driver_list); static __initdata LIST_HEAD(early_platform_device_list); From patchwork Tue Oct 9 13:24:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632553 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CAE4E112B for ; Tue, 9 Oct 2018 13:26:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF6CF289C4 for ; Tue, 9 Oct 2018 13:26:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3806289F5; Tue, 9 Oct 2018 13:26:49 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E504289C4 for ; Tue, 9 Oct 2018 13:26:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9BCB16B028B; Tue, 9 Oct 2018 09:26:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8CF0F6B028A; Tue, 9 Oct 2018 09:26:15 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 75C5F6B0289; Tue, 9 Oct 2018 09:26:15 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 282F96B0284 for ; Tue, 9 Oct 2018 09:26:15 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id v138-v6so837352pgb.7 for ; Tue, 09 Oct 2018 06:26:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0t8uXkuelOQDt36xt585mgrdkG+i2UBH2mxJX+JCUK8=; b=c477wGMDjTeyDxYwvBpC0RPtuXWph7GmmGbUK/ZQwM2pZZmMVKAYtl0HRne4VFcD8b UqPl9UFQXHqSWXrIuCZzKFDqhVqrx3F06HHEVqGevZSDU+Vpvm63GLMo2pKWO7/kJbUe cC1CLKGvZRZmqS1YFQNx1zydUKMYsJVxDJsS/krr1fBDU4tKSIl35aSQSICSLBmeALa+ 0h5veLGDpm/qCyeChUEDPhhPmFsWYVp71qsHVY5O67c2cZCHo065qbMiXqwP/21n+GEH m/Q+/Qgbt9Coyu0bX7ptb6mecqrQ4RimPZBsVfc5FHoQM++DmX8GI5GVHmRBQQb7j6Ls iGTw== X-Gm-Message-State: ABuFfojWAu7rHaaqXZirnERzfNbOnDicKWl3kD7vTG+VNtz02TDfb3Sl xchg53O503oltlAb5DoYV4xNa3WRN7441lLkxDIFVU37I+6/7CrOm1YHqsArMeixcomqMFaq+Rb 4lRgq6G4TA31/gd4EN4dik9qy7IDmQDrDlew0m/Z3cAMFHl+yOEq/8ESBuKn5IXI= X-Received: by 2002:a17:902:9f8c:: with SMTP id g12-v6mr29369058plq.309.1539091574851; Tue, 09 Oct 2018 06:26:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV61/nb/RbeB0Liw1edYLvH9+Otb8cF5LPPT6iRptBbpcIzgiGSLfPt9NiMQpbZXqgcCbcIUD X-Received: by 2002:a17:902:9f8c:: with SMTP id g12-v6mr29369026plq.309.1539091574205; Tue, 09 Oct 2018 06:26:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091574; cv=none; d=google.com; s=arc-20160816; b=UI4EsYsnz1A7waebmzg/PqZAi45zVV2B0nwBI/oDH8DD9kFe+gt5AyVzxwGQNSsQ/n OwfGUstd4thudSIFOGiJ4YwoLCOFG2EuzzrybU0Itq/U9GCqpwPSmGyJqHXhESMDsurs ZbApiyQ8salWG7BG0ptIREASLKO5YJe6TvgSF/CUXu8VfS8NCUfsqhgVPb2j1B7ahaz/ yIwnkGIdH/amvbsvubulAtxK9TWtSYw//a/MzJK3BWYhzokPLcjhLY/7Yc8fN0Uc7hp6 qRKVRBb9Fw+7chVsIYXzjvWwEfVgvLGGPLsPeyFB8DB8/lQnmcUXBA8qFDrovmpyT6j5 Q5jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=0t8uXkuelOQDt36xt585mgrdkG+i2UBH2mxJX+JCUK8=; b=BF+RHRo2548btOFMg3E0SaB5lZL/DhknSIhygP0im5OgglkHIRbm8GJO01IdCBWmtr IEUblnfsl6C//zxc8z1HlD39juHCJnJVfLTeIZ6D9bCKt3+yczupDAtsd1uZViO9Adwg PjqjeSmUvs56tse1zh2kpMc9UGTfmAB9m4hTFFkk3PdBJyV7m3s2a4cqLrKULepEZqmz 8RTlRRToaX+VrpGBShdZR3EzzoqtugJsaNnRKxKpM5mVRsnOxNfsCeMTdKsWzP0rzSVL TnKsqBC0ar71tlEO4SHEFIJKdSofse1qrCsoS1r9YKu4jEdpLEuGJ1osCp4sAIfoLGJY GBGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=YmOYnw6K; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id 1-v6si23159884plt.148.2018.10.09.06.26.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=YmOYnw6K; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=0t8uXkuelOQDt36xt585mgrdkG+i2UBH2mxJX+JCUK8=; b=YmOYnw6K8pYKh46DlaXiP9du+b 5GRswt6ZMjT5iH0UHH0fnBR2oIkaZx+XNktI7dC32Hl9G84c6pIothfhz67xcKMsjKaOT4AV5BrSt TzawuqnfVChIJFIUPIbypeHUoQgKQECbWUJg1GN+jo2GhEW3kUOtgNfxoXUat/vCTdhATygly1oik DgLzQyWbQ+vw/wXKkla0dQd3CfpeG9aGnOwPIf+DP62SMB4Nfe4fat2YERucjmhu7oezk8sKsxd+j mFAuuU0OIQaO/QEg33Fgiri7cgCR4aaa40h6AdG7Yuut+yhOj6YVTQwqKUC54jPtP5tFuJ0yPhVbJ FRB8eCxQ==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s1F-0001Ip-TO; Tue, 09 Oct 2018 13:25:50 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 19/33] powerpc/pci: remove the dma_set_mask pci_controller ops methods Date: Tue, 9 Oct 2018 15:24:46 +0200 Message-Id: <20181009132500.17643-20-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Unused now. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/pci-bridge.h | 2 -- arch/powerpc/kernel/dma.c | 7 ------- 2 files changed, 9 deletions(-) diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h index aace7033fa02..a50703af7db3 100644 --- a/arch/powerpc/include/asm/pci-bridge.h +++ b/arch/powerpc/include/asm/pci-bridge.h @@ -45,8 +45,6 @@ struct pci_controller_ops { void (*teardown_msi_irqs)(struct pci_dev *pdev); #endif - int (*dma_set_mask)(struct pci_dev *pdev, u64 dma_mask); - void (*shutdown)(struct pci_controller *hose); }; diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index 9ca9d2cec4ed..78ef4076e15c 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c @@ -267,13 +267,6 @@ int dma_set_mask(struct device *dev, u64 dma_mask) if (ppc_md.dma_set_mask) return ppc_md.dma_set_mask(dev, dma_mask); - if (dev_is_pci(dev)) { - struct pci_dev *pdev = to_pci_dev(dev); - struct pci_controller *phb = pci_bus_to_host(pdev->bus); - if (phb->controller_ops.dma_set_mask) - return phb->controller_ops.dma_set_mask(pdev, dma_mask); - } - if (!dev->dma_mask || !dma_supported(dev, dma_mask)) return -EIO; *dev->dma_mask = dma_mask; From patchwork Tue Oct 9 13:24:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632557 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 54F11112B for ; Tue, 9 Oct 2018 13:26:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49432289C4 for ; Tue, 9 Oct 2018 13:26:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D5EE289F5; Tue, 9 Oct 2018 13:26:59 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8924289C4 for ; Tue, 9 Oct 2018 13:26:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 131A16B0284; Tue, 9 Oct 2018 09:26:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0E4396B0287; Tue, 9 Oct 2018 09:26:16 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1E5E6B0285; Tue, 9 Oct 2018 09:26:15 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 620776B0286 for ; Tue, 9 Oct 2018 09:26:15 -0400 (EDT) Received: by mail-pl1-f197.google.com with SMTP id t1-v6so965049plz.17 for ; Tue, 09 Oct 2018 06:26:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=6xV/WpKVguy+7dNBIsuEqczBqEePEOdZd5rcV9GeR8s=; b=BcrEMAgMm4DwTc0eULUU1jGBSZ3vkTv181q8fs3eTFBhbyBsKZDWvvDOceunifdalo Q7DpdD4X7lf3R1eoNrqKABkXnJdpPPJ4wJJ2l2i3loECp3ebkzhMgLMyTXo4Zyyvl6Cu Sf6maKHHBBr2EO/3XVrCEh3vChzJrjj0hNQ/SrHaRGo6EQH1xENP2DHtxfI1m1Zc4EaQ a5WtDx+oqZ6AsLIzBUdo3rERl6PwS/onTUmbYbzH4Lw5ieAgHfhq0zwJIHYsdvqiWeA4 FtbYqi0hZQ+aF/hdhFY42GtceIy9PAfZAzLXlwyJkf+DZvXiDx9Nz9lcbUF7jez69+NF bPLQ== X-Gm-Message-State: ABuFfog/yvLGjHG4MyX+Wnnep3n7l+5P6BqffWM8ETAtQ+XnXzJKRR0E GxTfz0Y9j9YhkGplpwW29GTPlkSoRHfVL2SydKCDfspPQgFXD+wg6Xq18jta1tKt786juPJsjdh UM5nbUxwbTJBmOgkCRkLSJrjhbBqcBG9wGJ2isNG1ROvF3cCIjhA/sQiOZg5Bhhc= X-Received: by 2002:a62:401:: with SMTP id 1-v6mr29915985pfe.236.1539091575046; Tue, 09 Oct 2018 06:26:15 -0700 (PDT) X-Google-Smtp-Source: ACcGV61W3VEUhlrfC0EA40ejJzcV7xp/SnATldVTuPl9+u0BWJKienWb/k8rlYWy09DIJQKrE2C0 X-Received: by 2002:a62:401:: with SMTP id 1-v6mr29915920pfe.236.1539091574099; Tue, 09 Oct 2018 06:26:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091574; cv=none; d=google.com; s=arc-20160816; b=X2SjT9sgnwLjIfkJTwLiF0YrFqnUg66dSAFE/AhpnqEbxX6jHX+5GSryFTJYUAt5HP lz5PJRVUkuynwJ0UHEq41ucOow+/1DCu6GYzHq9pEdiKFghpfm8eRBSDS5NBlE7SVwkc PI9h2U3RwFmFCMnzeVIr2He7NkdcAWLC+PlD+GR4LQDCDFv/X5oGgGyrFBjBOPwv8/K7 Ebb2G1a7PXg9QhB0lWBAdBq0I4ubedQUeppp05IiI6tR735odiwba+/nfMXJM95kPmOM qAdNnwY851MeYTD76XDe+uj/0S+KEeiP7wy9aOAEEgZ4Wv/VHOWuCJDZuxUhgcLa/ifn NlFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=6xV/WpKVguy+7dNBIsuEqczBqEePEOdZd5rcV9GeR8s=; b=yxMUf/xiv8llpJlRvYZTKhbfB4l9t4VeO0l//Qeb2GNqM07ic8surncX4NGd0JJ1jG Sba2/tCxmVF7g6uINREkYqvZRLVdXu3qIqwM2D9BhNUrVLxLZ8wYT5kzDUTMG2r47O5Y dxiBAXqbhZpkfeU605LFoImDOZXPzFK9D3MBiZKtAoo1JMC7EoO8ejeWxBSBdYftqLcz nbp2cvEW94BD+sq7jPAtk9oHB8eexB5SXt5qkepYvR73/KpZpCMqALn5C+wiSlZcsr8G pIUgMpH6Z9nmyboniLSK6qRBRGlms2XkuezUbDAdhDUsJWD3wmeQamqycbRajfhg7bxO rqRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=BzQh9QHz; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id 14-v6si17134419pgm.488.2018.10.09.06.26.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=BzQh9QHz; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=6xV/WpKVguy+7dNBIsuEqczBqEePEOdZd5rcV9GeR8s=; b=BzQh9QHz3roG6GtLk9xod+o2+R QgEu+Yj0yhhbto0eCEpx65EdHrcciCT04Ks8VJeT3OtrGSnRTJI21Q2xY5lD76QOxNEyCcw0/O4T3 Ywtegp3xx1ZV3Nj3egui3CbzlOQuqPejD5flsBXtd4TzJVp2Es++u0xT7/PStAiuW6j5+ceDAx3xw CVSUn1kDOtg2Ys0EtScNRd5fwoKqfxOPfi7igYzMzMTv9WznNK4pJuoB/W58JDobYtxGVLRBF5whO WGHPxBKXrYKlo6Khd61o0hWj05EE6qhx3yeFyNgA9xxMcMPuu5rGAX4HAWpk1UXL1JSu7SqtRh/fV 4GhmwyZg==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s1I-0001Ko-H0; Tue, 09 Oct 2018 13:25:52 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 20/33] powerpc/dma: remove the iommu fallback for coherent allocations Date: Tue, 9 Oct 2018 15:24:47 +0200 Message-Id: <20181009132500.17643-21-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP All iommu capable platforms now always use the iommu code with the internal bypass, so there is not need for this magic anymore. Signed-off-by: Christoph Hellwig --- arch/powerpc/Kconfig | 4 --- arch/powerpc/kernel/dma.c | 68 ++------------------------------------- 2 files changed, 2 insertions(+), 70 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 06996df07cad..7097019d8907 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -119,9 +119,6 @@ config GENERIC_HWEIGHT bool default y -config ARCH_HAS_DMA_SET_COHERENT_MASK - bool - config PPC bool default y @@ -129,7 +126,6 @@ config PPC # Please keep this list sorted alphabetically. # select ARCH_HAS_DEVMEM_IS_ALLOWED - select ARCH_HAS_DMA_SET_COHERENT_MASK select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index 78ef4076e15c..bef91b8ad064 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c @@ -114,51 +114,6 @@ void __dma_nommu_free_coherent(struct device *dev, size_t size, } #endif /* !CONFIG_NOT_COHERENT_CACHE */ -static void *dma_nommu_alloc_coherent(struct device *dev, size_t size, - dma_addr_t *dma_handle, gfp_t flag, - unsigned long attrs) -{ - struct iommu_table *iommu; - - /* The coherent mask may be smaller than the real mask, check if - * we can really use the direct ops - */ - if (dma_nommu_dma_supported(dev, dev->coherent_dma_mask)) - return __dma_nommu_alloc_coherent(dev, size, dma_handle, - flag, attrs); - - /* Ok we can't ... do we have an iommu ? If not, fail */ - iommu = get_iommu_table_base(dev); - if (!iommu) - return NULL; - - /* Try to use the iommu */ - return iommu_alloc_coherent(dev, iommu, size, dma_handle, - dev->coherent_dma_mask, flag, - dev_to_node(dev)); -} - -static void dma_nommu_free_coherent(struct device *dev, size_t size, - void *vaddr, dma_addr_t dma_handle, - unsigned long attrs) -{ - struct iommu_table *iommu; - - /* See comments in dma_nommu_alloc_coherent() */ - if (dma_nommu_dma_supported(dev, dev->coherent_dma_mask)) - return __dma_nommu_free_coherent(dev, size, vaddr, dma_handle, - attrs); - /* Maybe we used an iommu ... */ - iommu = get_iommu_table_base(dev); - - /* If we hit that we should have never allocated in the first - * place so how come we are freeing ? - */ - if (WARN_ON(!iommu)) - return; - iommu_free_coherent(iommu, size, vaddr, dma_handle); -} - int dma_nommu_mmap_coherent(struct device *dev, struct vm_area_struct *vma, void *cpu_addr, dma_addr_t handle, size_t size, unsigned long attrs) @@ -228,8 +183,8 @@ static inline void dma_nommu_sync_single(struct device *dev, #endif const struct dma_map_ops dma_nommu_ops = { - .alloc = dma_nommu_alloc_coherent, - .free = dma_nommu_free_coherent, + .alloc = __dma_nommu_alloc_coherent, + .free = __dma_nommu_free_coherent, .mmap = dma_nommu_mmap_coherent, .map_sg = dma_nommu_map_sg, .dma_supported = dma_nommu_dma_supported, @@ -243,25 +198,6 @@ const struct dma_map_ops dma_nommu_ops = { }; EXPORT_SYMBOL(dma_nommu_ops); -int dma_set_coherent_mask(struct device *dev, u64 mask) -{ - if (!dma_supported(dev, mask)) { - /* - * We need to special case the direct DMA ops which can - * support a fallback for coherent allocations. There - * is no dma_op->set_coherent_mask() so we have to do - * things the hard way: - */ - if (get_dma_ops(dev) != &dma_nommu_ops || - get_iommu_table_base(dev) == NULL || - !dma_iommu_dma_supported(dev, mask)) - return -EIO; - } - dev->coherent_dma_mask = mask; - return 0; -} -EXPORT_SYMBOL(dma_set_coherent_mask); - int dma_set_mask(struct device *dev, u64 dma_mask) { if (ppc_md.dma_set_mask) From patchwork Tue Oct 9 13:24:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632567 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 923CF112B for ; Tue, 9 Oct 2018 13:27:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87C5C289DF for ; Tue, 9 Oct 2018 13:27:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C2BA28A5D; Tue, 9 Oct 2018 13:27:24 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2351289DF for ; Tue, 9 Oct 2018 13:27:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 995786B028E; Tue, 9 Oct 2018 09:26:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8F74C6B028F; Tue, 9 Oct 2018 09:26:31 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 798226B0290; Tue, 9 Oct 2018 09:26:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 354806B028E for ; Tue, 9 Oct 2018 09:26:31 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id z12-v6so1074356pfl.17 for ; Tue, 09 Oct 2018 06:26:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=+1EiEe+f+Zo4Ql+MI1HQ2VxHjecaPGIqGdVcvB4Xz1g=; b=jJ/3ZYnjqQ84Tm6n8X8LgJF7PRDiZN2XokSH6GMGE/JDUMjzvmS9+87xqPPVjMMJxU EbkehbWxVW+G4CQ/DVdHEMDKaYgsvHiBxvbgY3j8Dg1xD9W3OS7sOrGJ8jujEP32635p 2EezxsBtFDz4nS0EMlsZ/Phq+z2fvKLm7SV2OTKtf7S700vjHEVor84nf/lTqnoonh7w sMEoKpBnjbSwS1lEhAFrrMj6sP4s5NbOnsYkIw2M+HN4IDN4Lj2qRkuqc5N6z2OGN5mG 5Zlw/5oZb0zW54poblf4Op2n7Cr/4ABiJFdl2Kt8VpnEjxs0WB3uEf0Hc0jJUZa8AouI /i5w== X-Gm-Message-State: ABuFfoiSx9W1GCo7t6UjNMtc6Dd4sbdJOPKRRfsCADifjIZJy1CFybDF itHQvia/+xUSstBHOht0QC/IXnBHyJp5fxtyVTQIscKczv4UhYTuJJDQaRVdLCvECoUZHwfzRiD WMyVTeRpMwH71LzfZDSRSdPPgBdH3sJ3Itnn0C1kTdMxcb1FsAnPCAThLqEvOIAw= X-Received: by 2002:a63:991a:: with SMTP id d26-v6mr25757145pge.434.1539091590882; Tue, 09 Oct 2018 06:26:30 -0700 (PDT) X-Google-Smtp-Source: ACcGV63CY2lll3FMhp44GHGktRjGznXcyXFGlNCHPB8w8EXJfJ4gYszIRdX+cw/gRjoqt7AJzWWp X-Received: by 2002:a63:991a:: with SMTP id d26-v6mr25757098pge.434.1539091590010; Tue, 09 Oct 2018 06:26:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091589; cv=none; d=google.com; s=arc-20160816; b=PzWhbIHSGvFl4ttsnhK9HOYR+c8hZcG/V0GAZpnAVDx0FqsiaTPo76gQYyth0lR9Ni qev2jsO35hbObxw+vjvElR81zr/9IG1G7CY+z2hH6AefuqlHPd3PA8uD0/zqaHCrrjCk wLaXdyg3XnNkXrdjjiZ3LblUQf6lHlQgTLFCWki75V98G4Gap5UYHcSutYiihv+Wc1zw IK27G0OYmYUcqFSkJxKkElmf0iJheexfXmGvrLnztVNVpNyIxDNrJ4CPqiSRAC1F/sVg Yxb7JGZpzV12OdyROXZKTmqa5VNLM5gzStUkKJ284ezraFx7f3ABoQMlN/InEAhdqnp3 gqQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=+1EiEe+f+Zo4Ql+MI1HQ2VxHjecaPGIqGdVcvB4Xz1g=; b=fOMOGHBeEDcgRbBninvfP/oKOFbFOu3v2K3a+Eu78kQp7P3rt7oBb2nvLI0GKJTtVd aTWlPj8q4jP9goBhFsWNcSrJXPFe3GI6vcAI9/VVmMsd2IwSSlXRpkiyoTexX7mp2Apl NExWsqdLQnBommgvMDjH12dZ6aCtuXq2LnKRE3+4K+JqROwOI+QC7jWmOvO5ZRRvMdzz TE39rkpaycuNaABLfNfe2pK8DLeZ4JTI0jpPch+2cbAtRlOZhMyw3eU/6yQIM7SnAQUI nHE8+9kuimt/BvNWY9FQ6TYbXBsEsck+EonMdU25kQ4pN1KxoL6L+NVV9FqkDVNutHUB DqAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=dgI3l1FP; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id d9-v6si10273790pgc.299.2018.10.09.06.26.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=dgI3l1FP; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=+1EiEe+f+Zo4Ql+MI1HQ2VxHjecaPGIqGdVcvB4Xz1g=; b=dgI3l1FP6fHEl6ppF0L+Usvawj Stfrqmo9GTvLyX2Zz36kBGF7+aA556qH1F3T+xRKEbU3UMpeQ/NLOl6xuB1EkPNov0ZiswD7ZXec8 y6CJnsRgXJIB7l2hcHuOqdMMuu+kx7QPmeA7ARrko0L8gBOGhoX58RQY+R7rFRphPo0wSd2qmp67r vBOYnwKHMwz++VxaP6ICWLMlCoACQg5bN/zUmq8fBU+dsCvbgE3GPIvnhtCzxAvGIJW/8CDJfXR0x 3hESA1yBdWle9BwtpgbVGFDlFMD9fb57NK4sm50K6VAQewa0W2nmkG0t90GFDliTke94DB7e7BM9T v7hke3VQ==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s1L-0001MW-Cu; Tue, 09 Oct 2018 13:25:55 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 21/33] powerpc/dma: remove get_pci_dma_ops Date: Tue, 9 Oct 2018 15:24:48 +0200 Message-Id: <20181009132500.17643-22-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This function is only used by the Cell iommu code, which can keep track if it is using the iommu internally just as good. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/pci.h | 2 -- arch/powerpc/kernel/pci-common.c | 6 ------ arch/powerpc/platforms/cell/iommu.c | 17 ++++++++--------- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h index a01d2e3d6ff9..4f7cf0a7f89d 100644 --- a/arch/powerpc/include/asm/pci.h +++ b/arch/powerpc/include/asm/pci.h @@ -52,10 +52,8 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) #ifdef CONFIG_PCI extern void set_pci_dma_ops(const struct dma_map_ops *dma_ops); -extern const struct dma_map_ops *get_pci_dma_ops(void); #else /* CONFIG_PCI */ #define set_pci_dma_ops(d) -#define get_pci_dma_ops() NULL #endif #ifdef CONFIG_PPC64 diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 88e4f69a09e5..a84707680525 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -69,12 +69,6 @@ void set_pci_dma_ops(const struct dma_map_ops *dma_ops) pci_dma_ops = dma_ops; } -const struct dma_map_ops *get_pci_dma_ops(void) -{ - return pci_dma_ops; -} -EXPORT_SYMBOL(get_pci_dma_ops); - /* * This function should run under locking protection, specifically * hose_spinlock. diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c index fb51f78035ce..93c7e4aef571 100644 --- a/arch/powerpc/platforms/cell/iommu.c +++ b/arch/powerpc/platforms/cell/iommu.c @@ -544,6 +544,7 @@ static struct cbe_iommu *cell_iommu_for_node(int nid) static unsigned long cell_dma_nommu_offset; static unsigned long dma_iommu_fixed_base; +static bool cell_iommu_enabled; /* iommu_fixed_is_weak is set if booted with iommu_fixed=weak */ bool iommu_fixed_is_weak; @@ -572,16 +573,14 @@ static u64 cell_iommu_get_fixed_address(struct device *dev); static void cell_dma_dev_setup(struct device *dev) { - if (get_pci_dma_ops() == &dma_iommu_ops) { + if (cell_iommu_enabled) { u64 addr = cell_iommu_get_fixed_address(dev); if (addr != OF_BAD_ADDR) set_dma_offset(dev, addr + dma_iommu_fixed_base); set_iommu_table_base(dev, cell_get_iommu_table(dev)); - } else if (get_pci_dma_ops() == &dma_nommu_ops) { - set_dma_offset(dev, cell_dma_nommu_offset); } else { - BUG(); + set_dma_offset(dev, cell_dma_nommu_offset); } } @@ -599,11 +598,11 @@ static int cell_of_bus_notify(struct notifier_block *nb, unsigned long action, if (action != BUS_NOTIFY_ADD_DEVICE) return 0; - /* We use the PCI DMA ops */ - dev->dma_ops = get_pci_dma_ops(); - + if (cell_iommu_enabled) + dev->dma_ops = &dma_iommu_ops; + else + dev->dma_ops = &dma_nommu_ops; cell_dma_dev_setup(dev); - return 0; } @@ -1091,7 +1090,7 @@ static int __init cell_iommu_init(void) cell_pci_iommu_bypass_supported; } set_pci_dma_ops(&dma_iommu_ops); - + cell_iommu_enabled = true; bail: /* Register callbacks on OF platform device addition/removal * to handle linking them to the right DMA operations From patchwork Tue Oct 9 13:24:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632559 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 519A4112B for ; Tue, 9 Oct 2018 13:27:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 478CE289C4 for ; Tue, 9 Oct 2018 13:27:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BB9B289F5; Tue, 9 Oct 2018 13:27:04 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC68F289C4 for ; Tue, 9 Oct 2018 13:27:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 48F076B0285; Tue, 9 Oct 2018 09:26:20 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4192D6B0288; Tue, 9 Oct 2018 09:26:20 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23E3C6B0289; Tue, 9 Oct 2018 09:26:20 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id CB1466B0285 for ; Tue, 9 Oct 2018 09:26:19 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id m3-v6so985835plt.9 for ; Tue, 09 Oct 2018 06:26:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=GyWd0Lo9AxD2VefpnzNk6M6Gl77/Y8uKx1+B97yGPx0=; b=t9oAYxN+KTOdnxElobR0+baXf06g934Sbc3R6spd9e092jhpppoP5q8vqJbZvnKNzm srVwOvpdOrixLNDX5T+ayo1q3gN2vgJgg9xcJfLF+l/0zAfiQ6cLaAlpohbsu/nTMcYQ njCC2+lrCw9MJYuG06yJDpIYIQ5mEdOy1buBLONq0PQlc/vpJ7JbzNTvrrK2AsNe6/go PImm27K8LCbz4iG9caq/DC0UZikkY+6C+Vffdz5eeo606zcU8EzGhZm7R7+gNHZ/RsRH lVp7wFCkFzTHok0eC9Bj/ntXhwHdAqoBL/9hzNRKaAGOKWcDzekviIZAL3E8qDO9tEkp iwJg== X-Gm-Message-State: ABuFfogVU1DE4+JEfUGj0doDejpNvaVHF4APpixIx+rOefgoeS90sCic 0fevMazXFoq9N7jnUq9JUqqjsibIfGQ5AzS7ajxMKQGN6VrAeHWJYdUXiERH/eZfA145ZQcVm2j +CCkABZlkvKhvDfFnwEj5oqCRdbJHozpowCVKy+BB6HSqUKixFldKYEZJe2CPNk0= X-Received: by 2002:a63:ba5e:: with SMTP id l30-v6mr25599907pgu.76.1539091579521; Tue, 09 Oct 2018 06:26:19 -0700 (PDT) X-Google-Smtp-Source: ACcGV62fFHmDk+iG4cTHsjMsFKR5VIb1f7LZEu1MNJ5pvhBEmazc1dMC8iurpQ9L1TC2twPQPU6z X-Received: by 2002:a63:ba5e:: with SMTP id l30-v6mr25599857pgu.76.1539091578749; Tue, 09 Oct 2018 06:26:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091578; cv=none; d=google.com; s=arc-20160816; b=oqLZUUQqBdIMa6r+dqI1DihLxPWFRHIZel73P56NLYoP69JzFdC/flDVn37amnFjSU LYAPQcRY/TzBK1kekbPu0jJjimlufx/F/T5WBuO+U/yv+iGLRLitRsc7/oQPwXWVtCPi 96cjHscZtWhTY1ProcX7LbrxhySv7vZjdsq0sdsMZS/4345xIwykgGlXWzYWiMuIdxe6 H5kolSJWInBWBLSaB4zLn0UOAatoVFXJR1u3DpBQKs1jH5tB6ANGxPapVbnBUrQUcdw5 bsj/bKeoqc+ZOW2CTJu2PiTIbq+TCq7LATnh1ixSapPfpokvJY9/rINm/IS5kL8CWFoe eNbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=GyWd0Lo9AxD2VefpnzNk6M6Gl77/Y8uKx1+B97yGPx0=; b=Z+dECQJFruJ7D0sc7kIsCrsZbM4qOqjngTXpQAsBU9hbUc9BWPxl0Q8PPhZ81JZHb/ C+rw5kLgXGz4Kw0m9tOrw2qe38ht/8aCZIIknCc/7SIJjXBd9E9Rx/P/HlkSr4sCwDt1 eDdfsxOYyeFfz3ttlLrtH7jVlRd4m9mYfv8He2sqlob8rHUDQiwM9Hca5UA6pYMoqUcK r2Rk/sUHCjuQO85PAN+CoQppDYQf2wT9NCFrQMCR37A7gfHciz2v01OXqkb0++W/Smfe 2v8CmR4sQahLd2/8h/uEVrhS1dAxN3SWsZABnHJWly3/UC0tVPvW4su3z/PXNbaSxtGn ILFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=BMOV8qXB; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id g189-v6si19667977pgc.204.2018.10.09.06.26.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=BMOV8qXB; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=GyWd0Lo9AxD2VefpnzNk6M6Gl77/Y8uKx1+B97yGPx0=; b=BMOV8qXB41wC4W8/bbi3aYrijK TlI8/2FhwFlmlxnQQrJh6ZE76liyoTcn7el9pv24SU+6iiDV3Kxc0mHG1f9i0ZbSqOhURcKDWewm1 EfRV03cAbTTLgrvv68mqwEf2F91FqHyCjkzumggZTr5SaQhp0xu6LzuXQk6O3N9cCtPR9FlPiXjQY jVJa9JtYvg6KDlPdcWHczJYiwuJJ3Apu0rvzMvW55b//86+oeHpZIyefr6QbhhFb26WuEmzm9O1P7 szFvBivrpmQun3tvnXcED0SxsLghN8ErfOU46mqp0rhhUc8snhrlztJCfXcvALdRDcUcrOT5Dqe2X XQPYiDyQ==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s1O-0001OL-GI; Tue, 09 Oct 2018 13:25:58 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 22/33] powerpc/dma: move pci_dma_dev_setup_swiotlb to fsl_pci.c Date: Tue, 9 Oct 2018 15:24:49 +0200 Message-Id: <20181009132500.17643-23-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP pci_dma_dev_setup_swiotlb is only used by the fsl_pci code, and closely related to it, so fsl_pci.c seems like a better place for it. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/swiotlb.h | 2 -- arch/powerpc/kernel/dma-swiotlb.c | 11 ----------- arch/powerpc/sysdev/fsl_pci.c | 9 +++++++++ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/include/asm/swiotlb.h b/arch/powerpc/include/asm/swiotlb.h index f65ecf57b66c..26a0f12b835b 100644 --- a/arch/powerpc/include/asm/swiotlb.h +++ b/arch/powerpc/include/asm/swiotlb.h @@ -18,8 +18,6 @@ extern const struct dma_map_ops powerpc_swiotlb_dma_ops; extern unsigned int ppc_swiotlb_enable; int __init swiotlb_setup_bus_notifier(void); -extern void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev); - #ifdef CONFIG_SWIOTLB void swiotlb_detect_4g(void); #else diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c index 93a4622563c6..60cb86338233 100644 --- a/arch/powerpc/kernel/dma-swiotlb.c +++ b/arch/powerpc/kernel/dma-swiotlb.c @@ -63,17 +63,6 @@ const struct dma_map_ops powerpc_swiotlb_dma_ops = { .get_required_mask = swiotlb_powerpc_get_required, }; -void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev) -{ - struct pci_controller *hose; - struct dev_archdata *sd; - - hose = pci_bus_to_host(pdev->bus); - sd = &pdev->dev.archdata; - sd->max_direct_dma_addr = - hose->dma_window_base_cur + hose->dma_window_size; -} - static int ppc_swiotlb_bus_notify(struct notifier_block *nb, unsigned long action, void *data) { diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c index 918be816b097..561f97d698cc 100644 --- a/arch/powerpc/sysdev/fsl_pci.c +++ b/arch/powerpc/sysdev/fsl_pci.c @@ -114,6 +114,15 @@ static struct pci_ops fsl_indirect_pcie_ops = static u64 pci64_dma_offset; #ifdef CONFIG_SWIOTLB +static void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev) +{ + struct pci_controller *hose = pci_bus_to_host(pdev->bus); + struct dev_archdata *sd = &pdev->dev.archdata; + + sd->max_direct_dma_addr = + hose->dma_window_base_cur + hose->dma_window_size; +} + static void setup_swiotlb_ops(struct pci_controller *hose) { if (ppc_swiotlb_enable) { From patchwork Tue Oct 9 13:24:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632561 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E0F6315E8 for ; Tue, 9 Oct 2018 13:27:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2F7A289C4 for ; Tue, 9 Oct 2018 13:27:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4C1B289F5; Tue, 9 Oct 2018 13:27:08 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C045289C4 for ; Tue, 9 Oct 2018 13:27:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 663226B0288; Tue, 9 Oct 2018 09:26:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5E77E6B0289; Tue, 9 Oct 2018 09:26:22 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 489FC6B028A; Tue, 9 Oct 2018 09:26:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 00D296B0288 for ; Tue, 9 Oct 2018 09:26:22 -0400 (EDT) Received: by mail-pl1-f197.google.com with SMTP id s24-v6so973356plp.12 for ; Tue, 09 Oct 2018 06:26:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Z1NpYAlNjtOl6wtV5jUw9RPikGAiju1XuiWRoBAFPXo=; b=ctFjVnL6RuNyIelJ+FLVvU40aXmeyyeEo83liMDA6olLhyPAn7vqBVV/zSDWc05oTC fVES2sLK836+q3PQ50bCh4gUew+ic/fRf4E7Yn5hDNgEplnksEiWPiw+oaA+725Dih+7 41u61c1r5sfTaVcc14CXJ2gjodUKTLz1cScnQdnewoGsJNWHtQJAyKKoGBm26yqxx7f/ vh9x0vSvRFSjVfF5wCVCRiFPTdjw3jXwA9PRDFZ7DnrU0GVRQkIhVBAVzNCuwU/wkaWW 9Aucc8xnn1J+t4M95GCQJMBSO3NeSsaYvAFzt+gGZPx7n49Z0P1L2KHyWf7OkLOlWAYc KDAA== X-Gm-Message-State: ABuFfojf2rOI2WZ+STinQ7k1jkpE6v0NhaCmx7JK1++L3RmupD5ilw0T POeVsuokGLdwvNjJQqBrorp+owTXIKqvpYl6KD8oHfr+M8JYufTwTdJc6C2xZwJxgKuptXWzqgo K7pXHYOEUD7IrnvcpgJo5gL1RzqgND0qBFR5KCEnCpNwRuHh0VabpJfGsN8z+d30= X-Received: by 2002:a17:902:1e2:: with SMTP id b89-v6mr29174250plb.296.1539091581674; Tue, 09 Oct 2018 06:26:21 -0700 (PDT) X-Google-Smtp-Source: ACcGV61qOC9dAeSSew3BPP6OAgezey0UV+BzXPyAyKDOS3XxrGxlv20xAls5QNz8FDHwFIq+Fut0 X-Received: by 2002:a17:902:1e2:: with SMTP id b89-v6mr29174200plb.296.1539091580912; Tue, 09 Oct 2018 06:26:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091580; cv=none; d=google.com; s=arc-20160816; b=a/wh8AmSIu63PDT8f9BP5bF+S9quQXsYavxmsUAaYwMBPBltc9WDkDrQXn0+Vk7PWG QZhevRI02NL+lIETOvxp7WvSgRDJ0NJua/1Q0b+zB0BzjsPK64hgvTqAOUU+LcyRmX3x bESjNv/Rz5TX5DiCxjeM7HnvgN02Pz7XKdqT4r1w5MxBHKN6YFegLYGzs5a51o2N9JX6 YtG09orYdTlRqfAXzNuJQC0owHzVRtr4tE5UwJR/52cWtuL+6RhmSfRuVbIPYEXoNmkx S3dX7bWCnFHf5XbcXBIuH8n9KS5H4MAvE3ydGibCL3WhABq1hJ4/Sx8WEziLHXMI9LHX GX8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Z1NpYAlNjtOl6wtV5jUw9RPikGAiju1XuiWRoBAFPXo=; b=DGcU86FjfF30nThTsL37IwHB/07jnLkfQbxRPc7qcT1t362J65a0I97aF3uR/nzv4K StKjUpbK2T2Dl+gIC+rvU5XTfT6pCUR2AIiEYaozxCOqySUhJFBEshjMIH4OW8miFmDI TNuTVP2Y0dDjKbHRBkxbYj3u6queLiXPv6/OGFe0UMRes0G71eyNdWYJnJKkUIVMbOdI s72rBmPrrmbtAqV/4oCgO6/PlY/27oiPKI71pwAIQdJxnQK6nR3cFmRz2an+5WXjV2UL HTyRDtowRPAU46BIPIlnLbLmjJWi+3ULLPH/42CaQryJeShJzx9Y0qE6/9BxzwIb6zts xGbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=i9L1kOia; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id 17-v6si16975711pgz.577.2018.10.09.06.26.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=i9L1kOia; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=Z1NpYAlNjtOl6wtV5jUw9RPikGAiju1XuiWRoBAFPXo=; b=i9L1kOiaNfNO/7tZVTeWRXi2kz I0a1agaNzMsnb522ajukDtVwUPc2LpL27ozdBJ9e5zSvgje4+azhFCnTPzq6vLxMZgdUN7m52NRQp EDpw5ZUT7Z6yCVZGESJ9dPHF1jbJHlO9WSTQSey4XLseB6F6FlZJQWvgyRddKIuQClZPLZaNk4FOF DpOYFj/AJjdwhKFwLk/V+ZH1Bfk29QjQK6S+yhwnLgxpjmgUsSfD0VcnXjNcoXyaxA0AhNvUvVSZv Qtx828RuRHH8+AZ8OyeY+W+Zhpa2Z4MghUPWbV0g6EmjVD3KbNucebmbE/xEt5rGEp/L/XGWFa9QD cVc3bl+Q==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s1R-0001Q3-5q; Tue, 09 Oct 2018 13:26:01 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 23/33] powerpc/dma: remove max_direct_dma_addr Date: Tue, 9 Oct 2018 15:24:50 +0200 Message-Id: <20181009132500.17643-24-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The max_direct_dma_addr duplicates the bus_dma_mask field in struct device. Use the generic field instead. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/device.h | 3 --- arch/powerpc/include/asm/dma-direct.h | 4 +--- arch/powerpc/kernel/dma-swiotlb.c | 20 -------------------- arch/powerpc/kernel/dma.c | 5 ++--- arch/powerpc/sysdev/fsl_pci.c | 3 +-- 5 files changed, 4 insertions(+), 31 deletions(-) diff --git a/arch/powerpc/include/asm/device.h b/arch/powerpc/include/asm/device.h index 3814e1c2d4bc..a130be13ee83 100644 --- a/arch/powerpc/include/asm/device.h +++ b/arch/powerpc/include/asm/device.h @@ -38,9 +38,6 @@ struct dev_archdata { #ifdef CONFIG_IOMMU_API void *iommu_domain; #endif -#ifdef CONFIG_SWIOTLB - dma_addr_t max_direct_dma_addr; -#endif #ifdef CONFIG_PPC64 struct pci_dn *pci_data; #endif diff --git a/arch/powerpc/include/asm/dma-direct.h b/arch/powerpc/include/asm/dma-direct.h index 7702875aabb7..e00ab5d0612d 100644 --- a/arch/powerpc/include/asm/dma-direct.h +++ b/arch/powerpc/include/asm/dma-direct.h @@ -5,9 +5,7 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) { #ifdef CONFIG_SWIOTLB - struct dev_archdata *sd = &dev->archdata; - - if (sd->max_direct_dma_addr && addr + size > sd->max_direct_dma_addr) + if (dev->bus_dma_mask && addr + size > dev->bus_dma_mask) return false; #endif diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c index 60cb86338233..e05d95ff50ad 100644 --- a/arch/powerpc/kernel/dma-swiotlb.c +++ b/arch/powerpc/kernel/dma-swiotlb.c @@ -24,21 +24,6 @@ unsigned int ppc_swiotlb_enable; -static u64 swiotlb_powerpc_get_required(struct device *dev) -{ - u64 end, mask, max_direct_dma_addr = dev->archdata.max_direct_dma_addr; - - end = memblock_end_of_DRAM(); - if (max_direct_dma_addr && end > max_direct_dma_addr) - end = max_direct_dma_addr; - end += get_dma_offset(dev); - - mask = 1ULL << (fls64(end) - 1); - mask += mask - 1; - - return mask; -} - /* * At the moment, all platforms that use this code only require * swiotlb to be used if we're operating on HIGHMEM. Since @@ -60,22 +45,17 @@ const struct dma_map_ops powerpc_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, - .get_required_mask = swiotlb_powerpc_get_required, }; static int ppc_swiotlb_bus_notify(struct notifier_block *nb, unsigned long action, void *data) { struct device *dev = data; - struct dev_archdata *sd; /* We are only intereted in device addition */ if (action != BUS_NOTIFY_ADD_DEVICE) return 0; - sd = &dev->archdata; - sd->max_direct_dma_addr = 0; - /* May need to bounce if the device can't address all of DRAM */ if ((dma_get_mask(dev) + 1) < memblock_end_of_DRAM()) set_dma_ops(dev, &powerpc_swiotlb_dma_ops); diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index bef91b8ad064..e3d2c15b209c 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c @@ -30,11 +30,10 @@ static u64 __maybe_unused get_pfn_limit(struct device *dev) { u64 pfn = (dev->coherent_dma_mask >> PAGE_SHIFT) + 1; - struct dev_archdata __maybe_unused *sd = &dev->archdata; #ifdef CONFIG_SWIOTLB - if (sd->max_direct_dma_addr && dev->dma_ops == &powerpc_swiotlb_dma_ops) - pfn = min_t(u64, pfn, sd->max_direct_dma_addr >> PAGE_SHIFT); + if (dev->bus_dma_mask && dev->dma_ops == &powerpc_swiotlb_dma_ops) + pfn = min_t(u64, pfn, dev->bus_dma_mask >> PAGE_SHIFT); #endif return pfn; diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c index 561f97d698cc..f136567a5ed5 100644 --- a/arch/powerpc/sysdev/fsl_pci.c +++ b/arch/powerpc/sysdev/fsl_pci.c @@ -117,9 +117,8 @@ static u64 pci64_dma_offset; static void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev) { struct pci_controller *hose = pci_bus_to_host(pdev->bus); - struct dev_archdata *sd = &pdev->dev.archdata; - sd->max_direct_dma_addr = + pdev->dev.bus_dma_mask = hose->dma_window_base_cur + hose->dma_window_size; } From patchwork Tue Oct 9 13:24:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632563 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 43745112B for ; Tue, 9 Oct 2018 13:27:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 391DB289DF for ; Tue, 9 Oct 2018 13:27:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D54F289F5; Tue, 9 Oct 2018 13:27:13 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADD67289C4 for ; Tue, 9 Oct 2018 13:27:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C7E76B0289; Tue, 9 Oct 2018 09:26:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 350966B028A; Tue, 9 Oct 2018 09:26:24 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F3C96B028C; Tue, 9 Oct 2018 09:26:24 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id CD8E56B0289 for ; Tue, 9 Oct 2018 09:26:23 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id v7-v6so955442plo.23 for ; Tue, 09 Oct 2018 06:26:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=VVrA3gX4S4aK9b26/sI5R8iiOEO8w46y03v4nt2GxbY=; b=HxRgkmT4P3aVtGAPlCto9OnMLCR+z/RuVYgUO2PuEe2sHUmVixD2FS7B4x+my32g1P JOuMK2BagO8K+uYqXwvcSK0tC8OMbrJsFMbozPw2LuVcJeVZj8TREqKcQYRGtyy4c0vq MKuiSxIb/euyUKzTrGu12hfoyNLgfmHAe0JB85B73xnZD0Ujogc02D1AZA5L8ib4dHZL T1lKdDQueQq9VQ+kT+dVB23shzHr/+Z9T8QY6IdlJ0O3oMCpfGTu4WdwdBa5l3RzhHUg xZhDRzB9T3K2pzUIYApXcgU+FfWyDfAMrKFHJWwjZB48JqxbzOAVwRpxEmBK++FUNDYe ZzbQ== X-Gm-Message-State: ABuFfoig8V8xLTqsU/0caJYXzoxPAB+FqIQ+J+XKFC0kDutAKACOpHrj HFfcMFmnsnj2vglSc+w3yqHG3eLIQbcWwBFDEdYN8zQq7DGfSvRRWQtdyXWcwUaKL0eKC2J3giy lQoV+k0Rvdc4c4F6H0CKfeGOYjwUkkE7mQMp+UOxzJLPUqA91ZuMkjrCG5IUUf5E= X-Received: by 2002:a63:9b09:: with SMTP id r9-v6mr25713344pgd.307.1539091583533; Tue, 09 Oct 2018 06:26:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV61xEiVcq/jaglt9GYqkfGAvWjRKQhZ0rMR/fk1kKaeIn1nVpGMEHmOD1nsDg7+/+LL8cHSJ X-Received: by 2002:a63:9b09:: with SMTP id r9-v6mr25713310pgd.307.1539091582885; Tue, 09 Oct 2018 06:26:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091582; cv=none; d=google.com; s=arc-20160816; b=rzRXbM0UAcYER/MZriggnEiDJ1bEBQyOxY+LBC7Kslm7hXHZQcN7QrjMq03anVoMEQ bLNrx+b65kwbanRpXQehRjHrpLA/6W2FrVID35i5vOYUVbts8VeI474vPzj03xJWayCM Y8VzJ1t24YLW9R1q03EhUr4zZPf3TiMJbZtcOBG+YR+/Nn5gs7n8CwkRqQXY8i4GTw/5 oMlYT/yHUk0n72rTUE2lQu75fbPJay1hntFHBUOMx+Q+45tJhFG3p210xU4ZbwFdgqSj rqULBdvuL2Salz7BQWHOTem08EV3UqQ8EHQRV1i2e2za3m58NPIdwPZagWMDeTcs/BNE bDnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=VVrA3gX4S4aK9b26/sI5R8iiOEO8w46y03v4nt2GxbY=; b=vgttMvYLsod0D20T7iuxumZtl1fiIW71xVtvzRUE3yfBTiQEHPCi07EpulrbCK6c09 caZuha4sTfi79AueQ3EfNVeoM8TXAshAxBk5L/zf4bkt+4YKbFB5aIt9dfindZw9TgZ0 tf8QB5ORCklQkjsD8GkK7HLOuO9iCGt0C5zH5SxkLGEvhdnxPFGTnpB1YsVQqQAq65aU mTYyRm/0+bOth5udbFbI7AWTgNtofcWbjk/RRdKcizSZYMbpazJp5A6sIEfYZDcPQO1a Uxv7cUP1vjTzqRxxEiNv9vo55MqqZkaMfxXpZHK6MLKxn44kUffoT8haGIaloqtVZV19 QnuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=JvHYW2+N; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id p9-v6si14611530pfh.232.2018.10.09.06.26.22 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=JvHYW2+N; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=VVrA3gX4S4aK9b26/sI5R8iiOEO8w46y03v4nt2GxbY=; b=JvHYW2+NRx9uTFwvGoZUB3K994 Ltj4pFTEi1yyA7kwBwtmRHbedPTrG3gCPqY3wCtb3bZJEHjCU/sqzXnuLSNkRz+Gvu7vpO0Rls4T3 CEuP5xLYrWxsf1knWSzpOzUEjS/OdZMAKeCH2kieVo4v18xgHP53xYO+2HBmp6cuRYbJiS6eSWB9t KdmnUzrgjecB0KlFQoVB+hDIWFA7Gby/cIUFD544mthDIRFUSigTLJw/Hmmc1Z5LdqBHR3DB+daMT GFAtYLTlaT7t9DmlVXFMS50N0RdDWG4thjLXBau8unoiIp7Q7coMJg57S/4wMHn4/1Iu1QPE9dC9G WbMOli/w==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s1T-0001Rf-QG; Tue, 09 Oct 2018 13:26:04 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 24/33] powerpc/dma: fix an off-by-one in dma_capable Date: Tue, 9 Oct 2018 15:24:51 +0200 Message-Id: <20181009132500.17643-25-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP We need to compare the last byte in the dma range and not the one after it for the bus_dma_mask, just like we do for the regular dma_mask. Fix this cleanly by merging the two comparisms into one. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/dma-direct.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/include/asm/dma-direct.h b/arch/powerpc/include/asm/dma-direct.h index e00ab5d0612d..92d8aed86422 100644 --- a/arch/powerpc/include/asm/dma-direct.h +++ b/arch/powerpc/include/asm/dma-direct.h @@ -4,15 +4,11 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) { -#ifdef CONFIG_SWIOTLB - if (dev->bus_dma_mask && addr + size > dev->bus_dma_mask) - return false; -#endif - if (!dev->dma_mask) return false; - return addr + size - 1 <= *dev->dma_mask; + return addr + size - 1 <= + min_not_zero(*dev->dma_mask, dev->bus_dma_mask); } static inline dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr) From patchwork Tue Oct 9 13:24:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632565 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE56813AA for ; Tue, 9 Oct 2018 13:27:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3542289DF for ; Tue, 9 Oct 2018 13:27:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6CA828A5D; Tue, 9 Oct 2018 13:27:16 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69EB4289DF for ; Tue, 9 Oct 2018 13:27:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 492056B0291; Tue, 9 Oct 2018 09:26:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 378FD6B028E; Tue, 9 Oct 2018 09:26:25 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 21EC66B028F; Tue, 9 Oct 2018 09:26:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id CB6C66B028C for ; Tue, 9 Oct 2018 09:26:24 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id f4-v6so1102505pff.2 for ; Tue, 09 Oct 2018 06:26:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=2smE7t1ubnM/aBYiGbsyFVtZBSQMbwLYlNYKOPwJFGE=; b=WCR4vMn/kaiD7TER1mfa4Ulb9gxW/b1cffPrUw/RlHSaSYTLyi+gbn7rIpiBBFVGVP 1H7wWVDV0eZFF3hLXTWrUK+iBi+s27wE0XSaqIeDOMiu7+8XqAfo22yVTv7L/8vdVnZZ 0LLf9LHvOFmE3eSS+Gy6UDFTy7gtWM7/x23A0RHVO4d2vxCJ8n3tfBdYUWMsNvMrz4Lq wOg0cRCacmZGX+70a3hptKxntV8y8GdLEyYScEjyBdqnZAFa9CQ1zxTnWOpwctg47X1o oYaWmexc3if7QnpKtG7rlxf2WsY7hWf/9muanOYokfGyDso9qMkDuMczYceV5NOnOsql X6NQ== X-Gm-Message-State: ABuFfojBXVoeLtg+p+MRv7I9SKGTF1/FlHKB9UaXbjN68JYp4PTNqAes FHP19cj+y4dyPlGVDMtfMiPPQ62O2Fppa0tkCMAHbZsDzNSx6BUBHNtAWIRtmnC3S23iQ0Dhrkt XKkORLNVL/a9TVpef5f0yGfGnciialAfjLm2UJb/RNYac98alNhL7vL46UFRyoAk= X-Received: by 2002:a62:104b:: with SMTP id y72-v6mr30209917pfi.113.1539091584529; Tue, 09 Oct 2018 06:26:24 -0700 (PDT) X-Google-Smtp-Source: ACcGV60c1zR0SO76leyXV4OlBaO5Sp7arX5oB9Mv+TrDeFWDyRo/cRcR5OOu/4rf/r76zjdCNzSs X-Received: by 2002:a62:104b:: with SMTP id y72-v6mr30209872pfi.113.1539091583794; Tue, 09 Oct 2018 06:26:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091583; cv=none; d=google.com; s=arc-20160816; b=nxIEfIFQzonseoa0A2EpvG5lB91DOmaWI6FZiNK49OYuuiyD686Qe3OqEBRGTuDDau 7z1AhPxKNExQHpWiW0t1SksV9szthPzkrgQFFYU6Ge2ZOhA87vTes1Z/UZKW8hr1dDqd dmIAvBUFR35nxT4HMTWTMsJfImJOzJFtKTUAQl0+5mTlbgp8Jc+7caIhxuEBLAJKFD3I x6aAJqAAQtJGFSdC5E6Pk8gKFayGZVX/OwnUFdGY9URYNz6uou79nS0uYX9EUh/6wZWy f73AxkRbaBuFySviG/YG0Qj2vWJUYmY3JPLOrtX63AH1y0dRNdziwh4MltLWDA/wDdeE R8jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=2smE7t1ubnM/aBYiGbsyFVtZBSQMbwLYlNYKOPwJFGE=; b=ZklgH0J4hgxm6/w6ASzlbyht2I1hMkXrFFaVdYHQ4xPHriFe+yS9rhXADaPEbWOnQW f83oOWgwzfnMyzz/l1OqEoBagy7TlwBYSDyuDAk9aIr4dldI9Ak+9n1xoWHzr5HgzY5s RBArostReQE8WvL6HTG1d7UdaphQpwHFIDXFO4PpmJYwiwhzVd5qd0zH4pM4xZMn80sp tXunJLv00faPYjgrJl8Dtf4LLrQEjReYeloBxCtyQpfXhJCsApfGsXQ7yMU5qV4+ruKf KryRywdrfKK8BL2jwnuBqLVFF4ZvNBZMOik+nYfibHSiDH+SrXWPRVfikuoHS4k8rPp1 /z7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Ad4Bp8Y4; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id f94-v6si24786490plb.10.2018.10.09.06.26.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Ad4Bp8Y4; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=2smE7t1ubnM/aBYiGbsyFVtZBSQMbwLYlNYKOPwJFGE=; b=Ad4Bp8Y4dt+Sx1b+QODbLDE7jW qp3pnjRMZpzX4bSQV88DBJK7v7Lgn0m5NOQfgSEZCvvITTzqoNr+CddsojnVnWlmEsB32lIH4sHzz V24jwBHBDcpZ5eRtcvXvY0jubjpjqEwHaAILEnL8H+jHXN1JXpjhByXksdT2zV9z9X70sbeIkKtb+ mrUqpNwE3WbmPAOCLbhFHzWzP/JMJfpERrXPmznPR27oG3IOkfCR8U+dQDnvwDfUZiebEnI+OIUVJ XbQr7VAN3MCoQX4trkMweV2hHV8F62mxD9M+2yo+pc5s+DuTf0wB5b/EjlCp25EVPHcySO4Rh14hn ze/6Lmog==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s1W-0001TF-8H; Tue, 09 Oct 2018 13:26:06 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 25/33] cxl: drop the dma_set_mask callback from vphb Date: Tue, 9 Oct 2018 15:24:52 +0200 Message-Id: <20181009132500.17643-26-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The CXL code never even looks at the dma mask, so there is no good reason for this sanity check. Remove it because it gets in the way of the dma ops refactoring. Signed-off-by: Christoph Hellwig --- drivers/misc/cxl/vphb.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/misc/cxl/vphb.c b/drivers/misc/cxl/vphb.c index 7908633d9204..49da2f744bbf 100644 --- a/drivers/misc/cxl/vphb.c +++ b/drivers/misc/cxl/vphb.c @@ -11,17 +11,6 @@ #include #include "cxl.h" -static int cxl_dma_set_mask(struct pci_dev *pdev, u64 dma_mask) -{ - if (dma_mask < DMA_BIT_MASK(64)) { - pr_info("%s only 64bit DMA supported on CXL", __func__); - return -EIO; - } - - *(pdev->dev.dma_mask) = dma_mask; - return 0; -} - static int cxl_pci_probe_mode(struct pci_bus *bus) { return PCI_PROBE_NORMAL; @@ -220,7 +209,6 @@ static struct pci_controller_ops cxl_pci_controller_ops = .reset_secondary_bus = cxl_pci_reset_secondary_bus, .setup_msi_irqs = cxl_setup_msi_irqs, .teardown_msi_irqs = cxl_teardown_msi_irqs, - .dma_set_mask = cxl_dma_set_mask, }; int cxl_pci_vphb_add(struct cxl_afu *afu) From patchwork Tue Oct 9 13:24:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632577 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 93E7C112B for ; Tue, 9 Oct 2018 13:27:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CC14289DF for ; Tue, 9 Oct 2018 13:27:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 816B928A5D; Tue, 9 Oct 2018 13:27:45 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 173ED289DF for ; Tue, 9 Oct 2018 13:27:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB8016B0294; Tue, 9 Oct 2018 09:26:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B4AA66B0298; Tue, 9 Oct 2018 09:26:42 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E70F6B0299; Tue, 9 Oct 2018 09:26:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 47C316B0294 for ; Tue, 9 Oct 2018 09:26:42 -0400 (EDT) Received: by mail-pl1-f197.google.com with SMTP id f5-v6so975523plf.11 for ; Tue, 09 Oct 2018 06:26:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=rhvZ9hpGPuuxCEIVPRN0AfR1n9umfTu+Rj50rDnMvn0=; b=rQZNtocuSJCvcRe3C30o7BXhxlixGMi9aWwcpRNND10kdtgQz2HlQlwNveX+mTdOZ3 rnB+1yu1aeqA91YDQG4wozdgq1/1yjtlKKkBAtXoXifwH30nt4r9OmO+JraXnyN8qQQY QfV1WwfbnXhXWE2XxvkkJddhRyUeBGbrpJ2dPnpNoFYE9DONfBi/L3N7wARfddwSg7KV bgC94BVfwyw1fFy+kfSGRFfEBFXsgjaL1YesSeH/TopG+Ax+CnRQs0N6pdmPG9lUsos/ fNvvmnRxdXga+CUx4CVaTy+fVW7haKascwooaDyJXNIaNL+HVJiXEjTuiGlHvPUxOq9u R5NA== X-Gm-Message-State: ABuFfohfpXoyCuyWqze/VUi+rbFuZtJRiXqlQfEZqdWzgi/5dMvkpU7h 1DVN314hRkKLHdBUOKqESw5yPXB9irCzsv1FdpHJAeKMqALpTBr+02aGWfXV5sl334wA8Mwomaf 7PRvlOZ42NKLHWr7NLRqf08nBdQ7iICwjzaDY7wcVtfGUK+OmEG6sheDvMAk/puU= X-Received: by 2002:a62:85cb:: with SMTP id m72-v6mr29892401pfk.173.1539091601989; Tue, 09 Oct 2018 06:26:41 -0700 (PDT) X-Google-Smtp-Source: ACcGV61o4CUzvr+qOFimcY74DNpZEdfMLI5A9gXSbe+vZHyalQBobPF5jBg3BlWf2/D9ImecM4uT X-Received: by 2002:a62:85cb:: with SMTP id m72-v6mr29892358pfk.173.1539091601216; Tue, 09 Oct 2018 06:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091601; cv=none; d=google.com; s=arc-20160816; b=McOT2wGocRFJ/9LQurC9Nfc/vnxUNJWIdg0VU6EmWdnlGSfnNCbLaAj07auWOIxaAr +y33EkZpCdf+Vxzqb0HjiuNDPytYfr9xVZmotZ8asEoGPxH/iRNkv57lbSPd1pcugABx CA3Yoh0x0G+WtwyFaBOaqNx5Ng7/vH0+9Ie5BZ/q09ZkVAA4/VObr1lbFOtBsa/043Dy gSzMDTjvI3DKc+oYWUvYjxW676eO76CObESLsHQE7tQm8nFrI4yyLNlcXtUsClzrLKQT 18JYpV5JDY7znDleUIQP0CT5XqucnsldfpbyeFpQTEsn4BWSftQrTE05d1PbES3qVRZj YAAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=rhvZ9hpGPuuxCEIVPRN0AfR1n9umfTu+Rj50rDnMvn0=; b=X7l6UHM2xM5mUExAWq3bQt0ZQQz5Q2WD1Xqz1MT+D45CFKNBbsAmLvqXgt6x+GPutu GezLBV241qZm4s7ocMvb93lrFg03G1begXPYY98PjX1VzVa3hgiMzMgS+Eb3F0gIXumk ezf4g2L3tX8CaFFN66TuPJIJyUuHYCbhV3+AeE4QR6g3aOIq9GeQkNFX1zD15uPcEtgV 6PCA653pLOMU6m3MuZpfcXvpng0EQXdkDstbRF11oc6aMGNGUaRXCPdIna2lK+CBpnON sd2Lin8s+0+XWUuFm5Hngui7kpevijoSeWzto3gr6DwDWxgv5/r18MH0rD3EN2ivd6pS rbAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=tIPTZV00; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id 16-v6si27379086pfc.21.2018.10.09.06.26.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=tIPTZV00; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=rhvZ9hpGPuuxCEIVPRN0AfR1n9umfTu+Rj50rDnMvn0=; b=tIPTZV00fcQtIlC3PL5dfu7G1m s5PDg5sM2GO4v6FDj1h95I9EvzJjKhy78N1Yhl963NGJ4q8l7M87quNsuK6TAcgA0FnZkGF7L6M3R sCXfhaSIG9gmRbeTC/mrYMcjNtOU4MquxVUF8qEcF7ld+tvHiWlAt9EXHLeCdfpKQHo9oI1uQk7sW 1QwOxcMBAVRSMC8O5QBWT9AMk5Dow2eUCHWUHIlPtgFmKULPrfJzl8dIGklp5FLEcm9HmMcOp8vFM foaJpKDlE/sSsnoiUr0dtaoS8rtZpJeSOljP95oiUU5jlbFYNSjqQFIZTYuFsR56h+0aGs1p+g0Fp Fa6712tg==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s1Y-0001VV-M9; Tue, 09 Oct 2018 13:26:09 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 26/33] powerpc/fsl_pci: simplify fsl_pci_dma_set_mask Date: Tue, 9 Oct 2018 15:24:53 +0200 Message-Id: <20181009132500.17643-27-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP swiotlb will only bounce buffer the effectice dma address for the device is smaller than the actual DMA range. Instead of flipping between the swiotlb and nommu ops for FSL SOCs that have the second outbound window just don't set the bus dma_mask in this case. Signed-off-by: Christoph Hellwig --- arch/powerpc/sysdev/fsl_pci.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c index f136567a5ed5..296ffabc9386 100644 --- a/arch/powerpc/sysdev/fsl_pci.c +++ b/arch/powerpc/sysdev/fsl_pci.c @@ -143,7 +143,7 @@ static int fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask) * mapping that allows addressing any RAM address from across PCI. */ if (dev_is_pci(dev) && dma_mask >= pci64_dma_offset * 2 - 1) { - set_dma_ops(dev, &dma_nommu_ops); + dev->bus_dma_mask = 0; set_dma_offset(dev, pci64_dma_offset); } @@ -403,10 +403,6 @@ static void setup_pci_atmu(struct pci_controller *hose) out_be32(&pci->piw[win_idx].piwar, piwar); } - /* - * install our own dma_set_mask handler to fixup dma_ops - * and dma_offset - */ ppc_md.dma_set_mask = fsl_pci_dma_set_mask; pr_info("%pOF: Setup 64-bit PCI DMA window\n", hose->dn); From patchwork Tue Oct 9 13:24:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632571 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F05C15E8 for ; Tue, 9 Oct 2018 13:27:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74B9A289F5 for ; Tue, 9 Oct 2018 13:27:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E9EF28C53; Tue, 9 Oct 2018 13:27:33 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E33A28A5D for ; Tue, 9 Oct 2018 13:27:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B5316B0292; Tue, 9 Oct 2018 09:26:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 215ED6B0293; Tue, 9 Oct 2018 09:26:37 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 08F6A6B0294; Tue, 9 Oct 2018 09:26:36 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id B5BE76B0293 for ; Tue, 9 Oct 2018 09:26:36 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id r81-v6so1082245pfk.11 for ; Tue, 09 Oct 2018 06:26:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Ql7aNHvXxzTTeGCBs2l+3pR2u55du0W8IqjAoV6Ofu0=; b=Sr7K8G2MYh47bSseC4Dbejwy1ATlR2rQTj6DG7o//MH+ZgMbEwdKZrHfpqmjwDggK8 nXowOpwYzfH3amw/MbNOc/X7bgpFLJDEZoozGq+svhum0IMOoGkx2E+eB7kS0tuQsnDc 6VYaowR7PL4wxGqWmWAtcWt2WRZ1hzGm86JqsDAzEmbb9QnY0MSuilPUKBPmsj163NfU pyRQWX+XAX3FOYFTbEqxs65COGH7SOdb8JnG5Ppo2CR0aUu9Ij4pvYnUrTjKhiqyspQZ N3iumshm77+nN/eE1Dc1LWeUjEHhnsItfj23oXhxl4fvf5vH5XVEBsQ4v4IJFGiTr3xs Jvgw== X-Gm-Message-State: ABuFfojlEUC+PMdR2b4RS0EtN5kINQX9meI3ZoRHFwU1tRlW702JCUBd Nxf6YmHwvv1ppyo0aaXXnAT8wKesIlRb5er8UCOm3JwiZpr9+ODqyLOCDPWubfbXwQltgKTIkCk ZRSxEPI7YNRMl3dvX25ejg1Km6yk+f2e1l71eLdmrPbGUAZbuZe+/LEXSig5fl/0= X-Received: by 2002:a62:8a91:: with SMTP id o17-v6mr30411081pfk.184.1539091596373; Tue, 09 Oct 2018 06:26:36 -0700 (PDT) X-Google-Smtp-Source: ACcGV62Rmo5p5anm+I+DssWdoknFYlUN64YdaZMOFB9Tff3QohFoDLXQgbBmeFvD6lI5BRCZTtvO X-Received: by 2002:a62:8a91:: with SMTP id o17-v6mr30411019pfk.184.1539091595522; Tue, 09 Oct 2018 06:26:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091595; cv=none; d=google.com; s=arc-20160816; b=U8wa/FEcWI8Z0l3sVlYUTc2nhNWFKC5py8HVHoHEKsQgDC8oe8PCZ0608Dlfe01oRD M0bZHtO45ErioJXacpEf0530grPlbMmnkdbCXi5skw/hM2CpT1bsTAMAUzFlgwFAVDRl GrKp2ZiAGVGZS9sAUUnuum8rBS2Y+taekqdKAoxlyqqaWLD9rQxC3dqwjV9MMGjhFvoF IrP2A2hVZpi2odFjbRqPTCVm/iUVAYt/viP6s7ZwFh5kxuoH6acLTo/NhwPi34ce+V5P ozJ7aX9k4zKmCBdNW0rYbguMz93Lc0c3Q67ERu8xDK2SsPaNX+FqaplYOKrxTt8dZdxc 3cDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Ql7aNHvXxzTTeGCBs2l+3pR2u55du0W8IqjAoV6Ofu0=; b=IuKgbHKyU4UEbaRIB2PnETFgq2qj9wHiQJAwGfZLhlAKw5slTb/2/TufqBY4Llj4aQ LNdCl808kbRW6x/eN+dosXIy2KhIre/XMK8js0eglKHy1jeF4FfXUBl70ywWjvaoeIjb QJQ+GUGFZdSlfL6ih2IEBI659RbfGic/GgjemTNE8A6dDje6m6I/6TvWFQvZGpWb+ZIc HlzIMHC0vsuDaWRTe6C/bsqClRGjOQleOkFvnEO2ZfqIdJ81ba5xf5LoekUBy36tfnAf iGq6zvyioPhTxJEF2ud8nwfPsnXF7QwldY5gRO7V13P+eiYu0R3+vhqrb1NklNyI0Hnz Mu+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=VhBM8FnV; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id k5-v6si20376350pgi.99.2018.10.09.06.26.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=VhBM8FnV; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=Ql7aNHvXxzTTeGCBs2l+3pR2u55du0W8IqjAoV6Ofu0=; b=VhBM8FnV/Qb+hJcAxNWpyw9fjs 6Q0QpkQut2T2b2x7zH2vBrGPoBZ7Nddazm5NgWlGmEITQuh/VYiWFXAgEFmdG2tFGTp1XTNf4xule QvTfYZnRF035flgMM6Zlgs40ULWxeyO72tDCMRb/k8HL6h2mW5DnASyOnevYy6Z/gJJ9OV5imIhLO qiW9dwSI1vDt+rx3oM7OeCTS9CWUXBMcKitKCyIkg36gRE8UzpDCLxlDaanT1k3jpSCHKIVMWw4Do hfp7AF2F70U9I5gFCs7JlLzGtuCNeZ2iuVRs6zqNwIJCahrt5+e+/NUl2esH4mmei2gIY0GuAc0P1 0tZPIB3A==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s1b-0001Wk-6c; Tue, 09 Oct 2018 13:26:11 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 27/33] dma-mapping, powerpc: simplify the arch dma_set_mask override Date: Tue, 9 Oct 2018 15:24:54 +0200 Message-Id: <20181009132500.17643-28-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Instead of letting the architecture supply all of dma_set_mask just give it an additional hook selected by Kconfig. Signed-off-by: Christoph Hellwig --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/dma-mapping.h | 3 --- arch/powerpc/kernel/dma-swiotlb.c | 8 ++++++++ arch/powerpc/kernel/dma.c | 12 ------------ arch/powerpc/sysdev/fsl_pci.c | 4 ---- include/linux/dma-mapping.h | 11 ++++++++--- kernel/dma/Kconfig | 3 +++ 7 files changed, 20 insertions(+), 22 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 7097019d8907..7ea01687995d 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -126,6 +126,7 @@ config PPC # Please keep this list sorted alphabetically. # select ARCH_HAS_DEVMEM_IS_ALLOWED + select ARCH_HAS_DMA_SET_MASK if SWIOTLB select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index b1999880fc61..7694985f05ee 100644 --- a/arch/powerpc/include/asm/dma-mapping.h +++ b/arch/powerpc/include/asm/dma-mapping.h @@ -109,8 +109,5 @@ static inline void set_dma_offset(struct device *dev, dma_addr_t off) dev->archdata.dma_offset = off; } -#define HAVE_ARCH_DMA_SET_MASK 1 -extern int dma_set_mask(struct device *dev, u64 dma_mask); - #endif /* __KERNEL__ */ #endif /* _ASM_DMA_MAPPING_H */ diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c index e05d95ff50ad..dba216dd70fd 100644 --- a/arch/powerpc/kernel/dma-swiotlb.c +++ b/arch/powerpc/kernel/dma-swiotlb.c @@ -22,6 +22,14 @@ #include #include +bool arch_dma_set_mask(struct device *dev, u64 dma_mask) +{ + if (!ppc_md.dma_set_mask) + return 0; + return ppc_md.dma_set_mask(dev, dma_mask); +} +EXPORT_SYMBOL(arch_dma_set_mask); + unsigned int ppc_swiotlb_enable; /* diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index e3d2c15b209c..795afe387c91 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c @@ -197,18 +197,6 @@ const struct dma_map_ops dma_nommu_ops = { }; EXPORT_SYMBOL(dma_nommu_ops); -int dma_set_mask(struct device *dev, u64 dma_mask) -{ - if (ppc_md.dma_set_mask) - return ppc_md.dma_set_mask(dev, dma_mask); - - if (!dev->dma_mask || !dma_supported(dev, dma_mask)) - return -EIO; - *dev->dma_mask = dma_mask; - return 0; -} -EXPORT_SYMBOL(dma_set_mask); - static int __init dma_init(void) { #ifdef CONFIG_IBMVIO diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c index 296ffabc9386..cb91a3d113d1 100644 --- a/arch/powerpc/sysdev/fsl_pci.c +++ b/arch/powerpc/sysdev/fsl_pci.c @@ -135,9 +135,6 @@ static inline void setup_swiotlb_ops(struct pci_controller *hose) {} static int fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask) { - if (!dev->dma_mask || !dma_supported(dev, dma_mask)) - return -EIO; - /* * Fix up PCI devices that are able to DMA to the large inbound * mapping that allows addressing any RAM address from across PCI. @@ -147,7 +144,6 @@ static int fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask) set_dma_offset(dev, pci64_dma_offset); } - *dev->dma_mask = dma_mask; return 0; } diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 15bd41447025..8dd19e66c0e5 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -598,18 +598,23 @@ static inline int dma_supported(struct device *dev, u64 mask) return ops->dma_supported(dev, mask); } -#ifndef HAVE_ARCH_DMA_SET_MASK +#ifdef CONFIG_ARCH_HAS_DMA_SET_MASK +bool arch_dma_set_mask(struct device *dev, u64 mask); +#else +#define arch_dma_set_mask(dev, mask) true +#endif + static inline int dma_set_mask(struct device *dev, u64 mask) { if (!dev->dma_mask || !dma_supported(dev, mask)) return -EIO; - + if (!arch_dma_set_mask(dev, mask)) + return -EIO; dma_check_mask(dev, mask); *dev->dma_mask = mask; return 0; } -#endif static inline u64 dma_get_mask(struct device *dev) { diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig index 645c7a2ecde8..951045c90c2c 100644 --- a/kernel/dma/Kconfig +++ b/kernel/dma/Kconfig @@ -16,6 +16,9 @@ config ARCH_DMA_ADDR_T_64BIT config ARCH_HAS_DMA_COHERENCE_H bool +config ARCH_HAS_DMA_SET_MASK + bool + config HAVE_GENERIC_DMA_COHERENT bool From patchwork Tue Oct 9 13:24:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632569 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A068913AA for ; Tue, 9 Oct 2018 13:27:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98191289DF for ; Tue, 9 Oct 2018 13:27:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C2A328A5D; Tue, 9 Oct 2018 13:27:28 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19079289DF for ; Tue, 9 Oct 2018 13:27:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA6206B0290; Tue, 9 Oct 2018 09:26:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A05456B0292; Tue, 9 Oct 2018 09:26:36 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 881146B0293; Tue, 9 Oct 2018 09:26:36 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 43A196B0290 for ; Tue, 9 Oct 2018 09:26:36 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id e15-v6so1097491pfi.5 for ; Tue, 09 Oct 2018 06:26:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=5zhArYVOfpz3UhaczPVMIKMuoMp45C3OR3JQcBbTR4Q=; b=tKIUH73+bDQsdJ2swSSmhcPX2FV1GYKWSAL0WD20UDXXdsHRIAJJ/tVcBGmRc4F/en Xvd/jw38jR50GQAn/zTF5Ewi2IkPp1HaxZvHOcXVfDj3VhlI0WfXljhADKUnzPRfVVgS 1kpQ3tKi0bM2aPzLMkJVroKw1g82v4sAQ91F2FyLc2MOHFdPnkaSI3uNkKpQC23EJRm8 saI47NW/Yzsf+ppqN82KYDfj3moxKG2s64/eITLL91VUEje6uJqE5oAFtSB5Qo7eNjf9 Jpb1tzAJJYdjMeU34zHWAExwxVu08ZLBA8HX2Ysk7VKDhWegJ7sKU94Cbe4fAuSkV2zW q05w== X-Gm-Message-State: ABuFfojjPlDC+lOeEMhDS55IIJAw9aFcS3vYGvSiEghw7QJAJN6Ej98t XHtnYOym878qWraoC8d8kAzNfuyHrEcReUhtZkA4GGB2gl/m95O0PRg/h4rmsUdChArEK4m3PnQ gI2UEAc9M6NpFesqb1ZD48rpSOtWp+NE4NpqJXwNuhvhRQ9V5p6KtLtDGPVxeUgU= X-Received: by 2002:a17:902:7c12:: with SMTP id x18-v6mr23399731pll.206.1539091595955; Tue, 09 Oct 2018 06:26:35 -0700 (PDT) X-Google-Smtp-Source: ACcGV60SgLCDV6VriGZ1brf6EGrQBWL1U69A0OZ2V+tO2RMFCO7iMA64/yzY9o11/PHjUbs4CKXo X-Received: by 2002:a17:902:7c12:: with SMTP id x18-v6mr23399675pll.206.1539091595083; Tue, 09 Oct 2018 06:26:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091595; cv=none; d=google.com; s=arc-20160816; b=PrXqGEJ0WJsE6qBIo33BDXIyjsicCkAfzmVfVvYSYbg7y1+tjGAHwsS1p1ovwZvArL iNinvqviiu+aPx0lCLctJ3QF/k+emDVqvJElDN/92RPp/y2Uxbet2Tg1R+BQQxDmpIHU NMsoZXCOKdEkYgmDT9Z04vnG2D/WrjOJdTfMexT0K/Jqug3V2zxHchf+vXto9xMtKsvU 9qfnrMdHdsRGIT9+HyTYnsqtDAFYRYFLTUGDHwuY8HSphuI6D5gL+gmfK4koxpDtUYNt kyJoUz9xF5KL9p7Ou6Rp3G9+hWHxUiiKRaM8zaizbSKvlFA67Aur6IY365hSY5mmQ4PY rWyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=5zhArYVOfpz3UhaczPVMIKMuoMp45C3OR3JQcBbTR4Q=; b=iNrYqqkJ/bEyEZECD/GspWjJP1q4JIWIN6buxdbA+I/buX2p3pU3c3lrfEZket0l28 0URER7ABDhj3jF0e72wyEo+fkmlW93G7rGqlw8DTDWSd3ZQYm6JrGmNU/uRKWcUGxnyF ZmR1bKp97oHubzg2kO1os1qCh5gezlN6CEz8vyRv5Y54MZ08stPG9dJpgnqeYMIjGJa6 Ci7Q3qSCPuPuy/Ca7zr1el+jsNQ546+gmQjF5ZVlHWbDj/89JPkC0si7g95CAiJ41oIM VDj7+F4KeGOVy4r7+DxocIbedg4slgw/jL79yLKUKC9JIXyQNukX83405sAzB6D5wCGi JKkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=PEtGZznv; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id e73-v6si21587933pfb.98.2018.10.09.06.26.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=PEtGZznv; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=5zhArYVOfpz3UhaczPVMIKMuoMp45C3OR3JQcBbTR4Q=; b=PEtGZznvqjw8wP1A7IE3s7HgqV Decd25/6zt9jn4oWWFRxPmPK4LgotMOtwUgznAoFNeRbLrz/ug+wyEKCPIcF8WwlxqdyVO59W9yDE SKC/H5Ajlt6IlmlXMXFY/7a5Y06GWXqghS2wIrFZf9/O/IuZf/ay77uUu0cv3mycX3mvSnl8EnBCh gerYHus3pBh9CkGKEgQybx44AxRQ1erJlyA7MM86Ml/ravdyD4DQ3CUa09sY0pCH5LUFYj0o3aKqP IsilkrZNkNMGCo6dspHltDxM3yX7cNLTTb5mVYjMrkf+VCORu/lPswZCu987zHcheUK4F8UI9rvBi QD7c1j/A==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s1d-0001Y9-ME; Tue, 09 Oct 2018 13:26:14 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 28/33] powerpc/dma: use phys_to_dma instead of get_dma_offset Date: Tue, 9 Oct 2018 15:24:55 +0200 Message-Id: <20181009132500.17643-29-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Use the standard portable helper instead of the powerpc specific one, which is about to go away. Signed-off-by: Christoph Hellwig Acked-by: Benjamin Herrenschmidt --- arch/powerpc/kernel/dma-swiotlb.c | 2 +- arch/powerpc/kernel/dma.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c index dba216dd70fd..d33caff8c684 100644 --- a/arch/powerpc/kernel/dma-swiotlb.c +++ b/arch/powerpc/kernel/dma-swiotlb.c @@ -11,7 +11,7 @@ * */ -#include +#include #include #include #include diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index 795afe387c91..7f7f3a069b63 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c @@ -6,7 +6,7 @@ */ #include -#include +#include #include #include #include @@ -42,7 +42,7 @@ static u64 __maybe_unused get_pfn_limit(struct device *dev) int dma_nommu_dma_supported(struct device *dev, u64 mask) { #ifdef CONFIG_PPC64 - u64 limit = get_dma_offset(dev) + (memblock_end_of_DRAM() - 1); + u64 limit = phys_to_dma(dev, (memblock_end_of_DRAM() - 1)); /* Limit fits in the mask, we are good */ if (mask >= limit) @@ -100,7 +100,7 @@ void *__dma_nommu_alloc_coherent(struct device *dev, size_t size, return NULL; ret = page_address(page); memset(ret, 0, size); - *dma_handle = __pa(ret) + get_dma_offset(dev); + *dma_handle = phys_to_dma(dev,__pa(ret)); return ret; } @@ -139,7 +139,7 @@ int dma_nommu_map_sg(struct device *dev, struct scatterlist *sgl, int i; for_each_sg(sgl, sg, nents, i) { - sg->dma_address = sg_phys(sg) + get_dma_offset(dev); + sg->dma_address = phys_to_dma(dev, sg_phys(sg)); sg->dma_length = sg->length; if (attrs & DMA_ATTR_SKIP_CPU_SYNC) @@ -158,7 +158,7 @@ dma_addr_t dma_nommu_map_page(struct device *dev, struct page *page, if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC)) __dma_sync_page(page, offset, size, dir); - return page_to_phys(page) + offset + get_dma_offset(dev); + return phys_to_dma(dev, page_to_phys(page)) + offset; } #ifdef CONFIG_NOT_COHERENT_CACHE From patchwork Tue Oct 9 13:24:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632573 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 211D013AA for ; Tue, 9 Oct 2018 13:27:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15F8C289F5 for ; Tue, 9 Oct 2018 13:27:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A20B28ABE; Tue, 9 Oct 2018 13:27:38 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAE4D289F5 for ; Tue, 9 Oct 2018 13:27:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3770B6B0293; Tue, 9 Oct 2018 09:26:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 302C66B0294; Tue, 9 Oct 2018 09:26:38 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A19E6B0295; Tue, 9 Oct 2018 09:26:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id C83086B0293 for ; Tue, 9 Oct 2018 09:26:37 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id z28-v6so948499pff.4 for ; Tue, 09 Oct 2018 06:26:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0a3Usd7jISHTGQntO/3u9QFE1XioH+LvsPG+jqWFCRw=; b=k3LCkA1HwvgjjXzKMz9vyisS10Yze5VnV5+l134iLRfnwnoPF6kkGsG5hoFoab/j6q ajFXi7wFCUjNpvHzPVu/HJ2Dfig2ywme7nrqoLy/OprBT+v+QsJqk9np9PnLPZk2vFy/ BBXieHx5WoCahPVw5c/THRU0Kf55mG+WNSELdE1jw2eUpGiozZF15IMtMycZqgez6CCs nNLSi3PVQQKyBeAeFSZ7klO5/NY55Q5IKDO8IlvvXq1tT6HKlqU6LBoFD3FPw7L4j5Lr dAK74/s/aUpLiqg74q0wJy6wsST4FJj0tHFjiPPI2LqS1IRJqPBmN9E4XJFG7H/EnN12 zS6w== X-Gm-Message-State: ABuFfoiebfb6EXjOGoowKik8xAsNPNIsP3SZDU0yBz0HhMv+dtCswEEg GSpn7kYd1MSU1IDpYq6yJa9h/uPdNwiFXZ6edZB5zz0YiAXEhyxW/atcRoYp9NQWG/DtfH7M0Da cVsi8NpltZ03WZNQVpdUJHQpxuUfe7zkKg8UrLmxdGNa/dO49s2CyEfkiAAs5Haw= X-Received: by 2002:a63:9612:: with SMTP id c18-v6mr24808008pge.21.1539091597515; Tue, 09 Oct 2018 06:26:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV63MyNUGAr5Qq1ey1ooDTSRyZoWXXnE+jy7YeHMJTg35q3ZlAfVqSLqhkhYVgI1Y1/GVwFMU X-Received: by 2002:a63:9612:: with SMTP id c18-v6mr24807965pge.21.1539091596797; Tue, 09 Oct 2018 06:26:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091596; cv=none; d=google.com; s=arc-20160816; b=OdbLv7tJbyZX8GCCabJODsDgt8t70QOdXdUsFEahviwywqo+zHiRfQV0pWauwt/Pjg l2b029mzuQT0cl8Wi0BXg6CqvR1pNIPJlaMJE7DmkaQzDFJKyjRWUa1wH8kUdFc85nxS vroaWNQ2f8saRKoZiIdDMpm7IJv0V5klXbt9hFqY3WqxyCaRwc+3NAE6S1SNQTC0GgmI izNem95e3fZBOpjUyeADe8SQIqC6BpVDlcXDHwG/Lhlnc0ePUW69amWutZCejuhknMI1 Hc/pmub50u2sS6zcNJ5yGYYf0aBQYzftBoXePkojuvAZ6WSLMHhSgpqFP4lC6epqQmUr h3NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=0a3Usd7jISHTGQntO/3u9QFE1XioH+LvsPG+jqWFCRw=; b=TP2og1oWVkagxZlzodwrk+k0iruJL+tL70IrREwWlOkkOQPrZyBoqKW5Ai0hsG9YWp jTFooA35rzmowKPyoeXYt5cggrhx0NN/Le9RsDnPxmks7CbjnFxVlvAiseLlGhsEuy1M bqK5Cs8vu3dY24L27Q3pMhdJnm9RUnbMzXYY8zLUB6fMBSYvezZzycURCCjt0W02coD2 MqzBazRVl/EAxhzOk0GKvEm4MPxwjcLEEsKVAj/EBR/r2h/ViHiVE2DB9AeBwUWAdtnC A11WijdFPUUCrfzZO5PXt1m5s3WLN9SQkN4KqsBwEoXrBCyw/AkOCPcXDrZbdExs8pHx oRSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=eDYizs2X; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id j185-v6si607667pfc.186.2018.10.09.06.26.36 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=eDYizs2X; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=0a3Usd7jISHTGQntO/3u9QFE1XioH+LvsPG+jqWFCRw=; b=eDYizs2Xcd5TrD/sOO26KGAHiv OUMKqDL3TKwqnqPEvYkhQj3NeBiVzC8WaY1/SQV5Twiij5ZbZD66jlOEAf98dAH+K37FyNYWGlJwo 4Ps62LlJgN+MUKAEyCEl7rC/xRb9HEbmiwprcGpQZpWnJaj0p9xuKgrobTJBpounX5xjYSKHWu7sm WLTIoBf1e6I6ctKR7hTKwcE9BC+1dOWTAzM238wpoK5VoJQL45yrGYcos547K+dWkuNH6WKggk6c5 IT10ZxJecfQwnxgoTxGilho39M7pUX+wJZ/72l33cs2gsBux6OzamTM+Wu84g40giU4pt9dtL8l8i n+7WOvnA==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s1g-0001aC-Eb; Tue, 09 Oct 2018 13:26:16 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 29/33] powerpc/dma: remove get_dma_offset Date: Tue, 9 Oct 2018 15:24:56 +0200 Message-Id: <20181009132500.17643-30-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Just fold the calculation into __phys_to_dma/__dma_to_phys as those are the only places that should know about it. Signed-off-by: Christoph Hellwig Acked-by: Benjamin Herrenschmidt --- arch/powerpc/include/asm/dma-direct.h | 8 ++++++-- arch/powerpc/include/asm/dma-mapping.h | 16 ---------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/arch/powerpc/include/asm/dma-direct.h b/arch/powerpc/include/asm/dma-direct.h index 92d8aed86422..a2912b47102c 100644 --- a/arch/powerpc/include/asm/dma-direct.h +++ b/arch/powerpc/include/asm/dma-direct.h @@ -13,11 +13,15 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) static inline dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr) { - return paddr + get_dma_offset(dev); + if (!dev) + return paddr + PCI_DRAM_OFFSET; + return paddr + dev->archdata.dma_offset; } static inline phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t daddr) { - return daddr - get_dma_offset(dev); + if (!dev) + return daddr - PCI_DRAM_OFFSET; + return daddr - dev->archdata.dma_offset; } #endif /* ASM_POWERPC_DMA_DIRECT_H */ diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index 7694985f05ee..2d0879b0acf3 100644 --- a/arch/powerpc/include/asm/dma-mapping.h +++ b/arch/powerpc/include/asm/dma-mapping.h @@ -87,22 +87,6 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) return NULL; } -/* - * get_dma_offset() - * - * Get the dma offset on configurations where the dma address can be determined - * from the physical address by looking at a simple offset. Direct dma and - * swiotlb use this function, but it is typically not used by implementations - * with an iommu. - */ -static inline dma_addr_t get_dma_offset(struct device *dev) -{ - if (dev) - return dev->archdata.dma_offset; - - return PCI_DRAM_OFFSET; -} - static inline void set_dma_offset(struct device *dev, dma_addr_t off) { if (dev) From patchwork Tue Oct 9 13:24:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632581 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4F9DB13AA for ; Tue, 9 Oct 2018 13:27:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4625D289DF for ; Tue, 9 Oct 2018 13:27:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3713528A5D; Tue, 9 Oct 2018 13:27:54 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 846A8289DF for ; Tue, 9 Oct 2018 13:27:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B5A66B029A; Tue, 9 Oct 2018 09:26:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 23E336B029B; Tue, 9 Oct 2018 09:26:51 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 093B66B029C; Tue, 9 Oct 2018 09:26:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id AD2F66B029A for ; Tue, 9 Oct 2018 09:26:50 -0400 (EDT) Received: by mail-pl1-f200.google.com with SMTP id t8-v6so990968plo.4 for ; Tue, 09 Oct 2018 06:26:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=yIv6BDTf8SSyW4q5DR2O7BbFOqkppOKG2igrjWHb8Os=; b=GnRo99pB0+uEjF1wFzsSJr8TIm5uA6gPZqZ35Wi6o92oa6mBkhshP1rEv86GwQTgm/ qUML7i4vZVU23RQrH8/HbbAKQ48YnGUBUwZkreKQuPAZhVS6PpR97OzyMgitooI2B3vl hBku0r0kH51agYSiJAh3a5C00CHGtdRJK36jhn12APuYCYh6ZRzIx7Q3jlGX00z4SpEB kVusHuF/TJKAroiWH/xZaLPaLC1meG9BqVHLQfcngoON7EGSN8Gu1P1VurFh1kVDX2dR s+901/c29kXh+9yQI6PfX1w+atHoaZlfy3nNIH/4vAghHD0LuhIs7sDXMgRZccBeCyzl IFbw== X-Gm-Message-State: ABuFfoi/uG3aUc3piWA2+cjz6ogI1qIqxfOXKS4NBqswqVrYI2tdPfSS LY6Jh64Ebj2Ng6fh1K51BIT4tOMNh+LbA1fuLCzYIakNhUr7sIVFUz+IZqvibYcBO6W1DzJ9LsQ jNQhxpjnsOCYe7TzwEjoVvPRtzCEWskyo8jeH70wj5DiyDl+LIggJE4QIklSwCdU= X-Received: by 2002:a65:5a89:: with SMTP id c9-v6mr24954020pgt.216.1539091610383; Tue, 09 Oct 2018 06:26:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV61UDW51MrEJlQ2Bshds73Je4oz7ABeZeQklpHrh1ED13b93gnwkFKO2CgjIijomRyRJinLr X-Received: by 2002:a65:5a89:: with SMTP id c9-v6mr24953959pgt.216.1539091609317; Tue, 09 Oct 2018 06:26:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091609; cv=none; d=google.com; s=arc-20160816; b=GPvFdXYIqEd7NH+6H6L93Q3hJVhLFF+BZpPCxSloShcxuR9eZa9flbHQ6xQULW9c4X ZwRMPv7gImBSoXupWg0gqq4s1bqMHuIisERw0mFHsOffqupxfdxWky09uA4f+8wgRJ69 3rb2cWhXY/wMyWEpFXs0k4cJxEgp8iIKyPf1ZuI8wa3dlV1PwWRrUIs4pP12Q8EjVYTr hTOoGlmMB/YJF8hP49IweYY+mNHkvDp0TMkvwzMJSV/n3ln0qTBCStAQLpEoJeRqgbsq pzsPYqUqN1x31amanN3UqVsqAgwxlYpl4Kpbvw2NiGn79Bach8h8rLC/4mEBUZpFzhhJ PY+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=yIv6BDTf8SSyW4q5DR2O7BbFOqkppOKG2igrjWHb8Os=; b=YFdCIoNUxAGtoHoydnJqbPv8iBLewDHYxoU2sOC/G/SOpaf+CK4UZu9REL/CKyxnzR eicAbGW4rFKi4TwxBD4UlvKhBYtHMjtPiw0DcRW4BOr63pUuzdpb2YIgX5o0Bb6M4EZg df2FmkchICpuCBPuF3JhtXy8OeLoO0drlI4dm2/Bq0SmYAhLY6+jM8N5jmext7L05cJa lX8yI/ZFYurkX+WfFAwN/i/4oV+m8MUERfwGv4tSk4RXIh6hD5010sscxrImVTxhptHN dqHiJjUFDKpls6Z/WQDU3vjjMhX03hEdlNMnQyRwvGRXzAwfkaOCfZjbE9p/MwkRUj5O KcJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=QqaUKh2o; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id m4-v6si20743445plt.432.2018.10.09.06.26.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=QqaUKh2o; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=yIv6BDTf8SSyW4q5DR2O7BbFOqkppOKG2igrjWHb8Os=; b=QqaUKh2o32LY2ejJ6ACdm++PJN 9bHPTjax777yMMB+/jALpB3NPNqXVkL2DUVN8ai9c8iwFnvd89iIep2IOLB2X3yh2Wi8eoVE1qyMx XfA+Od6spw1X/mmg8bsX8mLzTMGExn35INk2oS2G4oMv8UIpVt0f++UkVNDcFxR6at7IqS4fcNeqK 0ZEntpKacfWVTw31oxnorN3k3/2P8GZrSZvcpJOhAUSN8cH8JIyZ5Y/4N98ElGPMBRToD9ZSPDdLv dfWEmSG+1qhZo7qj5a866Iby8SY+Y574WvixgRbPCNsUbfIs1lOUZxmMjZqQMUhukVjEhbQaA8ddb DIyW0TBA==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s1i-0001bW-VA; Tue, 09 Oct 2018 13:26:19 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 30/33] powerpc/dma: remove set_dma_offset Date: Tue, 9 Oct 2018 15:24:57 +0200 Message-Id: <20181009132500.17643-31-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP There is no good reason for this helper, just opencode it. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/dma-mapping.h | 6 ------ arch/powerpc/kernel/pci-common.c | 2 +- arch/powerpc/platforms/cell/iommu.c | 4 ++-- arch/powerpc/platforms/powernv/pci-ioda.c | 6 +++--- arch/powerpc/platforms/pseries/iommu.c | 7 ++----- arch/powerpc/sysdev/dart_iommu.c | 2 +- arch/powerpc/sysdev/fsl_pci.c | 2 +- drivers/misc/cxl/vphb.c | 2 +- 8 files changed, 11 insertions(+), 20 deletions(-) diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index 2d0879b0acf3..e12439ae8211 100644 --- a/arch/powerpc/include/asm/dma-mapping.h +++ b/arch/powerpc/include/asm/dma-mapping.h @@ -87,11 +87,5 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) return NULL; } -static inline void set_dma_offset(struct device *dev, dma_addr_t off) -{ - if (dev) - dev->archdata.dma_offset = off; -} - #endif /* __KERNEL__ */ #endif /* _ASM_DMA_MAPPING_H */ diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index a84707680525..fca2b0bafd82 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -966,7 +966,7 @@ static void pcibios_setup_device(struct pci_dev *dev) /* Hook up default DMA ops */ set_dma_ops(&dev->dev, pci_dma_ops); - set_dma_offset(&dev->dev, PCI_DRAM_OFFSET); + dev->dev.archdata.dma_offset = PCI_DRAM_OFFSET; /* Additional platform DMA/iommu setup */ phb = pci_bus_to_host(dev->bus); diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c index 93c7e4aef571..997ee0f5fc2f 100644 --- a/arch/powerpc/platforms/cell/iommu.c +++ b/arch/powerpc/platforms/cell/iommu.c @@ -577,10 +577,10 @@ static void cell_dma_dev_setup(struct device *dev) u64 addr = cell_iommu_get_fixed_address(dev); if (addr != OF_BAD_ADDR) - set_dma_offset(dev, addr + dma_iommu_fixed_base); + dev->archdata.dma_offset = addr + dma_iommu_fixed_base; set_iommu_table_base(dev, cell_get_iommu_table(dev)); } else { - set_dma_offset(dev, cell_dma_nommu_offset); + dev->archdata.dma_offset = cell_dma_nommu_offset; } } diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 5748b62e2e86..e2333e10598d 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -1660,7 +1660,7 @@ static void pnv_pci_ioda_dma_dev_setup(struct pnv_phb *phb, struct pci_dev *pdev pe = &phb->ioda.pe_array[pdn->pe_number]; WARN_ON(get_dma_ops(&pdev->dev) != &dma_iommu_ops); - set_dma_offset(&pdev->dev, pe->tce_bypass_base); + pdev->dev.archdata.dma_offset = pe->tce_bypass_base; set_iommu_table_base(&pdev->dev, pe->table_group.tables[0]); /* * Note: iommu_add_device() will fail here as @@ -1773,7 +1773,7 @@ static bool pnv_pci_ioda_iommu_bypass_supported(struct pci_dev *pdev, if (rc) return rc; /* 4GB offset bypasses 32-bit space */ - set_dma_offset(&pdev->dev, (1ULL << 32)); + pdev->dev.archdata.dma_offset = (1ULL << 32); return true; } @@ -1788,7 +1788,7 @@ static void pnv_ioda_setup_bus_dma(struct pnv_ioda_pe *pe, list_for_each_entry(dev, &bus->devices, bus_list) { set_iommu_table_base(&dev->dev, pe->table_group.tables[0]); - set_dma_offset(&dev->dev, pe->tce_bypass_base); + dev->dev.archdata.dma_offset = pe->tce_bypass_base; if (add_to_group) iommu_add_device(&dev->dev); diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 8965d174c53b..a2ff20d154fe 100644 --- a/arch/powerpc/platforms/pseries/iommu.c +++ b/arch/powerpc/platforms/pseries/iommu.c @@ -1197,7 +1197,6 @@ static bool iommu_bypass_supported_pSeriesLP(struct pci_dev *pdev, u64 dma_mask) { struct device_node *dn = pci_device_to_OF_node(pdev), *pdn; const __be32 *dma_window = NULL; - u64 dma_offset; /* only attempt to use a new window if 64-bit DMA is requested */ if (dma_mask < DMA_BIT_MASK(64)) @@ -1219,11 +1218,9 @@ static bool iommu_bypass_supported_pSeriesLP(struct pci_dev *pdev, u64 dma_mask) } if (pdn && PCI_DN(pdn)) { - dma_offset = enable_ddw(pdev, pdn); - if (dma_offset != 0) { - set_dma_offset(&pdev->dev, dma_offset); + pdev->dev.archdata.dma_offset = enable_ddw(pdev, pdn); + if (pdev->dev.archdata.dma_offset) return true; - } } return false; diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c index e7d1645a2d2e..21d7e8a30aea 100644 --- a/arch/powerpc/sysdev/dart_iommu.c +++ b/arch/powerpc/sysdev/dart_iommu.c @@ -386,7 +386,7 @@ static bool dart_device_on_pcie(struct device *dev) static void pci_dma_dev_setup_dart(struct pci_dev *dev) { if (dart_is_u4 && dart_device_on_pcie(&dev->dev)) - set_dma_offset(&dev->dev, DART_U4_BYPASS_BASE); + dev->dev.archdata.dma_offset = DART_U4_BYPASS_BASE; set_iommu_table_base(&dev->dev, &iommu_table_dart); } diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c index cb91a3d113d1..d6b7c91a9ce2 100644 --- a/arch/powerpc/sysdev/fsl_pci.c +++ b/arch/powerpc/sysdev/fsl_pci.c @@ -141,7 +141,7 @@ static int fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask) */ if (dev_is_pci(dev) && dma_mask >= pci64_dma_offset * 2 - 1) { dev->bus_dma_mask = 0; - set_dma_offset(dev, pci64_dma_offset); + dev->archdata.dma_offset = pci64_dma_offset; } return 0; diff --git a/drivers/misc/cxl/vphb.c b/drivers/misc/cxl/vphb.c index 49da2f744bbf..f0645ba1d728 100644 --- a/drivers/misc/cxl/vphb.c +++ b/drivers/misc/cxl/vphb.c @@ -44,7 +44,7 @@ static bool cxl_pci_enable_device_hook(struct pci_dev *dev) } set_dma_ops(&dev->dev, &dma_nommu_ops); - set_dma_offset(&dev->dev, PAGE_OFFSET); + dev->dev.archdata.dma_offset = PAGE_OFFSET; /* * Allocate a context to do cxl things too. If we eventually do real From patchwork Tue Oct 9 13:24:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632575 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 08205112B for ; Tue, 9 Oct 2018 13:27:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2B0D289DF for ; Tue, 9 Oct 2018 13:27:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E70C4289F5; Tue, 9 Oct 2018 13:27:41 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44E4728AB8 for ; Tue, 9 Oct 2018 13:27:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6DD026B0296; Tue, 9 Oct 2018 09:26:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 65D6A6B0298; Tue, 9 Oct 2018 09:26:42 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 46E6D6B0297; Tue, 9 Oct 2018 09:26:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id EF18D6B0294 for ; Tue, 9 Oct 2018 09:26:41 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id x2-v6so834728pgr.8 for ; Tue, 09 Oct 2018 06:26:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=NGCU2lrt5bq7Rc3mk/OMld2IdjRQQ5SDzs63QFi1+BM=; b=nPPhHj9nx4FTArTKYKDxtM38dbAU0Nbepo8ZYP2YgeZuMC5WBS9Gas4VO81rKt88id BhOqDmFl/hzEucVb6hZNI4VkoYEpyV2aKY9SUTICLU3W+btDjHl4KZHorn6+qdVe4/w8 5sw0MzPKNLCKaqLtp2zfxl519zyzQ+IbJv4YIoOh2i6LnDWaxN/Lo/unEOaQFT2Hbhl1 9Vz/6Z/qnIvq4lokodAyFI2pFUX3VdiNNRc6QTPmleiM+yA/u9Zy+KxcSCPdnvRHbn3t y1W1e15XNuUAgZ+MypOgNPQVJidUiPwNJJ4MyaPAlfm73ymEUPpwkUJ40HIRivylj70C sJyQ== X-Gm-Message-State: ABuFfohnSCdm4BefKvkBB+ut1djxJLBv0SW1Ci2xz65N4C1XcSsEkeGm ioJp38j86NwGFmTg4UU19NZAYizUvY5FLPsVrNJ5dMmd31iIxLY/9euQgqIMxwoKdbMJlqbH1MN vfbwELQdY+qIiHw2Ty+F/EX+US6t6yIiFla74KknxkOt8YZFyeZ8xwq7nMw83580= X-Received: by 2002:a62:35c2:: with SMTP id c185-v6mr25678146pfa.69.1539091601629; Tue, 09 Oct 2018 06:26:41 -0700 (PDT) X-Google-Smtp-Source: ACcGV60e4bhuZ8QHjHQkBjmbLUYCLQ9czvw5/pdAN9ouKURNYHnzKVvSxBM2t3AR73mF9QlVGN8e X-Received: by 2002:a62:35c2:: with SMTP id c185-v6mr25678082pfa.69.1539091600627; Tue, 09 Oct 2018 06:26:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091600; cv=none; d=google.com; s=arc-20160816; b=ROZfFzNV1UDzOYZ2NTAqUw1dVwdHbHat+/aaYyQqN1muQmMKO7XoFwR8/8Qy1asxHR 5OHMsqE/ZhwGofoblp6Q6hDOHx/XdI7XHpurekpeEChOQXWZUk/vUcSFDt59DVgv41FE ZvirA/8DIPEW8NPy+7e6Kf6CZRgs5t9LnJdqgJCIZ4Dj65XWH6KPuKAedG3hTidaTlrX AxE/e8pEFtOq91zEieQ93c7RJqu91AZYkAn8fgVcySpYyIqoV11X1mJE1rBlt/YXz/Jh Ch6a+BeFEhLpoDXHIZATGcvJW4OSv53K+q+NHRy+8kXwlukAq2bTF0vS2BujkxQwyroS my2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=NGCU2lrt5bq7Rc3mk/OMld2IdjRQQ5SDzs63QFi1+BM=; b=ZKk3patcp4ToZARuyjk0ZF8koT5KcOzllsQQ42rt3wkZROh1+KwCThkiAQHORBb2Ry uCR2cuquHM1WdepdY3c22O0oZXpv81OUi8qNXcZRc0J2nDnJyW1NMuogwXaBlcYotC13 0O/S/0qPu2ZjcQA+I6//0seAwLBsxPjiraz4zlfFqJjBlANJtu6L9r67/PkaeaKBF1IE u/HYdoytD+sDLQVRcapBQ1J1UkULtmvJQwDL9y7R3ToEZKeKQtABtZxf/adKmqUU8wWC M4ACR3g5T8xBTFaI4qexd+PAG/3HFqZJ8gc/LBzST5OgnwpBjpOpXEyh8kmYK+bwyS7j d2vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=l8UPegYX; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id z12-v6si19047795pgp.274.2018.10.09.06.26.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=l8UPegYX; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=NGCU2lrt5bq7Rc3mk/OMld2IdjRQQ5SDzs63QFi1+BM=; b=l8UPegYXTgla6zResoGtjiiUTT K+v5TvfDQ5H3YaN3kxyiX7jPgviqYWxTjEoEQZU4u+DiIpu467fj+ymlbo3+6mY8K4f8Ch/Kzqepg RNb8G6lbsBKg+mFZ3Z36s/Abf9X8IAvdUghidJn/Gy98NTsa4WRRRj4amyXkx9yjuyzvuDF6nNIQo /sBRmXtNeKN4pkfk91f/Bc35+5/kb2UJxoyNNdb4X4StNTdKP6D0Fm2dLvwxaviRFCS8SYf9vrwjp fxOhWVl6+nD8nUS+5I00J1JYd+IXujk1QOvjmcQbFDxZaVqqxC432carN1AGcsvLixsi7K0ma5kp9 WJiHx8zQ==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s1l-0001dF-Dg; Tue, 09 Oct 2018 13:26:21 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 31/33] powerpc/dma: remove dma_nommu_mmap_coherent Date: Tue, 9 Oct 2018 15:24:58 +0200 Message-Id: <20181009132500.17643-32-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The coherent cache version of this function already is functionally identicall to the default version, and by defining the arch_dma_coherent_to_pfn hook the same is ture for the noncoherent version as well. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/dma-mapping.h | 4 ---- arch/powerpc/kernel/dma-iommu.c | 1 - arch/powerpc/kernel/dma-swiotlb.c | 1 - arch/powerpc/kernel/dma.c | 19 ------------------- arch/powerpc/mm/dma-noncoherent.c | 7 +++++-- arch/powerpc/platforms/Kconfig.cputype | 1 + arch/powerpc/platforms/pseries/vio.c | 1 - 7 files changed, 6 insertions(+), 28 deletions(-) diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index e12439ae8211..ababad4b07a7 100644 --- a/arch/powerpc/include/asm/dma-mapping.h +++ b/arch/powerpc/include/asm/dma-mapping.h @@ -25,10 +25,6 @@ extern void *__dma_nommu_alloc_coherent(struct device *dev, size_t size, extern void __dma_nommu_free_coherent(struct device *dev, size_t size, void *vaddr, dma_addr_t dma_handle, unsigned long attrs); -extern int dma_nommu_mmap_coherent(struct device *dev, - struct vm_area_struct *vma, - void *cpu_addr, dma_addr_t handle, - size_t size, unsigned long attrs); int dma_nommu_map_sg(struct device *dev, struct scatterlist *sgl, int nents, enum dma_data_direction direction, unsigned long attrs); diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c index 7fa3636636fa..2e682004959f 100644 --- a/arch/powerpc/kernel/dma-iommu.c +++ b/arch/powerpc/kernel/dma-iommu.c @@ -172,7 +172,6 @@ int dma_iommu_mapping_error(struct device *dev, dma_addr_t dma_addr) const struct dma_map_ops dma_iommu_ops = { .alloc = dma_iommu_alloc_coherent, .free = dma_iommu_free_coherent, - .mmap = dma_nommu_mmap_coherent, .map_sg = dma_iommu_map_sg, .unmap_sg = dma_iommu_unmap_sg, .dma_supported = dma_iommu_dma_supported, diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c index d33caff8c684..c6f8519f8d4e 100644 --- a/arch/powerpc/kernel/dma-swiotlb.c +++ b/arch/powerpc/kernel/dma-swiotlb.c @@ -42,7 +42,6 @@ unsigned int ppc_swiotlb_enable; const struct dma_map_ops powerpc_swiotlb_dma_ops = { .alloc = __dma_nommu_alloc_coherent, .free = __dma_nommu_free_coherent, - .mmap = dma_nommu_mmap_coherent, .map_sg = swiotlb_map_sg_attrs, .unmap_sg = swiotlb_unmap_sg_attrs, .dma_supported = swiotlb_dma_supported, diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index 7f7f3a069b63..92cc402d249f 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c @@ -113,24 +113,6 @@ void __dma_nommu_free_coherent(struct device *dev, size_t size, } #endif /* !CONFIG_NOT_COHERENT_CACHE */ -int dma_nommu_mmap_coherent(struct device *dev, struct vm_area_struct *vma, - void *cpu_addr, dma_addr_t handle, size_t size, - unsigned long attrs) -{ - unsigned long pfn; - -#ifdef CONFIG_NOT_COHERENT_CACHE - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); - pfn = __dma_get_coherent_pfn((unsigned long)cpu_addr); -#else - pfn = page_to_pfn(virt_to_page(cpu_addr)); -#endif - return remap_pfn_range(vma, vma->vm_start, - pfn + vma->vm_pgoff, - vma->vm_end - vma->vm_start, - vma->vm_page_prot); -} - int dma_nommu_map_sg(struct device *dev, struct scatterlist *sgl, int nents, enum dma_data_direction direction, unsigned long attrs) @@ -184,7 +166,6 @@ static inline void dma_nommu_sync_single(struct device *dev, const struct dma_map_ops dma_nommu_ops = { .alloc = __dma_nommu_alloc_coherent, .free = __dma_nommu_free_coherent, - .mmap = dma_nommu_mmap_coherent, .map_sg = dma_nommu_map_sg, .dma_supported = dma_nommu_dma_supported, .map_page = dma_nommu_map_page, diff --git a/arch/powerpc/mm/dma-noncoherent.c b/arch/powerpc/mm/dma-noncoherent.c index 965ce3d19f5a..a016c9c356d5 100644 --- a/arch/powerpc/mm/dma-noncoherent.c +++ b/arch/powerpc/mm/dma-noncoherent.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -400,14 +401,16 @@ EXPORT_SYMBOL(__dma_sync_page); /* * Return the PFN for a given cpu virtual address returned by - * __dma_nommu_alloc_coherent. This is used by dma_mmap_coherent() + * __dma_nommu_alloc_coherent. */ -unsigned long __dma_get_coherent_pfn(unsigned long cpu_addr) +long arch_dma_coherent_to_pfn(struct device *dev, void *vaddr, + dma_addr_t dma_addr) { /* This should always be populated, so we don't test every * level. If that fails, we'll have a nice crash which * will be as good as a BUG_ON() */ + unsigned long cpu_addr = (unsigned long)vaddr; pgd_t *pgd = pgd_offset_k(cpu_addr); pud_t *pud = pud_offset(pgd, cpu_addr); pmd_t *pmd = pmd_offset(pud, cpu_addr); diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype index 6c6a7c72cae4..0c4fc631cb33 100644 --- a/arch/powerpc/platforms/Kconfig.cputype +++ b/arch/powerpc/platforms/Kconfig.cputype @@ -415,6 +415,7 @@ config NR_CPUS config NOT_COHERENT_CACHE bool depends on 4xx || PPC_8xx || E200 || PPC_MPC512x || GAMECUBE_COMMON + select ARCH_HAS_DMA_COHERENT_TO_PFN default n if PPC_47x default y diff --git a/arch/powerpc/platforms/pseries/vio.c b/arch/powerpc/platforms/pseries/vio.c index 1dfff53ebd7f..3ad74efc83bf 100644 --- a/arch/powerpc/platforms/pseries/vio.c +++ b/arch/powerpc/platforms/pseries/vio.c @@ -603,7 +603,6 @@ static void vio_dma_iommu_unmap_sg(struct device *dev, static const struct dma_map_ops vio_dma_mapping_ops = { .alloc = vio_dma_iommu_alloc_coherent, .free = vio_dma_iommu_free_coherent, - .mmap = dma_nommu_mmap_coherent, .map_sg = vio_dma_iommu_map_sg, .unmap_sg = vio_dma_iommu_unmap_sg, .map_page = vio_dma_iommu_map_page, From patchwork Tue Oct 9 13:24:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C5B8713AA for ; Tue, 9 Oct 2018 13:27:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBAC6289DF for ; Tue, 9 Oct 2018 13:27:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF66328A5D; Tue, 9 Oct 2018 13:27:59 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23DD4289DF for ; Tue, 9 Oct 2018 13:27:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 726706B029B; Tue, 9 Oct 2018 09:26:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 65B476B029D; Tue, 9 Oct 2018 09:26:58 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 501E66B029E; Tue, 9 Oct 2018 09:26:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id EEBAB6B029B for ; Tue, 9 Oct 2018 09:26:57 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id b27-v6so1083480pfm.15 for ; Tue, 09 Oct 2018 06:26:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Jk+qEpa2f+vfOmDwNCKukccvo29yrzbglGEhs69b4KE=; b=ohVsb0atUXLXXtD5zQSGlMd/kjwlnzNarRlrff7UyDfLw+VzKcgUSQpTT3+MzuiFqu MNVxBSQdojwy0PUAzdek4GtTjHVQqjV5omjfOsWFP9JYeWeVrpr4+H3dEhlM/fxZv3zx 7ZsSXd7Xgd0MWg3zT/AuOmVOi1mpOT0nD/0oFsUBDlpRnLFglNWJb5ohtdO/jLSZWHhw k9TBRFMXxcuJHPijINF7JN4xVbyIqh2dEZGynEASvzzT2k3DJbOM6NLIu1SD4ZZq62bj d0trFbLyAnzWGeeynIsmfhlryPPSFt3hPnHmplDIFG26OPQ/JubYS+ZRtbeMGlRWTFmK 1JZw== X-Gm-Message-State: ABuFfogxSadS1sErJzU4UL3agpS7SzcFDB53dAscF4sQtNNqSWIaU6+x KV9HqLOi8eFFzFKh1QfQSNnYmT2EkqMgnHIouglLYxM920B/MOESxNkYUWl+gXOOXhV7w8cFpkZ tNFe7XO0n3bOQzt6z/1r4jsPstRPqhRMe8CwBdiOl0WRc/xVBa/7y9GB0GGOePys= X-Received: by 2002:a17:902:7246:: with SMTP id c6-v6mr28944068pll.304.1539091617582; Tue, 09 Oct 2018 06:26:57 -0700 (PDT) X-Google-Smtp-Source: ACcGV61HqHILQlVTHzybVWN2sjmrEFNyrfT2UlCDrb+8Oyxwr/723lzFl6r+E2sx/vxZiHVhu0O5 X-Received: by 2002:a17:902:7246:: with SMTP id c6-v6mr28943947pll.304.1539091615584; Tue, 09 Oct 2018 06:26:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091615; cv=none; d=google.com; s=arc-20160816; b=Cvh9B5oy43ii98FV4c7VecEaQo2Nttmu/vY02yJh1lQZx5/LIHfq/wymUhf/wMpFTh XsyuyBGBYKNc0GqIiOkhMmpmPuRzTJHeKYkzFGqYibNtv5dsvyaQ4XnfdAGvNnvLQzSE n6Y2xEmnB+5AokU8oXBBQXSy5b7WzxU5rZ9UVJOwaKQD9Zho0Qib8U/c2BjAzjH7jNK4 MAvaqgS5yDm9KZ2QKSkFwGmLr8/QcWum5bk323pNDj/UQXQ9WwYEBK/6f06PtANPEH1V 0MRLY9mT5ive8xzFEfKQ63NXsxfKbdNkdu9eOVxV5MnJH/EL66/Pm3bU772u56s1RL7y m7tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Jk+qEpa2f+vfOmDwNCKukccvo29yrzbglGEhs69b4KE=; b=oKgeKmv1jf7Gvv6IDhx6CrsCNv/dYSpZTyYZ1KGVMP4TheccrL9bVbT/2Qovb/6KAa ZMvspu5agn24xZs+HpEiIsu0vAqEUG1wNes1IimeTj5G9w/HDKqnAIGYnvzEQfL4bVJK KDhbe/Cp1H+F4EDKXxh/nKQMjK6V/K8hQiLz9hN3HI0Ev5VSdFiFU4Y9N3CdICV6Apwh AP6wgd3Eg3sQzSM8Q0Yi0CppJ5lV01c3Yrge0HJf0lWsrdBzhAGUeQeZA5yKSd/ICzfE dhc72obIcUuLP2Yx4r22LDZRTXhGD8nFH0J2tWhrakSthOFcJu7cJgXni9JoVgXX0WhD rdxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Ms8le5cS; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id f19-v6si20717220pgb.465.2018.10.09.06.26.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Ms8le5cS; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=Jk+qEpa2f+vfOmDwNCKukccvo29yrzbglGEhs69b4KE=; b=Ms8le5cSTDam5NEwpT4FrS87r2 g78euj2wMFUj4QA5gnI0SJd7+OW6BNuunrwD03Qly1WyzaMYuL+H679beMQ+kA7SRf5/X7yTnsm6J bdhbtOHPaGAzb3PHaHdxui6nODtXVvYu81GW1VmQIssKO4W9nAEW4Y+MoeDJtwKDg92t1AiW9oNvM 8sIT0uOsN7meI1pIjIOkCkCDud9YV+jKO60ar+i87e/JA9h13u8xuoS09V3q+EHUtLv4D93OZtv6F ENMCbKr5T2JhI5ZwzWTlsUnHNQfs4qz8/NYCq1cSflFIN7BdNcYFbveNbybWhQGKe+2m/j3rAW/tT Vq4Q0osQ==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s1o-0001eH-3y; Tue, 09 Oct 2018 13:26:24 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 32/33] powerpc/dma: use generic direct and swiotlb ops Date: Tue, 9 Oct 2018 15:24:59 +0200 Message-Id: <20181009132500.17643-33-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP - The ppc32 case of dma_nommu_dma_supported already was a no-op, and the 64-bit case came to the same conclusion as dma_direct_supported, so replace it with the generic version. - supports CMA - Note that the cache maintainance in the existing code is a bit odd as it implements both the sync_to_device and sync_to_cpu callouts, but never flushes caches when unmapping. This patch keeps both directions arounds, which will lead to more flushing than the previous implementation. Someone more familar with the required CPUs should eventually take a look and optimize the cache flush handling if needed. Signed-off-by: Christoph Hellwig --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/dma-mapping.h | 40 ------ arch/powerpc/include/asm/pgtable.h | 1 - arch/powerpc/include/asm/swiotlb.h | 2 - arch/powerpc/kernel/Makefile | 2 +- arch/powerpc/kernel/dma-iommu.c | 11 +- arch/powerpc/kernel/dma-swiotlb.c | 24 +--- arch/powerpc/kernel/dma.c | 190 ------------------------- arch/powerpc/kernel/pci-common.c | 2 +- arch/powerpc/kernel/setup-common.c | 2 +- arch/powerpc/mm/dma-noncoherent.c | 35 +++-- arch/powerpc/mm/mem.c | 19 --- arch/powerpc/platforms/44x/warp.c | 2 +- arch/powerpc/platforms/Kconfig.cputype | 2 + arch/powerpc/platforms/cell/iommu.c | 4 +- arch/powerpc/platforms/pasemi/iommu.c | 2 +- arch/powerpc/platforms/pasemi/setup.c | 2 +- arch/powerpc/platforms/pseries/vio.c | 7 + arch/powerpc/sysdev/fsl_pci.c | 2 +- drivers/misc/cxl/vphb.c | 2 +- 20 files changed, 49 insertions(+), 303 deletions(-) delete mode 100644 arch/powerpc/kernel/dma.c diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 7ea01687995d..7d29524533b4 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -155,6 +155,7 @@ config PPC select CLONE_BACKWARDS select DCACHE_WORD_ACCESS if PPC64 && CPU_LITTLE_ENDIAN select DYNAMIC_FTRACE if FUNCTION_TRACER + select DMA_DIRECT_OPS select EDAC_ATOMIC_SCRUB select EDAC_SUPPORT select GENERIC_ATOMIC64 if PPC32 diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index ababad4b07a7..a59c42879194 100644 --- a/arch/powerpc/include/asm/dma-mapping.h +++ b/arch/powerpc/include/asm/dma-mapping.h @@ -18,45 +18,6 @@ #include #include -/* Some dma direct funcs must be visible for use in other dma_ops */ -extern void *__dma_nommu_alloc_coherent(struct device *dev, size_t size, - dma_addr_t *dma_handle, gfp_t flag, - unsigned long attrs); -extern void __dma_nommu_free_coherent(struct device *dev, size_t size, - void *vaddr, dma_addr_t dma_handle, - unsigned long attrs); -int dma_nommu_map_sg(struct device *dev, struct scatterlist *sgl, - int nents, enum dma_data_direction direction, - unsigned long attrs); -dma_addr_t dma_nommu_map_page(struct device *dev, struct page *page, - unsigned long offset, size_t size, - enum dma_data_direction dir, unsigned long attrs); -int dma_nommu_dma_supported(struct device *dev, u64 mask); - -#ifdef CONFIG_NOT_COHERENT_CACHE -/* - * DMA-consistent mapping functions for PowerPCs that don't support - * cache snooping. These allocate/free a region of uncached mapped - * memory space for use with DMA devices. Alternatively, you could - * allocate the space "normally" and use the cache management functions - * to ensure it is consistent. - */ -struct device; -extern void __dma_sync(void *vaddr, size_t size, int direction); -extern void __dma_sync_page(struct page *page, unsigned long offset, - size_t size, int direction); -extern unsigned long __dma_get_coherent_pfn(unsigned long cpu_addr); - -#else /* ! CONFIG_NOT_COHERENT_CACHE */ -/* - * Cache coherent cores. - */ - -#define __dma_sync(addr, size, rw) ((void)0) -#define __dma_sync_page(pg, off, sz, rw) ((void)0) - -#endif /* ! CONFIG_NOT_COHERENT_CACHE */ - static inline unsigned long device_to_mask(struct device *dev) { if (dev->dma_mask && *dev->dma_mask) @@ -71,7 +32,6 @@ static inline unsigned long device_to_mask(struct device *dev) #ifdef CONFIG_PPC64 extern const struct dma_map_ops dma_iommu_ops; #endif -extern const struct dma_map_ops dma_nommu_ops; static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) { diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 9bafb38e959e..853372fe1001 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -37,7 +37,6 @@ extern unsigned long empty_zero_page[]; extern pgd_t swapper_pg_dir[]; -int dma_pfn_limit_to_zone(u64 pfn_limit); extern void paging_init(void); /* diff --git a/arch/powerpc/include/asm/swiotlb.h b/arch/powerpc/include/asm/swiotlb.h index 26a0f12b835b..b7ff218109b3 100644 --- a/arch/powerpc/include/asm/swiotlb.h +++ b/arch/powerpc/include/asm/swiotlb.h @@ -13,8 +13,6 @@ #include -extern const struct dma_map_ops powerpc_swiotlb_dma_ops; - extern unsigned int ppc_swiotlb_enable; int __init swiotlb_setup_bus_notifier(void); diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index 3b66f2c19c84..4e9ff65b4eff 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile @@ -33,7 +33,7 @@ obj-y := cputable.o ptrace.o syscalls.o \ process.o systbl.o idle.o \ signal.o sysfs.o cacheinfo.o time.o \ prom.o traps.o setup-common.o \ - udbg.o misc.o io.o dma.o misc_$(BITS).o \ + udbg.o misc.o io.o misc_$(BITS).o \ of_platform.o prom_parse.o obj-$(CONFIG_PPC64) += setup_64.o sys_ppc32.o \ signal_64.o ptrace32.o \ diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c index 2e682004959f..0224925c5628 100644 --- a/arch/powerpc/kernel/dma-iommu.c +++ b/arch/powerpc/kernel/dma-iommu.c @@ -21,7 +21,7 @@ static inline bool dma_iommu_alloc_bypass(struct device *dev) { return dev->archdata.iommu_bypass && !iommu_fixed_is_weak && - dma_nommu_dma_supported(dev, dev->coherent_dma_mask); + dma_direct_supported(dev, dev->coherent_dma_mask); } static inline bool dma_iommu_map_bypass(struct device *dev, @@ -40,8 +40,7 @@ static void *dma_iommu_alloc_coherent(struct device *dev, size_t size, unsigned long attrs) { if (dma_iommu_alloc_bypass(dev)) - return __dma_nommu_alloc_coherent(dev, size, dma_handle, flag, - attrs); + return dma_direct_alloc(dev, size, dma_handle, flag, attrs); return iommu_alloc_coherent(dev, get_iommu_table_base(dev), size, dma_handle, dev->coherent_dma_mask, flag, dev_to_node(dev)); @@ -52,7 +51,7 @@ static void dma_iommu_free_coherent(struct device *dev, size_t size, unsigned long attrs) { if (dma_iommu_alloc_bypass(dev)) - __dma_nommu_free_coherent(dev, size, vaddr, dma_handle, attrs); + dma_direct_free(dev, size, vaddr, dma_handle, attrs); else iommu_free_coherent(get_iommu_table_base(dev), size, vaddr, dma_handle); @@ -69,7 +68,7 @@ static dma_addr_t dma_iommu_map_page(struct device *dev, struct page *page, unsigned long attrs) { if (dma_iommu_map_bypass(dev, attrs)) - return dma_nommu_map_page(dev, page, offset, size, direction, + return dma_direct_map_page(dev, page, offset, size, direction, attrs); return iommu_map_page(dev, get_iommu_table_base(dev), page, offset, size, device_to_mask(dev), direction, attrs); @@ -91,7 +90,7 @@ static int dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist, unsigned long attrs) { if (dma_iommu_map_bypass(dev, attrs)) - return dma_nommu_map_sg(dev, sglist, nelems, direction, attrs); + return dma_direct_map_sg(dev, sglist, nelems, direction, attrs); return ppc_iommu_map_sg(dev, get_iommu_table_base(dev), sglist, nelems, device_to_mask(dev), direction, attrs); } diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c index c6f8519f8d4e..bded4127791a 100644 --- a/arch/powerpc/kernel/dma-swiotlb.c +++ b/arch/powerpc/kernel/dma-swiotlb.c @@ -32,28 +32,6 @@ EXPORT_SYMBOL(arch_dma_set_mask); unsigned int ppc_swiotlb_enable; -/* - * At the moment, all platforms that use this code only require - * swiotlb to be used if we're operating on HIGHMEM. Since - * we don't ever call anything other than map_sg, unmap_sg, - * map_page, and unmap_page on highmem, use normal dma_ops - * for everything else. - */ -const struct dma_map_ops powerpc_swiotlb_dma_ops = { - .alloc = __dma_nommu_alloc_coherent, - .free = __dma_nommu_free_coherent, - .map_sg = swiotlb_map_sg_attrs, - .unmap_sg = swiotlb_unmap_sg_attrs, - .dma_supported = swiotlb_dma_supported, - .map_page = swiotlb_map_page, - .unmap_page = swiotlb_unmap_page, - .sync_single_for_cpu = swiotlb_sync_single_for_cpu, - .sync_single_for_device = swiotlb_sync_single_for_device, - .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, - .sync_sg_for_device = swiotlb_sync_sg_for_device, - .mapping_error = swiotlb_dma_mapping_error, -}; - static int ppc_swiotlb_bus_notify(struct notifier_block *nb, unsigned long action, void *data) { @@ -65,7 +43,7 @@ static int ppc_swiotlb_bus_notify(struct notifier_block *nb, /* May need to bounce if the device can't address all of DRAM */ if ((dma_get_mask(dev) + 1) < memblock_end_of_DRAM()) - set_dma_ops(dev, &powerpc_swiotlb_dma_ops); + set_dma_ops(dev, &swiotlb_dma_ops); return NOTIFY_DONE; } diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c deleted file mode 100644 index 92cc402d249f..000000000000 --- a/arch/powerpc/kernel/dma.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corporation - * - * Provide default implementations of the DMA mapping callbacks for - * directly mapped busses. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Generic direct DMA implementation - * - * This implementation supports a per-device offset that can be applied if - * the address at which memory is visible to devices is not 0. Platform code - * can set archdata.dma_data to an unsigned long holding the offset. By - * default the offset is PCI_DRAM_OFFSET. - */ - -static u64 __maybe_unused get_pfn_limit(struct device *dev) -{ - u64 pfn = (dev->coherent_dma_mask >> PAGE_SHIFT) + 1; - -#ifdef CONFIG_SWIOTLB - if (dev->bus_dma_mask && dev->dma_ops == &powerpc_swiotlb_dma_ops) - pfn = min_t(u64, pfn, dev->bus_dma_mask >> PAGE_SHIFT); -#endif - - return pfn; -} - -int dma_nommu_dma_supported(struct device *dev, u64 mask) -{ -#ifdef CONFIG_PPC64 - u64 limit = phys_to_dma(dev, (memblock_end_of_DRAM() - 1)); - - /* Limit fits in the mask, we are good */ - if (mask >= limit) - return 1; - -#ifdef CONFIG_FSL_SOC - /* Freescale gets another chance via ZONE_DMA, however - * that will have to be refined if/when they support iommus - */ - return 1; -#endif - /* Sorry ... */ - return 0; -#else - return 1; -#endif -} - -#ifndef CONFIG_NOT_COHERENT_CACHE -void *__dma_nommu_alloc_coherent(struct device *dev, size_t size, - dma_addr_t *dma_handle, gfp_t flag, - unsigned long attrs) -{ - void *ret; - struct page *page; - int node = dev_to_node(dev); -#ifdef CONFIG_FSL_SOC - u64 pfn = get_pfn_limit(dev); - int zone; - - /* - * This code should be OK on other platforms, but we have drivers that - * don't set coherent_dma_mask. As a workaround we just ifdef it. This - * whole routine needs some serious cleanup. - */ - - zone = dma_pfn_limit_to_zone(pfn); - if (zone < 0) { - dev_err(dev, "%s: No suitable zone for pfn %#llx\n", - __func__, pfn); - return NULL; - } - - switch (zone) { -#ifdef CONFIG_ZONE_DMA - case ZONE_DMA: - flag |= GFP_DMA; - break; -#endif - }; -#endif /* CONFIG_FSL_SOC */ - - page = alloc_pages_node(node, flag, get_order(size)); - if (page == NULL) - return NULL; - ret = page_address(page); - memset(ret, 0, size); - *dma_handle = phys_to_dma(dev,__pa(ret)); - - return ret; -} - -void __dma_nommu_free_coherent(struct device *dev, size_t size, - void *vaddr, dma_addr_t dma_handle, - unsigned long attrs) -{ - free_pages((unsigned long)vaddr, get_order(size)); -} -#endif /* !CONFIG_NOT_COHERENT_CACHE */ - -int dma_nommu_map_sg(struct device *dev, struct scatterlist *sgl, - int nents, enum dma_data_direction direction, - unsigned long attrs) -{ - struct scatterlist *sg; - int i; - - for_each_sg(sgl, sg, nents, i) { - sg->dma_address = phys_to_dma(dev, sg_phys(sg)); - sg->dma_length = sg->length; - - if (attrs & DMA_ATTR_SKIP_CPU_SYNC) - continue; - - __dma_sync_page(sg_page(sg), sg->offset, sg->length, direction); - } - - return nents; -} - -dma_addr_t dma_nommu_map_page(struct device *dev, struct page *page, - unsigned long offset, size_t size, - enum dma_data_direction dir, unsigned long attrs) -{ - if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC)) - __dma_sync_page(page, offset, size, dir); - - return phys_to_dma(dev, page_to_phys(page)) + offset; -} - -#ifdef CONFIG_NOT_COHERENT_CACHE -static inline void dma_nommu_sync_sg(struct device *dev, - struct scatterlist *sgl, int nents, - enum dma_data_direction direction) -{ - struct scatterlist *sg; - int i; - - for_each_sg(sgl, sg, nents, i) - __dma_sync_page(sg_page(sg), sg->offset, sg->length, direction); -} - -static inline void dma_nommu_sync_single(struct device *dev, - dma_addr_t dma_handle, size_t size, - enum dma_data_direction direction) -{ - __dma_sync(bus_to_virt(dma_handle), size, direction); -} -#endif - -const struct dma_map_ops dma_nommu_ops = { - .alloc = __dma_nommu_alloc_coherent, - .free = __dma_nommu_free_coherent, - .map_sg = dma_nommu_map_sg, - .dma_supported = dma_nommu_dma_supported, - .map_page = dma_nommu_map_page, -#ifdef CONFIG_NOT_COHERENT_CACHE - .sync_single_for_cpu = dma_nommu_sync_single, - .sync_single_for_device = dma_nommu_sync_single, - .sync_sg_for_cpu = dma_nommu_sync_sg, - .sync_sg_for_device = dma_nommu_sync_sg, -#endif -}; -EXPORT_SYMBOL(dma_nommu_ops); - -static int __init dma_init(void) -{ -#ifdef CONFIG_IBMVIO - dma_debug_add_bus(&vio_bus_type); -#endif - - return 0; -} -fs_initcall(dma_init); - diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index fca2b0bafd82..b645b3882815 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -62,7 +62,7 @@ resource_size_t isa_mem_base; EXPORT_SYMBOL(isa_mem_base); -static const struct dma_map_ops *pci_dma_ops = &dma_nommu_ops; +static const struct dma_map_ops *pci_dma_ops = &dma_direct_ops; void set_pci_dma_ops(const struct dma_map_ops *dma_ops) { diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index 93fa0c99681e..a012e2060f02 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c @@ -792,7 +792,7 @@ void arch_setup_pdev_archdata(struct platform_device *pdev) { pdev->archdata.dma_mask = DMA_BIT_MASK(32); pdev->dev.dma_mask = &pdev->archdata.dma_mask; - set_dma_ops(&pdev->dev, &dma_nommu_ops); + set_dma_ops(&pdev->dev, &dma_direct_ops); } static __init void print_system_info(void) diff --git a/arch/powerpc/mm/dma-noncoherent.c b/arch/powerpc/mm/dma-noncoherent.c index a016c9c356d5..75971a0619a6 100644 --- a/arch/powerpc/mm/dma-noncoherent.c +++ b/arch/powerpc/mm/dma-noncoherent.c @@ -152,8 +152,8 @@ static struct ppc_vm_region *ppc_vm_region_find(struct ppc_vm_region *head, unsi * Allocate DMA-coherent memory space and return both the kernel remapped * virtual and bus address for that space. */ -void *__dma_nommu_alloc_coherent(struct device *dev, size_t size, - dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs) +void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, + gfp_t gfp, unsigned long attrs) { struct page *page; struct ppc_vm_region *c; @@ -254,7 +254,7 @@ void *__dma_nommu_alloc_coherent(struct device *dev, size_t size, /* * free a page as defined by the above mapping. */ -void __dma_nommu_free_coherent(struct device *dev, size_t size, void *vaddr, +void arch_dma_free(struct device *dev, size_t size, void *vaddr, dma_addr_t dma_handle, unsigned long attrs) { struct ppc_vm_region *c; @@ -314,7 +314,7 @@ void __dma_nommu_free_coherent(struct device *dev, size_t size, void *vaddr, /* * make an area consistent. */ -void __dma_sync(void *vaddr, size_t size, int direction) +static void __dma_sync(void *vaddr, size_t size, int direction) { unsigned long start = (unsigned long)vaddr; unsigned long end = start + size; @@ -340,7 +340,6 @@ void __dma_sync(void *vaddr, size_t size, int direction) break; } } -EXPORT_SYMBOL(__dma_sync); #ifdef CONFIG_HIGHMEM /* @@ -387,21 +386,33 @@ static inline void __dma_sync_page_highmem(struct page *page, * __dma_sync_page makes memory consistent. identical to __dma_sync, but * takes a struct page instead of a virtual address */ -void __dma_sync_page(struct page *page, unsigned long offset, - size_t size, int direction) +static void __dma_sync_page(phys_addr_t paddr, size_t size, int dir) { + struct page *page = pfn_to_page(paddr >> PAGE_SHIFT); + unsigned offset = paddr & ~PAGE_MASK; + #ifdef CONFIG_HIGHMEM - __dma_sync_page_highmem(page, offset, size, direction); + __dma_sync_page_highmem(page, offset, size, dir); #else unsigned long start = (unsigned long)page_address(page) + offset; - __dma_sync((void *)start, size, direction); + __dma_sync((void *)start, size, dir); #endif } -EXPORT_SYMBOL(__dma_sync_page); + +void arch_sync_dma_for_device(struct device *dev, phys_addr_t paddr, + size_t size, enum dma_data_direction dir) +{ + __dma_sync_page(paddr, size, dir); +} + +void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t paddr, + size_t size, enum dma_data_direction dir) +{ + __dma_sync_page(paddr, size, dir); +} /* - * Return the PFN for a given cpu virtual address returned by - * __dma_nommu_alloc_coherent. + * Return the PFN for a given cpu virtual address returned by arch_dma_alloc. */ long arch_dma_coherent_to_pfn(struct device *dev, void *vaddr, dma_addr_t dma_addr) diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 8bff7e893bde..b76ff59ee94c 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -257,25 +257,6 @@ static int __init mark_nonram_nosave(void) */ static unsigned long max_zone_pfns[MAX_NR_ZONES]; -/* - * Find the least restrictive zone that is entirely below the - * specified pfn limit. Returns < 0 if no suitable zone is found. - * - * pfn_limit must be u64 because it can exceed 32 bits even on 32-bit - * systems -- the DMA limit can be higher than any possible real pfn. - */ -int dma_pfn_limit_to_zone(u64 pfn_limit) -{ - int i; - - for (i = TOP_ZONE; i >= 0; i--) { - if (max_zone_pfns[i] <= pfn_limit) - return i; - } - - return -EPERM; -} - /* * paging_init() sets up the page tables - in fact we've already done this. */ diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c index 7e4f8ca19ce8..c0e6fb270d59 100644 --- a/arch/powerpc/platforms/44x/warp.c +++ b/arch/powerpc/platforms/44x/warp.c @@ -47,7 +47,7 @@ static int __init warp_probe(void) if (!of_machine_is_compatible("pika,warp")) return 0; - /* For __dma_nommu_alloc_coherent */ + /* For arch_dma_alloc */ ISA_DMA_THRESHOLD = ~0L; return 1; diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype index 0c4fc631cb33..b1bc3b92f54a 100644 --- a/arch/powerpc/platforms/Kconfig.cputype +++ b/arch/powerpc/platforms/Kconfig.cputype @@ -416,6 +416,8 @@ config NOT_COHERENT_CACHE bool depends on 4xx || PPC_8xx || E200 || PPC_MPC512x || GAMECUBE_COMMON select ARCH_HAS_DMA_COHERENT_TO_PFN + select ARCH_HAS_SYNC_DMA_FOR_DEVICE + select ARCH_HAS_SYNC_DMA_FOR_CPU default n if PPC_47x default y diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c index 997ee0f5fc2f..348a815779c1 100644 --- a/arch/powerpc/platforms/cell/iommu.c +++ b/arch/powerpc/platforms/cell/iommu.c @@ -601,7 +601,7 @@ static int cell_of_bus_notify(struct notifier_block *nb, unsigned long action, if (cell_iommu_enabled) dev->dma_ops = &dma_iommu_ops; else - dev->dma_ops = &dma_nommu_ops; + dev->dma_ops = &dma_direct_ops; cell_dma_dev_setup(dev); return 0; } @@ -727,7 +727,7 @@ static int __init cell_iommu_init_disabled(void) unsigned long base = 0, size; /* When no iommu is present, we use direct DMA ops */ - set_pci_dma_ops(&dma_nommu_ops); + set_pci_dma_ops(&dma_direct_ops); /* First make sure all IOC translation is turned off */ cell_disable_iommus(); diff --git a/arch/powerpc/platforms/pasemi/iommu.c b/arch/powerpc/platforms/pasemi/iommu.c index f06c83f321e6..47bda2b7cbd7 100644 --- a/arch/powerpc/platforms/pasemi/iommu.c +++ b/arch/powerpc/platforms/pasemi/iommu.c @@ -186,7 +186,7 @@ static void pci_dma_dev_setup_pasemi(struct pci_dev *dev) */ if (dev->vendor == 0x1959 && dev->device == 0xa007 && !firmware_has_feature(FW_FEATURE_LPAR)) { - dev->dev.dma_ops = &dma_nommu_ops; + dev->dev.dma_ops = &dma_direct_ops; /* * Set the coherent DMA mask to prevent the iommu * being used unnecessarily diff --git a/arch/powerpc/platforms/pasemi/setup.c b/arch/powerpc/platforms/pasemi/setup.c index 9a6eb04cca83..afb44e3dd8d2 100644 --- a/arch/powerpc/platforms/pasemi/setup.c +++ b/arch/powerpc/platforms/pasemi/setup.c @@ -362,7 +362,7 @@ static int pcmcia_notify(struct notifier_block *nb, unsigned long action, return 0; /* We use the direct ops for localbus */ - dev->dma_ops = &dma_nommu_ops; + dev->dma_ops = &dma_direct_ops; return 0; } diff --git a/arch/powerpc/platforms/pseries/vio.c b/arch/powerpc/platforms/pseries/vio.c index 3ad74efc83bf..54ad2ae81bc8 100644 --- a/arch/powerpc/platforms/pseries/vio.c +++ b/arch/powerpc/platforms/pseries/vio.c @@ -1704,3 +1704,10 @@ int vio_disable_interrupts(struct vio_dev *dev) } EXPORT_SYMBOL(vio_disable_interrupts); #endif /* CONFIG_PPC_PSERIES */ + +static int __init vio_init(void) +{ + dma_debug_add_bus(&vio_bus_type); + return 0; +} +fs_initcall(vio_init); diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c index d6b7c91a9ce2..964a4aede6b1 100644 --- a/arch/powerpc/sysdev/fsl_pci.c +++ b/arch/powerpc/sysdev/fsl_pci.c @@ -126,7 +126,7 @@ static void setup_swiotlb_ops(struct pci_controller *hose) { if (ppc_swiotlb_enable) { hose->controller_ops.dma_dev_setup = pci_dma_dev_setup_swiotlb; - set_pci_dma_ops(&powerpc_swiotlb_dma_ops); + set_pci_dma_ops(&swiotlb_dma_ops); } } #else diff --git a/drivers/misc/cxl/vphb.c b/drivers/misc/cxl/vphb.c index f0645ba1d728..f4ca1a4ada66 100644 --- a/drivers/misc/cxl/vphb.c +++ b/drivers/misc/cxl/vphb.c @@ -43,7 +43,7 @@ static bool cxl_pci_enable_device_hook(struct pci_dev *dev) return false; } - set_dma_ops(&dev->dev, &dma_nommu_ops); + set_dma_ops(&dev->dev, &dma_direct_ops); dev->dev.archdata.dma_offset = PAGE_OFFSET; /* From patchwork Tue Oct 9 13:25:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10632579 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9F9813AA for ; Tue, 9 Oct 2018 13:27:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F730289DF for ; Tue, 9 Oct 2018 13:27:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92FF628A5D; Tue, 9 Oct 2018 13:27:49 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B3AE289DF for ; Tue, 9 Oct 2018 13:27:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DE7F6B0299; Tue, 9 Oct 2018 09:26:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 217FF6B029A; Tue, 9 Oct 2018 09:26:48 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B90E6B029B; Tue, 9 Oct 2018 09:26:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id B61ED6B0299 for ; Tue, 9 Oct 2018 09:26:47 -0400 (EDT) Received: by mail-pl1-f197.google.com with SMTP id d40-v6so977251pla.14 for ; Tue, 09 Oct 2018 06:26:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=K74mCYmVOLJRzyNfEnzhXh0UECbS5GU9R54tYFzJ4NQ=; b=Uy6KAg1YfVUyQ+2l8l22qGWpmJJVeLfuhV5IAR3+hJjbN2RKf8sNlBKZ5afjPBfxvd 9BUrAvQc4t5IP0Xq9XAa8lBuLTbPSUdRyI4Hbfs4OnaQH2feFzB/Cc1589f8ww4Qq/7Z XElBLG8a3iv/caW9cWoS2YAXRaUHTjk1dv9zKc99nhrK5K1d8LOtowaxRFWy3lbW6sjD p7w7oyqQWnC3yD5P7pGyElsgLxSoC5isPwIpFQ+fGKRJXY3GsgXoeuu+rRwywduPMneZ rgpZFM5T3pi00gvISiuiRSw7aeuVJMfWzFroLIV/zGsUSyuHQQpJBCLDKpNyDlqg5lnm TniA== X-Gm-Message-State: ABuFfoirEFxRDKvZK05dbM3az7kGbUL+tvsOxrQvfN+JnaQ3PtgV6EgE I62CMvC0gJzsBe6yeaLjG4Gg42kfDtTVOM1LPxXJtI0y+AvFCCGVstDV0PjO5FE9XSB4wxrUE0l zgKN6HpwvIFS6LrD9VXk+ER/6Ph6aE5oS0av4kEJs7cNjx/nRP9RnUS0POCT2RSg= X-Received: by 2002:a63:2323:: with SMTP id j35-v6mr25838841pgj.337.1539091607439; Tue, 09 Oct 2018 06:26:47 -0700 (PDT) X-Google-Smtp-Source: ACcGV61V0wuXA+k6EtyzzHIwl9FX93HbChFvBzgNzmazF/mEO3rZHPKkaf7ouF8Vdd9zw38ETwNb X-Received: by 2002:a63:2323:: with SMTP id j35-v6mr25838795pgj.337.1539091606756; Tue, 09 Oct 2018 06:26:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091606; cv=none; d=google.com; s=arc-20160816; b=wv1hTegTfIRNAfGzUbmEbEV2ou2QdyjrkM6s1jft0T6DxAzGpHraNW1NORtDv18bTy j/ok8pUHZx31bnU544YHbGXgzXgZKULOeET1cP70kJmuKtroEHDHRpLVNp0zxir0ILYH 0hQ+J91UqDFpB+ZPPNllxuqXvr26adDIFmizMO/F6RTZaktTgDNIAviQQLTiwSo+inBL pJ2wrVAwmjat7sb11fWgCQWGESf4HKGt1nT+ONaLasVuLfzwTQz7R7abXkBYrBjXCnPK Y/npCsasW0oEeWTs8gZEC013gT5ejbs3he85CDDz2FIGEeckBIjSA3d68RVsmXFxmVfc IR6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=K74mCYmVOLJRzyNfEnzhXh0UECbS5GU9R54tYFzJ4NQ=; b=rFGa5/AGjlSkAMtc9w/Q0eT/7OTJXCMnpXxTL4eJEzJIggCHkTZoupXXjgKZld2Tue oP5SbJ+7InYzS/9Hb/j8E1xWHt2DC+uTlLPUAgXIKedAyB9wFpuRcJMK+HmCxTMGMStP DoKgi9L/NjKfPMNIdFQoxATJp2H5Vd0gt1DPNBA0DWClSNu15qYQ8kqiJIQKJEnQr8wV SVmZo3SoDhLPiQFclw7OH0vTXMCrYyqArvyNwWJNagVHfIQWfSUBqREfBK6SwrQQA6wA kkCgOuTvGMFLNwDjY4795mEAVGxufzZBThMWx2r5gRpiYZ3fva9lwRICKu8ADE9ymeaQ zKtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=iOd+EwXl; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id m17-v6si22581170pfe.187.2018.10.09.06.26.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 06:26:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=iOd+EwXl; spf=pass (google.com: best guess record for domain of batv+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+39c443e67938b060f200+5525+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=K74mCYmVOLJRzyNfEnzhXh0UECbS5GU9R54tYFzJ4NQ=; b=iOd+EwXl95eb2AVGqS8jW/oHlA QkWuS3BVe5xM5dRfwO5pKw3OUinJ8vhM5YMk+pEEpBFS9VSO7m7WMf10lNcIvi6uonCHXdg7g5cBg s9zDsXqxuWo5FyU3W4R5fvifHnciQwKfrG79vSVhNQVH5ICk0jcpJMEdNp4x6CeKZjppu6oqzAEYb QheWujtsqDMvaU3hVYwlEJt6sQ9tbBe4LNe+8RbEmrb+0vl0Wi0pxXCqrq6tN8DEVn3ADjm9t79Uz n6nbJtlxZjGdjvtMy8bVVoAmTtchZSCUPjY7Ye1mas5OKo/Sao130eS9Re9qXUqw8Rfyj/kNW8Odg BX+B971Q==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s1q-0001fX-WC; Tue, 09 Oct 2018 13:26:27 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 33/33] powerpc/dma: trim the fat from Date: Tue, 9 Oct 2018 15:25:00 +0200 Message-Id: <20181009132500.17643-34-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP There is no need to provide anything but get_arch_dma_ops to . More the remaining declarations to and drop all the includes. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/dma-mapping.h | 29 -------------------------- arch/powerpc/include/asm/iommu.h | 10 +++++++++ arch/powerpc/platforms/44x/ppc476.c | 1 + 3 files changed, 11 insertions(+), 29 deletions(-) diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index a59c42879194..565d6f74b189 100644 --- a/arch/powerpc/include/asm/dma-mapping.h +++ b/arch/powerpc/include/asm/dma-mapping.h @@ -1,37 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2004 IBM - * - * Implements the generic device dma API for powerpc. - * the pci and vio busses */ #ifndef _ASM_DMA_MAPPING_H #define _ASM_DMA_MAPPING_H -#ifdef __KERNEL__ - -#include -#include -/* need struct page definitions */ -#include -#include -#include -#include -#include - -static inline unsigned long device_to_mask(struct device *dev) -{ - if (dev->dma_mask && *dev->dma_mask) - return *dev->dma_mask; - /* Assume devices without mask can take 32 bit addresses */ - return 0xfffffffful; -} - -/* - * Available generic sets of operations - */ -#ifdef CONFIG_PPC64 -extern const struct dma_map_ops dma_iommu_ops; -#endif static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) { @@ -43,5 +15,4 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) return NULL; } -#endif /* __KERNEL__ */ #endif /* _ASM_DMA_MAPPING_H */ diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h index 264d04f1dcd1..db745575e6a4 100644 --- a/arch/powerpc/include/asm/iommu.h +++ b/arch/powerpc/include/asm/iommu.h @@ -334,5 +334,15 @@ extern bool iommu_fixed_is_weak; #define iommu_fixed_is_weak false #endif +extern const struct dma_map_ops dma_iommu_ops; + +static inline unsigned long device_to_mask(struct device *dev) +{ + if (dev->dma_mask && *dev->dma_mask) + return *dev->dma_mask; + /* Assume devices without mask can take 32 bit addresses */ + return 0xfffffffful; +} + #endif /* __KERNEL__ */ #endif /* _ASM_IOMMU_H */ diff --git a/arch/powerpc/platforms/44x/ppc476.c b/arch/powerpc/platforms/44x/ppc476.c index e55933f9cd55..a5e61e5c16e2 100644 --- a/arch/powerpc/platforms/44x/ppc476.c +++ b/arch/powerpc/platforms/44x/ppc476.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include