From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: linux-kernel@vger.kernel.org, xen-devel@lists.xensource.com,
stefano.stabellini@eu.citrix.com
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH 05/10] xen/swiotlb: Move the error strings to its own function.
Date: Mon, 10 Sep 2012 15:46:02 -0400 [thread overview]
Message-ID: <1347306367-28669-6-git-send-email-konrad.wilk@oracle.com> (raw)
In-Reply-To: <1347306367-28669-1-git-send-email-konrad.wilk@oracle.com>
That way we can more easily reuse those errors when using the
late SWIOTLB init.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
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 a2aad6e..701b103 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)
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();
@@ -169,7 +191,7 @@ retry:
*/
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;
@@ -181,10 +203,7 @@ retry:
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);
@@ -199,8 +218,8 @@ error:
(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 *
--
1.7.7.6
next prev parent reply other threads:[~2012-09-10 19:56 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-10 19:45 [PATCH] Xen-SWIOTLB fixes (v4) for v3.7 Konrad Rzeszutek Wilk
2012-09-10 19:45 ` [PATCH 01/10] xen/swiotlb: Simplify the logic Konrad Rzeszutek Wilk
2012-09-10 19:45 ` [PATCH 02/10] xen/swiotlb: With more than 4GB on 64-bit, disable the native SWIOTLB Konrad Rzeszutek Wilk
2012-09-10 19:46 ` [PATCH 03/10] swiotlb: add the late swiotlb initialization function with iotlb memory Konrad Rzeszutek Wilk
2012-09-10 19:46 ` [PATCH 04/10] xen/swiotlb: Move the nr_tbl determination in its own function Konrad Rzeszutek Wilk
2012-09-14 16:08 ` Stefano Stabellini
2012-09-10 19:46 ` Konrad Rzeszutek Wilk [this message]
2012-09-14 16:00 ` [PATCH 05/10] xen/swiotlb: Move the error strings to " Stefano Stabellini
2012-09-10 19:46 ` [PATCH 06/10] xen/swiotlb: Use the swiotlb_late_init_with_tbl to init Xen-SWIOTLB late when PV PCI is used Konrad Rzeszutek Wilk
2012-09-14 16:26 ` Stefano Stabellini
2012-09-10 19:46 ` [PATCH 07/10] xen/pcifront: Use Xen-SWIOTLB when initting if required Konrad Rzeszutek Wilk
2012-09-10 19:46 ` [PATCH 08/10] xen/swiotlb: Remove functions not needed anymore Konrad Rzeszutek Wilk
2012-09-14 16:06 ` Stefano Stabellini
2012-09-14 17:06 ` Konrad Rzeszutek Wilk
2012-09-17 10:52 ` Stefano Stabellini
2012-09-10 19:46 ` [PATCH 09/10] xen/swiotlb: Fix compile warnings when using plain integer instead of NULL pointer Konrad Rzeszutek Wilk
2012-09-14 16:11 ` Stefano Stabellini
2012-09-10 19:46 ` [PATCH 10/10] xen/swiotlb: Depending on after_bootmem is not correct Konrad Rzeszutek Wilk
2012-09-14 16:10 ` Stefano Stabellini
2012-09-14 17:09 ` Konrad Rzeszutek Wilk
2012-09-17 14:23 ` Konrad Rzeszutek Wilk
2012-09-17 14:25 ` Is: [PATCH 11/10] xen/swiotlb: For early initialization, return zero on success. Was: " Konrad Rzeszutek Wilk
2012-09-17 14:53 ` Stefano Stabellini
2012-09-17 14:52 ` Stefano Stabellini
2012-09-17 17:02 ` Konrad Rzeszutek Wilk
[not found] ` <m2n.s.1TBAAE-152299@chiark.greenend.org.uk>
2012-09-13 15:53 ` [Xen-devel] [PATCH 09/10] xen/swiotlb: Fix compile warnings when using plain integer instead of NULL pointer Ian Jackson
2012-09-13 15:56 ` Ian Jackson
2012-09-13 16:00 ` Ian Jackson
2012-09-22 13:28 ` [Xen-devel] [PATCH] Xen-SWIOTLB fixes (v4) for v3.7 Konrad Rzeszutek Wilk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1347306367-28669-6-git-send-email-konrad.wilk@oracle.com \
--to=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).