Skip to content

Commit

Permalink
swiotlb: panic if nslabs is too small
Browse files Browse the repository at this point in the history
Panic on purpose if nslabs is too small, in order to sync with the remap
retry logic.

In addition, print the number of bytes for tlb alloc failure.

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Dongli Zhang authored and Christoph Hellwig committed Jun 22, 2022
1 parent 04c14e8 commit 0bf28fc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kernel/dma/swiotlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags,
if (swiotlb_force_disable)
return;

if (nslabs < IO_TLB_MIN_SLABS)
panic("%s: nslabs = %lu too small\n", __func__, nslabs);

/*
* By default allocate the bounce buffer memory from low memory, but
* allow to pick a location everywhere for hypervisors with guest
Expand All @@ -254,7 +257,8 @@ void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags,
else
tlb = memblock_alloc_low(bytes, PAGE_SIZE);
if (!tlb) {
pr_warn("%s: failed to allocate tlb structure\n", __func__);
pr_warn("%s: Failed to allocate %zu bytes tlb structure\n",
__func__, bytes);
return;
}

Expand Down

0 comments on commit 0bf28fc

Please sign in to comment.