Re: [PATCH v9 1/5] swiotlb: Split size parameter to map/unmap APIs
From: Joerg Roedel
Date: Wed Sep 11 2019 - 06:35:24 EST
On Wed, Sep 11, 2019 at 02:16:07PM +0800, Lu Baolu wrote:
> How about this change?
>
> diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
> index 89066efa3840..22a7848caca3 100644
> --- a/kernel/dma/swiotlb.c
> +++ b/kernel/dma/swiotlb.c
> @@ -466,8 +466,11 @@ phys_addr_t swiotlb_tbl_map_single(struct device
> *hwdev,
> pr_warn_once("%s is active and system is using DMA bounce
> buffers\n",
> sme_active() ? "SME" : "SEV");
>
> - if (WARN_ON(mapping_size > alloc_size))
> + if (mapping_size > alloc_size) {
> + dev_warn_once(hwdev, "Invalid sizes (mapping: %zd bytes,
> alloc: %zd bytes)",
> + mapping_size, alloc_size);
> return (phys_addr_t)DMA_MAPPING_ERROR;
> + }
>
> mask = dma_get_seg_boundary(hwdev);
>
> @@ -584,9 +587,6 @@ void swiotlb_tbl_unmap_single(struct device *hwdev,
> phys_addr_t tlb_addr,
> int index = (tlb_addr - io_tlb_start) >> IO_TLB_SHIFT;
> phys_addr_t orig_addr = io_tlb_orig_addr[index];
>
> - if (WARN_ON(mapping_size > alloc_size))
> - return;
> -
> /*
> * First, sync the memory before unmapping the entry
> */
Folded that into the commit, thanks Lu Baolu.