* [PATCH v4 03/11] swiotbl: add back swiotlb_alloc_boot() [not found] <1268421166-4791-1-git-send-email-albert_herranz@yahoo.es> @ 2010-03-12 19:12 ` Albert Herranz 2010-03-12 19:12 ` [PATCH v4 04/11] swiotlb: support NOT_COHERENT_CACHE PowerPC platforms Albert Herranz 2010-03-12 19:12 ` [PATCH v4 05/11] swiotlb: add swiotlb_set_default_size() Albert Herranz 2 siblings, 0 replies; 12+ messages in thread From: Albert Herranz @ 2010-03-12 19:12 UTC (permalink / raw) To: linux-usb, linuxppc-dev; +Cc: Albert Herranz, linux-kernel, x86, linux-ia64 This patch makes swiotlb_alloc_boot() available again. This weak function can be overloaded to modify slightly how the SWIOTLB and the overflow areas are allocated during boot. This will be used later to support the Nintendo Wii video game console, which requires placing the SWIOTLB area above 0x10000000 (MEM2). CC: linuxppc-dev@lists.ozlabs.org CC: linux-kernel@vger.kernel.org CC: x86@kernel.org CC: linux-ia64@vger.kernel.org Signed-off-by: Albert Herranz <albert_herranz@yahoo.es> --- include/linux/swiotlb.h | 2 ++ lib/swiotlb.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h index febedcf..3954228 100644 --- a/include/linux/swiotlb.h +++ b/include/linux/swiotlb.h @@ -24,6 +24,8 @@ extern int swiotlb_force; extern void swiotlb_init(int verbose); +extern void *swiotlb_alloc_boot(size_t bytes, unsigned long nslabs); + extern void *swiotlb_alloc_coherent(struct device *hwdev, size_t size, dma_addr_t *dma_handle, gfp_t flags); diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 437eedb..94db5df 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c @@ -117,6 +117,11 @@ setup_io_tlb_npages(char *str) __setup("swiotlb=", setup_io_tlb_npages); /* make io_tlb_overflow tunable too? */ +void * __weak __init swiotlb_alloc_boot(size_t size, unsigned long nslabs) +{ + return alloc_bootmem_low_pages(size); +} + /* Note that this doesn't work with highmem page */ static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev, volatile void *address) @@ -158,7 +163,7 @@ swiotlb_init_with_default_size(size_t default_size, int verbose) /* * Get IO TLB memory from the low pages */ - io_tlb_start = alloc_bootmem_low_pages(bytes); + io_tlb_start = swiotlb_alloc_boot(bytes, io_tlb_nslabs); if (!io_tlb_start) panic("Cannot allocate SWIOTLB buffer"); io_tlb_end = io_tlb_start + bytes; @@ -177,7 +182,8 @@ swiotlb_init_with_default_size(size_t default_size, int verbose) /* * Get the overflow emergency buffer */ - io_tlb_overflow_buffer = alloc_bootmem_low(io_tlb_overflow); + io_tlb_overflow_buffer = swiotlb_alloc_boot(io_tlb_overflow, + io_tlb_nslabs); if (!io_tlb_overflow_buffer) panic("Cannot allocate SWIOTLB overflow buffer!\n"); if (verbose) -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 04/11] swiotlb: support NOT_COHERENT_CACHE PowerPC platforms [not found] <1268421166-4791-1-git-send-email-albert_herranz@yahoo.es> 2010-03-12 19:12 ` [PATCH v4 03/11] swiotbl: add back swiotlb_alloc_boot() Albert Herranz @ 2010-03-12 19:12 ` Albert Herranz 2010-03-16 1:54 ` FUJITA Tomonori 2010-03-12 19:12 ` [PATCH v4 05/11] swiotlb: add swiotlb_set_default_size() Albert Herranz 2 siblings, 1 reply; 12+ messages in thread From: Albert Herranz @ 2010-03-12 19:12 UTC (permalink / raw) To: linux-usb, linuxppc-dev; +Cc: Albert Herranz, linux-kernel, x86, linux-ia64 The current SWIOTLB code does not support NOT_COHERENT_CACHE platforms. This patch adds support for NOT_COHERENT_CACHE platforms to SWIOTLB by adding two platform specific functions swiotlb_dma_sync_page() and swiotlb_dma_sync() which can be used to explicitly manage cache coherency. On PowerPC these functions are mapped to their corresponding __dma_sync_page() and __dma_sync() functions. On other architectures using SWIOTLB these functions are optimized out. This will be used later to support SWIOTLB on the Nintendo Wii video game console. CC: linuxppc-dev@lists.ozlabs.org CC: linux-kernel@vger.kernel.org CC: x86@kernel.org CC: linux-ia64@vger.kernel.org Signed-off-by: Albert Herranz <albert_herranz@yahoo.es> --- arch/ia64/include/asm/swiotlb.h | 10 ++++++++++ arch/powerpc/include/asm/swiotlb.h | 3 +++ arch/x86/include/asm/swiotlb.h | 10 ++++++++++ lib/swiotlb.c | 30 ++++++++++++++++++++++++------ 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/arch/ia64/include/asm/swiotlb.h b/arch/ia64/include/asm/swiotlb.h index f0acde6..6722090 100644 --- a/arch/ia64/include/asm/swiotlb.h +++ b/arch/ia64/include/asm/swiotlb.h @@ -14,4 +14,14 @@ static inline void pci_swiotlb_init(void) } #endif +static inline void swiotlb_dma_sync_page(struct page *page, + unsigned long offset, + size_t size, int direction) +{ +} + +static inline void swiotlb_dma_sync(void *vaddr, size_t size, int direction) +{ +} + #endif /* ASM_IA64__SWIOTLB_H */ diff --git a/arch/powerpc/include/asm/swiotlb.h b/arch/powerpc/include/asm/swiotlb.h index 8979d4c..603b343 100644 --- a/arch/powerpc/include/asm/swiotlb.h +++ b/arch/powerpc/include/asm/swiotlb.h @@ -22,4 +22,7 @@ int __init swiotlb_setup_bus_notifier(void); extern void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev); +#define swiotlb_dma_sync_page __dma_sync_page +#define swiotlb_dma_sync __dma_sync + #endif /* __ASM_SWIOTLB_H */ diff --git a/arch/x86/include/asm/swiotlb.h b/arch/x86/include/asm/swiotlb.h index 8085277..e5f6d9c 100644 --- a/arch/x86/include/asm/swiotlb.h +++ b/arch/x86/include/asm/swiotlb.h @@ -20,4 +20,14 @@ static inline void pci_swiotlb_init(void) static inline void dma_mark_clean(void *addr, size_t size) {} +static inline void swiotlb_dma_sync_page(struct page *page, + unsigned long offset, + size_t size, int direction) +{ +} + +static inline void swiotlb_dma_sync(void *vaddr, size_t size, int direction) +{ +} + #endif /* _ASM_X86_SWIOTLB_H */ diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 94db5df..8f2dad9 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c @@ -346,10 +346,13 @@ static void swiotlb_bounce(phys_addr_t phys, char *dma_addr, size_t size, local_irq_save(flags); buffer = kmap_atomic(pfn_to_page(pfn), KM_BOUNCE_READ); - if (dir == DMA_TO_DEVICE) + if (dir == DMA_TO_DEVICE) { memcpy(dma_addr, buffer + offset, sz); - else + swiotlb_dma_sync(dma_addr, sz, dir); + } else { + swiotlb_dma_sync(dma_addr, sz, dir); memcpy(buffer + offset, dma_addr, sz); + } kunmap_atomic(buffer, KM_BOUNCE_READ); local_irq_restore(flags); @@ -359,10 +362,14 @@ static void swiotlb_bounce(phys_addr_t phys, char *dma_addr, size_t size, offset = 0; } } else { - if (dir == DMA_TO_DEVICE) + if (dir == DMA_TO_DEVICE) { memcpy(dma_addr, phys_to_virt(phys), size); - else + swiotlb_dma_sync(dma_addr, size, dir); + + } else { + swiotlb_dma_sync(dma_addr, size, dir); memcpy(phys_to_virt(phys), dma_addr, size); + } } } @@ -542,6 +549,8 @@ sync_single(struct device *hwdev, char *dma_addr, size_t size, } } +#ifndef CONFIG_NOT_COHERENT_CACHE + void * swiotlb_alloc_coherent(struct device *hwdev, size_t size, dma_addr_t *dma_handle, gfp_t flags) @@ -606,6 +615,8 @@ swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr, } EXPORT_SYMBOL(swiotlb_free_coherent); +#endif /* !CONFIG_NOT_COHERENT_CACHE */ + static void swiotlb_full(struct device *dev, size_t size, int dir, int do_panic) { @@ -652,8 +663,10 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page *page, * we can safely return the device addr and not worry about bounce * buffering it. */ - if (dma_capable(dev, dev_addr, size) && !swiotlb_force) + if (dma_capable(dev, dev_addr, size) && !swiotlb_force) { + swiotlb_dma_sync_page(page, offset, size, dir); return dev_addr; + } /* * Oh well, have to allocate and map a bounce buffer. @@ -739,6 +752,8 @@ swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr, return; } + swiotlb_dma_sync(phys_to_virt(paddr), size, dir); + if (dir != DMA_FROM_DEVICE) return; @@ -835,8 +850,11 @@ swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems, return 0; } sg->dma_address = swiotlb_virt_to_bus(hwdev, map); - } else + } else { + swiotlb_dma_sync_page(sg_page(sg), sg->offset, + sg->length, dir); sg->dma_address = dev_addr; + } sg->dma_length = sg->length; } return nelems; -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v4 04/11] swiotlb: support NOT_COHERENT_CACHE PowerPC platforms 2010-03-12 19:12 ` [PATCH v4 04/11] swiotlb: support NOT_COHERENT_CACHE PowerPC platforms Albert Herranz @ 2010-03-16 1:54 ` FUJITA Tomonori 2010-03-16 2:25 ` FUJITA Tomonori 2010-03-16 6:09 ` Albert Herranz 0 siblings, 2 replies; 12+ messages in thread From: FUJITA Tomonori @ 2010-03-16 1:54 UTC (permalink / raw) To: albert_herranz; +Cc: linux-usb, linuxppc-dev, linux-kernel, x86, linux-ia64 On Fri, 12 Mar 2010 20:12:39 +0100 Albert Herranz <albert_herranz@yahoo.es> wrote: > The current SWIOTLB code does not support NOT_COHERENT_CACHE platforms. > This patch adds support for NOT_COHERENT_CACHE platforms to SWIOTLB by > adding two platform specific functions swiotlb_dma_sync_page() and > swiotlb_dma_sync() which can be used to explicitly manage cache coherency. > > On PowerPC these functions are mapped to their corresponding > __dma_sync_page() and __dma_sync() functions. > On other architectures using SWIOTLB these functions are optimized out. > > This will be used later to support SWIOTLB on the Nintendo Wii video game > console. > > CC: linuxppc-dev@lists.ozlabs.org > CC: linux-kernel@vger.kernel.org > CC: x86@kernel.org > CC: linux-ia64@vger.kernel.org > Signed-off-by: Albert Herranz <albert_herranz@yahoo.es> > --- > arch/ia64/include/asm/swiotlb.h | 10 ++++++++++ > arch/powerpc/include/asm/swiotlb.h | 3 +++ > arch/x86/include/asm/swiotlb.h | 10 ++++++++++ > lib/swiotlb.c | 30 ++++++++++++++++++++++++------ > 4 files changed, 47 insertions(+), 6 deletions(-) Why can't you use dma_sync_single_* instead of inventing new swiotlb sync functions? ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 04/11] swiotlb: support NOT_COHERENT_CACHE PowerPC platforms 2010-03-16 1:54 ` FUJITA Tomonori @ 2010-03-16 2:25 ` FUJITA Tomonori 2010-03-16 6:17 ` Albert Herranz 2010-03-16 6:09 ` Albert Herranz 1 sibling, 1 reply; 12+ messages in thread From: FUJITA Tomonori @ 2010-03-16 2:25 UTC (permalink / raw) To: albert_herranz; +Cc: linux-usb, linuxppc-dev, linux-kernel, x86, linux-ia64 On Tue, 16 Mar 2010 10:54:40 +0900 FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> wrote: > On Fri, 12 Mar 2010 20:12:39 +0100 > Albert Herranz <albert_herranz@yahoo.es> wrote: > > > The current SWIOTLB code does not support NOT_COHERENT_CACHE platforms. > > This patch adds support for NOT_COHERENT_CACHE platforms to SWIOTLB by > > adding two platform specific functions swiotlb_dma_sync_page() and > > swiotlb_dma_sync() which can be used to explicitly manage cache coherency. > > > > On PowerPC these functions are mapped to their corresponding > > __dma_sync_page() and __dma_sync() functions. > > On other architectures using SWIOTLB these functions are optimized out. > > > > This will be used later to support SWIOTLB on the Nintendo Wii video game > > console. > > > > CC: linuxppc-dev@lists.ozlabs.org > > CC: linux-kernel@vger.kernel.org > > CC: x86@kernel.org > > CC: linux-ia64@vger.kernel.org > > Signed-off-by: Albert Herranz <albert_herranz@yahoo.es> > > --- > > arch/ia64/include/asm/swiotlb.h | 10 ++++++++++ > > arch/powerpc/include/asm/swiotlb.h | 3 +++ > > arch/x86/include/asm/swiotlb.h | 10 ++++++++++ > > lib/swiotlb.c | 30 ++++++++++++++++++++++++------ > > 4 files changed, 47 insertions(+), 6 deletions(-) > > Why can't you use dma_sync_single_* instead of inventing new > swiotlb sync functions? If we want to make swiotlb generic (make on any architectures), we need to handle more cache issues here, I think. So it's better to have more generic ways instead of adding hooks to some archs. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 04/11] swiotlb: support NOT_COHERENT_CACHE PowerPC platforms 2010-03-16 2:25 ` FUJITA Tomonori @ 2010-03-16 6:17 ` Albert Herranz 0 siblings, 0 replies; 12+ messages in thread From: Albert Herranz @ 2010-03-16 6:17 UTC (permalink / raw) To: FUJITA Tomonori; +Cc: linux-usb, linuxppc-dev, linux-kernel, x86, linux-ia64 FUJITA Tomonori wrote: > If we want to make swiotlb generic (make on any architectures), we > need to handle more cache issues here, I think. So it's better to have > more generic ways instead of adding hooks to some archs. > Ok. So what would be an acceptable way of handling this in a generic way? Should we for example have 2 levels of DMA ops in the swiotlb case (swiotlb and "actual") and call the 2nd level ("actual") from the swiotlb code whenever we need to act on non-bounced buffers? Any other ideas? Thanks, Albert ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 04/11] swiotlb: support NOT_COHERENT_CACHE PowerPC platforms 2010-03-16 1:54 ` FUJITA Tomonori 2010-03-16 2:25 ` FUJITA Tomonori @ 2010-03-16 6:09 ` Albert Herranz 1 sibling, 0 replies; 12+ messages in thread From: Albert Herranz @ 2010-03-16 6:09 UTC (permalink / raw) To: FUJITA Tomonori; +Cc: linux-usb, linuxppc-dev, linux-kernel, x86, linux-ia64 FUJITA Tomonori wrote: > On Fri, 12 Mar 2010 20:12:39 +0100 > Albert Herranz <albert_herranz@yahoo.es> wrote: > >> The current SWIOTLB code does not support NOT_COHERENT_CACHE platforms. >> This patch adds support for NOT_COHERENT_CACHE platforms to SWIOTLB by >> adding two platform specific functions swiotlb_dma_sync_page() and >> swiotlb_dma_sync() which can be used to explicitly manage cache coherency. >> >> On PowerPC these functions are mapped to their corresponding >> __dma_sync_page() and __dma_sync() functions. >> On other architectures using SWIOTLB these functions are optimized out. >> >> This will be used later to support SWIOTLB on the Nintendo Wii video game >> console. >> >> CC: linuxppc-dev@lists.ozlabs.org >> CC: linux-kernel@vger.kernel.org >> CC: x86@kernel.org >> CC: linux-ia64@vger.kernel.org >> Signed-off-by: Albert Herranz <albert_herranz@yahoo.es> >> --- >> arch/ia64/include/asm/swiotlb.h | 10 ++++++++++ >> arch/powerpc/include/asm/swiotlb.h | 3 +++ >> arch/x86/include/asm/swiotlb.h | 10 ++++++++++ >> lib/swiotlb.c | 30 ++++++++++++++++++++++++------ >> 4 files changed, 47 insertions(+), 6 deletions(-) > > Why can't you use dma_sync_single_* instead of inventing new > swiotlb sync functions? > At least on PowerPC, the DMA ops are per-device hooks. We attach the swiotlb DMA ops functions to those hooks when we are using swiotlb. So calling dma_sync_single_*() would end up calling swiotlb_sync_single_*() which is not what we want. Thanks, Albert ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v4 05/11] swiotlb: add swiotlb_set_default_size() [not found] <1268421166-4791-1-git-send-email-albert_herranz@yahoo.es> 2010-03-12 19:12 ` [PATCH v4 03/11] swiotbl: add back swiotlb_alloc_boot() Albert Herranz 2010-03-12 19:12 ` [PATCH v4 04/11] swiotlb: support NOT_COHERENT_CACHE PowerPC platforms Albert Herranz @ 2010-03-12 19:12 ` Albert Herranz 2010-03-16 1:44 ` FUJITA Tomonori 2 siblings, 1 reply; 12+ messages in thread From: Albert Herranz @ 2010-03-12 19:12 UTC (permalink / raw) To: linux-usb, linuxppc-dev; +Cc: Albert Herranz, linux-kernel, x86, linux-ia64 The current SWIOTLB code uses a default of 64MB for the IO TLB area. This size can be influenced using a kernel command line parameter "swiotlb". Unfortunately, the parsing of the kernel command line is done _after_ the swiotlb is initialized on some architectures. This patch adds a new function swiotlb_set_default_size() which can be used before swiotlb_init() to indicate the desired IO TLB area size in bytes. This will be used later to implement a smaller IO TLB on the Nintendo Wii video game console which just comes with 24MB + 64MB of RAM. CC: linuxppc-dev@lists.ozlabs.org CC: linux-kernel@vger.kernel.org CC: x86@kernel.org CC: linux-ia64@vger.kernel.org Signed-off-by: Albert Herranz <albert_herranz@yahoo.es> --- include/linux/swiotlb.h | 2 ++ lib/swiotlb.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 0 deletions(-) diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h index 3954228..2af6a45 100644 --- a/include/linux/swiotlb.h +++ b/include/linux/swiotlb.h @@ -22,6 +22,8 @@ extern int swiotlb_force; */ #define IO_TLB_SHIFT 11 +extern size_t __init swiotlb_set_default_size(size_t size); + extern void swiotlb_init(int verbose); extern void *swiotlb_alloc_boot(size_t bytes, unsigned long nslabs); diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 8f2dad9..dbeca50 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c @@ -117,6 +117,26 @@ setup_io_tlb_npages(char *str) __setup("swiotlb=", setup_io_tlb_npages); /* make io_tlb_overflow tunable too? */ +/** + * swiotlb_set_default_size() - set the default size for the IO TLB + * @size: size in bytes of the IO TLB + * + * A platform can use this function to change the default size of the + * IO TLB when the default of 64MB is not suitable. + * This function must be called before swiotlb_init(). + * + * Note that on some platforms this is the only way to influence the + * size of the IO TLB, as the command line may be parsed _after_ the + * IO TLB is initialized. + */ +size_t __init swiotlb_set_default_size(size_t size) +{ + size_t previous_size = io_tlb_nslabs << IO_TLB_SHIFT; + + io_tlb_nslabs = size >> IO_TLB_SHIFT; + return previous_size; +} + void * __weak __init swiotlb_alloc_boot(size_t size, unsigned long nslabs) { return alloc_bootmem_low_pages(size); -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v4 05/11] swiotlb: add swiotlb_set_default_size() 2010-03-12 19:12 ` [PATCH v4 05/11] swiotlb: add swiotlb_set_default_size() Albert Herranz @ 2010-03-16 1:44 ` FUJITA Tomonori 2010-03-16 5:58 ` Albert Herranz 0 siblings, 1 reply; 12+ messages in thread From: FUJITA Tomonori @ 2010-03-16 1:44 UTC (permalink / raw) To: albert_herranz; +Cc: linux-usb, linuxppc-dev, linux-kernel, x86, linux-ia64 On Fri, 12 Mar 2010 20:12:40 +0100 Albert Herranz <albert_herranz@yahoo.es> wrote: > The current SWIOTLB code uses a default of 64MB for the IO TLB area. > This size can be influenced using a kernel command line parameter "swiotlb". > Unfortunately, the parsing of the kernel command line is done _after_ the > swiotlb is initialized on some architectures. > > This patch adds a new function swiotlb_set_default_size() which can be used > before swiotlb_init() to indicate the desired IO TLB area size in bytes. > > This will be used later to implement a smaller IO TLB on the Nintendo Wii > video game console which just comes with 24MB + 64MB of RAM. > > CC: linuxppc-dev@lists.ozlabs.org > CC: linux-kernel@vger.kernel.org > CC: x86@kernel.org > CC: linux-ia64@vger.kernel.org > Signed-off-by: Albert Herranz <albert_herranz@yahoo.es> > --- > include/linux/swiotlb.h | 2 ++ > lib/swiotlb.c | 20 ++++++++++++++++++++ > 2 files changed, 22 insertions(+), 0 deletions(-) Please fix the powerpc swiotlb initialization instead. Calling swiotlb_init() before parsing kernel parameters sounds wrong. Any reasons why you can't fix it? ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 05/11] swiotlb: add swiotlb_set_default_size() 2010-03-16 1:44 ` FUJITA Tomonori @ 2010-03-16 5:58 ` Albert Herranz 2010-03-16 10:08 ` FUJITA Tomonori 0 siblings, 1 reply; 12+ messages in thread From: Albert Herranz @ 2010-03-16 5:58 UTC (permalink / raw) To: FUJITA Tomonori, Benjamin Herrenschmidt Cc: linux-usb, linuxppc-dev, linux-kernel, x86, linux-ia64 FUJITA Tomonori wrote: > On Fri, 12 Mar 2010 20:12:40 +0100 > Albert Herranz <albert_herranz@yahoo.es> wrote: > >> The current SWIOTLB code uses a default of 64MB for the IO TLB area. >> This size can be influenced using a kernel command line parameter "swiotlb". >> Unfortunately, the parsing of the kernel command line is done _after_ the >> swiotlb is initialized on some architectures. >> >> This patch adds a new function swiotlb_set_default_size() which can be used >> before swiotlb_init() to indicate the desired IO TLB area size in bytes. >> >> This will be used later to implement a smaller IO TLB on the Nintendo Wii >> video game console which just comes with 24MB + 64MB of RAM. >> >> CC: linuxppc-dev@lists.ozlabs.org >> CC: linux-kernel@vger.kernel.org >> CC: x86@kernel.org >> CC: linux-ia64@vger.kernel.org >> Signed-off-by: Albert Herranz <albert_herranz@yahoo.es> >> --- >> include/linux/swiotlb.h | 2 ++ >> lib/swiotlb.c | 20 ++++++++++++++++++++ >> 2 files changed, 22 insertions(+), 0 deletions(-) > > Please fix the powerpc swiotlb initialization instead. > > Calling swiotlb_init() before parsing kernel parameters sounds > wrong. Any reasons why you can't fix it? > I think that this would be better asked by a PowerPC maintainer. Ben? If this is really a problem the swiotlb late init may be a solution too in this particular case. Thanks, Albert ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 05/11] swiotlb: add swiotlb_set_default_size() 2010-03-16 5:58 ` Albert Herranz @ 2010-03-16 10:08 ` FUJITA Tomonori 2010-03-16 19:28 ` Becky Bruce 0 siblings, 1 reply; 12+ messages in thread From: FUJITA Tomonori @ 2010-03-16 10:08 UTC (permalink / raw) To: albert_herranz Cc: fujita.tomonori, benh, linux-usb, linuxppc-dev, linux-kernel, x86, linux-ia64, beckyb On Tue, 16 Mar 2010 06:58:41 +0100 Albert Herranz <albert_herranz@yahoo.es> wrote: > FUJITA Tomonori wrote: > > On Fri, 12 Mar 2010 20:12:40 +0100 > > Albert Herranz <albert_herranz@yahoo.es> wrote: > > > >> The current SWIOTLB code uses a default of 64MB for the IO TLB area. > >> This size can be influenced using a kernel command line parameter "swiotlb". > >> Unfortunately, the parsing of the kernel command line is done _after_ the > >> swiotlb is initialized on some architectures. > >> > >> This patch adds a new function swiotlb_set_default_size() which can be used > >> before swiotlb_init() to indicate the desired IO TLB area size in bytes. > >> > >> This will be used later to implement a smaller IO TLB on the Nintendo Wii > >> video game console which just comes with 24MB + 64MB of RAM. > >> > >> CC: linuxppc-dev@lists.ozlabs.org > >> CC: linux-kernel@vger.kernel.org > >> CC: x86@kernel.org > >> CC: linux-ia64@vger.kernel.org > >> Signed-off-by: Albert Herranz <albert_herranz@yahoo.es> > >> --- > >> include/linux/swiotlb.h | 2 ++ > >> lib/swiotlb.c | 20 ++++++++++++++++++++ > >> 2 files changed, 22 insertions(+), 0 deletions(-) > > > > Please fix the powerpc swiotlb initialization instead. > > > > Calling swiotlb_init() before parsing kernel parameters sounds > > wrong. Any reasons why you can't fix it? > > > > I think that this would be better asked by a PowerPC maintainer. Ben? > > If this is really a problem the swiotlb late init may be a solution too in this particular case. Hmm, why swiotlb_late_init_with_default_size()? Why can't you initialize swiotlb in mem_init() like this (only compile tested)? Any time before freeing bootmem works for swiotlb. diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index b152de3..8f58986 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c @@ -39,7 +39,6 @@ #include <asm/serial.h> #include <asm/udbg.h> #include <asm/mmu_context.h> -#include <asm/swiotlb.h> #include "setup.h" @@ -343,11 +342,6 @@ void __init setup_arch(char **cmdline_p) ppc_md.setup_arch(); if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab); -#ifdef CONFIG_SWIOTLB - if (ppc_swiotlb_enable) - swiotlb_init(1); -#endif - paging_init(); /* Initialize the MMU context management stuff */ diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index 6354739..9143891 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -61,7 +61,6 @@ #include <asm/xmon.h> #include <asm/udbg.h> #include <asm/kexec.h> -#include <asm/swiotlb.h> #include <asm/mmu_context.h> #include "setup.h" @@ -541,11 +540,6 @@ void __init setup_arch(char **cmdline_p) if (ppc_md.setup_arch) ppc_md.setup_arch(); -#ifdef CONFIG_SWIOTLB - if (ppc_swiotlb_enable) - swiotlb_init(1); -#endif - paging_init(); /* Initialize the MMU context management stuff */ diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 311224c..448f972 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -48,6 +48,7 @@ #include <asm/sparsemem.h> #include <asm/vdso.h> #include <asm/fixmap.h> +#include <asm/swiotlb.h> #include "mmu_decl.h" @@ -320,6 +321,11 @@ void __init mem_init(void) struct page *page; unsigned long reservedpages = 0, codesize, initsize, datasize, bsssize; +#ifdef CONFIG_SWIOTLB + if (ppc_swiotlb_enable) + swiotlb_init(1); +#endif + num_physpages = lmb.memory.size >> PAGE_SHIFT; high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v4 05/11] swiotlb: add swiotlb_set_default_size() 2010-03-16 10:08 ` FUJITA Tomonori @ 2010-03-16 19:28 ` Becky Bruce 2010-03-16 23:16 ` FUJITA Tomonori 0 siblings, 1 reply; 12+ messages in thread From: Becky Bruce @ 2010-03-16 19:28 UTC (permalink / raw) To: FUJITA Tomonori Cc: albert_herranz, benh, linux-usb, linuxppc-dev, linux-kernel, x86, linux-ia64 On Mar 16, 2010, at 5:08 AM, FUJITA Tomonori wrote: > On Tue, 16 Mar 2010 06:58:41 +0100 > Albert Herranz <albert_herranz@yahoo.es> wrote: > >> FUJITA Tomonori wrote: >>> On Fri, 12 Mar 2010 20:12:40 +0100 >>> Albert Herranz <albert_herranz@yahoo.es> wrote: >>> >>>> The current SWIOTLB code uses a default of 64MB for the IO TLB >>>> area. >>>> This size can be influenced using a kernel command line parameter >>>> "swiotlb". >>>> Unfortunately, the parsing of the kernel command line is done >>>> _after_ the >>>> swiotlb is initialized on some architectures. >>>> >>>> This patch adds a new function swiotlb_set_default_size() which >>>> can be used >>>> before swiotlb_init() to indicate the desired IO TLB area size in >>>> bytes. >>>> >>>> This will be used later to implement a smaller IO TLB on the >>>> Nintendo Wii >>>> video game console which just comes with 24MB + 64MB of RAM. >>>> >>>> CC: linuxppc-dev@lists.ozlabs.org >>>> CC: linux-kernel@vger.kernel.org >>>> CC: x86@kernel.org >>>> CC: linux-ia64@vger.kernel.org >>>> Signed-off-by: Albert Herranz <albert_herranz@yahoo.es> >>>> --- >>>> include/linux/swiotlb.h | 2 ++ >>>> lib/swiotlb.c | 20 ++++++++++++++++++++ >>>> 2 files changed, 22 insertions(+), 0 deletions(-) >>> >>> Please fix the powerpc swiotlb initialization instead. >>> >>> Calling swiotlb_init() before parsing kernel parameters sounds >>> wrong. Any reasons why you can't fix it? >>> >> >> I think that this would be better asked by a PowerPC maintainer. Ben? >> >> If this is really a problem the swiotlb late init may be a solution >> too in this particular case. > > Hmm, why swiotlb_late_init_with_default_size()? > > Why can't you initialize swiotlb in mem_init() like this (only compile > tested)? Any time before freeing bootmem works for swiotlb. This is an oops in the original patchset - I think it should be fine to move the swiotlb_init later as Fujita suggests, at least for 32-bit powerpc. I just booted this on mpc8641 and everything seems OK. -Becky > > > diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/ > setup_32.c > index b152de3..8f58986 100644 > --- a/arch/powerpc/kernel/setup_32.c > +++ b/arch/powerpc/kernel/setup_32.c > @@ -39,7 +39,6 @@ > #include <asm/serial.h> > #include <asm/udbg.h> > #include <asm/mmu_context.h> > -#include <asm/swiotlb.h> > > #include "setup.h" > > @@ -343,11 +342,6 @@ void __init setup_arch(char **cmdline_p) > ppc_md.setup_arch(); > if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab); > > -#ifdef CONFIG_SWIOTLB > - if (ppc_swiotlb_enable) > - swiotlb_init(1); > -#endif > - > paging_init(); > > /* Initialize the MMU context management stuff */ > diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/ > setup_64.c > index 6354739..9143891 100644 > --- a/arch/powerpc/kernel/setup_64.c > +++ b/arch/powerpc/kernel/setup_64.c > @@ -61,7 +61,6 @@ > #include <asm/xmon.h> > #include <asm/udbg.h> > #include <asm/kexec.h> > -#include <asm/swiotlb.h> > #include <asm/mmu_context.h> > > #include "setup.h" > @@ -541,11 +540,6 @@ void __init setup_arch(char **cmdline_p) > if (ppc_md.setup_arch) > ppc_md.setup_arch(); > > -#ifdef CONFIG_SWIOTLB > - if (ppc_swiotlb_enable) > - swiotlb_init(1); > -#endif > - > paging_init(); > > /* Initialize the MMU context management stuff */ > diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c > index 311224c..448f972 100644 > --- a/arch/powerpc/mm/mem.c > +++ b/arch/powerpc/mm/mem.c > @@ -48,6 +48,7 @@ > #include <asm/sparsemem.h> > #include <asm/vdso.h> > #include <asm/fixmap.h> > +#include <asm/swiotlb.h> > > #include "mmu_decl.h" > > @@ -320,6 +321,11 @@ void __init mem_init(void) > struct page *page; > unsigned long reservedpages = 0, codesize, initsize, datasize, > bsssize; > > +#ifdef CONFIG_SWIOTLB > + if (ppc_swiotlb_enable) > + swiotlb_init(1); > +#endif > + > num_physpages = lmb.memory.size >> PAGE_SHIFT; > high_memory = (void *) __va(max_low_pfn * 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/ ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 05/11] swiotlb: add swiotlb_set_default_size() 2010-03-16 19:28 ` Becky Bruce @ 2010-03-16 23:16 ` FUJITA Tomonori 0 siblings, 0 replies; 12+ messages in thread From: FUJITA Tomonori @ 2010-03-16 23:16 UTC (permalink / raw) To: beckyb Cc: fujita.tomonori, albert_herranz, benh, linux-usb, linuxppc-dev, linux-kernel, x86, linux-ia64 On Tue, 16 Mar 2010 14:28:09 -0500 Becky Bruce <beckyb@kernel.crashing.org> wrote: > > On Mar 16, 2010, at 5:08 AM, FUJITA Tomonori wrote: > > > On Tue, 16 Mar 2010 06:58:41 +0100 > > Albert Herranz <albert_herranz@yahoo.es> wrote: > > > >> FUJITA Tomonori wrote: > >>> On Fri, 12 Mar 2010 20:12:40 +0100 > >>> Albert Herranz <albert_herranz@yahoo.es> wrote: > >>> > >>>> The current SWIOTLB code uses a default of 64MB for the IO TLB > >>>> area. > >>>> This size can be influenced using a kernel command line parameter > >>>> "swiotlb". > >>>> Unfortunately, the parsing of the kernel command line is done > >>>> _after_ the > >>>> swiotlb is initialized on some architectures. > >>>> > >>>> This patch adds a new function swiotlb_set_default_size() which > >>>> can be used > >>>> before swiotlb_init() to indicate the desired IO TLB area size in > >>>> bytes. > >>>> > >>>> This will be used later to implement a smaller IO TLB on the > >>>> Nintendo Wii > >>>> video game console which just comes with 24MB + 64MB of RAM. > >>>> > >>>> CC: linuxppc-dev@lists.ozlabs.org > >>>> CC: linux-kernel@vger.kernel.org > >>>> CC: x86@kernel.org > >>>> CC: linux-ia64@vger.kernel.org > >>>> Signed-off-by: Albert Herranz <albert_herranz@yahoo.es> > >>>> --- > >>>> include/linux/swiotlb.h | 2 ++ > >>>> lib/swiotlb.c | 20 ++++++++++++++++++++ > >>>> 2 files changed, 22 insertions(+), 0 deletions(-) > >>> > >>> Please fix the powerpc swiotlb initialization instead. > >>> > >>> Calling swiotlb_init() before parsing kernel parameters sounds > >>> wrong. Any reasons why you can't fix it? > >>> > >> > >> I think that this would be better asked by a PowerPC maintainer. Ben? > >> > >> If this is really a problem the swiotlb late init may be a solution > >> too in this particular case. > > > > Hmm, why swiotlb_late_init_with_default_size()? > > > > Why can't you initialize swiotlb in mem_init() like this (only compile > > tested)? Any time before freeing bootmem works for swiotlb. > > This is an oops in the original patchset - I think it should be fine > to move the swiotlb_init later as Fujita suggests, at least for 32-bit > powerpc. I just booted this on mpc8641 and everything seems OK. Thanks! I'll resend this patch in the proper format. This patch fixes the problem that powerpc ignores swiotlb boot options so we can merge it independent of Albert's patchset. ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2010-03-16 23:16 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1268421166-4791-1-git-send-email-albert_herranz@yahoo.es>
2010-03-12 19:12 ` [PATCH v4 03/11] swiotbl: add back swiotlb_alloc_boot() Albert Herranz
2010-03-12 19:12 ` [PATCH v4 04/11] swiotlb: support NOT_COHERENT_CACHE PowerPC platforms Albert Herranz
2010-03-16 1:54 ` FUJITA Tomonori
2010-03-16 2:25 ` FUJITA Tomonori
2010-03-16 6:17 ` Albert Herranz
2010-03-16 6:09 ` Albert Herranz
2010-03-12 19:12 ` [PATCH v4 05/11] swiotlb: add swiotlb_set_default_size() Albert Herranz
2010-03-16 1:44 ` FUJITA Tomonori
2010-03-16 5:58 ` Albert Herranz
2010-03-16 10:08 ` FUJITA Tomonori
2010-03-16 19:28 ` Becky Bruce
2010-03-16 23:16 ` FUJITA Tomonori
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox