From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: [PATCH 1/3] swiotlb: Export maximum allocation size Date: Thu, 10 Jan 2019 12:02:05 -0500 Message-ID: <20190110170205.GB27546@char.us.oracle.com> References: <20190110134433.15672-1-joro@8bytes.org> <20190110134433.15672-2-joro@8bytes.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20190110134433.15672-2-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Joerg Roedel Cc: Jens Axboe , Joerg Roedel , brijesh.singh-5C7GfCeVMHo@public.gmane.org, "Michael S . Tsirkin" , Jason Wang , jon.grimm-5C7GfCeVMHo@public.gmane.org, jfehlig-IBi9RG/b67k@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, hch-jcswGhMUV9g@public.gmane.org List-Id: iommu@lists.linux-foundation.org On Thu, Jan 10, 2019 at 02:44:31PM +0100, Joerg Roedel wrote: > From: Joerg Roedel > > The SWIOTLB implementation has a maximum size it can > allocate dma-handles for. This needs to be exported so that > device drivers don't try to allocate larger chunks. > > This is especially important for block device drivers like > virtio-blk, that might do DMA through SWIOTLB. Why not use swiotlb_nr_tbl ? That is how drivers/gpu/drm use to figure if they need to limit the size of pages. > > Signed-off-by: Joerg Roedel > --- > include/linux/swiotlb.h | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h > index 7c007ed7505f..0bcc80a97036 100644 > --- a/include/linux/swiotlb.h > +++ b/include/linux/swiotlb.h > @@ -72,6 +72,11 @@ static inline bool is_swiotlb_buffer(phys_addr_t paddr) > return paddr >= io_tlb_start && paddr < io_tlb_end; > } > > +static inline size_t swiotlb_max_alloc_size(void) > +{ > + return ((1UL << IO_TLB_SHIFT) * IO_TLB_SEGSIZE); > +} > + > bool swiotlb_map(struct device *dev, phys_addr_t *phys, dma_addr_t *dma_addr, > size_t size, enum dma_data_direction dir, unsigned long attrs); > void __init swiotlb_exit(void); > @@ -95,6 +100,13 @@ static inline unsigned int swiotlb_max_segment(void) > { > return 0; > } > + > +static inline size_t swiotlb_max_alloc_size(void) > +{ > + /* There is no limit when SWIOTLB isn't used */ > + return ~0UL; > +} > + > #endif /* CONFIG_SWIOTLB */ > > extern void swiotlb_print_info(void); > -- > 2.17.1 >