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: Christoph Hellwig <hch@lst.de>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
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.
*/
if (early) {
} else
rc = swiotlb_late_init_with_tbl(start, nslabs);
-end:
if (!rc)
swiotlb_set_max_segment(PAGE_SIZE);
unsigned long i, bytes;
size_t alloc_size;
+ /* protect against double initialization */
+ if (WARN_ON_ONCE(io_tlb_start))
+ return -ENOMEM;
+
bytes = nslabs << IO_TLB_SHIFT;
io_tlb_nslabs = nslabs;
{
unsigned long i, bytes;
+ /* protect against double initialization */
+ if (WARN_ON_ONCE(io_tlb_start))
+ return -ENOMEM;
+
bytes = nslabs << IO_TLB_SHIFT;
io_tlb_nslabs = nslabs;