[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190115162322.GA4681@8bytes.org>
Date: Tue, 15 Jan 2019 17:23:22 +0100
From: Joerg Roedel <joro@...tes.org>
To: Christoph Hellwig <hch@....de>
Cc: "Michael S . Tsirkin" <mst@...hat.com>,
Jason Wang <jasowang@...hat.com>,
Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
Jens Axboe <axboe@...nel.dk>,
virtualization@...ts.linux-foundation.org,
linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
iommu@...ts.linux-foundation.org, jfehlig@...e.com,
jon.grimm@....com, brijesh.singh@....com, jroedel@...e.de
Subject: Re: [PATCH 2/3] dma: Introduce dma_max_mapping_size()
On Tue, Jan 15, 2019 at 02:37:54PM +0100, Christoph Hellwig wrote:
> > +size_t dma_direct_max_mapping_size(struct device *dev)
> > +{
> > + /*
> > + * Return the minimum of the direct DMA limit and the SWIOTLB limit.
> > + * Since direct DMA has no limit, it is fine to just return the SWIOTLB
> > + * limit.
> > + */
> > + return swiotlb_max_mapping_size(dev);
>
> Well, if we don't actually use the swiotlb buffers despite it being
> compiled in or even allocated we don't need the limit.
Right, I thought about that too, but didn't find a generic way to check
for all the cases. There are various checks that could be done:
1) Check if SWIOTLB is initialized at all, if not, return
SIZE_MAX as the limit. This can't be checked from dma-direct
code right now, but could be easily implemented.
2) Check for swiotlb=force needs to be done.
3) Check whether the device can access all of available RAM. I
have no idea how to check that in an architecture independent
way. It also has to take memory hotplug into account as well
as the DMA mask of the device.
An easy approximation could be to omit the limit if the
dma-mask covers all of the physical address bits available
on the platform. It would require to pass the dma-mask as an
additional parameter like it is done in dma_supported().
Any better ideas for how to implement 3)?
Regards,
Joerg
Powered by blists - more mailing lists