* [PATCH] swiotlb-0.8.2: seperation of physical/virtual address translation and core memory allocation.
@ 2010-06-04 17:52 Konrad Rzeszutek Wilk
2010-06-04 17:52 ` [PATCH 1/5] swiotlb: add swiotlb_tbl_map_single library function Konrad Rzeszutek Wilk
2010-06-04 18:42 ` [PATCH] swiotlb-0.8.2: seperation of physical/virtual address translation and core memory allocation Andrew Morton
0 siblings, 2 replies; 10+ messages in thread
From: Konrad Rzeszutek Wilk @ 2010-06-04 17:52 UTC (permalink / raw)
To: albert_herranz, fujita.tomonori, akpm
Cc: linux-kernel, jeremy, iommu, linux, dwmw2, chrisw, Ian.Campbell
Please include the following patches, located at this git tree:
git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb-2.6.git swiotlb-0.8.2
in your -mm tree.
Attached is a set of patches that separate the address translation
(virt_to_phys, virt_to_bus, etc) and allocation of the SWIOTLB buffer
from the SWIOTLB library.
Since the last posting [v8.1] I've done:
- Rolled-up the last two patches in one.
- Rebased against linus latest. That meant dealing with swiotlb_sync_single_range_* changes.
- added Acked-by: Fujita Tomonori and Tested-by: Albert Herranz
[v7-v8 changes:]
- Minimized the list of exported functions.
- Integrated Fujita's patches and changed "swiotlb_tlb" to "swiotlb_tbl" in them.
[v6-v7 changes:]
- Minimized the amount of exported functions/variable with a prefix of: "swiotbl_tbl".
- Made the usage of 'int dir' to be 'enum dma_data_direction'.
[v5-v6 changes:]
- Made the exported functions/variables have the 'swiotlb_bk' prefix.
- dropped the checkpatches/other reworks
.. and the writeup for this set set of patches:
The idea behind this set of patches is to make it possible to have separate
mechanisms for translating virtual to physical or virtual to DMA addresses
on platforms which need an SWIOTLB, and where physical != PCI bus address
and also able to allocate the core IOTLB memory outside SWIOTLB.
One customers of this is the pv-ops project, which can switch between
different modes of operation depending on the environment it is running in:
bare-metal or virtualized (Xen for now). Another is the Wii DMA - used to
implement the MEM2 DMA facility needed by its EHCI controller (for details:
http://lkml.org/lkml/2010/5/18/303)
On bare-metal SWIOTLB is used when there are no hardware IOMMU. In virtualized
environment it used when PCI pass-through(*1) is enabled for the guest. The problems
with PCI pass-through is that the guest's idea of PFN's is not the real thing.
To fix that, there is translation layer for PFN->machine frame number and vice-versa.
To bubble that up to the SWIOTLB layer there are two possible solutions.
One solution has been to wholesale copy the SWIOTLB, stick it in
arch/x86/xen/swiotlb.c and modify the virt_to_phys, phys_to_virt and others
to use the Xen address translation functions. Unfortunately, since the kernel can
run on bare-metal, there would be big code overlap with the real SWIOTLB.
(git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git xen/dom0/swiotlb-new)
Another approach, which this set of patches explores, is to abstract the
address translation and address determination functions away from the
SWIOTLB book-keeping functions. This way the core SWIOTLB library functions
are present in one place, while the address related functions are in
a separate library that can be loaded when running under non-bare-metal platform.
The changes since commit 9dda696f0de87a2e5cfabb147e28c76b7d3c6846:
Linus Torvalds:
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
are as follow:
FUJITA Tomonori (2):
swiotlb: add swiotlb_tbl_map_single library function
swiotlb: add the swiotlb initialization function with iotlb memory
Konrad Rzeszutek Wilk (3):
swiotlb: Make internal bookkeeping functions have 'swiotlb_tbl' prefix.
swiotlb: search and replace "int dir" with "enum dma_data_direction dir"
swiotlb: Make swiotlb bookkeeping functions visible in the header file.
include/linux/swiotlb.h | 27 +++++++++-
lib/swiotlb.c | 137 ++++++++++++++++++++++++++++-------------------
2 files changed, 106 insertions(+), 58 deletions(-)
*1: PCI passthrough:
Haven't posted those yet. Located at:
git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen.git pv/pcifront-2.6.34
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/5] swiotlb: add swiotlb_tbl_map_single library function
2010-06-04 17:52 [PATCH] swiotlb-0.8.2: seperation of physical/virtual address translation and core memory allocation Konrad Rzeszutek Wilk
@ 2010-06-04 17:52 ` Konrad Rzeszutek Wilk
2010-06-04 17:52 ` [PATCH 2/5] swiotlb: add the swiotlb initialization function with iotlb memory Konrad Rzeszutek Wilk
2010-06-04 18:42 ` [PATCH] swiotlb-0.8.2: seperation of physical/virtual address translation and core memory allocation Andrew Morton
1 sibling, 1 reply; 10+ messages in thread
From: Konrad Rzeszutek Wilk @ 2010-06-04 17:52 UTC (permalink / raw)
To: albert_herranz, fujita.tomonori, akpm
Cc: linux-kernel, jeremy, iommu, linux, dwmw2, chrisw, Ian.Campbell
From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
swiotlb_tbl_map_single() takes the DMA address of iotlb instead of
using swiotlb_virt_to_bus().
[v2: changed swiotlb_tlb to swiotlb_tbl]
[v3: changed u64 to dma_addr_t]
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-by: Albert Herranz <albert_herranz@yahoo.es>
---
lib/swiotlb.c | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index a009055..783aff0 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -361,25 +361,22 @@ static void swiotlb_bounce(phys_addr_t phys, char *dma_addr, size_t size,
}
}
-/*
- * Allocates bounce buffer and returns its kernel virtual address.
- */
-static void *
-map_single(struct device *hwdev, phys_addr_t phys, size_t size, int dir)
+void *swiotlb_tbl_map_single(struct device *hwdev, dma_addr_t tbl_dma_addr,
+ phys_addr_t phys, size_t size, int dir)
{
unsigned long flags;
char *dma_addr;
unsigned int nslots, stride, index, wrap;
int i;
- unsigned long start_dma_addr;
unsigned long mask;
unsigned long offset_slots;
unsigned long max_slots;
mask = dma_get_seg_boundary(hwdev);
- start_dma_addr = swiotlb_virt_to_bus(hwdev, io_tlb_start) & mask;
- offset_slots = ALIGN(start_dma_addr, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT;
+ tbl_dma_addr &= mask;
+
+ offset_slots = ALIGN(tbl_dma_addr, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT;
/*
* Carefully handle integer overflow which can occur when mask == ~0UL.
@@ -468,6 +465,18 @@ found:
}
/*
+ * Allocates bounce buffer and returns its kernel virtual address.
+ */
+
+static void *
+map_single(struct device *hwdev, phys_addr_t phys, size_t size, int dir)
+{
+ dma_addr_t start_dma_addr = swiotlb_virt_to_bus(hwdev, io_tlb_start);
+
+ return swiotlb_tbl_map_single(hwdev, start_dma_addr, phys, size, dir);
+}
+
+/*
* dma_addr is the kernel virtual address of the bounce buffer to unmap.
*/
static void
--
1.6.2.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/5] swiotlb: add the swiotlb initialization function with iotlb memory
2010-06-04 17:52 ` [PATCH 1/5] swiotlb: add swiotlb_tbl_map_single library function Konrad Rzeszutek Wilk
@ 2010-06-04 17:52 ` Konrad Rzeszutek Wilk
2010-06-04 17:52 ` [PATCH 3/5] swiotlb: Make internal bookkeeping functions have 'swiotlb_tbl' prefix Konrad Rzeszutek Wilk
0 siblings, 1 reply; 10+ messages in thread
From: Konrad Rzeszutek Wilk @ 2010-06-04 17:52 UTC (permalink / raw)
To: albert_herranz, fujita.tomonori, akpm
Cc: linux-kernel, jeremy, iommu, linux, dwmw2, chrisw, Ian.Campbell
From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This enables the caller to initialize swiotlb with its own iotlb
memory.
[v2: changed ..with_tlb to ..with_tbl]
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-by: Albert Herranz <albert_herranz@yahoo.es>
---
include/linux/swiotlb.h | 1 +
lib/swiotlb.c | 48 +++++++++++++++++++++++++++++-----------------
2 files changed, 31 insertions(+), 18 deletions(-)
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 81a4e21..b406261 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -23,6 +23,7 @@ extern int swiotlb_force;
#define IO_TLB_SHIFT 11
extern void swiotlb_init(int verbose);
+extern void swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose);
extern void
*swiotlb_alloc_coherent(struct device *hwdev, size_t size,
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 783aff0..ec61e15 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -140,28 +140,14 @@ void swiotlb_print_info(void)
(unsigned long long)pend);
}
-/*
- * Statically reserve bounce buffer space and initialize bounce buffer data
- * structures for the software IO TLB used to implement the DMA API.
- */
-void __init
-swiotlb_init_with_default_size(size_t default_size, int verbose)
+void __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
{
unsigned long i, bytes;
- if (!io_tlb_nslabs) {
- io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
- io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
- }
+ bytes = nslabs << IO_TLB_SHIFT;
- bytes = io_tlb_nslabs << IO_TLB_SHIFT;
-
- /*
- * Get IO TLB memory from the low pages
- */
- io_tlb_start = alloc_bootmem_low_pages(bytes);
- if (!io_tlb_start)
- panic("Cannot allocate SWIOTLB buffer");
+ io_tlb_nslabs = nslabs;
+ io_tlb_start = tlb;
io_tlb_end = io_tlb_start + bytes;
/*
@@ -185,6 +171,32 @@ swiotlb_init_with_default_size(size_t default_size, int verbose)
swiotlb_print_info();
}
+/*
+ * Statically reserve bounce buffer space and initialize bounce buffer data
+ * structures for the software IO TLB used to implement the DMA API.
+ */
+void __init
+swiotlb_init_with_default_size(size_t default_size, int verbose)
+{
+ unsigned long bytes;
+
+ if (!io_tlb_nslabs) {
+ io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
+ io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
+ }
+
+ bytes = io_tlb_nslabs << IO_TLB_SHIFT;
+
+ /*
+ * Get IO TLB memory from the low pages
+ */
+ io_tlb_start = alloc_bootmem_low_pages(bytes);
+ if (!io_tlb_start)
+ panic("Cannot allocate SWIOTLB buffer");
+
+ swiotlb_init_with_tbl(io_tlb_start, io_tlb_nslabs, verbose);
+}
+
void __init
swiotlb_init(int verbose)
{
--
1.6.2.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/5] swiotlb: Make internal bookkeeping functions have 'swiotlb_tbl' prefix.
2010-06-04 17:52 ` [PATCH 2/5] swiotlb: add the swiotlb initialization function with iotlb memory Konrad Rzeszutek Wilk
@ 2010-06-04 17:52 ` Konrad Rzeszutek Wilk
2010-06-04 17:52 ` [PATCH 4/5] swiotlb: search and replace "int dir" with "enum dma_data_direction dir" Konrad Rzeszutek Wilk
0 siblings, 1 reply; 10+ messages in thread
From: Konrad Rzeszutek Wilk @ 2010-06-04 17:52 UTC (permalink / raw)
To: albert_herranz, fujita.tomonori, akpm
Cc: linux-kernel, jeremy, iommu, linux, dwmw2, chrisw, Ian.Campbell,
Konrad Rzeszutek Wilk
The functions that operate on io_tlb_list/io_tlb_start/io_tlb_orig_addr
have the prefix 'swiotlb_tbl' now.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Tested-by: Albert Herranz <albert_herranz@yahoo.es>
---
lib/swiotlb.c | 24 +++++++++++++-----------
1 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index ec61e15..1fc15bf 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -61,8 +61,8 @@ enum dma_sync_target {
int swiotlb_force;
/*
- * Used to do a quick range check in unmap_single and
- * sync_single_*, to see if the memory was in fact allocated by this
+ * Used to do a quick range check in swiotlb_tbl_unmap_single and
+ * swiotlb_tbl_sync_single_*, to see if the memory was in fact allocated by this
* API.
*/
static char *io_tlb_start, *io_tlb_end;
@@ -492,7 +492,8 @@ map_single(struct device *hwdev, phys_addr_t phys, size_t size, int dir)
* dma_addr is the kernel virtual address of the bounce buffer to unmap.
*/
static void
-do_unmap_single(struct device *hwdev, char *dma_addr, size_t size, int dir)
+swiotlb_tbl_unmap_single(struct device *hwdev, char *dma_addr, size_t size,
+ int dir)
{
unsigned long flags;
int i, count, nslots = ALIGN(size, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT;
@@ -532,7 +533,7 @@ do_unmap_single(struct device *hwdev, char *dma_addr, size_t size, int dir)
}
static void
-sync_single(struct device *hwdev, char *dma_addr, size_t size,
+swiotlb_tbl_sync_single(struct device *hwdev, char *dma_addr, size_t size,
int dir, int target)
{
int index = (dma_addr - io_tlb_start) >> IO_TLB_SHIFT;
@@ -580,8 +581,8 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
}
if (!ret) {
/*
- * We are either out of memory or the device can't DMA
- * to GFP_DMA memory; fall back on map_single(), which
+ * We are either out of memory or the device can't DMA to
+ * GFP_DMA memory; fall back on map_single(), which
* will grab memory from the lowest available address range.
*/
ret = map_single(hwdev, 0, size, DMA_FROM_DEVICE);
@@ -599,7 +600,7 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
(unsigned long long)dev_addr);
/* DMA_TO_DEVICE to avoid memcpy in unmap_single */
- do_unmap_single(hwdev, ret, size, DMA_TO_DEVICE);
+ swiotlb_tbl_unmap_single(hwdev, ret, size, DMA_TO_DEVICE);
return NULL;
}
*dma_handle = dev_addr;
@@ -617,8 +618,8 @@ swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
if (!is_swiotlb_buffer(paddr))
free_pages((unsigned long)vaddr, get_order(size));
else
- /* DMA_TO_DEVICE to avoid memcpy in unmap_single */
- do_unmap_single(hwdev, vaddr, size, DMA_TO_DEVICE);
+ /* DMA_TO_DEVICE to avoid memcpy in swiotlb_tbl_unmap_single */
+ swiotlb_tbl_unmap_single(hwdev, vaddr, size, DMA_TO_DEVICE);
}
EXPORT_SYMBOL(swiotlb_free_coherent);
@@ -708,7 +709,7 @@ static void unmap_single(struct device *hwdev, dma_addr_t dev_addr,
BUG_ON(dir == DMA_NONE);
if (is_swiotlb_buffer(paddr)) {
- do_unmap_single(hwdev, phys_to_virt(paddr), size, dir);
+ swiotlb_tbl_unmap_single(hwdev, phys_to_virt(paddr), size, dir);
return;
}
@@ -751,7 +752,8 @@ swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr,
BUG_ON(dir == DMA_NONE);
if (is_swiotlb_buffer(paddr)) {
- sync_single(hwdev, phys_to_virt(paddr), size, dir, target);
+ swiotlb_tbl_sync_single(hwdev, phys_to_virt(paddr), size, dir,
+ target);
return;
}
--
1.6.2.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/5] swiotlb: search and replace "int dir" with "enum dma_data_direction dir"
2010-06-04 17:52 ` [PATCH 3/5] swiotlb: Make internal bookkeeping functions have 'swiotlb_tbl' prefix Konrad Rzeszutek Wilk
@ 2010-06-04 17:52 ` Konrad Rzeszutek Wilk
2010-06-04 17:52 ` [PATCH 5/5] swiotlb: Make swiotlb bookkeeping functions visible in the header file Konrad Rzeszutek Wilk
0 siblings, 1 reply; 10+ messages in thread
From: Konrad Rzeszutek Wilk @ 2010-06-04 17:52 UTC (permalink / raw)
To: albert_herranz, fujita.tomonori, akpm
Cc: linux-kernel, jeremy, iommu, linux, dwmw2, chrisw, Ian.Campbell,
Konrad Rzeszutek Wilk
. to catch anybody doing something funky.
[v2: swiotlb_sync_single_range_* no more - removed usage]
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Tested-by: Albert Herranz <albert_herranz@yahoo.es>
---
include/linux/swiotlb.h | 4 ++--
lib/swiotlb.c | 23 +++++++++++++----------
2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index b406261..00ff153 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -43,11 +43,11 @@ extern void swiotlb_unmap_page(struct device *hwdev, dma_addr_t dev_addr,
extern int
swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nents,
- int direction);
+ enum dma_data_direction direction);
extern void
swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
- int direction);
+ enum dma_data_direction direction);
extern int
swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems,
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 1fc15bf..5f60157 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -374,7 +374,8 @@ static void swiotlb_bounce(phys_addr_t phys, char *dma_addr, size_t size,
}
void *swiotlb_tbl_map_single(struct device *hwdev, dma_addr_t tbl_dma_addr,
- phys_addr_t phys, size_t size, int dir)
+ phys_addr_t phys, size_t size,
+ enum dma_data_direction dir)
{
unsigned long flags;
char *dma_addr;
@@ -481,7 +482,8 @@ found:
*/
static void *
-map_single(struct device *hwdev, phys_addr_t phys, size_t size, int dir)
+map_single(struct device *hwdev, phys_addr_t phys, size_t size,
+ enum dma_data_direction dir)
{
dma_addr_t start_dma_addr = swiotlb_virt_to_bus(hwdev, io_tlb_start);
@@ -493,7 +495,7 @@ map_single(struct device *hwdev, phys_addr_t phys, size_t size, int dir)
*/
static void
swiotlb_tbl_unmap_single(struct device *hwdev, char *dma_addr, size_t size,
- int dir)
+ enum dma_data_direction dir)
{
unsigned long flags;
int i, count, nslots = ALIGN(size, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT;
@@ -534,7 +536,7 @@ swiotlb_tbl_unmap_single(struct device *hwdev, char *dma_addr, size_t size,
static void
swiotlb_tbl_sync_single(struct device *hwdev, char *dma_addr, size_t size,
- int dir, int target)
+ enum dma_data_direction dir, int target)
{
int index = (dma_addr - io_tlb_start) >> IO_TLB_SHIFT;
phys_addr_t phys = io_tlb_orig_addr[index];
@@ -624,7 +626,8 @@ swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
EXPORT_SYMBOL(swiotlb_free_coherent);
static void
-swiotlb_full(struct device *dev, size_t size, int dir, int do_panic)
+swiotlb_full(struct device *dev, size_t size, enum dma_data_direction dir,
+ int do_panic)
{
/*
* Ran out of IOMMU space for this operation. This is very bad.
@@ -702,7 +705,7 @@ EXPORT_SYMBOL_GPL(swiotlb_map_page);
* whatever the device wrote there.
*/
static void unmap_single(struct device *hwdev, dma_addr_t dev_addr,
- size_t size, int dir)
+ size_t size, enum dma_data_direction dir)
{
phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
@@ -745,7 +748,7 @@ EXPORT_SYMBOL_GPL(swiotlb_unmap_page);
*/
static void
swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr,
- size_t size, int dir, int target)
+ size_t size, enum dma_data_direction dir, int target)
{
phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
@@ -832,7 +835,7 @@ EXPORT_SYMBOL(swiotlb_map_sg_attrs);
int
swiotlb_map_sg(struct device *hwdev, struct scatterlist *sgl, int nelems,
- int dir)
+ enum dma_data_direction dir)
{
return swiotlb_map_sg_attrs(hwdev, sgl, nelems, dir, NULL);
}
@@ -859,7 +862,7 @@ EXPORT_SYMBOL(swiotlb_unmap_sg_attrs);
void
swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sgl, int nelems,
- int dir)
+ enum dma_data_direction dir)
{
return swiotlb_unmap_sg_attrs(hwdev, sgl, nelems, dir, NULL);
}
@@ -874,7 +877,7 @@ EXPORT_SYMBOL(swiotlb_unmap_sg);
*/
static void
swiotlb_sync_sg(struct device *hwdev, struct scatterlist *sgl,
- int nelems, int dir, int target)
+ int nelems, enum dma_data_direction dir, int target)
{
struct scatterlist *sg;
int i;
--
1.6.2.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/5] swiotlb: Make swiotlb bookkeeping functions visible in the header file.
2010-06-04 17:52 ` [PATCH 4/5] swiotlb: search and replace "int dir" with "enum dma_data_direction dir" Konrad Rzeszutek Wilk
@ 2010-06-04 17:52 ` Konrad Rzeszutek Wilk
0 siblings, 0 replies; 10+ messages in thread
From: Konrad Rzeszutek Wilk @ 2010-06-04 17:52 UTC (permalink / raw)
To: albert_herranz, fujita.tomonori, akpm
Cc: linux-kernel, jeremy, iommu, linux, dwmw2, chrisw, Ian.Campbell,
Konrad Rzeszutek Wilk
We put the functions dealing with the operations on
the SWIOTLB buffer in the header and make those functions non-static.
And also make the functions exported via EXPORT_SYMBOL_GPL.
[v2: swiotlb_sync_single_range_for_* no more. Remove usage.]
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Tested-by: Albert Herranz <albert_herranz@yahoo.es>
---
include/linux/swiotlb.h | 22 ++++++++++++++++++++++
lib/swiotlb.c | 29 ++++++++++++++---------------
2 files changed, 36 insertions(+), 15 deletions(-)
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 00ff153..881cd9c 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -25,6 +25,28 @@ extern int swiotlb_force;
extern void swiotlb_init(int verbose);
extern void swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose);
+/*
+ * Enumeration for sync targets
+ */
+enum dma_sync_target {
+ SYNC_FOR_CPU = 0,
+ SYNC_FOR_DEVICE = 1,
+};
+extern void *swiotlb_tbl_map_single(struct device *hwdev, dma_addr_t tbl_dma_addr,
+ phys_addr_t phys, size_t size,
+ enum dma_data_direction dir);
+
+extern void swiotlb_tbl_unmap_single(struct device *hwdev, char *dma_addr,
+ size_t size, enum dma_data_direction dir);
+
+extern void swiotlb_tbl_sync_single(struct device *hwdev, char *dma_addr,
+ size_t size, enum dma_data_direction dir,
+ enum dma_sync_target target);
+
+/* Accessory functions. */
+extern void swiotlb_bounce(phys_addr_t phys, char *dma_addr, size_t size,
+ enum dma_data_direction dir);
+
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 5f60157..34e3082 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -50,14 +50,6 @@
*/
#define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT)
-/*
- * Enumeration for sync targets
- */
-enum dma_sync_target {
- SYNC_FOR_CPU = 0,
- SYNC_FOR_DEVICE = 1,
-};
-
int swiotlb_force;
/*
@@ -335,8 +327,8 @@ static int is_swiotlb_buffer(phys_addr_t paddr)
/*
* Bounce: copy the swiotlb buffer back to the original dma location
*/
-static void swiotlb_bounce(phys_addr_t phys, char *dma_addr, size_t size,
- enum dma_data_direction dir)
+void swiotlb_bounce(phys_addr_t phys, char *dma_addr, size_t size,
+ enum dma_data_direction dir)
{
unsigned long pfn = PFN_DOWN(phys);
@@ -372,6 +364,7 @@ static void swiotlb_bounce(phys_addr_t phys, char *dma_addr, size_t size,
memcpy(phys_to_virt(phys), dma_addr, size);
}
}
+EXPORT_SYMBOL_GPL(swiotlb_bounce);
void *swiotlb_tbl_map_single(struct device *hwdev, dma_addr_t tbl_dma_addr,
phys_addr_t phys, size_t size,
@@ -476,6 +469,7 @@ found:
return dma_addr;
}
+EXPORT_SYMBOL_GPL(swiotlb_tbl_map_single);
/*
* Allocates bounce buffer and returns its kernel virtual address.
@@ -493,7 +487,7 @@ map_single(struct device *hwdev, phys_addr_t phys, size_t size,
/*
* dma_addr is the kernel virtual address of the bounce buffer to unmap.
*/
-static void
+void
swiotlb_tbl_unmap_single(struct device *hwdev, char *dma_addr, size_t size,
enum dma_data_direction dir)
{
@@ -533,10 +527,12 @@ swiotlb_tbl_unmap_single(struct device *hwdev, char *dma_addr, size_t size,
}
spin_unlock_irqrestore(&io_tlb_lock, flags);
}
+EXPORT_SYMBOL_GPL(swiotlb_tbl_unmap_single);
-static void
+void
swiotlb_tbl_sync_single(struct device *hwdev, char *dma_addr, size_t size,
- enum dma_data_direction dir, int target)
+ enum dma_data_direction dir,
+ enum dma_sync_target target)
{
int index = (dma_addr - io_tlb_start) >> IO_TLB_SHIFT;
phys_addr_t phys = io_tlb_orig_addr[index];
@@ -560,6 +556,7 @@ swiotlb_tbl_sync_single(struct device *hwdev, char *dma_addr, size_t size,
BUG();
}
}
+EXPORT_SYMBOL_GPL(swiotlb_tbl_sync_single);
void *
swiotlb_alloc_coherent(struct device *hwdev, size_t size,
@@ -748,7 +745,8 @@ EXPORT_SYMBOL_GPL(swiotlb_unmap_page);
*/
static void
swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr,
- size_t size, enum dma_data_direction dir, int target)
+ size_t size, enum dma_data_direction dir,
+ enum dma_sync_target target)
{
phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
@@ -877,7 +875,8 @@ EXPORT_SYMBOL(swiotlb_unmap_sg);
*/
static void
swiotlb_sync_sg(struct device *hwdev, struct scatterlist *sgl,
- int nelems, enum dma_data_direction dir, int target)
+ int nelems, enum dma_data_direction dir,
+ enum dma_sync_target target)
{
struct scatterlist *sg;
int i;
--
1.6.2.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] swiotlb-0.8.2: seperation of physical/virtual address translation and core memory allocation.
2010-06-04 17:52 [PATCH] swiotlb-0.8.2: seperation of physical/virtual address translation and core memory allocation Konrad Rzeszutek Wilk
2010-06-04 17:52 ` [PATCH 1/5] swiotlb: add swiotlb_tbl_map_single library function Konrad Rzeszutek Wilk
@ 2010-06-04 18:42 ` Andrew Morton
2010-06-04 20:06 ` [PATCH] swiotlb-0.8.2^H3: " Konrad Rzeszutek Wilk
1 sibling, 1 reply; 10+ messages in thread
From: Andrew Morton @ 2010-06-04 18:42 UTC (permalink / raw)
To: Konrad Rzeszutek Wilk
Cc: albert_herranz, fujita.tomonori, linux-kernel, jeremy, iommu,
linux, dwmw2, chrisw, Ian.Campbell, Stephen Rothwell
On Fri, 4 Jun 2010 13:52:30 -0400
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> wrote:
> Please include the following patches, located at this git tree:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb-2.6.git swiotlb-0.8.2
>
> in your -mm tree.
I don't put individual git trees into -mm any more - I get them from
linux-next.
I could grab the individual patches but I don't see that this gains
anyone anything. I'd suggest that you ask Stephen to include this tree
in linux-next then ask Linus to pull it into 2.6.36-rc1.
> [nice description]
The sad thing is that this description will get lost because it isn't
attached to a particular patch. So what I do is to copy the nice
covering description into the changelog for [patch 1/n] and then, after
it I put the text
This patch:
and then follow it with the specific description for [patch 1/n]. I
suggest that you make such change in this tree.
It's not a very good solution because anyone who is looking at [patch
5/n] isn't likely to think to look in some other patch for the overall
story. I guess it would be better if patches 2..n included the text
"see <patch name> for a description of this work" or similar.
Even better would be if git understood this workflow - if it was able
to take commentary-only commits and to bidirectionally link those
commentaries to the invividual commits which they describe.
The patches themselves look good and suitably reviewed to me. My one
very minor comment is that include/linux/swiotlb.h ends up with a
mixture of "enum dma_data_direction dir" and "enum dma_data_direction
direction", which could be cleaned up.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] swiotlb-0.8.2^H3: seperation of physical/virtual address translation and core memory allocation.
2010-06-04 18:42 ` [PATCH] swiotlb-0.8.2: seperation of physical/virtual address translation and core memory allocation Andrew Morton
@ 2010-06-04 20:06 ` Konrad Rzeszutek Wilk
2010-06-05 12:07 ` Stephen Rothwell
0 siblings, 1 reply; 10+ messages in thread
From: Konrad Rzeszutek Wilk @ 2010-06-04 20:06 UTC (permalink / raw)
To: Andrew Morton, Stephen Rothwell
Cc: albert_herranz, fujita.tomonori, linux-kernel, jeremy, iommu,
linux, dwmw2, chrisw, Ian.Campbell
> > in your -mm tree.
>
> I don't put individual git trees into -mm any more - I get them from
> linux-next.
Ahh. OK.
>
> I could grab the individual patches but I don't see that this gains
> anyone anything. I'd suggest that you ask Stephen to include this tree
> in linux-next then ask Linus to pull it into 2.6.36-rc1.
Stephen,
I was wondering if you wouldn't mind including the following git tree
in your linux-next?
git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb-2.6.git
The patches are in the MAIN branch (and also in swiotlb-0.8.3).
They have the Tested-by, Signed-off-by, and Acked-by signatures.
Andrew,
> > [nice description]
Thank you.
>
> The sad thing is that this description will get lost because it isn't
.. snip..
> and then follow it with the specific description for [patch 1/n]. I
> suggest that you make such change in this tree.
Done!
>
> It's not a very good solution because anyone who is looking at [patch
.. snip ..
> "see <patch name> for a description of this work" or similar.
Done!
>
> Even better would be if git understood this workflow - if it was able
> to take commentary-only commits and to bidirectionally link those
> commentaries to the invividual commits which they describe.
>
..snip.
> mixture of "enum dma_data_direction dir" and "enum dma_data_direction
> direction", which could be cleaned up.
Oh, good catch. Fixed that.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] swiotlb-0.8.2^H3: seperation of physical/virtual address translation and core memory allocation.
2010-06-04 20:06 ` [PATCH] swiotlb-0.8.2^H3: " Konrad Rzeszutek Wilk
@ 2010-06-05 12:07 ` Stephen Rothwell
2010-06-07 16:01 ` Konrad Rzeszutek Wilk
0 siblings, 1 reply; 10+ messages in thread
From: Stephen Rothwell @ 2010-06-05 12:07 UTC (permalink / raw)
To: Konrad Rzeszutek Wilk
Cc: Andrew Morton, albert_herranz, fujita.tomonori, linux-kernel,
jeremy, iommu, linux, dwmw2, chrisw, Ian.Campbell
[-- Attachment #1: Type: text/plain, Size: 2171 bytes --]
Hi Konrad,
On Fri, 4 Jun 2010 16:06:04 -0400 Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> wrote:
>
> I was wondering if you wouldn't mind including the following git tree
> in your linux-next?
>
> git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb-2.6.git
>
> The patches are in the MAIN branch (and also in swiotlb-0.8.3).
OK, I have added the master branch of that tree. It will appear in
linux-next from Monday.
> They have the Tested-by, Signed-off-by, and Acked-by signatures.
Could you move the Signed-off-by etc lines to the bottom of the commit
message if that first commit, please?
Thanks for adding your subsystem tree as a participant of linux-next. As
you may know, this is not a judgment of your code. The purpose of
linux-next is for integration testing and to lower the impact of
conflicts between subsystems in the next merge window.
You will need to ensure that the patches/commits in your tree/series have
been:
* submitted under GPL v2 (or later) and include the Contributor's
Signed-off-by,
* posted to the relevant mailing list,
* reviewed by you (or another maintainer of your subsystem tree),
* successfully unit tested, and
* destined for the current or next Linux merge window.
Basically, this should be just what you would send to Linus (or ask him
to fetch). It is allowed to be rebased if you deem it necessary.
--
Cheers,
Stephen Rothwell
sfr@canb.auug.org.au
Legal Stuff:
By participating in linux-next, your subsystem tree contributions are
public and will be included in the linux-next trees. You may be sent
e-mail messages indicating errors or other issues when the
patches/commits from your subsystem tree are merged and tested in
linux-next. These messages may also be cross-posted to the linux-next
mailing list, the linux-kernel mailing list, etc. The linux-next tree
project and IBM (my employer) make no warranties regarding the linux-next
project, the testing procedures, the results, the e-mails, etc. If you
don't agree to these ground rules, let me know and I'll remove your tree
from participation in linux-next.
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] swiotlb-0.8.2^H3: seperation of physical/virtual address translation and core memory allocation.
2010-06-05 12:07 ` Stephen Rothwell
@ 2010-06-07 16:01 ` Konrad Rzeszutek Wilk
0 siblings, 0 replies; 10+ messages in thread
From: Konrad Rzeszutek Wilk @ 2010-06-07 16:01 UTC (permalink / raw)
To: Stephen Rothwell
Cc: Andrew Morton, albert_herranz, fujita.tomonori, linux-kernel,
jeremy, iommu, linux, dwmw2, chrisw, Ian.Campbell
> > git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb-2.6.git
> >
> > The patches are in the MAIN branch (and also in swiotlb-0.8.3).
>
> OK, I have added the master branch of that tree. It will appear in
> linux-next from Monday.
Excellent. Thank you.
>
> > They have the Tested-by, Signed-off-by, and Acked-by signatures.
>
> Could you move the Signed-off-by etc lines to the bottom of the commit
> message if that first commit, please?
Done.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-06-07 16:02 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-04 17:52 [PATCH] swiotlb-0.8.2: seperation of physical/virtual address translation and core memory allocation Konrad Rzeszutek Wilk
2010-06-04 17:52 ` [PATCH 1/5] swiotlb: add swiotlb_tbl_map_single library function Konrad Rzeszutek Wilk
2010-06-04 17:52 ` [PATCH 2/5] swiotlb: add the swiotlb initialization function with iotlb memory Konrad Rzeszutek Wilk
2010-06-04 17:52 ` [PATCH 3/5] swiotlb: Make internal bookkeeping functions have 'swiotlb_tbl' prefix Konrad Rzeszutek Wilk
2010-06-04 17:52 ` [PATCH 4/5] swiotlb: search and replace "int dir" with "enum dma_data_direction dir" Konrad Rzeszutek Wilk
2010-06-04 17:52 ` [PATCH 5/5] swiotlb: Make swiotlb bookkeeping functions visible in the header file Konrad Rzeszutek Wilk
2010-06-04 18:42 ` [PATCH] swiotlb-0.8.2: seperation of physical/virtual address translation and core memory allocation Andrew Morton
2010-06-04 20:06 ` [PATCH] swiotlb-0.8.2^H3: " Konrad Rzeszutek Wilk
2010-06-05 12:07 ` Stephen Rothwell
2010-06-07 16:01 ` Konrad Rzeszutek Wilk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox