Skip to contentSkip to conversation

powerpc: rework dma-noncoherent to use generic vmap/vunmap functions

PATCH In review Ilya Yanok 4 participants 8 messages Jan 9, 2009 – Feb 12, 2009 PowerPC

lore
Share & tools
lore

Ilya Yanok

author
#0 lore raw

PATCH 1/1 powerpc: rework dma-noncoherent to use generic vmap/vunmap functions

This patch rewrites consistent dma allocations support to use vmalloc layer to allocate virtual memory space from vmalloc pool and get rid of CONFIG_CONSISTENT_{START,SIZE}.

---
 arch/powerpc/Kconfig                           |   25 --
 arch/powerpc/configs/40x/acadia_defconfig      |    2 -
 arch/powerpc/configs/40x/ep405_defconfig       |    2 -
 arch/powerpc/configs/40x/hcu4_defconfig        |    2 -
 arch/powerpc/configs/40x/kilauea_defconfig     |    2 -
 arch/powerpc/configs/40x/makalu_defconfig      |    2 -
 arch/powerpc/configs/40x/virtex_defconfig      |    2 -
 arch/powerpc/configs/40x/walnut_defconfig      |    2 -
 arch/powerpc/configs/44x/arches_defconfig      |    2 -
 arch/powerpc/configs/44x/bamboo_defconfig      |    2 -
 arch/powerpc/configs/44x/canyonlands_defconfig |    2 -
 arch/powerpc/configs/44x/ebony_defconfig       |    2 -
 arch/powerpc/configs/44x/katmai_defconfig      |    2 -
 arch/powerpc/configs/44x/rainier_defconfig     |    2 -
 arch/powerpc/configs/44x/sam440ep_defconfig    |    2 -
 arch/powerpc/configs/44x/sequoia_defconfig     |    2 -
 arch/powerpc/configs/44x/taishan_defconfig     |    2 -
 arch/powerpc/configs/44x/virtex5_defconfig     |    2 -
 arch/powerpc/configs/44x/warp_defconfig        |    2 -
 arch/powerpc/configs/adder875_defconfig        |    2 -
 arch/powerpc/configs/c2k_defconfig             |    2 -
 arch/powerpc/configs/ep88xc_defconfig          |    2 -
 arch/powerpc/configs/mgsuvd_defconfig          |    2 -
 arch/powerpc/configs/mpc866_ads_defconfig      |    2 -
 arch/powerpc/configs/mpc885_ads_defconfig      |    2 -
 arch/powerpc/configs/ppc40x_defconfig          |    2 -
 arch/powerpc/configs/ppc44x_defconfig          |    2 -
 arch/powerpc/configs/prpmc2800_defconfig       |    2 -
 arch/powerpc/lib/dma-noncoherent.c             |  278 +++--------------------
 29 files changed, 37 insertions(+), 320 deletions(-)
arch/powerpc/Kconfig +0 -25
index 525c13a..a451a06 100644
@@ -777,31 +777,6 @@ config TASK_SIZE
 	default "0x80000000" if PPC_PREP || PPC_8xx
 	default "0xc0000000"
 
-config CONSISTENT_START_BOOL
-	bool "Set custom consistent memory pool address"
-	depends on ADVANCED_OPTIONS && NOT_COHERENT_CACHE
-	help
-	  This option allows you to set the base virtual address
-	  of the consistent memory pool.  This pool of virtual
-	  memory is used to make consistent memory allocations.
-
-config CONSISTENT_START
-	hex "Base virtual address of consistent memory pool" if CONSISTENT_START_BOOL
-	default "0xfd000000" if (NOT_COHERENT_CACHE && 8xx)
-	default "0xff100000" if NOT_COHERENT_CACHE
-
-config CONSISTENT_SIZE_BOOL
-	bool "Set custom consistent memory pool size"
-	depends on ADVANCED_OPTIONS && NOT_COHERENT_CACHE
-	help
-	  This option allows you to set the size of the
-	  consistent memory pool.  This pool of virtual memory
-	  is used to make consistent memory allocations.
-
-config CONSISTENT_SIZE
-	hex "Size of consistent memory pool" if CONSISTENT_SIZE_BOOL
-	default "0x00200000" if NOT_COHERENT_CACHE
-
 config PIN_TLB
 	bool "Pinned Kernel TLBs (860 ONLY)"
 	depends on ADVANCED_OPTIONS && 8xx
arch/powerpc/configs/40x/acadia_defconfig +0 -2
index 25572cc..ea5d89c 100644
@@ -265,8 +265,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/40x/ep405_defconfig +0 -2
index b80ba7a..1f3ebea 100644
@@ -267,8 +267,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/40x/hcu4_defconfig +0 -2
index 45dcb82..bfb010d 100644
@@ -265,8 +265,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/40x/kilauea_defconfig +0 -2
index e2f3695..40e181f 100644
@@ -265,8 +265,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/40x/makalu_defconfig +0 -2
index 413c778..bb2c4ae 100644
@@ -265,8 +265,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/40x/virtex_defconfig +0 -2
index 9a9350d..d082d98 100644
@@ -273,8 +273,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/40x/walnut_defconfig +0 -2
index 5820e0a..c1c37eb 100644
@@ -268,8 +268,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/arches_defconfig +0 -2
index 082158d..2784aa4 100644
@@ -272,8 +272,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/bamboo_defconfig +0 -2
index f47c2f3..4821b4f 100644
@@ -276,8 +276,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/canyonlands_defconfig +0 -2
index 0694756..be68259 100644
@@ -272,8 +272,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/ebony_defconfig +0 -2
index c993757..8e0ce20 100644
@@ -274,8 +274,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/katmai_defconfig +0 -2
index e326ee8..d1767b4 100644
@@ -270,8 +270,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/rainier_defconfig +0 -2
index 927f829..fb1309f 100644
@@ -274,8 +274,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/sam440ep_defconfig +0 -2
index 15f48e0..79ded88 100644
@@ -275,8 +275,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/sequoia_defconfig +0 -2
index 562beea..ef65b9f 100644
@@ -276,8 +276,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/taishan_defconfig +0 -2
index 427bb6a..6e97ae9 100644
@@ -274,8 +274,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/virtex5_defconfig +0 -2
index 7513d36..5b2ccd6 100644
@@ -278,8 +278,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/warp_defconfig +0 -2
index 59cbd27..126be06 100644
@@ -266,8 +266,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/adder875_defconfig +0 -2
index 024f279..f5e50c0 100644
@@ -265,8 +265,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0x80000000
-CONFIG_CONSISTENT_START=0xfd000000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/c2k_defconfig +0 -2
index 5078594..b877f07 100644
@@ -307,8 +307,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/ep88xc_defconfig +0 -2
index 870d289..8aacae7 100644
@@ -265,8 +265,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0x80000000
-CONFIG_CONSISTENT_START=0xfd000000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/mgsuvd_defconfig +0 -2
index fbaa67f..0da7b58 100644
@@ -262,8 +262,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0x80000000
-CONFIG_CONSISTENT_START=0xfd000000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/mpc866_ads_defconfig +0 -2
index 8272b1a..e16bd69 100644
@@ -262,8 +262,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0x80000000
-CONFIG_CONSISTENT_START=0xfd000000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/mpc885_ads_defconfig +0 -2
index a4283b6..0937771 100644
@@ -272,8 +272,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0x80000000
-CONFIG_CONSISTENT_START=0xfd000000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/ppc40x_defconfig +0 -2
index 4256e2c..0cbb6c3 100644
@@ -275,8 +275,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/ppc44x_defconfig +0 -2
index cfc94cf..54e5583 100644
@@ -286,8 +286,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/prpmc2800_defconfig +0 -2
index 6046dc0..bb61e21 100644
@@ -272,8 +272,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/lib/dma-noncoherent.c +37 -241

333 lines not on this page · raw message

Signature · 1 line
1.6.0.6
#1 lore raw
Quoted 3 lines · Ilya Yanok

This patch rewrites consistent dma allocations support to use vmalloc layer to allocate virtual memory space from vmalloc pool and get rid of CONFIG_CONSISTENT_{START,SIZE}.

Ah good, I like that. I haven't reviewed in details yet but that's the right approach. I'll have a closer look hopefully tomorrow.

I seems too late for .29 though...

Cheers,
Ben.

#2 lore raw
In reply to Ilya Yanok
Quoted 3 lines · Ilya Yanok

This patch rewrites consistent dma allocations support to use vmalloc layer to allocate virtual memory space from vmalloc pool and get rid of CONFIG_CONSISTENT_{START,SIZE}.

Impressive patch. I'll pull it into my tree and see how it works on 4xx and 5200.

BTW, you can drop all the defconfig updates in this patch. The old config values will just disappear when 'make *_defconfig' is run. Putting them in the patch makes it far more likely that it won't apply at a later date.

g.

Quoted 771 lines
---
 arch/powerpc/Kconfig                           |   25 --
 arch/powerpc/configs/40x/acadia_defconfig      |    2 -
 arch/powerpc/configs/40x/ep405_defconfig       |    2 -
 arch/powerpc/configs/40x/hcu4_defconfig        |    2 -
 arch/powerpc/configs/40x/kilauea_defconfig     |    2 -
 arch/powerpc/configs/40x/makalu_defconfig      |    2 -
 arch/powerpc/configs/40x/virtex_defconfig      |    2 -
 arch/powerpc/configs/40x/walnut_defconfig      |    2 -
 arch/powerpc/configs/44x/arches_defconfig      |    2 -
 arch/powerpc/configs/44x/bamboo_defconfig      |    2 -
 arch/powerpc/configs/44x/canyonlands_defconfig |    2 -
 arch/powerpc/configs/44x/ebony_defconfig       |    2 -
 arch/powerpc/configs/44x/katmai_defconfig      |    2 -
 arch/powerpc/configs/44x/rainier_defconfig     |    2 -
 arch/powerpc/configs/44x/sam440ep_defconfig    |    2 -
 arch/powerpc/configs/44x/sequoia_defconfig     |    2 -
 arch/powerpc/configs/44x/taishan_defconfig     |    2 -
 arch/powerpc/configs/44x/virtex5_defconfig     |    2 -
 arch/powerpc/configs/44x/warp_defconfig        |    2 -
 arch/powerpc/configs/adder875_defconfig        |    2 -
 arch/powerpc/configs/c2k_defconfig             |    2 -
 arch/powerpc/configs/ep88xc_defconfig          |    2 -
 arch/powerpc/configs/mgsuvd_defconfig          |    2 -
 arch/powerpc/configs/mpc866_ads_defconfig      |    2 -
 arch/powerpc/configs/mpc885_ads_defconfig      |    2 -
 arch/powerpc/configs/ppc40x_defconfig          |    2 -
 arch/powerpc/configs/ppc44x_defconfig          |    2 -
 arch/powerpc/configs/prpmc2800_defconfig       |    2 -
 arch/powerpc/lib/dma-noncoherent.c             |  278 +++--------------------
 29 files changed, 37 insertions(+), 320 deletions(-)
arch/powerpc/Kconfig +0 -25
index 525c13a..a451a06 100644
@@ -777,31 +777,6 @@ config TASK_SIZE
       default "0x80000000" if PPC_PREP || PPC_8xx
       default "0xc0000000"
 
-config CONSISTENT_START_BOOL
-       bool "Set custom consistent memory pool address"
-       depends on ADVANCED_OPTIONS && NOT_COHERENT_CACHE
-       help
-         This option allows you to set the base virtual address
-         of the consistent memory pool.  This pool of virtual
-         memory is used to make consistent memory allocations.
-
-config CONSISTENT_START
-       hex "Base virtual address of consistent memory pool" if CONSISTENT_START_BOOL
-       default "0xfd000000" if (NOT_COHERENT_CACHE && 8xx)
-       default "0xff100000" if NOT_COHERENT_CACHE
-
-config CONSISTENT_SIZE_BOOL
-       bool "Set custom consistent memory pool size"
-       depends on ADVANCED_OPTIONS && NOT_COHERENT_CACHE
-       help
-         This option allows you to set the size of the
-         consistent memory pool.  This pool of virtual memory
-         is used to make consistent memory allocations.
-
-config CONSISTENT_SIZE
-       hex "Size of consistent memory pool" if CONSISTENT_SIZE_BOOL
-       default "0x00200000" if NOT_COHERENT_CACHE
-
 config PIN_TLB
       bool "Pinned Kernel TLBs (860 ONLY)"
       depends on ADVANCED_OPTIONS && 8xx
arch/powerpc/configs/40x/acadia_defconfig +0 -2
index 25572cc..ea5d89c 100644
@@ -265,8 +265,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/40x/ep405_defconfig +0 -2
index b80ba7a..1f3ebea 100644
@@ -267,8 +267,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/40x/hcu4_defconfig +0 -2
index 45dcb82..bfb010d 100644
@@ -265,8 +265,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/40x/kilauea_defconfig +0 -2
index e2f3695..40e181f 100644
@@ -265,8 +265,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/40x/makalu_defconfig +0 -2
index 413c778..bb2c4ae 100644
@@ -265,8 +265,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/40x/virtex_defconfig +0 -2
index 9a9350d..d082d98 100644
@@ -273,8 +273,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/40x/walnut_defconfig +0 -2
index 5820e0a..c1c37eb 100644
@@ -268,8 +268,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/arches_defconfig +0 -2
index 082158d..2784aa4 100644
@@ -272,8 +272,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/bamboo_defconfig +0 -2
index f47c2f3..4821b4f 100644
@@ -276,8 +276,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/canyonlands_defconfig +0 -2
index 0694756..be68259 100644
@@ -272,8 +272,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/ebony_defconfig +0 -2
index c993757..8e0ce20 100644
@@ -274,8 +274,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/katmai_defconfig +0 -2
index e326ee8..d1767b4 100644
@@ -270,8 +270,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/rainier_defconfig +0 -2
index 927f829..fb1309f 100644
@@ -274,8 +274,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/sam440ep_defconfig +0 -2
index 15f48e0..79ded88 100644
@@ -275,8 +275,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/sequoia_defconfig +0 -2
index 562beea..ef65b9f 100644
@@ -276,8 +276,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/taishan_defconfig +0 -2
index 427bb6a..6e97ae9 100644
@@ -274,8 +274,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/virtex5_defconfig +0 -2
index 7513d36..5b2ccd6 100644
@@ -278,8 +278,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/44x/warp_defconfig +0 -2
index 59cbd27..126be06 100644
@@ -266,8 +266,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/adder875_defconfig +0 -2
index 024f279..f5e50c0 100644
@@ -265,8 +265,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0x80000000
-CONFIG_CONSISTENT_START=0xfd000000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/c2k_defconfig +0 -2
index 5078594..b877f07 100644
@@ -307,8 +307,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/ep88xc_defconfig +0 -2
index 870d289..8aacae7 100644
@@ -265,8 +265,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0x80000000
-CONFIG_CONSISTENT_START=0xfd000000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/mgsuvd_defconfig +0 -2
index fbaa67f..0da7b58 100644
@@ -262,8 +262,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0x80000000
-CONFIG_CONSISTENT_START=0xfd000000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/mpc866_ads_defconfig +0 -2
index 8272b1a..e16bd69 100644
@@ -262,8 +262,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0x80000000
-CONFIG_CONSISTENT_START=0xfd000000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/mpc885_ads_defconfig +0 -2
index a4283b6..0937771 100644
@@ -272,8 +272,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0x80000000
-CONFIG_CONSISTENT_START=0xfd000000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/ppc40x_defconfig +0 -2
index 4256e2c..0cbb6c3 100644
@@ -275,8 +275,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/ppc44x_defconfig +0 -2
index cfc94cf..54e5583 100644
@@ -286,8 +286,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/configs/prpmc2800_defconfig +0 -2
index 6046dc0..bb61e21 100644
@@ -272,8 +272,6 @@ CONFIG_PAGE_OFFSET=0xc0000000
 CONFIG_KERNEL_START=0xc0000000
 CONFIG_PHYSICAL_START=0x00000000
 CONFIG_TASK_SIZE=0xc0000000
-CONFIG_CONSISTENT_START=0xff100000
-CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_NET=y
 
 #
arch/powerpc/lib/dma-noncoherent.c +37 -242
index 31734c0..f6c932f 100644
@@ -29,121 +29,11 @@
 #include <linux/types.h>
 #include <linux/highmem.h>
 #include <linux/dma-mapping.h>
+#include <linux/vmalloc.h>
 
 #include <asm/tlbflush.h>
 
 /*
- * This address range defaults to a value that is safe for all
- * platforms which currently set CONFIG_NOT_COHERENT_CACHE. It
- * can be further configured for specific applications under
- * the "Advanced Setup" menu. -Matt
- */
-#define CONSISTENT_BASE        (CONFIG_CONSISTENT_START)
-#define CONSISTENT_END (CONFIG_CONSISTENT_START + CONFIG_CONSISTENT_SIZE)
-#define CONSISTENT_OFFSET(x)   (((unsigned long)(x) - CONSISTENT_BASE) >> PAGE_SHIFT)
-
-/*
- * This is the page table (2MB) covering uncached, DMA consistent allocations
- */
-static pte_t *consistent_pte;
-static DEFINE_SPINLOCK(consistent_lock);
-
-/*
- * VM region handling support.
- *
- * This should become something generic, handling VM region allocations for
- * vmalloc and similar (ioremap, module space, etc).
- *
- * I envisage vmalloc()'s supporting vm_struct becoming:
- *
- *  struct vm_struct {
- *    struct vm_region region;
- *    unsigned long    flags;
- *    struct page      **pages;
- *    unsigned int     nr_pages;
- *    unsigned long    phys_addr;
- *  };
- *
- * get_vm_area() would then call vm_region_alloc with an appropriate
- * struct vm_region head (eg):
- *
- *  struct vm_region vmalloc_head = {
- *     .vm_list        = LIST_HEAD_INIT(vmalloc_head.vm_list),
- *     .vm_start       = VMALLOC_START,
- *     .vm_end         = VMALLOC_END,
- *  };
- *
- * However, vmalloc_head.vm_start is variable (typically, it is dependent on
- * the amount of RAM found at boot time.)  I would imagine that get_vm_area()
- * would have to initialise this each time prior to calling vm_region_alloc().
- */
-struct vm_region {
-       struct list_head        vm_list;
-       unsigned long           vm_start;
-       unsigned long           vm_end;
-};
-
-static struct vm_region consistent_head = {
-       .vm_list        = LIST_HEAD_INIT(consistent_head.vm_list),
-       .vm_start       = CONSISTENT_BASE,
-       .vm_end         = CONSISTENT_END,
-};
-
-static struct vm_region *
-vm_region_alloc(struct vm_region *head, size_t size, gfp_t gfp)
-{
-       unsigned long addr = head->vm_start, end = head->vm_end - size;
-       unsigned long flags;
-       struct vm_region *c, *new;
-
-       new = kmalloc(sizeof(struct vm_region), gfp);
-       if (!new)
-               goto out;
-
-       spin_lock_irqsave(&consistent_lock, flags);
-
-       list_for_each_entry(c, &head->vm_list, vm_list) {
-               if ((addr + size) < addr)
-                       goto nospc;
-               if ((addr + size) <= c->vm_start)
-                       goto found;
-               addr = c->vm_end;
-               if (addr > end)
-                       goto nospc;
-       }
-
- found:
-       /*
-        * Insert this entry _before_ the one we found.
-        */
-       list_add_tail(&new->vm_list, &c->vm_list);
-       new->vm_start = addr;
-       new->vm_end = addr + size;
-
-       spin_unlock_irqrestore(&consistent_lock, flags);
-       return new;
-
- nospc:
-       spin_unlock_irqrestore(&consistent_lock, flags);
-       kfree(new);
- out:
-       return NULL;
-}
-
-static struct vm_region *vm_region_find(struct vm_region *head, unsigned long addr)
-{
-       struct vm_region *c;
-
-       list_for_each_entry(c, &head->vm_list, vm_list) {
-               if (c->vm_start == addr)
-                       goto out;
-       }
-       c = NULL;
- out:
-       return c;
-}
-
-/*
 * Allocate DMA-coherent memory space and return both the kernel remapped
 * virtual and bus address for that space.
 */
@@ -151,19 +41,17 @@ void *
 __dma_alloc_coherent(size_t size, dma_addr_t *handle, gfp_t gfp)
 {
       struct page *page;
-       struct vm_region *c;
       unsigned long order;
+       void *v;
+       int i;
+       struct page *pages[PAGE_ALIGN(size)>>PAGE_SHIFT];
+       struct page *end;
       u64 mask = 0x00ffffff, limit; /* ISA default */
 
-       if (!consistent_pte) {
-               printk(KERN_ERR "%s: not initialised\n", __func__);
-               dump_stack();
-               return NULL;
-       }
-
+       BUG_ON(!mem_init_done);
       size = PAGE_ALIGN(size);
       limit = (mask + 1) & ~mask;
-       if ((limit && size >= limit) || size >= (CONSISTENT_END - CONSISTENT_BASE)) {
+       if (limit && size >= limit) {
               printk(KERN_WARNING "coherent allocation too big (requested %#x mask %#Lx)\n",
                      size, mask);
               return NULL;
@@ -178,6 +66,8 @@ __dma_alloc_coherent(size_t size, dma_addr_t *handle, gfp_t gfp)
       if (!page)
               goto no_page;
 
+       end = page + (1 << order);
+
       /*
        * Invalidate any data that might be lurking in the
        * kernel direct-mapped region for device DMA.
@@ -188,45 +78,34 @@ __dma_alloc_coherent(size_t size, dma_addr_t *handle, gfp_t gfp)
               flush_dcache_range(kaddr, kaddr + size);
       }
 
+       split_page(page, order);
+
       /*
-        * Allocate a virtual address in the consistent mapping region.
+        * Set the "dma handle"
        */
-       c = vm_region_alloc(&consistent_head, size,
-                           gfp & ~(__GFP_DMA | __GFP_HIGHMEM));
-       if (c) {
-               unsigned long vaddr = c->vm_start;
-               pte_t *pte = consistent_pte + CONSISTENT_OFFSET(vaddr);
-               struct page *end = page + (1 << order);
-
-               split_page(page, order);
-
-               /*
-                * Set the "dma handle"
-                */
-               *handle = page_to_phys(page);
-
-               do {
-                       BUG_ON(!pte_none(*pte));
-
-                       SetPageReserved(page);
-                       set_pte_at(&init_mm, vaddr,
-                                  pte, mk_pte(page, pgprot_noncached(PAGE_KERNEL)));
-                       page++;
-                       pte++;
-                       vaddr += PAGE_SIZE;
-               } while (size -= PAGE_SIZE);
+       *handle = page_to_phys(page);
+       for (i = 0; i < size>>PAGE_SHIFT; i++)
+               pages[i] = page + i;
+       v = vmap(pages, size>>PAGE_SHIFT, VM_IOREMAP,
+                       pgprot_noncached(PAGE_KERNEL));
+       if (!v)
+               goto out;
 
-               /*
-                * Free the otherwise unused pages.
-                */
-               while (page < end) {
-                       __free_page(page);
-                       page++;
-               }
+       do {
+               SetPageReserved(page);
+               page++;
+       } while (size -= PAGE_SIZE);
 
-               return (void *)c->vm_start;
+       /*
+        * Free the otherwise unused pages.
+        */
+       while (page < end) {
+               __free_page(page);
+               page++;
       }
 
+       return v;
+     out:
       if (page)
               __free_pages(page, order);
 no_page:
@@ -239,105 +118,22 @@ EXPORT_SYMBOL(__dma_alloc_coherent);
 */
 void __dma_free_coherent(size_t size, void *vaddr)
 {
-       struct vm_region *c;
-       unsigned long flags, addr;
-       pte_t *ptep;
+       struct page *page;
 
       size = PAGE_ALIGN(size);
+       page = vmalloc_to_page(vaddr);
 
-       spin_lock_irqsave(&consistent_lock, flags);
+       vunmap(vaddr);
 
-       c = vm_region_find(&consistent_head, (unsigned long)vaddr);
-       if (!c)
-               goto no_area;
-
-       if ((c->vm_end - c->vm_start) != size) {
-               printk(KERN_ERR "%s: freeing wrong coherent size (%ld != %d)\n",
-                      __func__, c->vm_end - c->vm_start, size);
-               dump_stack();
-               size = c->vm_end - c->vm_start;
-       }
-
-       ptep = consistent_pte + CONSISTENT_OFFSET(c->vm_start);
-       addr = c->vm_start;
       do {
-               pte_t pte = ptep_get_and_clear(&init_mm, addr, ptep);
-               unsigned long pfn;
-
-               ptep++;
-               addr += PAGE_SIZE;
-
-               if (!pte_none(pte) && pte_present(pte)) {
-                       pfn = pte_pfn(pte);
-
-                       if (pfn_valid(pfn)) {
-                               struct page *page = pfn_to_page(pfn);
-                               ClearPageReserved(page);
-
-                               __free_page(page);
-                               continue;
-                       }
-               }
-
-               printk(KERN_CRIT "%s: bad page in kernel page table\n",
-                      __func__);
+               ClearPageReserved(page);
+               __free_page(page);
+               page++;
       } while (size -= PAGE_SIZE);
-
-       flush_tlb_kernel_range(c->vm_start, c->vm_end);
-
-       list_del(&c->vm_list);
-
-       spin_unlock_irqrestore(&consistent_lock, flags);
-
-       kfree(c);
-       return;
-
- no_area:
-       spin_unlock_irqrestore(&consistent_lock, flags);
-       printk(KERN_ERR "%s: trying to free invalid coherent area: %p\n",
-              __func__, vaddr);
-       dump_stack();
 }
 EXPORT_SYMBOL(__dma_free_coherent);
 
 /*
- * Initialise the consistent memory allocation.
- */
-static int __init dma_alloc_init(void)
-{
-       pgd_t *pgd;
-       pud_t *pud;
-       pmd_t *pmd;
-       pte_t *pte;
-       int ret = 0;
-
-       do {
-               pgd = pgd_offset(&init_mm, CONSISTENT_BASE);
-               pud = pud_alloc(&init_mm, pgd, CONSISTENT_BASE);
-               pmd = pmd_alloc(&init_mm, pud, CONSISTENT_BASE);
-               if (!pmd) {
-                       printk(KERN_ERR "%s: no pmd tables\n", __func__);
-                       ret = -ENOMEM;
-                       break;
-               }
-               WARN_ON(!pmd_none(*pmd));
-
-               pte = pte_alloc_kernel(pmd, CONSISTENT_BASE);
-               if (!pte) {
-                       printk(KERN_ERR "%s: no pte tables\n", __func__);
-                       ret = -ENOMEM;
-                       break;
-               }
-
-               consistent_pte = pte;
-       } while (0);
-
-       return ret;
-}
-
-core_initcall(dma_alloc_init);
-
-/*
 * make an area consistent.
 */
 void __dma_sync(void *vaddr, size_t size, int direction)
--

1.6.0.6

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
#3 lore raw
Quoted 7 lines · Grant Likely
Quoted 3 lines · Ilya Yanok

This patch rewrites consistent dma allocations support to use vmalloc layer to allocate virtual memory space from vmalloc pool and get rid of CONFIG_CONSISTENT_{START,SIZE}.

Impressive patch. I'll pull it into my tree and see how it works on 4xx and 5200.

Doing my job for me now? ;)

Quoted 4 lines

BTW, you can drop all the defconfig updates in this patch. The old config values will just disappear when 'make *_defconfig' is run. Putting them in the patch makes it far more likely that it won't apply at a later date.

Yes, totally agreed. I update the 4xx defconfigs every release, so they will get changed when I do that.

As Ben said, this is probably too late for .29, but definitely seems like the right way to go.

josh

#4 lore raw
In reply to Ilya Yanok
Quoted 3 lines · Ilya Yanok

This patch rewrites consistent dma allocations support to use vmalloc layer to allocate virtual memory space from vmalloc pool and get rid of CONFIG_CONSISTENT_{START,SIZE}.

So as commented before, please drop the defconfig updates.

I'm happy with the idea but I have a few nits with the implementation:

arch/powerpc/lib/dma-noncoherent.c void * · line 47

Quoted 13 lines
arch/powerpc/lib/dma-noncoherent.c +3 -2
-/*
  * Allocate DMA-coherent memory space and return both the kernel remapped
  * virtual and bus address for that space.
  */
@@ -151,19 +41,17 @@ void *
 __dma_alloc_coherent(size_t size, dma_addr_t *handle, gfp_t gfp)
 {
 	struct page *page;
-	struct vm_region *c;
 	unsigned long order;
+	void *v;
+	int i;
+	struct page *pages[PAGE_ALIGN(size)>>PAGE_SHIFT];

I'm not -too- fan of that page list one the stack up there.

I understand why you don't wantto kmalloc something here etc... but that's what __vmalloc_area() does and it's somewhat useful to keep track of the page array that way, it might prove handy in the future.

Might even be worth adding a generic patch to add a VM_COHERENT_DMA flag so they can be listed as such and make sure you set the "caller" field yourself with your own caller.

(Hint: look at the output of /proc/vmallocinfo)

Also, the mucking around with PG_Reserved shouldn't be of any use anymore.

Cheers,
Ben.

author
#5 lore raw

Hi Ben,

excuse me for so long time to reply.

Quoted 7 lines · Benjamin Herrenschmidt
Quoted 4 lines

This patch rewrites consistent dma allocations support to use vmalloc layer to allocate virtual memory space from vmalloc pool and get rid of CONFIG_CONSISTENT_{START,SIZE}.

So as commented before, please drop the defconfig updates.

Ok.

Quoted 17 lines
Quoted 5 lines
arch/powerpc/lib/dma-noncoherent.c +0 -1
-/*
  * Allocate DMA-coherent memory space and return both the kernel remapped
  * virtual and bus address for that space.
  */

arch/powerpc/lib/dma-noncoherent.c void * · line 48

Quoted 9 lines
arch/powerpc/lib/dma-noncoherent.c +3 -1
@@ -151,19 +41,17 @@ void *
 __dma_alloc_coherent(size_t size, dma_addr_t *handle, gfp_t gfp)
 {
 	struct page *page;
-	struct vm_region *c;
 	unsigned long order;
+	void *v;
+	int i;
+	struct page *pages[PAGE_ALIGN(size)>>PAGE_SHIFT];
 

I'm not -too- fan of that page list one the stack up there.

Quoted 4 lines

I understand why you don't wantto kmalloc something here etc... but that's what __vmalloc_area() does and it's somewhat useful to keep track of the page array that way, it might prove handy in the future.

I don't like array being on stack too... But I fear I didn't understand what were you talking about here...
__vmalloc_area does kmalloc or vmalloc to allocate pages array and then allocates pages one by one but we need physically contiguous pages here... (And that is why we don't really need to store pages array) So I just added kmalloc/vmalloc to allocate the pages array and stored it in vm_struct structure.

Quoted 4 lines

Might even be worth adding a generic patch to add a VM_COHERENT_DMA flag so they can be listed as such and make sure you set the "caller" field yourself with your own caller.

I used __builtin_return_address(1) as the 'caller' so I get useful output in /proc/vmallocinfo (btw, ioremap doesn't provide useful 'caller'). Do you think we have high chances of such a patch being accepted in lkml? Well, I'll try to do this (for now I stick with VM_IOREMAP).

Quoted 5 lines

(Hint: look at the output of /proc/vmallocinfo)

Also, the mucking around with PG_Reserved shouldn't be of any use anymore.

Ok, removed.

Please review the updated patch (I'll post it as a followup).

Regards, Ilya.

#6 lore raw
Quoted 1 line

btw, ioremap doesn't provide useful 'caller').

I fixed that :-) (see patches I posted to the list, though that's waiting for a patch to go upstream first that adds a __get_vm_area_caller() that I need for ppc64).

Cheers,
Ben.

author
#7 lore raw

Hi Ben,

Quoted 7 lines · Benjamin Herrenschmidt
Quoted 2 lines

btw, ioremap doesn't provide useful 'caller').

I fixed that :-) (see patches I posted to the list, though that's waiting for a patch to go upstream first that adds a __get_vm_area_caller() that I need for ppc64).

Yep, I saw them. Btw, I've posted update consistent memory patch in a new thread please take a look.

Regards, Ilya.