diff options
| author | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2012-08-23 14:03:55 -0400 |
|---|---|---|
| committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2012-09-17 10:14:59 -0400 |
| commit | 5bab7864b1167f9a72d375f6854027db436a1cc1 (patch) | |
| tree | 39dcbc1ae928b72c709b311a4bdeca6bc545c82f | |
| parent | 1cef36a529f44dbb3612ee0deeb0b5563de36163 (diff) | |
xen/swiotlb: Move the error strings to its own function.
That way we can more easily reuse those errors when using the
late SWIOTLB init.
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
| -rw-r--r-- | drivers/xen/swiotlb-xen.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c index a2aad6ec2401..701b1035fa6f 100644 --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c | |||
| @@ -154,11 +154,33 @@ static unsigned long xen_set_nslabs(unsigned long nr_tbl) | |||
| 154 | 154 | ||
| 155 | return xen_io_tlb_nslabs << IO_TLB_SHIFT; | 155 | return xen_io_tlb_nslabs << IO_TLB_SHIFT; |
| 156 | } | 156 | } |
| 157 | |||
| 158 | enum xen_swiotlb_err { | ||
| 159 | XEN_SWIOTLB_UNKNOWN = 0, | ||
| 160 | XEN_SWIOTLB_ENOMEM, | ||
| 161 | XEN_SWIOTLB_EFIXUP | ||
| 162 | }; | ||
| 163 | |||
| 164 | static const char *xen_swiotlb_error(enum xen_swiotlb_err err) | ||
| 165 | { | ||
| 166 | switch (err) { | ||
| 167 | case XEN_SWIOTLB_ENOMEM: | ||
| 168 | return "Cannot allocate Xen-SWIOTLB buffer\n"; | ||
| 169 | case XEN_SWIOTLB_EFIXUP: | ||
| 170 | return "Failed to get contiguous memory for DMA from Xen!\n"\ | ||
| 171 | "You either: don't have the permissions, do not have"\ | ||
| 172 | " enough free memory under 4GB, or the hypervisor memory"\ | ||
| 173 | " is too fragmented!"; | ||
| 174 | default: | ||
| 175 | break; | ||
| 176 | } | ||
| 177 | return ""; | ||
| 178 | } | ||
| 157 | void __init xen_swiotlb_init(int verbose) | 179 | void __init xen_swiotlb_init(int verbose) |
| 158 | { | 180 | { |
| 159 | unsigned long bytes; | 181 | unsigned long bytes; |
| 160 | int rc = -ENOMEM; | 182 | int rc = -ENOMEM; |
| 161 | char *m = NULL; | 183 | enum xen_swiotlb_err m_ret = XEN_SWIOTLB_UNKNOWN; |
| 162 | unsigned int repeat = 3; | 184 | unsigned int repeat = 3; |
| 163 | 185 | ||
| 164 | xen_io_tlb_nslabs = swiotlb_nr_tbl(); | 186 | xen_io_tlb_nslabs = swiotlb_nr_tbl(); |
| @@ -169,7 +191,7 @@ retry: | |||
| 169 | */ | 191 | */ |
| 170 | xen_io_tlb_start = alloc_bootmem_pages(PAGE_ALIGN(bytes)); | 192 | xen_io_tlb_start = alloc_bootmem_pages(PAGE_ALIGN(bytes)); |
| 171 | if (!xen_io_tlb_start) { | 193 | if (!xen_io_tlb_start) { |
| 172 | m = "Cannot allocate Xen-SWIOTLB buffer!\n"; | 194 | m_ret = XEN_SWIOTLB_ENOMEM; |
| 173 | goto error; | 195 | goto error; |
| 174 | } | 196 | } |
| 175 | xen_io_tlb_end = xen_io_tlb_start + bytes; | 197 | xen_io_tlb_end = xen_io_tlb_start + bytes; |
| @@ -181,10 +203,7 @@ retry: | |||
| 181 | xen_io_tlb_nslabs); | 203 | xen_io_tlb_nslabs); |
| 182 | if (rc) { | 204 | if (rc) { |
| 183 | free_bootmem(__pa(xen_io_tlb_start), PAGE_ALIGN(bytes)); | 205 | free_bootmem(__pa(xen_io_tlb_start), PAGE_ALIGN(bytes)); |
| 184 | m = "Failed to get contiguous memory for DMA from Xen!\n"\ | 206 | m_ret = XEN_SWIOTLB_EFIXUP; |
| 185 | "You either: don't have the permissions, do not have"\ | ||
| 186 | " enough free memory under 4GB, or the hypervisor memory"\ | ||
| 187 | "is too fragmented!"; | ||
| 188 | goto error; | 207 | goto error; |
| 189 | } | 208 | } |
| 190 | start_dma_addr = xen_virt_to_bus(xen_io_tlb_start); | 209 | start_dma_addr = xen_virt_to_bus(xen_io_tlb_start); |
| @@ -199,8 +218,8 @@ error: | |||
| 199 | (xen_io_tlb_nslabs << IO_TLB_SHIFT) >> 20); | 218 | (xen_io_tlb_nslabs << IO_TLB_SHIFT) >> 20); |
| 200 | goto retry; | 219 | goto retry; |
| 201 | } | 220 | } |
| 202 | xen_raw_printk("%s (rc:%d)", m, rc); | 221 | xen_raw_printk("%s (rc:%d)", xen_swiotlb_error(m_ret), rc); |
| 203 | panic("%s (rc:%d)", m, rc); | 222 | panic("%s (rc:%d)", xen_swiotlb_error(m_ret), rc); |
| 204 | } | 223 | } |
| 205 | 224 | ||
| 206 | void * | 225 | void * |
