[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241119090507.GB28466@willie-the-truck>
Date: Tue, 19 Nov 2024 09:05:08 +0000
From: Will Deacon <will@...nel.org>
To: Leon Romanovsky <leon@...nel.org>
Cc: Jens Axboe <axboe@...nel.dk>, Jason Gunthorpe <jgg@...pe.ca>,
Robin Murphy <robin.murphy@....com>, Joerg Roedel <joro@...tes.org>,
Christoph Hellwig <hch@....de>, Sagi Grimberg <sagi@...mberg.me>,
Keith Busch <kbusch@...nel.org>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Logan Gunthorpe <logang@...tatee.com>,
Yishai Hadas <yishaih@...dia.com>,
Shameer Kolothum <shameerali.kolothum.thodi@...wei.com>,
Kevin Tian <kevin.tian@...el.com>,
Alex Williamson <alex.williamson@...hat.com>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Jérôme Glisse <jglisse@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Jonathan Corbet <corbet@....net>, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-block@...r.kernel.org,
linux-rdma@...r.kernel.org, iommu@...ts.linux.dev,
linux-nvme@...ts.infradead.org, linux-pci@...r.kernel.org,
kvm@...r.kernel.org, linux-mm@...ck.org,
Randy Dunlap <rdunlap@...radead.org>
Subject: Re: [PATCH v3 07/17] dma-mapping: Implement link/unlink ranges API
On Mon, Nov 18, 2024 at 08:55:33PM +0200, Leon Romanovsky wrote:
> On Mon, Nov 18, 2024 at 02:59:30PM +0000, Will Deacon wrote:
> > On Sun, Nov 10, 2024 at 03:46:54PM +0200, Leon Romanovsky wrote:
> > > +static void __iommu_dma_iova_unlink(struct device *dev,
> > > + struct dma_iova_state *state, size_t offset, size_t size,
> > > + enum dma_data_direction dir, unsigned long attrs,
> > > + bool free_iova)
> > > +{
> > > + struct iommu_domain *domain = iommu_get_dma_domain(dev);
> > > + struct iommu_dma_cookie *cookie = domain->iova_cookie;
> > > + struct iova_domain *iovad = &cookie->iovad;
> > > + dma_addr_t addr = state->addr + offset;
> > > + size_t iova_start_pad = iova_offset(iovad, addr);
> > > + struct iommu_iotlb_gather iotlb_gather;
> > > + size_t unmapped;
> > > +
> > > + if ((state->__size & DMA_IOVA_USE_SWIOTLB) ||
> > > + (!dev_is_dma_coherent(dev) && !(attrs & DMA_ATTR_SKIP_CPU_SYNC)))
> > > + iommu_dma_iova_unlink_range_slow(dev, addr, size, dir, attrs);
> > > +
> > > + iommu_iotlb_gather_init(&iotlb_gather);
> > > + iotlb_gather.queued = free_iova && READ_ONCE(cookie->fq_domain);
> > > +
> > > + size = iova_align(iovad, size + iova_start_pad);
> > > + addr -= iova_start_pad;
> > > + unmapped = iommu_unmap_fast(domain, addr, size, &iotlb_gather);
> > > + WARN_ON(unmapped != size);
> >
> > Does the new API require that the 'size' passed to dma_iova_unlink()
> > exactly match the 'size' passed to the corresponding call to
> > dma_iova_link()? I ask because the IOMMU page-table code is built around
> > the assumption that partial unmap() operations never occur (i.e.
> > operations which could require splitting a huge mapping). We just
> > removed [1] that code from the Arm IO page-table implementations, so it
> > would be good to avoid adding it back for this.
>
> dma_iova_link/dma_iova_unlink() don't have any assumptions in addition
> to already existing for dma_map_sg/dma_unmap_sg(). In reality, it means
> that all calls to unlink will have same size as for link.
Ok, great. Any chance you could call that out in the documentation patch,
please?
Will
Powered by blists - more mailing lists