[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v1 07/16] dma-mapping: convert dma_direct_*map_page to be phys_addr_t based



On Mon, Aug 04, 2025 at 03:42:41PM +0300, Leon Romanovsky wrote:
> --- a/kernel/dma/direct.h
> +++ b/kernel/dma/direct.h
> @@ -80,42 +80,54 @@ static inline void dma_direct_sync_single_for_cpu(struct 
> device *dev,
>               arch_dma_mark_clean(paddr, size);
>  }
>  
> -static inline dma_addr_t dma_direct_map_page(struct device *dev,
> -             struct page *page, unsigned long offset, size_t size,
> -             enum dma_data_direction dir, unsigned long attrs)
> +static inline dma_addr_t dma_direct_map_phys(struct device *dev,
> +             phys_addr_t phys, size_t size, enum dma_data_direction dir,
> +             unsigned long attrs)
>  {
> -     phys_addr_t phys = page_to_phys(page) + offset;
> -     dma_addr_t dma_addr = phys_to_dma(dev, phys);
> +     bool is_mmio = attrs & DMA_ATTR_MMIO;
> +     dma_addr_t dma_addr;
> +     bool capable;
> +
> +     dma_addr = (is_mmio) ? phys : phys_to_dma(dev, phys);
> +     capable = dma_capable(dev, dma_addr, size, is_mmio);
> +     if (is_mmio) {
> +            if (unlikely(!capable))
> +                    goto err_overflow;
> +            return dma_addr;

Similar remark here, shouldn't we be checking swiotlb things for
ATTR_MMIO and failing if swiotlb is needed?

> -     if (is_swiotlb_force_bounce(dev)) {
> -             if (is_pci_p2pdma_page(page))
> -                     return DMA_MAPPING_ERROR;

This

> -     if (unlikely(!dma_capable(dev, dma_addr, size, true)) ||
> -         dma_kmalloc_needs_bounce(dev, size, dir)) {
> -             if (is_pci_p2pdma_page(page))
> -                     return DMA_MAPPING_ERROR;

And this

Jason



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.