Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 329175
b: refs/heads/master
c: 5bab786
h: refs/heads/master
i:
  329173: 3015780
  329171: dd1701a
  329167: 2d6896b
v: v3
  • Loading branch information
Konrad Rzeszutek Wilk committed Sep 17, 2012
1 parent d4b081b commit ff15ede
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 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: 1cef36a529f44dbb3612ee0deeb0b5563de36163
refs/heads/master: 5bab7864b1167f9a72d375f6854027db436a1cc1
35 changes: 27 additions & 8 deletions trunk/drivers/xen/swiotlb-xen.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,33 @@ static unsigned long xen_set_nslabs(unsigned long nr_tbl)

return xen_io_tlb_nslabs << IO_TLB_SHIFT;
}

enum xen_swiotlb_err {
XEN_SWIOTLB_UNKNOWN = 0,
XEN_SWIOTLB_ENOMEM,
XEN_SWIOTLB_EFIXUP
};

static const char *xen_swiotlb_error(enum xen_swiotlb_err err)
{
switch (err) {
case XEN_SWIOTLB_ENOMEM:
return "Cannot allocate Xen-SWIOTLB buffer\n";
case XEN_SWIOTLB_EFIXUP:
return "Failed to get contiguous memory for DMA from Xen!\n"\
"You either: don't have the permissions, do not have"\
" enough free memory under 4GB, or the hypervisor memory"\
" is too fragmented!";
default:
break;
}
return "";
}
void __init xen_swiotlb_init(int verbose)
{
unsigned long bytes;
int rc = -ENOMEM;
char *m = NULL;
enum xen_swiotlb_err m_ret = XEN_SWIOTLB_UNKNOWN;
unsigned int repeat = 3;

xen_io_tlb_nslabs = swiotlb_nr_tbl();
Expand All @@ -169,7 +191,7 @@ void __init xen_swiotlb_init(int verbose)
*/
xen_io_tlb_start = alloc_bootmem_pages(PAGE_ALIGN(bytes));
if (!xen_io_tlb_start) {
m = "Cannot allocate Xen-SWIOTLB buffer!\n";
m_ret = XEN_SWIOTLB_ENOMEM;
goto error;
}
xen_io_tlb_end = xen_io_tlb_start + bytes;
Expand All @@ -181,10 +203,7 @@ void __init xen_swiotlb_init(int verbose)
xen_io_tlb_nslabs);
if (rc) {
free_bootmem(__pa(xen_io_tlb_start), PAGE_ALIGN(bytes));
m = "Failed to get contiguous memory for DMA from Xen!\n"\
"You either: don't have the permissions, do not have"\
" enough free memory under 4GB, or the hypervisor memory"\
"is too fragmented!";
m_ret = XEN_SWIOTLB_EFIXUP;
goto error;
}
start_dma_addr = xen_virt_to_bus(xen_io_tlb_start);
Expand All @@ -199,8 +218,8 @@ void __init xen_swiotlb_init(int verbose)
(xen_io_tlb_nslabs << IO_TLB_SHIFT) >> 20);
goto retry;
}
xen_raw_printk("%s (rc:%d)", m, rc);
panic("%s (rc:%d)", m, rc);
xen_raw_printk("%s (rc:%d)", xen_swiotlb_error(m_ret), rc);
panic("%s (rc:%d)", xen_swiotlb_error(m_ret), rc);
}

void *
Expand Down

0 comments on commit ff15ede

Please sign in to comment.