On Tue, 2020-07-28 at 12:47 +0200, Christoph Hellwig wrote:
> When allocating coherent pool memory for an IOMMU mapping we don't care
> about the DMA mask.  Move the guess for the initial GFP mask into the
> dma_direct_alloc_pages and pass dma_coherent_ok as a function pointer
> argument so that it doesn't get applied to the IOMMU case.
> 
> Signed-off-by: Christoph Hellwig <[email protected]>
> ---
>  drivers/iommu/dma-iommu.c   |   4 +-
>  include/linux/dma-direct.h  |   3 -
>  include/linux/dma-mapping.h |   5 +-
>  kernel/dma/direct.c         |  13 ++--
>  kernel/dma/pool.c           | 114 +++++++++++++++---------------------
>  5 files changed, 62 insertions(+), 77 deletions(-)
> 

[...]

> -static inline struct gen_pool *dma_get_safer_pool(struct gen_pool *bad_pool)
> +static struct page *__dma_alloc_from_pool(struct device *dev, size_t size,
> +             struct gen_pool *pool, void **cpu_addr,
> +             bool (*phys_addr_ok)(struct device *, phys_addr_t, size_t))
>  {
> -     if (bad_pool == atomic_pool_kernel)
> -             return atomic_pool_dma32 ? : atomic_pool_dma;
> +     unsigned long addr;
> +     phys_addr_t phys;
>  
> -     if (bad_pool == atomic_pool_dma32)
> -             return atomic_pool_dma;
> +     addr = gen_pool_alloc(pool, size);
> +     if (!addr)
> +             return NULL;
>  
> -     return NULL;
> -}
> +     phys = gen_pool_virt_to_phys(pool, addr);
> +     if (!phys_addr_ok(dev, phys, size)) {

Shoudn't we check if phys_addr_ok() != NULL?

Regards,
Nicolas


Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to