Skip to content

Commit 4e7372e

Browse files
stefano-xilinxkonradwilk
authored andcommitted
xen/swiotlb: don't initialize swiotlb twice on arm64
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 <[email protected]> Reviewed-by: Boris Ostrovsky <[email protected]> Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
1 parent 063b827 commit 4e7372e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/xen/swiotlb-xen.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,15 @@ int __ref xen_swiotlb_init(int verbose, bool early)
211211
retry:
212212
bytes = xen_set_nslabs(xen_io_tlb_nslabs);
213213
order = get_order(xen_io_tlb_nslabs << IO_TLB_SHIFT);
214+
215+
/*
216+
* IO TLB memory already allocated. Just use it.
217+
*/
218+
if (io_tlb_start != 0) {
219+
xen_io_tlb_start = phys_to_virt(io_tlb_start);
220+
goto end;
221+
}
222+
214223
/*
215224
* Get IO TLB memory from any location.
216225
*/
@@ -237,7 +246,6 @@ int __ref xen_swiotlb_init(int verbose, bool early)
237246
m_ret = XEN_SWIOTLB_ENOMEM;
238247
goto error;
239248
}
240-
xen_io_tlb_end = xen_io_tlb_start + bytes;
241249
/*
242250
* And replace that memory with pages under 4GB.
243251
*/
@@ -264,6 +272,8 @@ int __ref xen_swiotlb_init(int verbose, bool early)
264272
} else
265273
rc = swiotlb_late_init_with_tbl(xen_io_tlb_start, xen_io_tlb_nslabs);
266274

275+
end:
276+
xen_io_tlb_end = xen_io_tlb_start + bytes;
267277
if (!rc)
268278
swiotlb_set_max_segment(PAGE_SIZE);
269279

0 commit comments

Comments
 (0)