* [PATCH 0/3] minor cleanups for swiotlb
@ 2008-09-08 9:53 FUJITA Tomonori
2008-09-08 9:53 ` [PATCH 1/3] swiotlb: use map_single instead of swiotlb_map_single in swiotlb_alloc_coherent FUJITA Tomonori
2008-09-08 13:55 ` [PATCH 0/3] minor cleanups for swiotlb Ingo Molnar
0 siblings, 2 replies; 6+ messages in thread
From: FUJITA Tomonori @ 2008-09-08 9:53 UTC (permalink / raw)
To: linux-kernel; +Cc: mingo, tony.luck
This patchset is minor cleanups for swiotlb. It doesn't confilict with
the swiotlb fixes for the x86 tree (that I've just sent):
http://lkml.org/lkml/2008/9/8/30
This can be cleanly applied to tip/master and tip/x86/iommu.
Ingo, can you apply this to your tree?
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] swiotlb: use map_single instead of swiotlb_map_single in swiotlb_alloc_coherent
2008-09-08 9:53 [PATCH 0/3] minor cleanups for swiotlb FUJITA Tomonori
@ 2008-09-08 9:53 ` FUJITA Tomonori
2008-09-08 9:53 ` [PATCH 2/3] swiotlb: use unmap_single instead of swiotlb_unmap_single in swiotlb_free_coherent FUJITA Tomonori
2008-09-08 13:55 ` [PATCH 0/3] minor cleanups for swiotlb Ingo Molnar
1 sibling, 1 reply; 6+ messages in thread
From: FUJITA Tomonori @ 2008-09-08 9:53 UTC (permalink / raw)
To: linux-kernel; +Cc: mingo, tony.luck, FUJITA Tomonori
We always need swiotlb memory here so address_needs_mapping and
swiotlb_force testings are irrelevant. map_single should be used here
instead of swiotlb_map_single.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
lib/swiotlb.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 3066ffe..2fb485d 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -483,12 +483,9 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
* swiotlb_map_single(), which will grab memory from
* the lowest available address range.
*/
- dma_addr_t handle;
- handle = swiotlb_map_single(NULL, NULL, size, DMA_FROM_DEVICE);
- if (swiotlb_dma_mapping_error(hwdev, handle))
+ ret = map_single(hwdev, NULL, size, DMA_FROM_DEVICE);
+ if (!ret)
return NULL;
-
- ret = bus_to_virt(handle);
}
memset(ret, 0, size);
--
1.5.5.GIT
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] swiotlb: use unmap_single instead of swiotlb_unmap_single in swiotlb_free_coherent
2008-09-08 9:53 ` [PATCH 1/3] swiotlb: use map_single instead of swiotlb_map_single in swiotlb_alloc_coherent FUJITA Tomonori
@ 2008-09-08 9:53 ` FUJITA Tomonori
2008-09-08 9:53 ` [PATCH 3/3] swiotlb: add is_swiotlb_buffer helper function FUJITA Tomonori
0 siblings, 1 reply; 6+ messages in thread
From: FUJITA Tomonori @ 2008-09-08 9:53 UTC (permalink / raw)
To: linux-kernel; +Cc: mingo, tony.luck, FUJITA Tomonori
We don't need any check in swiotlb_unmap_single here. unmap_single is
appropriate.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
lib/swiotlb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 2fb485d..bf61c73 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -513,7 +513,7 @@ swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
free_pages((unsigned long) vaddr, get_order(size));
else
/* DMA_TO_DEVICE to avoid memcpy in unmap_single */
- swiotlb_unmap_single (hwdev, dma_handle, size, DMA_TO_DEVICE);
+ unmap_single(hwdev, vaddr, size, DMA_TO_DEVICE);
}
static void
--
1.5.5.GIT
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] swiotlb: add is_swiotlb_buffer helper function
2008-09-08 9:53 ` [PATCH 2/3] swiotlb: use unmap_single instead of swiotlb_unmap_single in swiotlb_free_coherent FUJITA Tomonori
@ 2008-09-08 9:53 ` FUJITA Tomonori
0 siblings, 0 replies; 6+ messages in thread
From: FUJITA Tomonori @ 2008-09-08 9:53 UTC (permalink / raw)
To: linux-kernel; +Cc: mingo, tony.luck, FUJITA Tomonori
This adds is_swiotlb_buffer() helper function to see whether a buffer
belongs to the swiotlb buffer or not.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
lib/swiotlb.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index bf61c73..b5f5d11 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -283,6 +283,11 @@ address_needs_mapping(struct device *hwdev, dma_addr_t addr)
return (addr & ~mask) != 0;
}
+static int is_swiotlb_buffer(char *addr)
+{
+ return addr >= io_tlb_start && addr < io_tlb_end;
+}
+
/*
* Allocates bounce buffer and returns its kernel virtual address.
*/
@@ -508,8 +513,7 @@ swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
dma_addr_t dma_handle)
{
WARN_ON(irqs_disabled());
- if (!(vaddr >= (void *)io_tlb_start
- && vaddr < (void *)io_tlb_end))
+ if (!is_swiotlb_buffer(vaddr))
free_pages((unsigned long) vaddr, get_order(size));
else
/* DMA_TO_DEVICE to avoid memcpy in unmap_single */
@@ -602,7 +606,7 @@ swiotlb_unmap_single_attrs(struct device *hwdev, dma_addr_t dev_addr,
char *dma_addr = bus_to_virt(dev_addr);
BUG_ON(dir == DMA_NONE);
- if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end)
+ if (is_swiotlb_buffer(dma_addr))
unmap_single(hwdev, dma_addr, size, dir);
else if (dir == DMA_FROM_DEVICE)
dma_mark_clean(dma_addr, size);
@@ -632,7 +636,7 @@ swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr,
char *dma_addr = bus_to_virt(dev_addr);
BUG_ON(dir == DMA_NONE);
- if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end)
+ if (is_swiotlb_buffer(dma_addr))
sync_single(hwdev, dma_addr, size, dir, target);
else if (dir == DMA_FROM_DEVICE)
dma_mark_clean(dma_addr, size);
@@ -663,7 +667,7 @@ swiotlb_sync_single_range(struct device *hwdev, dma_addr_t dev_addr,
char *dma_addr = bus_to_virt(dev_addr) + offset;
BUG_ON(dir == DMA_NONE);
- if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end)
+ if (is_swiotlb_buffer(dma_addr))
sync_single(hwdev, dma_addr, size, dir, target);
else if (dir == DMA_FROM_DEVICE)
dma_mark_clean(dma_addr, size);
--
1.5.5.GIT
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] minor cleanups for swiotlb
2008-09-08 9:53 [PATCH 0/3] minor cleanups for swiotlb FUJITA Tomonori
2008-09-08 9:53 ` [PATCH 1/3] swiotlb: use map_single instead of swiotlb_map_single in swiotlb_alloc_coherent FUJITA Tomonori
@ 2008-09-08 13:55 ` Ingo Molnar
2008-09-08 16:47 ` Luck, Tony
1 sibling, 1 reply; 6+ messages in thread
From: Ingo Molnar @ 2008-09-08 13:55 UTC (permalink / raw)
To: FUJITA Tomonori, tony.luck
Cc: linux-kernel, mingo, tony.luck, the arch/x86 maintainers
* FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> wrote:
> This patchset is minor cleanups for swiotlb. It doesn't confilict with
> the swiotlb fixes for the x86 tree (that I've just sent):
>
> http://lkml.org/lkml/2008/9/8/30
>
> This can be cleanly applied to tip/master and tip/x86/iommu.
>
> Ingo, can you apply this to your tree?
applied to tip/x86/iommu, thanks!
Tony, since ia64 makes use of CONFIG_SWIOTLB, do you have any objections
to carrying these patches in tip/x86/iommu?
Ingo
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH 0/3] minor cleanups for swiotlb
2008-09-08 13:55 ` [PATCH 0/3] minor cleanups for swiotlb Ingo Molnar
@ 2008-09-08 16:47 ` Luck, Tony
0 siblings, 0 replies; 6+ messages in thread
From: Luck, Tony @ 2008-09-08 16:47 UTC (permalink / raw)
To: Ingo Molnar, FUJITA Tomonori
Cc: linux-kernel@vger.kernel.org, mingo@redhat.com,
the arch/x86 maintainers
> applied to tip/x86/iommu, thanks!
>
> Tony, since ia64 makes use of CONFIG_SWIOTLB, do you have any objections
> to carrying these patches in tip/x86/iommu?
No objections from me.
-Tony
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-09-08 16:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-08 9:53 [PATCH 0/3] minor cleanups for swiotlb FUJITA Tomonori
2008-09-08 9:53 ` [PATCH 1/3] swiotlb: use map_single instead of swiotlb_map_single in swiotlb_alloc_coherent FUJITA Tomonori
2008-09-08 9:53 ` [PATCH 2/3] swiotlb: use unmap_single instead of swiotlb_unmap_single in swiotlb_free_coherent FUJITA Tomonori
2008-09-08 9:53 ` [PATCH 3/3] swiotlb: add is_swiotlb_buffer helper function FUJITA Tomonori
2008-09-08 13:55 ` [PATCH 0/3] minor cleanups for swiotlb Ingo Molnar
2008-09-08 16:47 ` Luck, Tony
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox