Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1255012 > unrolled thread
| Started by | Nishanth Aravamudan <nacc@linux.vnet.ibm.com> |
|---|---|
| First post | 2015-10-23 23:00 +0200 |
| Last post | 2015-10-28 03:00 +0100 |
| Articles | 20 on this page of 39 — 8 participants |
Back to article view | Back to linux.kernel
[PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-23 23:00 +0200
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-23 23:00 +0200
[PATCH 1/7 v3] dma-mapping: add generic dma_get_page_shift API Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-23 23:00 +0200
[PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-23 23:00 +0200
Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift Alexey Kardashevskiy <aik@ozlabs.ru> - 2015-10-27 07:10 +0100
Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift "Busch, Keith" <keith.busch@intel.com> - 2015-10-27 15:10 +0100
Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-27 23:30 +0100
Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift Alexey Kardashevskiy <aik@ozlabs.ru> - 2015-10-28 02:10 +0100
Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-28 03:00 +0100
Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2015-10-28 03:30 +0100
Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-28 03:40 +0100
Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2015-10-28 04:30 +0100
[PATCH 4/7 v2] pseries/iommu: implement DDW-aware dma_get_page_shift Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-23 23:00 +0200
Re: [PATCH 4/7 v2] pseries/iommu: implement DDW-aware dma_get_page_shift Alexey Kardashevskiy <aik@ozlabs.ru> - 2015-10-27 07:00 +0100
Re: [PATCH 4/7 v2] pseries/iommu: implement DDW-aware dma_get_page_shift Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-27 23:30 +0100
[RFC PATCH 6/7] sparc/dma-mapping: override dma_get_page_shift Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-23 23:10 +0200
[PATCH 7/7 v2] drivers/nvme: default to the IOMMU page size Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-23 23:10 +0200
[PATCH 5/7] [RFC PATCH 5/7] sparc: rename kernel/iommu_common.h -> include/asm/iommu_common.h Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-23 23:10 +0200
Re: [PATCH 5/7] [RFC PATCH 5/7] sparc: rename kernel/iommu_common.h -> include/asm/iommu_common.h Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-23 23:10 +0200
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA David Miller <davem@davemloft.net> - 2015-10-27 02:20 +0100
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-27 23:30 +0100
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA "Busch, Keith" <keith.busch@intel.com> - 2015-10-27 23:40 +0100
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA David Miller <davem@davemloft.net> - 2015-10-28 01:40 +0100
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA "Busch, Keith" <keith.busch@intel.com> - 2015-10-28 15:00 +0100
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA Christoph Hellwig <hch@infradead.org> - 2015-10-29 13:00 +0100
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-29 17:00 +0100
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA "Busch, Keith" <keith.busch@intel.com> - 2015-10-29 18:30 +0100
[PATCH 1/1 v3] drivers/nvme: default to 4k device page size Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-30 22:40 +0100
Re: [PATCH 1/1 v3] drivers/nvme: default to 4k device page size Keith Busch <keith.busch@intel.com> - 2015-10-30 22:50 +0100
Re: [PATCH 1/1 v3] drivers/nvme: default to 4k device page size Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-30 23:20 +0100
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA David Miller <davem@davemloft.net> - 2015-10-30 02:40 +0100
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-30 22:40 +0100
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA Julian Calaby <julian.calaby@gmail.com> - 2015-10-28 00:00 +0100
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA Julian Calaby <julian.calaby@gmail.com> - 2015-10-28 00:50 +0100
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2015-10-28 01:40 +0100
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA David Miller <davem@davemloft.net> - 2015-10-28 01:50 +0100
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-28 00:50 +0100
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA David Miller <davem@davemloft.net> - 2015-10-28 01:40 +0100
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA Nishanth Aravamudan <nacc@linux.vnet.ibm.com> - 2015-10-28 03:00 +0100
Page 1 of 2 [1] 2 Next page →
| From | Nishanth Aravamudan <nacc@linux.vnet.ibm.com> |
|---|---|
| Date | 2015-10-23 23:00 +0200 |
| Subject | [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA |
| Message-ID | <qmRBo-4gB-11@gated-at.bofh.it> |
We received a bug report recently when DDW (64-bit direct DMA on Power) is not enabled for NVMe devices. In that case, we fall back to 32-bit DMA via the IOMMU, which is always done via 4K TCEs (Translation Control Entries). The NVMe device driver, though, assumes that the DMA alignment for the PRP entries will match the device's page size, and that the DMA aligment matches the kernel's page aligment. On Power, the the IOMMU page size, as mentioned above, can be 4K, while the device can have a page size of 8K, while the kernel has a page size of 64K. This eventually trips the BUG_ON in nvme_setup_prps(), as we have a 'dma_len' that is a multiple of 4K but not 8K (e.g., 0xF000). In this particular case, and generally, we want to use the IOMMU's page size for the default device page size, rather than the kernel's page size. This series consists of five patches: 1) add a generic dma_get_page_shift implementation that just returns PAGE_SHIFT 2) override the generic implementation on Power to use the IOMMU table's page shift if available 3) allow further specific overriding on power with machdep platform overrides 4) use the machdep override on pseries, as the DDW code puts the TCE shift in a special property and there is no IOMMU table available 5) move some sparc code around to make IOMMU_PAGE_SHIFT available in include/asm 6) override the generic implementation on sparce to use IOMMU_PAGE_SHIFT 7) leverage the new API in the NVMe driver With these patches, a NVMe device survives our internal hardware exerciser; the kernel BUGs within a few seconds without the patch. arch/powerpc/include/asm/dma-mapping.h | 3 +++ arch/powerpc/include/asm/machdep.h | 3 ++- arch/powerpc/kernel/dma.c | 11 +++++++++++ arch/powerpc/platforms/pseries/iommu.c | 36 ++++++++++++++++++++++++++++++++++++ arch/sparc/include/asm/dma-mapping.h | 8 ++++++++ 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 +-- drivers/block/nvme-core.c | 3 ++- include/linux/dma-mapping.h | 7 +++++++ 16 files changed, 127 insertions(+), 61 deletions(-) v1 -> v2: Based upon feedback from Christoph Hellwig, rather than using an arch-specific hack, expose the DMA page shift via a generic DMA API and override it on Power as needed. v2 -> v3: Based upon feedback from Christoph Hellwig, put the generic implementation in include/linux/dma-mapping.h, since not all archs use include/asm-generic/dma-mapping-common.h. Add sparc implementation, as that arch seems to have a different IOMMU page size. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Nishanth Aravamudan <nacc@linux.vnet.ibm.com> |
|---|---|
| Date | 2015-10-23 23:00 +0200 |
| Message-ID | <qmRBo-4gB-21@gated-at.bofh.it> |
| In reply to | #1255012 |
[Sorry, subject should have been 0/7!] On 23.10.2015 [13:54:20 -0700], Nishanth Aravamudan wrote: > We received a bug report recently when DDW (64-bit direct DMA on Power) > is not enabled for NVMe devices. In that case, we fall back to 32-bit > DMA via the IOMMU, which is always done via 4K TCEs (Translation Control > Entries). > > The NVMe device driver, though, assumes that the DMA alignment for the > PRP entries will match the device's page size, and that the DMA aligment > matches the kernel's page aligment. On Power, the the IOMMU page size, > as mentioned above, can be 4K, while the device can have a page size of > 8K, while the kernel has a page size of 64K. This eventually trips the > BUG_ON in nvme_setup_prps(), as we have a 'dma_len' that is a multiple > of 4K but not 8K (e.g., 0xF000). > > In this particular case, and generally, we want to use the IOMMU's page > size for the default device page size, rather than the kernel's page > size. > > This series consists of five patches: > > 1) add a generic dma_get_page_shift implementation that just returns > PAGE_SHIFT > 2) override the generic implementation on Power to use the IOMMU table's > page shift if available > 3) allow further specific overriding on power with machdep platform > overrides > 4) use the machdep override on pseries, as the DDW code puts the TCE > shift in a special property and there is no IOMMU table available > 5) move some sparc code around to make IOMMU_PAGE_SHIFT available in > include/asm > 6) override the generic implementation on sparce to use IOMMU_PAGE_SHIFT > 7) leverage the new API in the NVMe driver > > With these patches, a NVMe device survives our internal hardware > exerciser; the kernel BUGs within a few seconds without the patch. > > arch/powerpc/include/asm/dma-mapping.h | 3 +++ > arch/powerpc/include/asm/machdep.h | 3 ++- > arch/powerpc/kernel/dma.c | 11 +++++++++++ > arch/powerpc/platforms/pseries/iommu.c | 36 ++++++++++++++++++++++++++++++++++++ > arch/sparc/include/asm/dma-mapping.h | 8 ++++++++ > 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 +-- > drivers/block/nvme-core.c | 3 ++- > include/linux/dma-mapping.h | 7 +++++++ > 16 files changed, 127 insertions(+), 61 deletions(-) > > v1 -> v2: > Based upon feedback from Christoph Hellwig, rather than using an > arch-specific hack, expose the DMA page shift via a generic DMA API and > override it on Power as needed. > v2 -> v3: > Based upon feedback from Christoph Hellwig, put the generic > implementation in include/linux/dma-mapping.h, since not all archs use > include/asm-generic/dma-mapping-common.h. > Add sparc implementation, as that arch seems to have a different IOMMU > page size. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Nishanth Aravamudan <nacc@linux.vnet.ibm.com> |
|---|---|
| Date | 2015-10-23 23:00 +0200 |
| Subject | [PATCH 1/7 v3] dma-mapping: add generic dma_get_page_shift API |
| Message-ID | <qmRBp-4gB-23@gated-at.bofh.it> |
| In reply to | #1255012 |
Drivers like NVMe need to be able to determine the page size used for
DMA transfers. Add a new API that defaults to return PAGE_SHIFT on all
architectures.
Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
---
v1 -> v2:
Based upon feedback from Christoph Hellwig, implement the IOMMU page
size lookup as a generic DMA API, rather than an architecture-specific
hack.
v2 -> v3:
Based upon feedback from Christoph Hellwig that not all architectures
have moved to dma-mapping-common.h, so move the #ifdef and default to
linux/dma-mapping.h.
---
include/linux/dma-mapping.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index ac07ff0..7eaba8d 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -95,6 +95,13 @@ static inline u64 dma_get_mask(struct device *dev)
return DMA_BIT_MASK(32);
}
+#ifndef HAVE_ARCH_DMA_GET_PAGE_SHIFT
+static inline unsigned long dma_get_page_shift(struct device *dev)
+{
+ return PAGE_SHIFT;
+}
+#endif
+
#ifdef CONFIG_ARCH_HAS_DMA_SET_COHERENT_MASK
int dma_set_coherent_mask(struct device *dev, u64 mask);
#else
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Nishanth Aravamudan <nacc@linux.vnet.ibm.com> |
|---|---|
| Date | 2015-10-23 23:00 +0200 |
| Subject | [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift |
| Message-ID | <qmRBp-4gB-25@gated-at.bofh.it> |
| In reply to | #1255012 |
On Power, the kernel's page size can differ from the IOMMU's page size,
so we need to override the generic implementation, which always returns
the kernel's page size. Lookup the IOMMU's page size from struct
iommu_table, if available. Fallback to the kernel's page size,
otherwise.
Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
---
arch/powerpc/include/asm/dma-mapping.h | 3 +++
arch/powerpc/kernel/dma.c | 9 +++++++++
2 files changed, 12 insertions(+)
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index 7f522c0..c5638f4 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -125,6 +125,9 @@ 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);
+#define HAVE_ARCH_DMA_GET_PAGE_SHIFT 1
+extern unsigned long dma_get_page_shift(struct device *dev);
+
#include <asm-generic/dma-mapping-common.h>
extern int __dma_set_mask(struct device *dev, u64 dma_mask);
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index 59503ed..e805af2 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -335,6 +335,15 @@ int dma_set_mask(struct device *dev, u64 dma_mask)
}
EXPORT_SYMBOL(dma_set_mask);
+unsigned long dma_get_page_shift(struct device *dev)
+{
+ struct iommu_table *tbl = get_iommu_table_base(dev);
+ if (tbl)
+ return tbl->it_page_shift;
+ return PAGE_SHIFT;
+}
+EXPORT_SYMBOL(dma_get_page_shift);
+
u64 __dma_get_required_mask(struct device *dev)
{
struct dma_map_ops *dma_ops = get_dma_ops(dev);
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Alexey Kardashevskiy <aik@ozlabs.ru> |
|---|---|
| Date | 2015-10-27 07:10 +0100 |
| Subject | Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift |
| Message-ID | <qo5Ch-1Ga-3@gated-at.bofh.it> |
| In reply to | #1255016 |
On 10/24/2015 07:57 AM, Nishanth Aravamudan wrote:
> On Power, the kernel's page size can differ from the IOMMU's page size,
> so we need to override the generic implementation, which always returns
> the kernel's page size. Lookup the IOMMU's page size from struct
> iommu_table, if available. Fallback to the kernel's page size,
> otherwise.
>
> Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
> ---
> arch/powerpc/include/asm/dma-mapping.h | 3 +++
> arch/powerpc/kernel/dma.c | 9 +++++++++
> 2 files changed, 12 insertions(+)
>
> diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
> index 7f522c0..c5638f4 100644
> --- a/arch/powerpc/include/asm/dma-mapping.h
> +++ b/arch/powerpc/include/asm/dma-mapping.h
> @@ -125,6 +125,9 @@ 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);
>
> +#define HAVE_ARCH_DMA_GET_PAGE_SHIFT 1
> +extern unsigned long dma_get_page_shift(struct device *dev);
> +
> #include <asm-generic/dma-mapping-common.h>
>
> extern int __dma_set_mask(struct device *dev, u64 dma_mask);
> diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
> index 59503ed..e805af2 100644
> --- a/arch/powerpc/kernel/dma.c
> +++ b/arch/powerpc/kernel/dma.c
> @@ -335,6 +335,15 @@ int dma_set_mask(struct device *dev, u64 dma_mask)
> }
> EXPORT_SYMBOL(dma_set_mask);
>
> +unsigned long dma_get_page_shift(struct device *dev)
> +{
> + struct iommu_table *tbl = get_iommu_table_base(dev);
> + if (tbl)
> + return tbl->it_page_shift;
All PCI devices have this initialized on POWER (at least, our, IBM's POWER)
so 4K will always be returned here while in the case of
(get_dma_ops(dev)==&dma_direct_ops) it could actually return PAGE_SHIFT. Is
4K still preferred value to return here?
> + return PAGE_SHIFT;
> +}
> +EXPORT_SYMBOL(dma_get_page_shift);
> +
> u64 __dma_get_required_mask(struct device *dev)
> {
> struct dma_map_ops *dma_ops = get_dma_ops(dev);
>
--
Alexey
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Busch, Keith" <keith.busch@intel.com> |
|---|---|
| Date | 2015-10-27 15:10 +0100 |
| Subject | Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift |
| Message-ID | <qod6O-6ak-15@gated-at.bofh.it> |
| In reply to | #1256479 |
On Tue, Oct 27, 2015 at 05:02:16PM +1100, Alexey Kardashevskiy wrote:
> >+unsigned long dma_get_page_shift(struct device *dev)
> >+{
> >+ struct iommu_table *tbl = get_iommu_table_base(dev);
> >+ if (tbl)
> >+ return tbl->it_page_shift;
>
>
> All PCI devices have this initialized on POWER (at least, our, IBM's
> POWER) so 4K will always be returned here while in the case of
> (get_dma_ops(dev)==&dma_direct_ops) it could actually return
> PAGE_SHIFT. Is 4K still preferred value to return here?
4k is always a safe option to return, but ideally you want to return the
highest guaranteed DMA address alignment. The driver just needs to know
which bits to mask from virtual addresses such that the offset is the
same as the DMA address.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Nishanth Aravamudan <nacc@linux.vnet.ibm.com> |
|---|---|
| Date | 2015-10-27 23:30 +0100 |
| Subject | Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift |
| Message-ID | <qokUH-2vz-47@gated-at.bofh.it> |
| In reply to | #1256479 |
On 27.10.2015 [17:02:16 +1100], Alexey Kardashevskiy wrote:
> On 10/24/2015 07:57 AM, Nishanth Aravamudan wrote:
> >On Power, the kernel's page size can differ from the IOMMU's page size,
> >so we need to override the generic implementation, which always returns
> >the kernel's page size. Lookup the IOMMU's page size from struct
> >iommu_table, if available. Fallback to the kernel's page size,
> >otherwise.
> >
> >Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
> >---
> > arch/powerpc/include/asm/dma-mapping.h | 3 +++
> > arch/powerpc/kernel/dma.c | 9 +++++++++
> > 2 files changed, 12 insertions(+)
> >
> >diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
> >index 7f522c0..c5638f4 100644
> >--- a/arch/powerpc/include/asm/dma-mapping.h
> >+++ b/arch/powerpc/include/asm/dma-mapping.h
> >@@ -125,6 +125,9 @@ 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);
> >
> >+#define HAVE_ARCH_DMA_GET_PAGE_SHIFT 1
> >+extern unsigned long dma_get_page_shift(struct device *dev);
> >+
> > #include <asm-generic/dma-mapping-common.h>
> >
> > extern int __dma_set_mask(struct device *dev, u64 dma_mask);
> >diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
> >index 59503ed..e805af2 100644
> >--- a/arch/powerpc/kernel/dma.c
> >+++ b/arch/powerpc/kernel/dma.c
> >@@ -335,6 +335,15 @@ int dma_set_mask(struct device *dev, u64 dma_mask)
> > }
> > EXPORT_SYMBOL(dma_set_mask);
> >
> >+unsigned long dma_get_page_shift(struct device *dev)
> >+{
> >+ struct iommu_table *tbl = get_iommu_table_base(dev);
> >+ if (tbl)
> >+ return tbl->it_page_shift;
>
>
> All PCI devices have this initialized on POWER (at least, our, IBM's
> POWER) so 4K will always be returned here while in the case of
> (get_dma_ops(dev)==&dma_direct_ops) it could actually return
> PAGE_SHIFT. Is 4K still preferred value to return here?
Right, so the logic of my series, goes like this:
a) We currently are assuming DMA_PAGE_SHIFT (conceptual constant) is
PAGE_SHIFT everywhere, including Power.
b) After 2/7, the Power code will return either the IOMMU table's shift
value, if set, or PAGE_SHIFT (I guess this would be the case if
get_dma_ops(dev) == &dma_direct_ops, as you said). That is no different
than we have now, except we can return the accurate IOMMU value if
available.
3) After 3/7, the platform can override the generic Power
get_dma_page_shift().
4) After 4/7, pseries will return the DDW value, if available, then
fallback to the IOMMU table's value. I think in the case of
get_dma_ops(dev)==&dma_direct_ops, the only way that can happen is if we
are using DDW, right?
-Nish
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Alexey Kardashevskiy <aik@ozlabs.ru> |
|---|---|
| Date | 2015-10-28 02:10 +0100 |
| Subject | Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift |
| Message-ID | <qonpw-4h9-9@gated-at.bofh.it> |
| In reply to | #1257439 |
On 10/28/2015 09:27 AM, Nishanth Aravamudan wrote:
> On 27.10.2015 [17:02:16 +1100], Alexey Kardashevskiy wrote:
>> On 10/24/2015 07:57 AM, Nishanth Aravamudan wrote:
>>> On Power, the kernel's page size can differ from the IOMMU's page size,
>>> so we need to override the generic implementation, which always returns
>>> the kernel's page size. Lookup the IOMMU's page size from struct
>>> iommu_table, if available. Fallback to the kernel's page size,
>>> otherwise.
>>>
>>> Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
>>> ---
>>> arch/powerpc/include/asm/dma-mapping.h | 3 +++
>>> arch/powerpc/kernel/dma.c | 9 +++++++++
>>> 2 files changed, 12 insertions(+)
>>>
>>> diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
>>> index 7f522c0..c5638f4 100644
>>> --- a/arch/powerpc/include/asm/dma-mapping.h
>>> +++ b/arch/powerpc/include/asm/dma-mapping.h
>>> @@ -125,6 +125,9 @@ 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);
>>>
>>> +#define HAVE_ARCH_DMA_GET_PAGE_SHIFT 1
>>> +extern unsigned long dma_get_page_shift(struct device *dev);
>>> +
>>> #include <asm-generic/dma-mapping-common.h>
>>>
>>> extern int __dma_set_mask(struct device *dev, u64 dma_mask);
>>> diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
>>> index 59503ed..e805af2 100644
>>> --- a/arch/powerpc/kernel/dma.c
>>> +++ b/arch/powerpc/kernel/dma.c
>>> @@ -335,6 +335,15 @@ int dma_set_mask(struct device *dev, u64 dma_mask)
>>> }
>>> EXPORT_SYMBOL(dma_set_mask);
>>>
>>> +unsigned long dma_get_page_shift(struct device *dev)
>>> +{
>>> + struct iommu_table *tbl = get_iommu_table_base(dev);
>>> + if (tbl)
>>> + return tbl->it_page_shift;
>>
>>
>> All PCI devices have this initialized on POWER (at least, our, IBM's
>> POWER) so 4K will always be returned here while in the case of
>> (get_dma_ops(dev)==&dma_direct_ops) it could actually return
>> PAGE_SHIFT. Is 4K still preferred value to return here?
>
> Right, so the logic of my series, goes like this:
>
> a) We currently are assuming DMA_PAGE_SHIFT (conceptual constant) is
> PAGE_SHIFT everywhere, including Power.
>
> b) After 2/7, the Power code will return either the IOMMU table's shift
> value, if set, or PAGE_SHIFT (I guess this would be the case if
> get_dma_ops(dev) == &dma_direct_ops, as you said). That is no different
> than we have now, except we can return the accurate IOMMU value if
> available.
If it is not available, then something went wrong and BUG_ON(!tbl ||
!tbl->it_page_shift) make more sense here than pretending that this
function can ever return PAGE_SHIFT. imho.
>
> 3) After 3/7, the platform can override the generic Power
> get_dma_page_shift().
>
> 4) After 4/7, pseries will return the DDW value, if available, then
> fallback to the IOMMU table's value. I think in the case of
> get_dma_ops(dev)==&dma_direct_ops, the only way that can happen is if we
> are using DDW, right?
This is for pseries guests; for the powernv host it is a "bypass" mode
which does 64bit direct DMA mapping and there is no additional window for
that (i.e. DIRECT64_PROPNAME, etc).
--
Alexey
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Nishanth Aravamudan <nacc@linux.vnet.ibm.com> |
|---|---|
| Date | 2015-10-28 03:00 +0100 |
| Subject | Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift |
| Message-ID | <qoobU-4xv-1@gated-at.bofh.it> |
| In reply to | #1257540 |
On 28.10.2015 [12:00:20 +1100], Alexey Kardashevskiy wrote:
> On 10/28/2015 09:27 AM, Nishanth Aravamudan wrote:
> >On 27.10.2015 [17:02:16 +1100], Alexey Kardashevskiy wrote:
> >>On 10/24/2015 07:57 AM, Nishanth Aravamudan wrote:
> >>>On Power, the kernel's page size can differ from the IOMMU's page size,
> >>>so we need to override the generic implementation, which always returns
> >>>the kernel's page size. Lookup the IOMMU's page size from struct
> >>>iommu_table, if available. Fallback to the kernel's page size,
> >>>otherwise.
> >>>
> >>>Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
> >>>---
> >>> arch/powerpc/include/asm/dma-mapping.h | 3 +++
> >>> arch/powerpc/kernel/dma.c | 9 +++++++++
> >>> 2 files changed, 12 insertions(+)
> >>>
> >>>diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
> >>>index 7f522c0..c5638f4 100644
> >>>--- a/arch/powerpc/include/asm/dma-mapping.h
> >>>+++ b/arch/powerpc/include/asm/dma-mapping.h
> >>>@@ -125,6 +125,9 @@ 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);
> >>>
> >>>+#define HAVE_ARCH_DMA_GET_PAGE_SHIFT 1
> >>>+extern unsigned long dma_get_page_shift(struct device *dev);
> >>>+
> >>> #include <asm-generic/dma-mapping-common.h>
> >>>
> >>> extern int __dma_set_mask(struct device *dev, u64 dma_mask);
> >>>diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
> >>>index 59503ed..e805af2 100644
> >>>--- a/arch/powerpc/kernel/dma.c
> >>>+++ b/arch/powerpc/kernel/dma.c
> >>>@@ -335,6 +335,15 @@ int dma_set_mask(struct device *dev, u64 dma_mask)
> >>> }
> >>> EXPORT_SYMBOL(dma_set_mask);
> >>>
> >>>+unsigned long dma_get_page_shift(struct device *dev)
> >>>+{
> >>>+ struct iommu_table *tbl = get_iommu_table_base(dev);
> >>>+ if (tbl)
> >>>+ return tbl->it_page_shift;
> >>
> >>
> >>All PCI devices have this initialized on POWER (at least, our, IBM's
> >>POWER) so 4K will always be returned here while in the case of
> >>(get_dma_ops(dev)==&dma_direct_ops) it could actually return
> >>PAGE_SHIFT. Is 4K still preferred value to return here?
> >
> >Right, so the logic of my series, goes like this:
> >
> >a) We currently are assuming DMA_PAGE_SHIFT (conceptual constant) is
> >PAGE_SHIFT everywhere, including Power.
> >
> >b) After 2/7, the Power code will return either the IOMMU table's shift
> >value, if set, or PAGE_SHIFT (I guess this would be the case if
> >get_dma_ops(dev) == &dma_direct_ops, as you said). That is no different
> >than we have now, except we can return the accurate IOMMU value if
> >available.
>
> If it is not available, then something went wrong and BUG_ON(!tbl ||
> !tbl->it_page_shift) make more sense here than pretending that this
> function can ever return PAGE_SHIFT. imho.
That's a good point, thanks!
> >3) After 3/7, the platform can override the generic Power
> >get_dma_page_shift().
> >
> >4) After 4/7, pseries will return the DDW value, if available, then
> >fallback to the IOMMU table's value. I think in the case of
> >get_dma_ops(dev)==&dma_direct_ops, the only way that can happen is if we
> >are using DDW, right?
>
> This is for pseries guests; for the powernv host it is a "bypass"
> mode which does 64bit direct DMA mapping and there is no additional
> window for that (i.e. DIRECT64_PROPNAME, etc).
You're right! I should update the code to handle both cases.
In "bypass" mode, what TCE size is used? Is it guaranteed to be 4K?
Seems like this would be a different platform implentation I'd put in
for 'powernv', is that right?
My apologies for missing that, and thank you for the review!
-Nish
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Benjamin Herrenschmidt <benh@kernel.crashing.org> |
|---|---|
| Date | 2015-10-28 03:30 +0100 |
| Subject | Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift |
| Message-ID | <qooEW-4Wx-19@gated-at.bofh.it> |
| In reply to | #1257570 |
On Tue, 2015-10-27 at 18:54 -0700, Nishanth Aravamudan wrote: > > In "bypass" mode, what TCE size is used? Is it guaranteed to be 4K? None :-) The TCEs are completely bypassed. You get a N:M linear mapping of all memory starting at 1<<59 PCI side. > Seems like this would be a different platform implentation I'd put in > for 'powernv', is that right? > > My apologies for missing that, and thank you for the review! Cheers, Ben. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Nishanth Aravamudan <nacc@linux.vnet.ibm.com> |
|---|---|
| Date | 2015-10-28 03:40 +0100 |
| Subject | Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift |
| Message-ID | <qooOB-50K-3@gated-at.bofh.it> |
| In reply to | #1257594 |
On 28.10.2015 [11:20:05 +0900], Benjamin Herrenschmidt wrote: > On Tue, 2015-10-27 at 18:54 -0700, Nishanth Aravamudan wrote: > > > > In "bypass" mode, what TCE size is used? Is it guaranteed to be 4K? > > None :-) The TCEs are completely bypassed. You get a N:M linear mapping > of all memory starting at 1<<59 PCI side. Err, duh, sorry! Ok, so in that case, DMA page shift is PAGE_SHIFT, then? -Nish -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Benjamin Herrenschmidt <benh@kernel.crashing.org> |
|---|---|
| Date | 2015-10-28 04:30 +0100 |
| Subject | Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift |
| Message-ID | <qopB0-5Ed-13@gated-at.bofh.it> |
| In reply to | #1257599 |
On Tue, 2015-10-27 at 19:30 -0700, Nishanth Aravamudan wrote: > On 28.10.2015 [11:20:05 +0900], Benjamin Herrenschmidt wrote: > > On Tue, 2015-10-27 at 18:54 -0700, Nishanth Aravamudan wrote: > > > > > > In "bypass" mode, what TCE size is used? Is it guaranteed to be > > > 4K? > > > > None :-) The TCEs are completely bypassed. You get a N:M linear > > mapping > > of all memory starting at 1<<59 PCI side. > > Err, duh, sorry! Ok, so in that case, DMA page shift is PAGE_SHIFT, > then? I think so. Cheers, Ben. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Nishanth Aravamudan <nacc@linux.vnet.ibm.com> |
|---|---|
| Date | 2015-10-23 23:00 +0200 |
| Subject | [PATCH 4/7 v2] pseries/iommu: implement DDW-aware dma_get_page_shift |
| Message-ID | <qmRBp-4gB-27@gated-at.bofh.it> |
| In reply to | #1255012 |
When DDW (Dynamic DMA Windows) are present for a device, we have stored
the TCE (Translation Control Entry) size in a special device tree
property. Check if we have enabled DDW for the device and return the TCE
size from that property if present. If the property isn't present,
fallback to looking the value up in struct iommu_table. If we don't find
a iommu_table, fallback to the kernel's page size.
Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
---
arch/powerpc/platforms/pseries/iommu.c | 36 ++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index 0946b98..1bf6471 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -1292,6 +1292,40 @@ static u64 dma_get_required_mask_pSeriesLP(struct device *dev)
return dma_iommu_ops.get_required_mask(dev);
}
+static unsigned long dma_get_page_shift_pSeriesLP(struct device *dev)
+{
+ struct iommu_table *tbl;
+
+ 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 DDW configuration, the TCE shift is stored in
+ * the property
+ */
+ if (dn && PCI_DN(dn)) {
+ const struct dynamic_dma_window_prop *direct64 =
+ of_get_property(dn, DIRECT64_PROPNAME, NULL);
+ if (direct64)
+ return be32_to_cpu(direct64->tce_shift);
+ }
+ }
+
+ tbl = get_iommu_table_base(dev);
+ if (tbl)
+ return tbl->it_page_shift;
+
+ return PAGE_SHIFT;
+}
+
#else /* CONFIG_PCI */
#define pci_dma_bus_setup_pSeries NULL
#define pci_dma_dev_setup_pSeries NULL
@@ -1299,6 +1333,7 @@ static u64 dma_get_required_mask_pSeriesLP(struct device *dev)
#define pci_dma_dev_setup_pSeriesLP NULL
#define dma_set_mask_pSeriesLP NULL
#define dma_get_required_mask_pSeriesLP NULL
+#define dma_get_page_shift_pSeriesLP NULL
#endif /* !CONFIG_PCI */
static int iommu_mem_notifier(struct notifier_block *nb, unsigned long action,
@@ -1395,6 +1430,7 @@ void iommu_init_early_pSeries(void)
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;
+ ppc_md.dma_get_page_shift = dma_get_page_shift_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;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Alexey Kardashevskiy <aik@ozlabs.ru> |
|---|---|
| Date | 2015-10-27 07:00 +0100 |
| Subject | Re: [PATCH 4/7 v2] pseries/iommu: implement DDW-aware dma_get_page_shift |
| Message-ID | <qo5sB-1nr-1@gated-at.bofh.it> |
| In reply to | #1255017 |
On 10/24/2015 07:59 AM, Nishanth Aravamudan wrote:
> When DDW (Dynamic DMA Windows) are present for a device, we have stored
> the TCE (Translation Control Entry) size in a special device tree
> property. Check if we have enabled DDW for the device and return the TCE
> size from that property if present. If the property isn't present,
> fallback to looking the value up in struct iommu_table. If we don't find
> a iommu_table, fallback to the kernel's page size.
>
> Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
> ---
> arch/powerpc/platforms/pseries/iommu.c | 36 ++++++++++++++++++++++++++++++++++
> 1 file changed, 36 insertions(+)
>
> diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
> index 0946b98..1bf6471 100644
> --- a/arch/powerpc/platforms/pseries/iommu.c
> +++ b/arch/powerpc/platforms/pseries/iommu.c
> @@ -1292,6 +1292,40 @@ static u64 dma_get_required_mask_pSeriesLP(struct device *dev)
> return dma_iommu_ops.get_required_mask(dev);
> }
>
> +static unsigned long dma_get_page_shift_pSeriesLP(struct device *dev)
> +{
> + struct iommu_table *tbl;
> +
> + 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 DDW configuration, the TCE shift is stored in
> + * the property
> + */
> + if (dn && PCI_DN(dn)) {
> + const struct dynamic_dma_window_prop *direct64 =
> + of_get_property(dn, DIRECT64_PROPNAME, NULL);
This DIRECT64_PROPNAME property is only present under pHyp, QEMU/KVM does
not set it as 64bit windows are dynamic there so something like
find_existing_ddw() needs to be used here.
> + if (direct64)
> + return be32_to_cpu(direct64->tce_shift);
> + }
> + }
> +
> + tbl = get_iommu_table_base(dev);
> + if (tbl)
> + return tbl->it_page_shift;
> +
> + return PAGE_SHIFT;
> +}
> +
> #else /* CONFIG_PCI */
> #define pci_dma_bus_setup_pSeries NULL
> #define pci_dma_dev_setup_pSeries NULL
> @@ -1299,6 +1333,7 @@ static u64 dma_get_required_mask_pSeriesLP(struct device *dev)
> #define pci_dma_dev_setup_pSeriesLP NULL
> #define dma_set_mask_pSeriesLP NULL
> #define dma_get_required_mask_pSeriesLP NULL
> +#define dma_get_page_shift_pSeriesLP NULL
> #endif /* !CONFIG_PCI */
>
> static int iommu_mem_notifier(struct notifier_block *nb, unsigned long action,
> @@ -1395,6 +1430,7 @@ void iommu_init_early_pSeries(void)
> 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;
> + ppc_md.dma_get_page_shift = dma_get_page_shift_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;
>
--
Alexey
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Nishanth Aravamudan <nacc@linux.vnet.ibm.com> |
|---|---|
| Date | 2015-10-27 23:30 +0100 |
| Subject | Re: [PATCH 4/7 v2] pseries/iommu: implement DDW-aware dma_get_page_shift |
| Message-ID | <qokUG-2vz-13@gated-at.bofh.it> |
| In reply to | #1256477 |
On 27.10.2015 [16:56:10 +1100], Alexey Kardashevskiy wrote:
> On 10/24/2015 07:59 AM, Nishanth Aravamudan wrote:
> >When DDW (Dynamic DMA Windows) are present for a device, we have stored
> >the TCE (Translation Control Entry) size in a special device tree
> >property. Check if we have enabled DDW for the device and return the TCE
> >size from that property if present. If the property isn't present,
> >fallback to looking the value up in struct iommu_table. If we don't find
> >a iommu_table, fallback to the kernel's page size.
> >
> >Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
> >---
> > arch/powerpc/platforms/pseries/iommu.c | 36 ++++++++++++++++++++++++++++++++++
> > 1 file changed, 36 insertions(+)
> >
> >diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
> >index 0946b98..1bf6471 100644
> >--- a/arch/powerpc/platforms/pseries/iommu.c
> >+++ b/arch/powerpc/platforms/pseries/iommu.c
> >@@ -1292,6 +1292,40 @@ static u64 dma_get_required_mask_pSeriesLP(struct device *dev)
> > return dma_iommu_ops.get_required_mask(dev);
> > }
> >
> >+static unsigned long dma_get_page_shift_pSeriesLP(struct device *dev)
> >+{
> >+ struct iommu_table *tbl;
> >+
> >+ 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 DDW configuration, the TCE shift is stored in
> >+ * the property
> >+ */
> >+ if (dn && PCI_DN(dn)) {
> >+ const struct dynamic_dma_window_prop *direct64 =
> >+ of_get_property(dn, DIRECT64_PROPNAME, NULL);
>
>
> This DIRECT64_PROPNAME property is only present under pHyp, QEMU/KVM
> does not set it as 64bit windows are dynamic there so something like
> find_existing_ddw() needs to be used here.
DIRECT64_PROPNAME is a Linux thing, not a pHyp or QEMU/KVM thing -- it's
created by the Linux DDW logic and left in the device-tree when we
successfully configure DDW.
You're right, though, that logically find_existing_ddw() would be better
to use here. I'll spin up a new version.
-Nish
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Nishanth Aravamudan <nacc@linux.vnet.ibm.com> |
|---|---|
| Date | 2015-10-23 23:10 +0200 |
| Subject | [RFC PATCH 6/7] sparc/dma-mapping: override dma_get_page_shift |
| Message-ID | <qmRL3-4HE-1@gated-at.bofh.it> |
| In reply to | #1255012 |
On sparc, the kernel's page size differs from the IOMMU's page size, so
override the generic implementation, which always returns the kernel's
page size, and return IOMMU_PAGE_SHIFT instead.
Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
---
I know very little about sparc, so please correct me if this patch is
invalid.
arch/sparc/include/asm/dma-mapping.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/sparc/include/asm/dma-mapping.h b/arch/sparc/include/asm/dma-mapping.h
index a21da59..76ba470 100644
--- a/arch/sparc/include/asm/dma-mapping.h
+++ b/arch/sparc/include/asm/dma-mapping.h
@@ -52,6 +52,14 @@ static inline int dma_set_mask(struct device *dev, u64 mask)
return -EINVAL;
}
+/* for IOMMU_PAGE_SHIFT */
+#include <asm/iommu_common.h>
+#define HAVE_ARCH_DMA_GET_PAGE_SHIFT 1
+static inline unsigned long dma_get_page_shift(struct device *dev)
+{
+ return IOMMU_PAGE_SHIFT;
+}
+
#include <asm-generic/dma-mapping-common.h>
#endif
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Nishanth Aravamudan <nacc@linux.vnet.ibm.com> |
|---|---|
| Date | 2015-10-23 23:10 +0200 |
| Subject | [PATCH 7/7 v2] drivers/nvme: default to the IOMMU page size |
| Message-ID | <qmRL4-4HE-3@gated-at.bofh.it> |
| In reply to | #1255012 |
We received a bug report recently when DDW (64-bit direct DMA on Power) is not enabled for NVMe devices. In that case, we fall back to 32-bit DMA via the IOMMU, which is always done via 4K TCEs (Translation Control Entries). The NVMe device driver, though, assumes that the DMA alignment for the PRP entries will match the device's page size, and that the DMA aligment matches the kernel's page aligment. On Power, the the IOMMU page size, as mentioned above, can be 4K, while the device can have a page size of 8K, while the kernel has a page size of 64K. This eventually trips the BUG_ON in nvme_setup_prps(), as we have a 'dma_len' that is a multiple of 4K but not 8K (e.g., 0xF000). In this particular case of page sizes, we clearly want to use the IOMMU's page size in the driver. And generally, the NVMe driver in this function should be using the IOMMU's page size for the default device page size, rather than the kernel's page size. With this patch, a NVMe device survives our internal hardware exerciser; the kernel BUGs within a few seconds without the patch. Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com> --- v1 -> v2: Based upon feedback from Christoph Hellwig, implement the IOMMU page size lookup as a generic DMA API, rather than an architecture-specific hack. drivers/block/nvme-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c index 6f04771..5a79106 100644 --- a/drivers/block/nvme-core.c +++ b/drivers/block/nvme-core.c @@ -18,6 +18,7 @@ #include <linux/blk-mq.h> #include <linux/cpu.h> #include <linux/delay.h> +#include <linux/dma-mapping.h> #include <linux/errno.h> #include <linux/fs.h> #include <linux/genhd.h> @@ -1711,7 +1712,7 @@ static int nvme_configure_admin_queue(struct nvme_dev *dev) u32 aqa; u64 cap = readq(&dev->bar->cap); struct nvme_queue *nvmeq; - unsigned page_shift = PAGE_SHIFT; + unsigned page_shift = dma_get_page_shift(dev->dev); unsigned dev_page_min = NVME_CAP_MPSMIN(cap) + 12; unsigned dev_page_max = NVME_CAP_MPSMAX(cap) + 12; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Nishanth Aravamudan <nacc@linux.vnet.ibm.com> |
|---|---|
| Date | 2015-10-23 23:10 +0200 |
| Subject | [PATCH 5/7] [RFC PATCH 5/7] sparc: rename kernel/iommu_common.h -> include/asm/iommu_common.h |
| Message-ID | <qmRL4-4HE-17@gated-at.bofh.it> |
| In reply to | #1255012 |
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 <nacc@linux.vnet.ibm.com>
---
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 <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/scatterlist.h>
+#include <linux/device.h>
+#include <linux/iommu-helper.h>
+#include <linux/scatterlist.h>
+
+#include <asm/iommu.h>
+
+/*
+ * 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 <asm/iommu.h>
+#include <asm/iommu_common.h>
-#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 <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/scatterlist.h>
-#include <linux/device.h>
-#include <linux/iommu-helper.h>
-#include <linux/scatterlist.h>
-
-#include <asm/iommu.h>
-
-/*
- * 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 <linux/of_device.h>
#include <asm/iommu.h>
+#include <asm/iommu_common.h>
#include <asm/irq.h>
#include <asm/starfire.h>
#include <asm/prom.h>
#include <asm/upa.h>
#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 <asm/apb.h>
#include <asm/iommu.h>
+#include <asm/iommu_common.h>
#include <asm/irq.h>
#include <asm/prom.h>
#include <asm/upa.h>
#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 <linux/of_device.h>
#include <asm/iommu.h>
+#include <asm/iommu_common.h>
#include <asm/irq.h>
#include <asm/pstate.h>
#include <asm/prom.h>
#include <asm/upa.h>
#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 <linux/iommu-common.h>
#include <asm/iommu.h>
+#include <asm/iommu_common.h>
#include <asm/irq.h>
#include <asm/hypervisor.h>
#include <asm/prom.h>
#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 <linux/kernel.h>
#include <linux/interrupt.h>
+#include <asm/iommu_common.h>
#include <asm/upa.h>
#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 <asm/prom.h>
#include <asm/oplib.h>
#include <asm/starfire.h>
-
-#include "iommu_common.h"
+#include <asm/iommu_common.h>
#define MAP_BASE ((u32)0xc0000000)
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Nishanth Aravamudan <nacc@linux.vnet.ibm.com> |
|---|---|
| Date | 2015-10-23 23:10 +0200 |
| Subject | Re: [PATCH 5/7] [RFC PATCH 5/7] sparc: rename kernel/iommu_common.h -> include/asm/iommu_common.h |
| Message-ID | <qmRL4-4HE-19@gated-at.bofh.it> |
| In reply to | #1255023 |
[Apologies for the subject line, should just have the [RFC PATCH 5/7]]
On 23.10.2015 [14:00:08 -0700], Nishanth Aravamudan wrote:
> 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 <nacc@linux.vnet.ibm.com>
> ---
> 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 <linux/kernel.h>
> +#include <linux/types.h>
> +#include <linux/sched.h>
> +#include <linux/mm.h>
> +#include <linux/scatterlist.h>
> +#include <linux/device.h>
> +#include <linux/iommu-helper.h>
> +#include <linux/scatterlist.h>
> +
> +#include <asm/iommu.h>
> +
> +/*
> + * 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 <asm/iommu.h>
> +#include <asm/iommu_common.h>
>
> -#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 <linux/kernel.h>
> -#include <linux/types.h>
> -#include <linux/sched.h>
> -#include <linux/mm.h>
> -#include <linux/scatterlist.h>
> -#include <linux/device.h>
> -#include <linux/iommu-helper.h>
> -#include <linux/scatterlist.h>
> -
> -#include <asm/iommu.h>
> -
> -/*
> - * 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 <linux/of_device.h>
>
> #include <asm/iommu.h>
> +#include <asm/iommu_common.h>
> #include <asm/irq.h>
> #include <asm/starfire.h>
> #include <asm/prom.h>
> #include <asm/upa.h>
>
> #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 <asm/apb.h>
> #include <asm/iommu.h>
> +#include <asm/iommu_common.h>
> #include <asm/irq.h>
> #include <asm/prom.h>
> #include <asm/upa.h>
>
> #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 <linux/of_device.h>
>
> #include <asm/iommu.h>
> +#include <asm/iommu_common.h>
> #include <asm/irq.h>
> #include <asm/pstate.h>
> #include <asm/prom.h>
> #include <asm/upa.h>
>
> #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 <linux/iommu-common.h>
>
> #include <asm/iommu.h>
> +#include <asm/iommu_common.h>
> #include <asm/irq.h>
> #include <asm/hypervisor.h>
> #include <asm/prom.h>
>
> #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 <linux/kernel.h>
> #include <linux/interrupt.h>
>
> +#include <asm/iommu_common.h>
> #include <asm/upa.h>
>
> #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 <asm/prom.h>
> #include <asm/oplib.h>
> #include <asm/starfire.h>
> -
> -#include "iommu_common.h"
> +#include <asm/iommu_common.h>
>
> #define MAP_BASE ((u32)0xc0000000)
>
> --
> 1.9.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2015-10-27 02:20 +0100 |
| Message-ID | <qo15D-78q-3@gated-at.bofh.it> |
| In reply to | #1255012 |
From: Nishanth Aravamudan <nacc@linux.vnet.ibm.com> Date: Fri, 23 Oct 2015 13:54:20 -0700 > 1) add a generic dma_get_page_shift implementation that just returns > PAGE_SHIFT I won't object to this patch series, but if I had implemented this I would have required the architectures to implement this explicitly, one-by-one. I think it is less error prone and more likely to end up with all the architectures setting this correctly. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.kernel
csiph-web