From: Stefano Stabellini <sstabellini@kernel.org>
To: konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, jgross@suse.com
Cc: xen-devel@lists.xenproject.org, Julien.Grall@arm.com,
sstabellini@kernel.org
Subject: [Xen-devel] [PATCH v2] xen/swiotlb: don't initialize swiotlb twice on arm64
Date: Tue, 28 May 2019 15:48:22 -0700 (PDT) [thread overview]
Message-ID: <alpine.DEB.2.21.1905281546410.16734@sstabellini-ThinkPad-T480s> (raw)
Message-ID: <20190528224822.rM7eZfwZSXO7-sGa7maCfLg7H_mMkrbh2myHfBF2QxU@z> (raw)
From: Stefano Stabellini <stefanos@xilinx.com>
On arm64 swiotlb is often (not always) already initialized by mem_init.
We don't want to initialize it twice, which would trigger a second
memory allocation. Moreover, the second memory pool is typically made of
high pages and ends up replacing the original memory pool of low pages.
As a side effect of this change, it is possible to have low pages in
swiotlb-xen on arm64.
Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>
---
Changes in v2:
- improve commit message
- don't add nested ifs
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index 877baf2..8a3cdd1 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -211,6 +211,15 @@ int __ref xen_swiotlb_init(int verbose, bool early)
retry:
bytes = xen_set_nslabs(xen_io_tlb_nslabs);
order = get_order(xen_io_tlb_nslabs << IO_TLB_SHIFT);
+
+ /*
+ * IO TLB memory already allocated. Just use it.
+ */
+ if (io_tlb_start != 0) {
+ xen_io_tlb_start = phys_to_virt(io_tlb_start);
+ goto end;
+ }
+
/*
* Get IO TLB memory from any location.
*/
@@ -240,7 +249,6 @@ int __ref xen_swiotlb_init(int verbose, bool early)
m_ret = XEN_SWIOTLB_ENOMEM;
goto error;
}
- xen_io_tlb_end = xen_io_tlb_start + bytes;
/*
* And replace that memory with pages under 4GB.
*/
@@ -267,6 +275,8 @@ int __ref xen_swiotlb_init(int verbose, bool early)
} else
rc = swiotlb_late_init_with_tbl(xen_io_tlb_start, xen_io_tlb_nslabs);
+end:
+ xen_io_tlb_end = xen_io_tlb_start + bytes;
if (!rc)
swiotlb_set_max_segment(PAGE_SIZE);
--
2.7.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next reply other threads:[~2019-05-28 22:48 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-28 22:48 Stefano Stabellini [this message]
2019-05-28 22:48 ` [Xen-devel] [PATCH v2] xen/swiotlb: don't initialize swiotlb twice on arm64 Stefano Stabellini
2019-05-28 23:50 ` Boris Ostrovsky
2019-05-28 23:50 ` [Xen-devel] " Boris Ostrovsky
2019-06-03 18:25 ` Stefano Stabellini
2019-06-03 18:25 ` [Xen-devel] " Stefano Stabellini
2019-06-03 23:16 ` Boris Ostrovsky
2019-06-03 23:16 ` [Xen-devel] " Boris Ostrovsky
2019-06-04 16:51 ` Stefano Stabellini
2019-06-04 19:41 ` Boris Ostrovsky
2019-06-05 14:13 ` Konrad Rzeszutek Wilk
2019-06-05 14:24 ` Juergen Gross
2019-06-13 14:23 ` Konrad Rzeszutek Wilk
2019-06-13 15:04 ` Juergen Gross
2019-06-13 21:00 ` Konrad Rzeszutek Wilk
2019-06-17 8:21 ` Christoph Hellwig
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=alpine.DEB.2.21.1905281546410.16734@sstabellini-ThinkPad-T480s \
--to=sstabellini@kernel.org \
--cc=Julien.Grall@arm.com \
--cc=boris.ostrovsky@oracle.com \
--cc=jgross@suse.com \
--cc=konrad.wilk@oracle.com \
--cc=xen-devel@lists.xenproject.org \
/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).