Merge tag 'dma-mapping-6.7-2023-10-30' of git://git.infradead.org/users/hch/dma-mapping
[linux-2.6-microblaze.git] / kernel / dma / swiotlb.c
index fd5dacd..2620227 100644 (file)
@@ -678,6 +678,11 @@ static struct io_tlb_pool *swiotlb_alloc_pool(struct device *dev,
        size_t pool_size;
        size_t tlb_size;
 
+       if (nslabs > SLABS_PER_PAGE << MAX_ORDER) {
+               nslabs = SLABS_PER_PAGE << MAX_ORDER;
+               nareas = limit_nareas(nareas, nslabs);
+       }
+
        pool_size = sizeof(*pool) + array_size(sizeof(*pool->areas), nareas);
        pool = kzalloc(pool_size, gfp);
        if (!pool)