swiotlb: panic if nslabs is too small
authorDongli Zhang <dongli.zhang@oracle.com>
Sat, 11 Jun 2022 08:25:14 +0000 (01:25 -0700)
committerChristoph Hellwig <hch@lst.de>
Wed, 22 Jun 2022 10:42:09 +0000 (12:42 +0200)
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>
kernel/dma/swiotlb.c

index fd21f4162f4b315c5c0b08b18fd4b6021b4a6086..1758b724c7a8da5e1fe8532169c4786e68523d54 100644 (file)
@@ -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
@@ -254,7 +257,8 @@ retry:
        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;
        }