From patchwork Fri Oct 23 21:00:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Aravamudan X-Patchwork-Id: 535267 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 32FBA140D7A for ; Sat, 24 Oct 2015 08:00:20 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752413AbbJWVAT (ORCPT ); Fri, 23 Oct 2015 17:00:19 -0400 Received: from e37.co.us.ibm.com ([32.97.110.158]:45862 "EHLO e37.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751265AbbJWVAR (ORCPT ); Fri, 23 Oct 2015 17:00:17 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 23 Oct 2015 15:00:17 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 23 Oct 2015 15:00:14 -0600 X-IBM-Helo: d03dlp01.boulder.ibm.com X-IBM-MailFrom: nacc@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org;sparclinux@vger.kernel.org Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 512591FF0049; Fri, 23 Oct 2015 14:48:26 -0600 (MDT) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t9NKxA5B29032634; Fri, 23 Oct 2015 13:59:10 -0700 Received: from d03av01.boulder.ibm.com (localhost [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t9NL0BjI016303; Fri, 23 Oct 2015 15:00:14 -0600 Received: from kernel.stglabs.ibm.com (kernel.stglabs.ibm.com [9.114.214.19]) by d03av01.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t9NL0Ade016213; Fri, 23 Oct 2015 15:00:10 -0600 Received: by kernel.stglabs.ibm.com (Postfix, from userid 1031) id 3B188240303; Fri, 23 Oct 2015 14:00:08 -0700 (PDT) Date: Fri, 23 Oct 2015 14:00:08 -0700 From: Nishanth Aravamudan To: "David S. Miller" Cc: Matthew Wilcox , Keith Busch , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Alexey Kardashevskiy , David Gibson , Christoph Hellwig , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org Subject: [PATCH 5/7] [RFC PATCH 5/7] sparc: rename kernel/iommu_common.h -> include/asm/iommu_common.h Message-ID: <20151023210008.GG10197@linux.vnet.ibm.com> References: <20151023205420.GA10197@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20151023205420.GA10197@linux.vnet.ibm.com> X-Operating-System: Linux 3.13.0-40-generic (x86_64) User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15102321-0025-0000-0000-00001E3497D8 Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org In order to cleanly expose the desired IOMMU page shift via the new dma_get_page_shift API, we need to have the sparc constants available in a more typical location. There should be no functional impact to this move, but it is untested. Signed-off-by: Nishanth Aravamudan --- arch/sparc/include/asm/iommu_common.h | 51 +++++++++++++++++++++++++++++++++++ arch/sparc/kernel/iommu.c | 2 +- arch/sparc/kernel/iommu_common.h | 51 ----------------------------------- arch/sparc/kernel/pci_psycho.c | 2 +- arch/sparc/kernel/pci_sabre.c | 2 +- arch/sparc/kernel/pci_schizo.c | 2 +- arch/sparc/kernel/pci_sun4v.c | 2 +- arch/sparc/kernel/psycho_common.c | 2 +- arch/sparc/kernel/sbus.c | 3 +-- 9 files changed, 58 insertions(+), 59 deletions(-) create mode 100644 arch/sparc/include/asm/iommu_common.h delete mode 100644 arch/sparc/kernel/iommu_common.h diff --git a/arch/sparc/include/asm/iommu_common.h b/arch/sparc/include/asm/iommu_common.h new file mode 100644 index 0000000..b40cec2 --- /dev/null +++ b/arch/sparc/include/asm/iommu_common.h @@ -0,0 +1,51 @@ +/* iommu_common.h: UltraSparc SBUS/PCI common iommu declarations. + * + * Copyright (C) 1999, 2008 David S. Miller (davem@davemloft.net) + */ + +#ifndef _IOMMU_COMMON_H +#define _IOMMU_COMMON_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/* + * These give mapping size of each iommu pte/tlb. + */ +#define IO_PAGE_SHIFT 13 +#define IO_PAGE_SIZE (1UL << IO_PAGE_SHIFT) +#define IO_PAGE_MASK (~(IO_PAGE_SIZE-1)) +#define IO_PAGE_ALIGN(addr) ALIGN(addr, IO_PAGE_SIZE) + +#define IO_TSB_ENTRIES (128*1024) +#define IO_TSB_SIZE (IO_TSB_ENTRIES * 8) + +/* + * This is the hardwired shift in the iotlb tag/data parts. + */ +#define IOMMU_PAGE_SHIFT 13 + +#define SG_ENT_PHYS_ADDRESS(SG) (__pa(sg_virt((SG)))) + +static inline int is_span_boundary(unsigned long entry, + unsigned long shift, + unsigned long boundary_size, + struct scatterlist *outs, + struct scatterlist *sg) +{ + unsigned long paddr = SG_ENT_PHYS_ADDRESS(outs); + int nr = iommu_num_pages(paddr, outs->dma_length + sg->length, + IO_PAGE_SIZE); + + return iommu_is_span_boundary(entry, nr, shift, boundary_size); +} + +#endif /* _IOMMU_COMMON_H */ diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c index 5320689..f9b6077 100644 --- a/arch/sparc/kernel/iommu.c +++ b/arch/sparc/kernel/iommu.c @@ -20,8 +20,8 @@ #endif #include +#include -#include "iommu_common.h" #include "kernel.h" #define STC_CTXMATCH_ADDR(STC, CTX) \ diff --git a/arch/sparc/kernel/iommu_common.h b/arch/sparc/kernel/iommu_common.h deleted file mode 100644 index b40cec2..0000000 --- a/arch/sparc/kernel/iommu_common.h +++ /dev/null @@ -1,51 +0,0 @@ -/* iommu_common.h: UltraSparc SBUS/PCI common iommu declarations. - * - * Copyright (C) 1999, 2008 David S. Miller (davem@davemloft.net) - */ - -#ifndef _IOMMU_COMMON_H -#define _IOMMU_COMMON_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -/* - * These give mapping size of each iommu pte/tlb. - */ -#define IO_PAGE_SHIFT 13 -#define IO_PAGE_SIZE (1UL << IO_PAGE_SHIFT) -#define IO_PAGE_MASK (~(IO_PAGE_SIZE-1)) -#define IO_PAGE_ALIGN(addr) ALIGN(addr, IO_PAGE_SIZE) - -#define IO_TSB_ENTRIES (128*1024) -#define IO_TSB_SIZE (IO_TSB_ENTRIES * 8) - -/* - * This is the hardwired shift in the iotlb tag/data parts. - */ -#define IOMMU_PAGE_SHIFT 13 - -#define SG_ENT_PHYS_ADDRESS(SG) (__pa(sg_virt((SG)))) - -static inline int is_span_boundary(unsigned long entry, - unsigned long shift, - unsigned long boundary_size, - struct scatterlist *outs, - struct scatterlist *sg) -{ - unsigned long paddr = SG_ENT_PHYS_ADDRESS(outs); - int nr = iommu_num_pages(paddr, outs->dma_length + sg->length, - IO_PAGE_SIZE); - - return iommu_is_span_boundary(entry, nr, shift, boundary_size); -} - -#endif /* _IOMMU_COMMON_H */ diff --git a/arch/sparc/kernel/pci_psycho.c b/arch/sparc/kernel/pci_psycho.c index 7dce27b..332fd6f 100644 --- a/arch/sparc/kernel/pci_psycho.c +++ b/arch/sparc/kernel/pci_psycho.c @@ -15,13 +15,13 @@ #include #include +#include #include #include #include #include #include "pci_impl.h" -#include "iommu_common.h" #include "psycho_common.h" #define DRIVER_NAME "psycho" diff --git a/arch/sparc/kernel/pci_sabre.c b/arch/sparc/kernel/pci_sabre.c index 00a616f..6c2c616 100644 --- a/arch/sparc/kernel/pci_sabre.c +++ b/arch/sparc/kernel/pci_sabre.c @@ -16,12 +16,12 @@ #include #include +#include #include #include #include #include "pci_impl.h" -#include "iommu_common.h" #include "psycho_common.h" #define DRIVER_NAME "sabre" diff --git a/arch/sparc/kernel/pci_schizo.c b/arch/sparc/kernel/pci_schizo.c index c664d3e..ef23ab2 100644 --- a/arch/sparc/kernel/pci_schizo.c +++ b/arch/sparc/kernel/pci_schizo.c @@ -13,13 +13,13 @@ #include #include +#include #include #include #include #include #include "pci_impl.h" -#include "iommu_common.h" #define DRIVER_NAME "schizo" #define PFX DRIVER_NAME ": " diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c index d2fe57d..1d72295 100644 --- a/arch/sparc/kernel/pci_sun4v.c +++ b/arch/sparc/kernel/pci_sun4v.c @@ -18,12 +18,12 @@ #include #include +#include #include #include #include #include "pci_impl.h" -#include "iommu_common.h" #include "pci_sun4v.h" diff --git a/arch/sparc/kernel/psycho_common.c b/arch/sparc/kernel/psycho_common.c index 8db48e8..8eec09d 100644 --- a/arch/sparc/kernel/psycho_common.c +++ b/arch/sparc/kernel/psycho_common.c @@ -5,10 +5,10 @@ #include #include +#include #include #include "pci_impl.h" -#include "iommu_common.h" #include "psycho_common.h" #define PSYCHO_STRBUF_CTRL_DENAB 0x0000000000000002ULL diff --git a/arch/sparc/kernel/sbus.c b/arch/sparc/kernel/sbus.c index be5bdf9..a92cdf6 100644 --- a/arch/sparc/kernel/sbus.c +++ b/arch/sparc/kernel/sbus.c @@ -24,8 +24,7 @@ #include #include #include - -#include "iommu_common.h" +#include #define MAP_BASE ((u32)0xc0000000)