Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 329173
b: refs/heads/master
c: 74838b7
h: refs/heads/master
i:
  329171: dd1701a
v: v3
  • Loading branch information
Konrad Rzeszutek Wilk committed Aug 21, 2012
1 parent 849da97 commit 3015780
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fc2341df9e31be8a3940f4e302372d7ef46bab8c
refs/heads/master: 74838b75379a53678ffc5f59de86161d21e2c808
1 change: 1 addition & 0 deletions trunk/include/linux/swiotlb.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern int swiotlb_force;
extern void swiotlb_init(int verbose);
extern void swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose);
extern unsigned long swiotlb_nr_tbl(void);
extern int swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs);

/*
* Enumeration for sync targets
Expand Down
33 changes: 24 additions & 9 deletions trunk/lib/swiotlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
* Statically reserve bounce buffer space and initialize bounce buffer data
* structures for the software IO TLB used to implement the DMA API.
*/
void __init
static void __init
swiotlb_init_with_default_size(size_t default_size, int verbose)
{
unsigned long bytes;
Expand Down Expand Up @@ -206,8 +206,9 @@ swiotlb_init(int verbose)
int
swiotlb_late_init_with_default_size(size_t default_size)
{
unsigned long i, bytes, req_nslabs = io_tlb_nslabs;
unsigned long bytes, req_nslabs = io_tlb_nslabs;
unsigned int order;
int rc = 0;

if (!io_tlb_nslabs) {
io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
Expand All @@ -229,16 +230,32 @@ swiotlb_late_init_with_default_size(size_t default_size)
order--;
}

if (!io_tlb_start)
goto cleanup1;

if (!io_tlb_start) {
io_tlb_nslabs = req_nslabs;
return -ENOMEM;
}
if (order != get_order(bytes)) {
printk(KERN_WARNING "Warning: only able to allocate %ld MB "
"for software IO TLB\n", (PAGE_SIZE << order) >> 20);
io_tlb_nslabs = SLABS_PER_PAGE << order;
bytes = io_tlb_nslabs << IO_TLB_SHIFT;
}
rc = swiotlb_late_init_with_tbl(io_tlb_start, io_tlb_nslabs);
if (rc)
free_pages((unsigned long)io_tlb_start, order);
return rc;
}

int
swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)
{
unsigned long i, bytes;

bytes = nslabs << IO_TLB_SHIFT;

io_tlb_nslabs = nslabs;
io_tlb_start = tlb;
io_tlb_end = io_tlb_start + bytes;

memset(io_tlb_start, 0, bytes);

/*
Expand Down Expand Up @@ -288,10 +305,8 @@ swiotlb_late_init_with_default_size(size_t default_size)
io_tlb_list = NULL;
cleanup2:
io_tlb_end = NULL;
free_pages((unsigned long)io_tlb_start, order);
io_tlb_start = NULL;
cleanup1:
io_tlb_nslabs = req_nslabs;
io_tlb_nslabs = 0;
return -ENOMEM;
}

Expand Down

0 comments on commit 3015780

Please sign in to comment.