Commit 5d0538b2 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Konrad Rzeszutek Wilk

swiotlb: lift the double initialization protection from xen-swiotlb

Lift the double initialization protection from xen-swiotlb to the core
code to avoid exposing too many swiotlb internals.  Also upgrade the
check to a warning as it should not happen.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
parent cbce9952
...@@ -172,12 +172,6 @@ int __ref xen_swiotlb_init(int verbose, bool early) ...@@ -172,12 +172,6 @@ int __ref xen_swiotlb_init(int verbose, bool early)
bytes = nslabs << IO_TLB_SHIFT; bytes = nslabs << IO_TLB_SHIFT;
order = get_order(bytes); order = get_order(bytes);
/*
* IO TLB memory already allocated. Just use it.
*/
if (io_tlb_start != 0)
goto end;
/* /*
* Get IO TLB memory from any location. * Get IO TLB memory from any location.
*/ */
...@@ -232,7 +226,6 @@ int __ref xen_swiotlb_init(int verbose, bool early) ...@@ -232,7 +226,6 @@ int __ref xen_swiotlb_init(int verbose, bool early)
} else } else
rc = swiotlb_late_init_with_tbl(start, nslabs); rc = swiotlb_late_init_with_tbl(start, nslabs);
end:
if (!rc) if (!rc)
swiotlb_set_max_segment(PAGE_SIZE); swiotlb_set_max_segment(PAGE_SIZE);
......
...@@ -229,6 +229,10 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose) ...@@ -229,6 +229,10 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
unsigned long i, bytes; unsigned long i, bytes;
size_t alloc_size; size_t alloc_size;
/* protect against double initialization */
if (WARN_ON_ONCE(io_tlb_start))
return -ENOMEM;
bytes = nslabs << IO_TLB_SHIFT; bytes = nslabs << IO_TLB_SHIFT;
io_tlb_nslabs = nslabs; io_tlb_nslabs = nslabs;
...@@ -367,6 +371,10 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs) ...@@ -367,6 +371,10 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)
{ {
unsigned long i, bytes; unsigned long i, bytes;
/* protect against double initialization */
if (WARN_ON_ONCE(io_tlb_start))
return -ENOMEM;
bytes = nslabs << IO_TLB_SHIFT; bytes = nslabs << IO_TLB_SHIFT;
io_tlb_nslabs = nslabs; io_tlb_nslabs = nslabs;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment