MIPS: Use dma-mapping-common.h and use swiotlb for Octeon.
Subsystems (3)
cover MIPS: Use dma-mapping-common.h and use swiotlb for Octeon.
The Octeon family of SOCs support physical memory outside of the 32-bit addressing range. To support 32-bit devices, we need to use the swiotlb bounce buffer mechanism.
There are several parts to the patch set.
1 - Set the proper dma_masks for the octeon_mgmt platform device so
that it continues to function with the rewritten dma mapping code to follow.
2,3,4 - Establish a properly constrained DMA32 zone for Octeon.
5 - Convert MIPS to use dma-mapping-common.h
6,7 - Trivial swiotlb changes.
8 - Get MIPS ready to use swiotlb.
9 - Rewrite Octeon dma mapping code.
Since the only non-MIPS parts of this patch set are trivial changes to swiotlb, I would suggest that they could all be merged via Ralf's tree if deemed acceptable.
David Daney (9):
MIPS: Octeon: Set dma_masks for octeon_mgmt device.
MIPS: Allow MAX_DMA32_PFN to be overridden.
MIPS: Octeon: Adjust top of DMA32 zone.
MIPS: Octeon: Select ZONE_DMA32
MIPS: Convert DMA to use dma-mapping-common.h
swiotlb: Declare swiotlb_init_with_default_size()
swiotlb: Make bounce buffer bounds non-static.
MIPS: Add a platform hook for swiotlb setup.
MIPS: Octeon: Rewrite DMA mapping functions.
arch/mips/Kconfig | 3 + arch/mips/cavium-octeon/Kconfig | 12 + arch/mips/cavium-octeon/dma-octeon.c | 529 +++++++++----------- arch/mips/cavium-octeon/octeon-platform.c | 5 + arch/mips/include/asm/bootinfo.h | 5 + arch/mips/include/asm/device.h | 15 +- arch/mips/include/asm/dma-mapping.h | 125 ++++-- arch/mips/include/asm/dma.h | 3 + .../asm/mach-cavium-octeon/cpu-feature-overrides.h | 6 + .../include/asm/mach-cavium-octeon/dma-coherence.h | 19 +- arch/mips/include/asm/octeon/pci-octeon.h | 10 + arch/mips/kernel/setup.c | 5 + arch/mips/mm/dma-default.c | 179 +++---- arch/mips/pci/pci-octeon.c | 60 ++- arch/mips/pci/pcie-octeon.c | 5 + include/linux/swiotlb.h | 7 + lib/swiotlb.c | 62 ++-- 17 files changed, 571 insertions(+), 479 deletions(-)
Signature · 1 line
1.7.2.2
PATCH 1/9 MIPS: Octeon: Set dma_masks for octeon_mgmt device.
This allows follow-on patches to dma mapping functions to work with the octeon mgmt device..
--- arch/mips/cavium-octeon/octeon-platform.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
arch/mips/cavium-octeon/octeon-platform.c +5 -0
@@ -10,6 +10,7 @@#include <linux/init.h> #include <linux/irq.h> #include <linux/i2c.h> +#include <linux/dma-mapping.h> #include <linux/module.h> #include <linux/platform_device.h>
@@ -301,6 +302,10 @@ static int __init octeon_mgmt_device_init(void) ret = -ENOMEM ; goto out; } +/* No DMA restrictions */ + pd->dev.coherent_dma_mask =DMA_BIT_MASK (64 ); + pd->dev.dma_mask = &pd->dev.coherent_dma_mask; +switch (port) {case 0 : mgmt_port_resource.start =OCTEON_IRQ_MII0 ;
Signature · 1 line
1.7.2.2
PATCH 2/9 MIPS: Allow MAX_DMA32_PFN to be overridden.
In reply to David DaneyDMA mapping may reduce the usable physical address range usable for 32-bit DMA.
--- arch/mips/include/asm/dma.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
arch/mips/include/asm/dma.h +3 -0
@@ -91,7 +91,10 @@#define MAX_DMA_ADDRESS (PAGE_OFFSET + 0x01000000)#endif #define MAX_DMA_PFN PFN_DOWN(virt_to_phys((void *)MAX_DMA_ADDRESS)) + +#ifndef MAX_DMA32_PFN #define MAX_DMA32_PFN (1UL << (32 - PAGE_SHIFT)) +#endif /* 8237 DMA controllers */ #define IO_DMA1_BASE 0x00/* 8 bit slave DMA, channels 0..3 */
Signature · 1 line
1.7.2.2
PATCH 3/9 MIPS: Octeon: Adjust top of DMA32 zone.
In reply to David DaneyOn OCTEON, we reserve the last 256MB of 32-bit PCI address space, mapping the RAM in this region at a high DMA address. This makes memory in this region unavailable for 32-bit DMA.
--- .../asm/mach-cavium-octeon/cpu-feature-overrides.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h +6 -0
@@ -81,4 +81,10 @@ static inline int octeon_has_saa(void) return id >= 0x000d0300; } +/* +* The last 256MB are reserved for device to device mappings and the +* BAR1 hole. +*/ +#define MAX_DMA32_PFN (((1ULL << 32) - (1ULL << 28)) >> PAGE_SHIFT) +#endif
Signature · 1 line
1.7.2.2
PATCH 4/9 MIPS: Octeon: Select ZONE_DMA32
In reply to David DaneyGive us a nice place to allocate coherent DMA memory for 32-bit devices.
--- arch/mips/Kconfig | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
arch/mips/Kconfig +1 -0
@@ -693,6 +693,7 @@ config CAVIUM_OCTEON_REFERENCE_BOARD select SWAP_IO_SPACE select HW_HAS_PCI select ARCH_SUPPORTS_MSI + select ZONE_DMA32 help This option supports all of the Octeon reference boards from Cavium Networks. It builds a kernel that dynamically determines the Octeon
Signature · 1 line
1.7.2.2
PATCH 5/9 MIPS: Convert DMA to use dma-mapping-common.h
In reply to David DaneyUse asm-generic/dma-mapping-common.h to handle all DMA mapping operations and establish a default get_dma_ops() that forwards all operations to the existing code.
Augment dev_archdata to carry a pointer to the struct dma_map_ops, allowing DMA operations to be overridden on a per device basis. Currently this is never filled in, so the default dma_map_ops are used. A follow-on patch sets this for Octeon PCI devices.
Also initialize the dma_debug system as it is now used if it is configured.
--- arch/mips/Kconfig | 2 + arch/mips/include/asm/device.h | 15 +++- arch/mips/include/asm/dma-mapping.h | 125 +++++++++++++++++-------- arch/mips/mm/dma-default.c | 179 +++++++++++++--------------------- 4 files changed, 172 insertions(+), 149 deletions(-)
arch/mips/Kconfig +2 -0
@@ -14,6 +14,8 @@ config MIPS select HAVE_KRETPROBES select RTC_LIB if !MACH_LOONGSON select GENERIC_ATOMIC64 if !64BIT + select HAVE_DMA_ATTRS + select HAVE_DMA_API_DEBUG mainmenu "Linux/MIPS Kernel Configuration"
arch/mips/include/asm/device.h +14 -1
@@ -3,4 +3,17 @@* * This file is released under the GPLv2 */ -#include <asm-generic/device.h> +#ifndef _ASM_MIPS_DEVICE_H +#define _ASM_MIPS_DEVICE_H + +struct mips_dma_map_ops ; + +struct dev_archdata { +/* DMA operations on that device */ +struct mips_dma_map_ops *dma_ops; +}; + +struct pdev_archdata { +}; + +#endif /* _ASM_MIPS_DEVICE_H*/
arch/mips/include/asm/dma-mapping.h +87 -38
142 lines not on this page · raw message
arch/mips/mm/dma-default.c +69 -110
288 lines not on this page · raw message
Signature · 1 line
1.7.2.2
PATCH 1/1 MIPS: Remove plat_map_dma_mem_page().
It is now unused.
---
This is a small addition to the rest of the patch set. It could be rolled into [PATCH 5/9] MIPS: Convert DMA to use dma-mapping-common.h
arch/mips/include/asm/mach-generic/dma-coherence.h | 6 ------ arch/mips/include/asm/mach-ip27/dma-coherence.h | 7 ------- arch/mips/include/asm/mach-ip32/dma-coherence.h | 12 ------------ arch/mips/include/asm/mach-jazz/dma-coherence.h | 5 ----- .../mips/include/asm/mach-loongson/dma-coherence.h | 6 ------ arch/mips/include/asm/mach-powertv/dma-coherence.h | 6 ------ 6 files changed, 0 insertions(+), 42 deletions(-)
arch/mips/include/asm/mach-generic/dma-coherence.h +0 -6
@@ -17,12 +17,6 @@ static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,return virt_to_phys (addr); } -static inline dma_addr_t plat_map_dma_mem_page (struct device *dev, -struct page *page) -{ -return page_to_phys (page); -} -static inline unsigned long plat_dma_addr_to_phys (struct device *dev,dma_addr_t dma_addr) {
arch/mips/include/asm/mach-ip27/dma-coherence.h +0 -7
@@ -26,13 +26,6 @@ static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,return pa; } -static dma_addr_t plat_map_dma_mem_page (struct device *dev,struct page *page) -{ -dma_addr_t pa =dev_to_baddr (dev,page_to_phys (page)); - -return pa; -} -static unsigned long plat_dma_addr_to_phys (struct device *dev,dma_addr_t dma_addr) {
arch/mips/include/asm/mach-ip32/dma-coherence.h +0 -12
@@ -37,18 +37,6 @@ static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,return pa; } -static dma_addr_t plat_map_dma_mem_page (struct device *dev,struct page *page) -{ -dma_addr_t pa; - - pa =page_to_phys (page) &RAM_OFFSET_MASK ; - -if (dev ==NULL ) - pa +=CRIME_HI_MEM_BASE ; - -return pa; -} -/* This is almost certainly wrong but it's what dma-ip32.c used to use */ static unsigned long plat_dma_addr_to_phys (struct device *dev,dma_addr_t dma_addr)
arch/mips/include/asm/mach-jazz/dma-coherence.h +0 -5
@@ -17,11 +17,6 @@ static dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, size_t size)return vdma_alloc (virt_to_phys (addr), size); } -static dma_addr_t plat_map_dma_mem_page (struct device *dev,struct page *page) -{ -return vdma_alloc (page_to_phys (page),PAGE_SIZE ); -} -static unsigned long plat_dma_addr_to_phys (struct device *dev,dma_addr_t dma_addr) {
arch/mips/include/asm/mach-loongson/dma-coherence.h +0 -6
@@ -19,12 +19,6 @@ static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,return virt_to_phys (addr) |0x80000000 ; } -static inline dma_addr_t plat_map_dma_mem_page (struct device *dev, -struct page *page) -{ -return page_to_phys (page) |0x80000000 ; -} -static inline unsigned long plat_dma_addr_to_phys (struct device *dev,dma_addr_t dma_addr) {
arch/mips/include/asm/mach-powertv/dma-coherence.h +0 -6
@@ -70,12 +70,6 @@ static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,return phys_to_dma (virt_to_phys (addr)); } -static inline dma_addr_t plat_map_dma_mem_page (struct device *dev, -struct page *page) -{ -return phys_to_dma (page_to_phys (page)); -} -static inline unsigned long plat_dma_addr_to_phys (struct device *dev,dma_addr_t dma_addr) {
Signature · 1 line
1.7.2.2
Re: [PATCH 5/9] MIPS: Convert DMA to use dma-mapping-common.h
In reply to David DaneyQuoted 61 lines · On Thu, 23 Sep 2010 15:38:12 -0700 David Daney <[email protected]>…
Use
asm-generic/dma-mapping-common.hto handle all DMA mapping operations and establish a defaultget_dma_ops()that forwards all operations to the existing code.Augment
dev_archdatato carry a pointer to the structdma_map_ops, allowing DMA operations to be overridden on a per device basis. Currently this is never filled in, so the defaultdma_map_opsare used. A follow-on patch sets this for Octeon PCI devices.Also initialize the
dma_debugsystem as it is now used if it is configured.Signed-off-by David Daney <[email protected]>--- arch/mips/Kconfig | 2 + arch/mips/include/asm/device.h | 15 +++- arch/mips/include/asm/dma-mapping.h | 125 +++++++++++++++++-------- arch/mips/mm/dma-default.c | 179 +++++++++++++--------------------- 4 files changed, 172 insertions(+), 149 deletions(-)arch/mips/Kconfig +2
-0@@ -14,6 +14,8 @@ config MIPS select HAVE_KRETPROBES select RTC_LIB if !MACH_LOONGSON select GENERIC_ATOMIC64 if !64BIT + select HAVE_DMA_ATTRS + select HAVE_DMA_API_DEBUG mainmenu "Linux/MIPS Kernel Configuration"arch/mips/include/asm/device.h +14
-1@@ -3,4 +3,17 @@* * This file is released under the GPLv2 */ -#include <asm-generic/device.h> +#ifndef _ASM_MIPS_DEVICE_H +#define _ASM_MIPS_DEVICE_H + +struct mips_dma_map_ops ; + +struct dev_archdata { +/* DMA operations on that device */ +struct mips_dma_map_ops *dma_ops; +}; + +struct pdev_archdata { +}; + +#endif /* _ASM_MIPS_DEVICE_H*/ arch/mips/include/asm/dma-mapping.h +0
-0
arch/mips/include/asm/dma-mapping.h line 12
Quoted 10 lines
arch/mips/include/asm/dma-mapping.h +5
-2@@ -5,51 +5,67 @@#include <asm/cache.h> #include <asm-generic/dma-coherent.h> -void *dma_alloc_noncoherent (struct device *dev,size_t size, -dma_addr_t *dma_handle,gfp_t flag); +struct mips_dma_map_ops { +struct dma_map_ops dma_map_ops; +dma_addr_t (*phys_to_dma)(struct device *dev,phys_addr_t paddr); +phys_addr_t (*dma_to_phys)(struct device *dev,dma_addr_t daddr); +};
The above code doesn't look great but we don't want to add phys_to_dma and dma_to_phys to dma_map_ops struct, and these functions on MIPS looks too complicated for ifdef. So I guess that we need to live with the above code.
Re: [PATCH 5/9] MIPS: Convert DMA to use dma-mapping-common.h
Quoted 67 lines · FUJITA Tomonori
Quoted 64 lines · On Thu, 23 Sep 2010 15:38:12 -0700 David Daney<[email protected]>…
Use
asm-generic/dma-mapping-common.hto handle all DMA mapping operations and establish a defaultget_dma_ops()that forwards all operations to the existing code.Augment
dev_archdatato carry a pointer to the structdma_map_ops, allowing DMA operations to be overridden on a per device basis. Currently this is never filled in, so the defaultdma_map_opsare used. A follow-on patch sets this for Octeon PCI devices.Also initialize the
dma_debugsystem as it is now used if it is configured.Signed-off-by David Daney<[email protected]>--- arch/mips/Kconfig | 2 + arch/mips/include/asm/device.h | 15 +++- arch/mips/include/asm/dma-mapping.h | 125 +++++++++++++++++-------- arch/mips/mm/dma-default.c | 179 +++++++++++++--------------------- 4 files changed, 172 insertions(+), 149 deletions(-)arch/mips/Kconfig +2
-0@@ -14,6 +14,8 @@ config MIPS select HAVE_KRETPROBES select RTC_LIB if !MACH_LOONGSON select GENERIC_ATOMIC64 if !64BIT + select HAVE_DMA_ATTRS + select HAVE_DMA_API_DEBUG mainmenu "Linux/MIPS Kernel Configuration"arch/mips/include/asm/device.h +14
-1@@ -3,4 +3,17 @@* * This file is released under the GPLv2 */ -#include <asm-generic/device.h> +#ifndef _ASM_MIPS_DEVICE_H +#define _ASM_MIPS_DEVICE_H + +struct mips_dma_map_ops ; + +struct dev_archdata { +/* DMA operations on that device */ +struct mips_dma_map_ops *dma_ops; +}; + +struct pdev_archdata { +}; + +#endif /* _ASM_MIPS_DEVICE_H*/ arch/mips/include/asm/dma-mapping.h +0
-0@@ -5,51 +5,67 @@#include <asm/cache.h> #include <asm-generic/dma-coherent.h>
Quoted 13 lines
arch/mips/include/asm/dma-mapping.h line 12
Quoted 7 lines
arch/mips/include/asm/dma-mapping.h +5
-2-void *dma_alloc_noncoherent (struct device *dev,size_t size, -dma_addr_t *dma_handle,gfp_t flag); +struct mips_dma_map_ops { +struct dma_map_ops dma_map_ops; +dma_addr_t (*phys_to_dma)(struct device *dev,phys_addr_t paddr); +phys_addr_t (*dma_to_phys)(struct device *dev,dma_addr_t daddr); +};The above code doesn't look great but we don't want to add
phys_to_dmaanddma_to_phystodma_map_opsstruct, and these functions on MIPS looks too complicated for ifdef. So I guess that we need to live with the above code.
I think you have a point here. I will attempt to move these two into a chip specific operations vector, and leave the more generic MIPS version with the simplified static definition.
Thanks,
David Daney
Re: [PATCH 5/9] MIPS: Convert DMA to use dma-mapping-common.h
Quoted 22 lines · On Mon, 27 Sep 2010 10:35:15 -0700 David Daney <[email protected]>…
Quoted 8 lines
Quoted 8 lines
arch/mips/include/asm/dma-mapping.h +0
-0@@ -5,51 +5,67 @@#include <asm/cache.h> #include <asm-generic/dma-coherent.h> Quoted 13 lines
arch/mips/include/asm/dma-mapping.h line 12
Quoted 7 lines
arch/mips/include/asm/dma-mapping.h +5
-2-void *dma_alloc_noncoherent (struct device *dev,size_t size, -dma_addr_t *dma_handle,gfp_t flag); +struct mips_dma_map_ops { +struct dma_map_ops dma_map_ops; +dma_addr_t (*phys_to_dma)(struct device *dev,phys_addr_t paddr); +phys_addr_t (*dma_to_phys)(struct device *dev,dma_addr_t daddr); +};The above code doesn't look great but we don't want to add
phys_to_dmaanddma_to_phystodma_map_opsstruct, and these functions on MIPS looks too complicated for ifdef. So I guess that we need to live with the above code.
Quoted 3 lines
I think you have a point here. I will attempt to move these two into a chip specific operations vector, and leave the more generic MIPS version with the simplified static definition.
Yeah, that sounds a better (cleaner) approach.
PATCH 6/9 swiotlb: Declare swiotlb_init_with_default_size()
In reply to David DaneyIt comes from swiotlb.c and must be called by external code, so declare it.
--- include/linux/swiotlb.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
include/linux/swiotlb.h +1 -0
@@ -23,6 +23,7 @@ extern int swiotlb_force;#define IO_TLB_SHIFT 11extern void swiotlb_init (int verbose); +extern void swiotlb_init_with_default_size (size_t ,int );extern void swiotlb_init_with_tbl (char *tlb,unsigned long nslabs,int verbose);/*
Signature · 1 line
1.7.2.2
Re: [PATCH 6/9] swiotlb: Declare swiotlb_init_with_default_size()
Quoted 17 lines · David Daney
It comes from
swiotlb.cand must be called by external code, so declare it.Signed-off-by David Daney <[email protected]>Cc Andrew Morton <[email protected]>Cc FUJITA Tomonori <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>Cc Ingo Molnar <[email protected]>Cc Andre Goddard Rosa <[email protected]>--- include/linux/swiotlb.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)include/linux/swiotlb.h +0
-0
include/linux/swiotlb.h extern int swiotlb_force; · line 27
Quoted 5 lines
include/linux/swiotlb.h +1
-0@@ -23,6 +23,7 @@ extern int swiotlb_force;#define IO_TLB_SHIFT 11extern void swiotlb_init (int verbose); +extern void swiotlb_init_with_default_size (size_t ,int );extern void swiotlb_init_with_tbl (char *tlb,unsigned long nslabs,int verbose);
Just use the swiotlb_init_with_tbl. If you need an example of how it is utilized, take a look at how swiotlb-xen.c does it.
PATCH 7/9 swiotlb: Make bounce buffer bounds non-static.
In reply to David DaneyOcteon PCI mapping has to be established to cover the bounce buffers, so it has to have access to the bounds.
Rename the bounds variables to match the names of other parts of swiotlb.
--- include/linux/swiotlb.h | 6 ++++ lib/swiotlb.c | 62 +++++++++++++++++++++++----------------------- 2 files changed, 37 insertions(+), 31 deletions(-)
include/linux/swiotlb.h +6 -0
@@ -22,6 +22,12 @@ extern int swiotlb_force;*/ #define IO_TLB_SHIFT 11 +/* +* The memory range used by the swiotlb +*/ +extern char *swiotlb_start; +extern char *swiotlb_end; +extern void swiotlb_init (int verbose);extern void swiotlb_init_with_default_size (size_t ,int );extern void swiotlb_init_with_tbl (char *tlb,unsigned long nslabs,int verbose);
lib/swiotlb.c +31 -31
169 lines not on this page · raw message
Signature · 1 line
1.7.2.2
Re: [PATCH 7/9] swiotlb: Make bounce buffer bounds non-static.
Quoted 2 lines · On Thu, 23 Sep 2010 15:47:31 -0700 David Daney <[email protected]>…
Octeon PCI mapping has to be established to cover the bounce buffers, so it has to have access to the bounds.
Why can't you use swiotlb_init_with_tbl() instead?
Re: [PATCH 7/9] swiotlb: Make bounce buffer bounds non-static.
Quoted 8 lines · FUJITA Tomonori
Quoted 2 lines · On Thu, 23 Sep 2010 15:47:31 -0700 David Daney<[email protected]>…
Octeon PCI mapping has to be established to cover the bounce buffers, so it has to have access to the bounds.
Why can't you use
swiotlb_init_with_tbl()instead?
Yes, as pointed out be several people, that would be better.
The swiotlb_init_with_tbl() didn't exist in earlier kernel versions and this simplification was missed when I forward ported the patch set.
By using this function, I think the entire patch set will be MIPS specific, making it unnecessary to touch the generic swiotlb code.
Thanks,
David Daney
PATCH 8/9 MIPS: Add a platform hook for swiotlb setup.
In reply to David DaneyThis allows platforms that are using the swiotlb to initialize it.
--- arch/mips/include/asm/bootinfo.h | 5 +++++ arch/mips/kernel/setup.c | 5 +++++ 2 files changed, 10 insertions(+), 0 deletions(-)
arch/mips/include/asm/bootinfo.h +5 -0
@@ -125,4 +125,9 @@ extern unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3;*/ extern void plat_mem_setup (void ); +/* +* Optional platform hook to call swiotlb_setup(). +*/ +extern void plat_swiotlb_setup (void ); +#endif /* _ASM_BOOTINFO_H */
arch/mips/kernel/setup.c +5 -0
@@ -488,6 +488,11 @@ static void __init arch_mem_init(char **cmdline_p)bootmem_init ();sparse_init (); + +#ifdef CONFIG_SWIOTLB +plat_swiotlb_setup (); +#endif +paging_init (); }
Signature · 1 line
1.7.2.2
Re: [PATCH 8/9] MIPS: Add a platform hook for swiotlb setup.
Hello.
Quoted 27 lines · David Daney
This allows platforms that are using the swiotlb to initialize it.
Signed-off-by David Daney <[email protected]>--- arch/mips/include/asm/bootinfo.h | 5 +++++ arch/mips/kernel/setup.c | 5 +++++ 2 files changed, 10 insertions(+), 0 deletions(-)arch/mips/include/asm/bootinfo.h +5
-0@@ -125,4 +125,9 @@ extern unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3;*/ extern void plat_mem_setup (void ); +/* +* Optional platform hook to call swiotlb_setup(). +*/ +extern void plat_swiotlb_setup (void ); +#endif /* _ASM_BOOTINFO_H */ arch/mips/kernel/setup.c +0
-0
arch/mips/kernel/setup.c static void __init arch_mem_init(char **cmdline_p) · line 494
Quoted 7 lines
arch/mips/kernel/setup.c +4
-0@@ -488,6 +488,11 @@ static void __init arch_mem_init(char **cmdline_p)bootmem_init ();sparse_init (); + +#ifdef CONFIG_SWIOTLB +plat_swiotlb_setup (); +#endif
We should avoid #ifdef's in function bodies. Why not defile an empty
'inline' in the header above if CONFIG_SWIOTLB is not defined?
WBR, Sergei
Re: [PATCH 8/9] MIPS: Add a platform hook for swiotlb setup.
Quoted 34 lines · Sergei Shtylyov
Hello.
Quoted 30 lines · David Daney
This allows platforms that are using the swiotlb to initialize it.
Signed-off-by David Daney <[email protected]>---
arch/mips/include/asm/bootinfo.h| 5 +++++arch/mips/kernel/setup.c| 5 +++++2 files changed, 10 insertions(+), 0 deletions(-)arch/mips/include/asm/bootinfo.h +5
-0@@ -125,4 +125,9 @@ extern unsigned long fw_arg0, fw_arg1, fw_arg2,fw_arg3; */ extern void plat_mem_setup (void ); +/* +* Optional platform hook to call swiotlb_setup(). +*/ +extern void plat_swiotlb_setup (void ); +#endif /*
_ASM_BOOTINFO_H*/arch/mips/kernel/setup.c +0
-0@@ -488,6 +488,11 @@ static void __init arch_mem_init(char **cmdline_p)
Quoted 10 lines
arch/mips/kernel/setup.c static void __init arch_mem_init(char **cmdline_p) · line 494
Quoted 6 lines
arch/mips/kernel/setup.c +4
-0bootmem_init ();sparse_init (); + +#ifdef CONFIG_SWIOTLB +plat_swiotlb_setup (); +#endif We should avoid #ifdef's in function bodies. Why not defile an empty 'inline' in the header above if
CONFIG_SWIOTLBis not defined?
Good idea. I will wait several days and collect any more feedback and generate a new patch set.
David Daney
Re: [PATCH 8/9] MIPS: Add a platform hook for swiotlb setup.
Quoted 10 lines · David Daney
Quoted 7 lines
arch/mips/kernel/setup.c static void __init arch_mem_init(char **cmdline_p) · line 494
Quoted 3 lines
arch/mips/kernel/setup.c +3
-0+#ifdef CONFIG_SWIOTLB +plat_swiotlb_setup (); +#endif We should avoid #ifdef's in function bodies. Why not defile an empty 'inline' in the header above if
CONFIG_SWIOTLBis not defined?Good idea. I will wait several days and collect any more feedback and generate a new patch set.
I'd also wait for a few more days so interested parties outside of the MIPS world will have a chance to comment.
Ralf
PATCH 9/9 MIPS: Octeon: Rewrite DMA mapping functions.
In reply to David DaneyAll Octeon chips can support more than 4GB of RAM. Also due to how Octeon PCI is setup, even some configurations with less than 4GB of RAM will have portions that are not accessible from 32-bit devices.
Enable the swiotlb code to handle the cases where a device cannot directly do DMA. This is a complete rewrite of the Octeon DMA mapping code.
--- arch/mips/cavium-octeon/Kconfig | 12 + arch/mips/cavium-octeon/dma-octeon.c | 529 +++++++++----------- .../include/asm/mach-cavium-octeon/dma-coherence.h | 19 +- arch/mips/include/asm/octeon/pci-octeon.h | 10 + arch/mips/pci/pci-octeon.c | 60 ++- arch/mips/pci/pcie-octeon.c | 5 + 6 files changed, 336 insertions(+), 299 deletions(-)
arch/mips/cavium-octeon/Kconfig +12 -0
@@ -87,3 +87,15 @@ config ARCH_SPARSEMEM_ENABLE config CAVIUM_OCTEON_HELPER def_bool y depends on OCTEON_ETHERNET || PCI + +config IOMMU_HELPER + bool + +config NEED_SG_DMA_LENGTH + bool + +config SWIOTLB + def_bool y + depends on CPU_CAVIUM_OCTEON + select IOMMU_HELPER + select NEED_SG_DMA_LENGTH
arch/mips/cavium-octeon/dma-octeon.c +245 -284
580 lines not on this page · raw message
arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h +10 -9
@@ -15,41 +15,40 @@struct device ; -dma_addr_t octeon_map_dma_mem (struct device *,void *,size_t ); -void octeon_unmap_dma_mem (struct device *,dma_addr_t ); +void octeon_pci_dma_init (void );static inline dma_addr_t plat_map_dma_mem (struct device *dev,void *addr,size_t size) { -return octeon_map_dma_mem (dev, addr, size); +BUG (); }static inline dma_addr_t plat_map_dma_mem_page (struct device *dev,struct page *page) { -return octeon_map_dma_mem (dev,page_address (page),PAGE_SIZE ); +BUG (); }static inline unsigned long plat_dma_addr_to_phys (struct device *dev,dma_addr_t dma_addr) { -return dma_addr; +BUG (); }static inline void plat_unmap_dma_mem (struct device *dev,dma_addr_t dma_addr,size_t size,enum dma_data_direction direction) { -octeon_unmap_dma_mem (dev, dma_addr); +BUG (); }static inline int plat_dma_supported (struct device *dev,u64 mask) { -return 1 ; +BUG (); }static inline void plat_extra_sync_for_device (struct device *dev) { -mb (); +BUG (); }static inline int plat_device_is_coherent (struct device *dev)
@@ -60,7 +59,9 @@ static inline int plat_device_is_coherent(struct device *dev)static inline int plat_dma_mapping_error (struct device *dev,dma_addr_t dma_addr) { -return dma_addr ==-1 ; +BUG (); } +extern struct mips_dma_map_ops octeon_pci_dma_map_ops; +#endif /* __ASM_MACH_CAVIUM_OCTEON_DMA_COHERENCE_H */
arch/mips/include/asm/octeon/pci-octeon.h +10 -0
@@ -36,6 +36,16 @@ extern int (*octeon_pcibios_map_irq)(const struct pci_dev *dev, u8 slot, u8 pin);/* +* For PCI (not PCIe) the BAR2 base address. +*/ +#define OCTEON_BAR2_PCI_ADDRESS 0x8000000000ull + +/* +* For PCI (not PCIe) the base of the memory mapped by BAR1 +*/ +extern u64 octeon_bar1_pci_phys; + +/* * The following defines are used when octeon_dma_bar_type = * OCTEON_DMA_BAR_TYPE_BIG */
arch/mips/pci/pci-octeon.c +54 -6
108 lines not on this page · raw message
arch/mips/pci/pcie-octeon.c +5 -0
@@ -75,6 +75,8 @@ union cvmx_pcie_address { } mem; }; +#include <dma-coherence.h> +/** * Return the Core virtual base address for PCIe IO access. IOs are * read/written as an offset from this address.
@@ -1391,6 +1393,9 @@ static int __init octeon_pcie_setup(void)cvmx_pcie_get_io_size (1 ) -1 ;register_pci_controller (&octeon_pcie1_controller); } + +octeon_pci_dma_init (); +return 0 ; }
Signature · 1 line
1.7.2.2
PATCH 1/1 MIPS: Octeon: Remove plat_map_dma_mem_page().
It is now unused.
---
This is a small addition to the rest of the patch set. It could be rolled into [PATCH 9/9] MIPS: Octeon: Rewrite DMA mapping functions.
.../include/asm/mach-cavium-octeon/dma-coherence.h | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-)
arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h +0 -6
@@ -23,12 +23,6 @@ static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,BUG (); } -static inline dma_addr_t plat_map_dma_mem_page (struct device *dev, -struct page *page) -{ -BUG (); -} -static inline unsigned long plat_dma_addr_to_phys (struct device *dev,dma_addr_t dma_addr) {
Signature · 1 line
1.7.2.2