* [LINUX] dma: Use swiotlb mask for coherent mappings too
@ 2006-12-20 5:14 Herbert Xu
2006-12-20 11:50 ` Jan Beulich
0 siblings, 1 reply; 5+ messages in thread
From: Herbert Xu @ 2006-12-20 5:14 UTC (permalink / raw)
To: Keir Fraser, Xen Development Mailing List, Calvin Webster
Hi Keir:
[LINUX] dma: Use swiotlb mask for coherent mappings too
The recent change to use a default DMA bit width of 30 bits (required
by chips like the b44) only converted the streaming DMA primitives.
The coherent mappings are still hard-coded to 31 bits. This means that
b44 still doesn't work under Xen.
This patch makes the io_tlb_dma_bits variable global and uses it for
coherent memory mappings.
Thanks to Calvin Webster for providing a machine with a b44 and 2G
of memory I've been able to verify that this finally makes the b44
work under Xen.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
diff -r 057f7c4dbed1 linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c Tue Dec 19 12:00:11 2006 +0000
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c Wed Dec 20 16:07:24 2006 +1100
@@ -15,6 +15,7 @@
#include <linux/version.h>
#include <asm/io.h>
#include <xen/balloon.h>
+#include <asm/swiotlb.h>
#include <asm/tlbflush.h>
#include <asm-i386/mach-xen/asm/swiotlb.h>
#include <asm/bug.h>
@@ -183,8 +184,8 @@ void *dma_alloc_coherent(struct device *
ret = (void *)vstart;
if (ret != NULL) {
- /* NB. Hardcode 31 address bits for now: aacraid limitation. */
- if (xen_create_contiguous_region(vstart, order, 31) != 0) {
+ if (xen_create_contiguous_region(vstart, order,
+ io_tlb_dma_bits) != 0) {
free_pages(vstart, order);
return NULL;
}
diff -r 057f7c4dbed1 linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c Tue Dec 19 12:00:11 2006 +0000
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c Wed Dec 20 16:07:24 2006 +1100
@@ -98,7 +98,7 @@ static struct phys_addr {
*/
static DEFINE_SPINLOCK(io_tlb_lock);
-static unsigned int io_tlb_dma_bits = DEFAULT_IO_TLB_DMA_BITS;
+unsigned int io_tlb_dma_bits = DEFAULT_IO_TLB_DMA_BITS;
static int __init
setup_io_tlb_bits(char *str)
{
diff -r 057f7c4dbed1 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h Tue Dec 19 12:00:11 2006 +0000
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h Wed Dec 20 16:07:24 2006 +1100
@@ -34,6 +34,8 @@ extern int swiotlb_dma_supported(struct
extern int swiotlb_dma_supported(struct device *hwdev, u64 mask);
extern void swiotlb_init(void);
+extern int io_tlb_dma_bits;
+
#ifdef CONFIG_SWIOTLB
extern int swiotlb;
#else
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LINUX] dma: Use swiotlb mask for coherent mappings too
2006-12-20 5:14 [LINUX] dma: Use swiotlb mask for coherent mappings too Herbert Xu
@ 2006-12-20 11:50 ` Jan Beulich
2006-12-20 11:55 ` Keir Fraser
0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2006-12-20 11:50 UTC (permalink / raw)
To: Herbert Xu, Keir Fraser; +Cc: Xen Development Mailing List, Calvin Webster
As we're going to have a swiotlb_{alloc,free}_coherent implementation after the sync
with lib/swiotlb.c anyway, wouldn't it make sense to have dma_{alloc,free}_coherent
call the former rather than setting up things by itself? If course, this will increase
pressure on the swiotlb memory, but otoh it could reduce the likelihood of the
contiguous region setup failing (especially if those are of non-zero order).
Jan
>>> Herbert Xu <herbert@gondor.apana.org.au> 20.12.06 06:14 >>>
Hi Keir:
[LINUX] dma: Use swiotlb mask for coherent mappings too
The recent change to use a default DMA bit width of 30 bits (required
by chips like the b44) only converted the streaming DMA primitives.
The coherent mappings are still hard-coded to 31 bits. This means that
b44 still doesn't work under Xen.
This patch makes the io_tlb_dma_bits variable global and uses it for
coherent memory mappings.
Thanks to Calvin Webster for providing a machine with a b44 and 2G
of memory I've been able to verify that this finally makes the b44
work under Xen.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
diff -r 057f7c4dbed1 linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c Tue Dec 19 12:00:11 2006 +0000
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c Wed Dec 20 16:07:24 2006 +1100
@@ -15,6 +15,7 @@
#include <linux/version.h>
#include <asm/io.h>
#include <xen/balloon.h>
+#include <asm/swiotlb.h>
#include <asm/tlbflush.h>
#include <asm-i386/mach-xen/asm/swiotlb.h>
#include <asm/bug.h>
@@ -183,8 +184,8 @@ void *dma_alloc_coherent(struct device *
ret = (void *)vstart;
if (ret != NULL) {
- /* NB. Hardcode 31 address bits for now: aacraid limitation. */
- if (xen_create_contiguous_region(vstart, order, 31) != 0) {
+ if (xen_create_contiguous_region(vstart, order,
+ io_tlb_dma_bits) != 0) {
free_pages(vstart, order);
return NULL;
}
diff -r 057f7c4dbed1 linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c Tue Dec 19 12:00:11 2006 +0000
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c Wed Dec 20 16:07:24 2006 +1100
@@ -98,7 +98,7 @@ static struct phys_addr {
*/
static DEFINE_SPINLOCK(io_tlb_lock);
-static unsigned int io_tlb_dma_bits = DEFAULT_IO_TLB_DMA_BITS;
+unsigned int io_tlb_dma_bits = DEFAULT_IO_TLB_DMA_BITS;
static int __init
setup_io_tlb_bits(char *str)
{
diff -r 057f7c4dbed1 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h Tue Dec 19 12:00:11 2006 +0000
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h Wed Dec 20 16:07:24 2006 +1100
@@ -34,6 +34,8 @@ extern int swiotlb_dma_supported(struct
extern int swiotlb_dma_supported(struct device *hwdev, u64 mask);
extern void swiotlb_init(void);
+extern int io_tlb_dma_bits;
+
#ifdef CONFIG_SWIOTLB
extern int swiotlb;
#else
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LINUX] dma: Use swiotlb mask for coherent mappings too
2006-12-20 11:50 ` Jan Beulich
@ 2006-12-20 11:55 ` Keir Fraser
2006-12-20 12:38 ` Jan Beulich
0 siblings, 1 reply; 5+ messages in thread
From: Keir Fraser @ 2006-12-20 11:55 UTC (permalink / raw)
To: Jan Beulich, Herbert Xu, Keir Fraser
Cc: Xen Development Mailing List, Calvin Webster
We could fall back to swiotlb_alloc/free_coherent?
I took the patch but renamed io_tlb_dma_bits to dma_bits. This makes more
sense for users anyway I think -- they're unlikely to care whether
allocations go thru swiotlb or not, they just want to specify what device
limitation they require the kernel to handle by whatever means it chooses.
So now it's 'dma_bits=' rather than 'io_tlb_dma_bits=', which happens to
neatly be the same as the Xen boot parameter's name.
-- Keir
On 20/12/06 11:50, "Jan Beulich" <jbeulich@novell.com> wrote:
> As we're going to have a swiotlb_{alloc,free}_coherent implementation after
> the sync
> with lib/swiotlb.c anyway, wouldn't it make sense to have
> dma_{alloc,free}_coherent
> call the former rather than setting up things by itself? If course, this will
> increase
> pressure on the swiotlb memory, but otoh it could reduce the likelihood of the
> contiguous region setup failing (especially if those are of non-zero order).
>
> Jan
>
>>>> Herbert Xu <herbert@gondor.apana.org.au> 20.12.06 06:14 >>>
> Hi Keir:
>
> [LINUX] dma: Use swiotlb mask for coherent mappings too
>
> The recent change to use a default DMA bit width of 30 bits (required
> by chips like the b44) only converted the streaming DMA primitives.
> The coherent mappings are still hard-coded to 31 bits. This means that
> b44 still doesn't work under Xen.
>
> This patch makes the io_tlb_dma_bits variable global and uses it for
> coherent memory mappings.
>
> Thanks to Calvin Webster for providing a machine with a b44 and 2G
> of memory I've been able to verify that this finally makes the b44
> work under Xen.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
>
> Cheers,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LINUX] dma: Use swiotlb mask for coherent mappings too
2006-12-20 11:55 ` Keir Fraser
@ 2006-12-20 12:38 ` Jan Beulich
2006-12-20 13:36 ` Keir Fraser
0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2006-12-20 12:38 UTC (permalink / raw)
To: Keir Fraser; +Cc: Xen Development Mailing List, Herbert Xu, Calvin Webster
>>> Keir Fraser <keir@xensource.com> 20.12.06 12:55 >>>
>We could fall back to swiotlb_alloc/free_coherent?
Hmm, that would mean extra tracking, as dma_free_coherent must have a way
to tell whether to call xen_destroy_contiguous_region directly or invoke
swiotlb_free_coherent (and I wouldn't want to make io_tlb_{start,end} global).
Jan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LINUX] dma: Use swiotlb mask for coherent mappings too
2006-12-20 12:38 ` Jan Beulich
@ 2006-12-20 13:36 ` Keir Fraser
0 siblings, 0 replies; 5+ messages in thread
From: Keir Fraser @ 2006-12-20 13:36 UTC (permalink / raw)
To: Jan Beulich, Keir Fraser
Cc: Xen Development Mailing List, Herbert Xu, Calvin Webster
On 20/12/06 12:38, "Jan Beulich" <jbeulich@novell.com> wrote:
>>>> Keir Fraser <keir@xensource.com> 20.12.06 12:55 >>>
>> We could fall back to swiotlb_alloc/free_coherent?
>
> Hmm, that would mean extra tracking, as dma_free_coherent must have a way
> to tell whether to call xen_destroy_contiguous_region directly or invoke
> swiotlb_free_coherent (and I wouldn't want to make io_tlb_{start,end} global).
dma_alloc_coherent is used to allocate some rather big areas in some cases
(e.g., when uploading firmware) which I'm sure would not fit in the
swiotlb's 64kB contiguous allocations. Some kind of is-within-aperture query
function would seem a reasonable addition to the swiotlb API.
-- Keir
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-12-20 13:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-20 5:14 [LINUX] dma: Use swiotlb mask for coherent mappings too Herbert Xu
2006-12-20 11:50 ` Jan Beulich
2006-12-20 11:55 ` Keir Fraser
2006-12-20 12:38 ` Jan Beulich
2006-12-20 13:36 ` Keir Fraser
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.