xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
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: [PATCH] xen/swiotlb: don't initialize swiotlb twice on arm64
Date: Wed, 22 May 2019 16:26:24 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.21.1905221622190.20440@sstabellini-ThinkPad-T480s> (raw)

From: Stefano Stabellini <stefanos@xilinx.com>

On arm64 swiotlb is already initialized by mem_init. We don't want to
initialize it twice, the memory is already allocated. Detect this
condition in swiotlb-xen and skip the second initialization.

Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>

---

There are other issues which I found recently affecting the swiotlb on
arm64 -- I'll send the other patches separately.

diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index 877baf2..8fcda2bf4 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -206,6 +206,7 @@ int __ref xen_swiotlb_init(int verbose, bool early)
 	int rc = -ENOMEM;
 	enum xen_swiotlb_err m_ret = XEN_SWIOTLB_UNKNOWN;
 	unsigned int repeat = 3;
+	bool pre_initialized = false;
 
 	xen_io_tlb_nslabs = swiotlb_nr_tbl();
 retry:
@@ -214,7 +215,10 @@ int __ref xen_swiotlb_init(int verbose, bool early)
 	/*
 	 * Get IO TLB memory from any location.
 	 */
-	if (early) {
+	if (io_tlb_start != 0) {
+		xen_io_tlb_start = phys_to_virt(io_tlb_start);
+		pre_initialized = true;
+	} else if (early) {
 		xen_io_tlb_start = memblock_alloc(PAGE_ALIGN(bytes),
 						  PAGE_SIZE);
 		if (!xen_io_tlb_start)
@@ -264,7 +268,7 @@ int __ref xen_swiotlb_init(int verbose, bool early)
 			 verbose))
 			panic("Cannot allocate SWIOTLB buffer");
 		rc = 0;
-	} else
+	} else if (!pre_initialized)
 		rc = swiotlb_late_init_with_tbl(xen_io_tlb_start, xen_io_tlb_nslabs);
 
 	if (!rc)

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

WARNING: multiple messages have this Message-ID (diff)
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] xen/swiotlb: don't initialize swiotlb twice on arm64
Date: Wed, 22 May 2019 16:26:24 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.21.1905221622190.20440@sstabellini-ThinkPad-T480s> (raw)
Message-ID: <20190522232624.OSqno9ILJBy9WhF-lQrfBf0qB7KIlhmRl7SyILj2fm0@z> (raw)

From: Stefano Stabellini <stefanos@xilinx.com>

On arm64 swiotlb is already initialized by mem_init. We don't want to
initialize it twice, the memory is already allocated. Detect this
condition in swiotlb-xen and skip the second initialization.

Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>

---

There are other issues which I found recently affecting the swiotlb on
arm64 -- I'll send the other patches separately.

diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index 877baf2..8fcda2bf4 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -206,6 +206,7 @@ int __ref xen_swiotlb_init(int verbose, bool early)
 	int rc = -ENOMEM;
 	enum xen_swiotlb_err m_ret = XEN_SWIOTLB_UNKNOWN;
 	unsigned int repeat = 3;
+	bool pre_initialized = false;
 
 	xen_io_tlb_nslabs = swiotlb_nr_tbl();
 retry:
@@ -214,7 +215,10 @@ int __ref xen_swiotlb_init(int verbose, bool early)
 	/*
 	 * Get IO TLB memory from any location.
 	 */
-	if (early) {
+	if (io_tlb_start != 0) {
+		xen_io_tlb_start = phys_to_virt(io_tlb_start);
+		pre_initialized = true;
+	} else if (early) {
 		xen_io_tlb_start = memblock_alloc(PAGE_ALIGN(bytes),
 						  PAGE_SIZE);
 		if (!xen_io_tlb_start)
@@ -264,7 +268,7 @@ int __ref xen_swiotlb_init(int verbose, bool early)
 			 verbose))
 			panic("Cannot allocate SWIOTLB buffer");
 		rc = 0;
-	} else
+	} else if (!pre_initialized)
 		rc = swiotlb_late_init_with_tbl(xen_io_tlb_start, xen_io_tlb_nslabs);
 
 	if (!rc)

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

             reply	other threads:[~2019-05-22 23:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22 23:26 Stefano Stabellini [this message]
2019-05-22 23:26 ` [Xen-devel] [PATCH] xen/swiotlb: don't initialize swiotlb twice on arm64 Stefano Stabellini
2019-05-23  8:54 ` Julien Grall
2019-05-23  8:54   ` [Xen-devel] " Julien Grall
2019-05-28 22:48   ` Stefano Stabellini
2019-05-28 22:48     ` [Xen-devel] " Stefano Stabellini

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.1905221622190.20440@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).