Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-10-17 Thread Joerg Roedel
On Thu, Oct 16, 2014 at 10:23:07AM -0700, Olav Haugan wrote: On 10/15/2014 2:16 AM, Thierry Reding wrote: Perhaps make the return value ssize_t so that we can propagate errors? I am fine with that. Joerg? I am not so sure this is a good idea. On error the function should return the size

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-10-16 Thread Olav Haugan
On 10/15/2014 2:16 AM, Thierry Reding wrote: On Mon, Oct 06, 2014 at 12:02:47PM -0700, Olav Haugan wrote: On 9/25/2014 10:01 AM, Joerg Roedel wrote: On Mon, Aug 11, 2014 at 03:45:50PM -0700, Olav Haugan wrote: +static inline int iommu_map_sg(struct iommu_domain *domain, unsigned long iova, +

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-10-15 Thread Thierry Reding
On Mon, Oct 06, 2014 at 12:02:47PM -0700, Olav Haugan wrote: On 9/25/2014 10:01 AM, Joerg Roedel wrote: On Mon, Aug 11, 2014 at 03:45:50PM -0700, Olav Haugan wrote: +static inline int iommu_map_sg(struct iommu_domain *domain, unsigned long iova, + struct scatterlist

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-10-06 Thread Olav Haugan
On 9/25/2014 10:01 AM, Joerg Roedel wrote: On Mon, Aug 11, 2014 at 03:45:50PM -0700, Olav Haugan wrote: +static inline int iommu_map_sg(struct iommu_domain *domain, unsigned long iova, + struct scatterlist *sg, unsigned int nents, + int

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-09-25 Thread Joerg Roedel
On Mon, Aug 11, 2014 at 03:45:50PM -0700, Olav Haugan wrote: +static inline int iommu_map_sg(struct iommu_domain *domain, unsigned long iova, +struct scatterlist *sg, unsigned int nents, +int prot, unsigned long flags) +{ + return

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-20 Thread Konrad Rzeszutek Wilk
On Tue, Aug 19, 2014 at 10:52:46PM +0200, Laurent Pinchart wrote: On Tuesday 19 August 2014 11:40:24 Olav Haugan wrote: On 8/19/2014 9:11 AM, Laurent Pinchart wrote: On Tuesday 19 August 2014 13:59:54 Joerg Roedel wrote: On Mon, Aug 18, 2014 at 03:47:56PM -0700, Olav Haugan wrote: If

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-20 Thread Laurent Pinchart
Hi Konrad, On Wednesday 20 August 2014 09:02:50 Konrad Rzeszutek Wilk wrote: On Tue, Aug 19, 2014 at 10:52:46PM +0200, Laurent Pinchart wrote: On Tuesday 19 August 2014 11:40:24 Olav Haugan wrote: On 8/19/2014 9:11 AM, Laurent Pinchart wrote: On Tuesday 19 August 2014 13:59:54 Joerg

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-19 Thread Joerg Roedel
On Mon, Aug 18, 2014 at 03:47:56PM -0700, Olav Haugan wrote: If the alignment is not correct then iommu_map() will return error. Not sure what other option we have here (and why make it different behavior than iommu_map which just return error when it is not aligned properly). I don't think we

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-19 Thread Laurent Pinchart
On Tuesday 19 August 2014 13:59:54 Joerg Roedel wrote: On Mon, Aug 18, 2014 at 03:47:56PM -0700, Olav Haugan wrote: If the alignment is not correct then iommu_map() will return error. Not sure what other option we have here (and why make it different behavior than iommu_map which just

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-19 Thread Olav Haugan
On 8/19/2014 4:59 AM, Joerg Roedel wrote: On Mon, Aug 18, 2014 at 03:47:56PM -0700, Olav Haugan wrote: If the alignment is not correct then iommu_map() will return error. Not sure what other option we have here (and why make it different behavior than iommu_map which just return error when it

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-19 Thread Olav Haugan
On 8/19/2014 9:11 AM, Laurent Pinchart wrote: On Tuesday 19 August 2014 13:59:54 Joerg Roedel wrote: On Mon, Aug 18, 2014 at 03:47:56PM -0700, Olav Haugan wrote: If the alignment is not correct then iommu_map() will return error. Not sure what other option we have here (and why make it

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-19 Thread Laurent Pinchart
On Tuesday 19 August 2014 11:40:24 Olav Haugan wrote: On 8/19/2014 9:11 AM, Laurent Pinchart wrote: On Tuesday 19 August 2014 13:59:54 Joerg Roedel wrote: On Mon, Aug 18, 2014 at 03:47:56PM -0700, Olav Haugan wrote: If the alignment is not correct then iommu_map() will return error. Not

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-19 Thread Thierry Reding
On Tue, Aug 19, 2014 at 10:52:46PM +0200, Laurent Pinchart wrote: On Tuesday 19 August 2014 11:40:24 Olav Haugan wrote: On 8/19/2014 9:11 AM, Laurent Pinchart wrote: On Tuesday 19 August 2014 13:59:54 Joerg Roedel wrote: On Mon, Aug 18, 2014 at 03:47:56PM -0700, Olav Haugan wrote: If

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-18 Thread j...@8bytes.org
On Tue, Aug 12, 2014 at 09:56:11AM -0700, Olav Haugan wrote: On 8/12/2014 3:48 AM, Rob Clark wrote: iirc, one plan for 'flags' was some sort of DONT_FLUSH_TLB flag for drivers which wanted to map/unmap N buffers with a single flush at the end. There might have been some other usages

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-18 Thread Rob Clark
On Mon, Aug 18, 2014 at 10:07 AM, j...@8bytes.org j...@8bytes.org wrote: On Tue, Aug 12, 2014 at 09:56:11AM -0700, Olav Haugan wrote: On 8/12/2014 3:48 AM, Rob Clark wrote: iirc, one plan for 'flags' was some sort of DONT_FLUSH_TLB flag for drivers which wanted to map/unmap N buffers with a

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-18 Thread Olav Haugan
On 8/18/2014 11:32 AM, Rob Clark wrote: On Mon, Aug 18, 2014 at 10:07 AM, j...@8bytes.org j...@8bytes.org wrote: On Tue, Aug 12, 2014 at 09:56:11AM -0700, Olav Haugan wrote: On 8/12/2014 3:48 AM, Rob Clark wrote: iirc, one plan for 'flags' was some sort of DONT_FLUSH_TLB flag for drivers

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-18 Thread j...@8bytes.org
On Mon, Aug 18, 2014 at 01:48:46PM -0700, Olav Haugan wrote: On 8/18/2014 11:32 AM, Rob Clark wrote: No, I do not have other uses right now. But could imagine use cases like force insert minimum mapping size here mapping flag etc. I think it is worth discussing to add a flush() function to

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-18 Thread Joerg Roedel
On Mon, Aug 11, 2014 at 03:45:50PM -0700, Olav Haugan wrote: +int default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova, + struct scatterlist *sg, unsigned int nents, + int prot, unsigned long flags) +{ + int ret = 0; +

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-18 Thread Olav Haugan
On 8/18/2014 2:55 PM, Joerg Roedel wrote: On Mon, Aug 11, 2014 at 03:45:50PM -0700, Olav Haugan wrote: +int default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova, + struct scatterlist *sg, unsigned int nents, + int prot, unsigned long

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-12 Thread Rob Clark
On Mon, Aug 11, 2014 at 9:51 PM, Hiroshi Doyu hd...@nvidia.com wrote: Hi Olav, Olav Haugan ohau...@codeaurora.org writes: @@ -93,6 +94,10 @@ enum iommu_attr { * @detach_dev: detach device from an iommu domain * @map: map a physically contiguous memory region to an iommu domain *

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-12 Thread Olav Haugan
On 8/11/2014 6:35 PM, Konrad Rzeszutek Wilk wrote: On Mon, Aug 11, 2014 at 03:45:50PM -0700, Olav Haugan wrote: .. snip.. +for_each_sg(sg, s, nents, i) { +phys_addr_t phys = page_to_phys(sg_page(s)); +size_t page_len = s-offset + s-length; + +ret =

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-12 Thread Laurent Pinchart
Hi Olav, Thank you for the patch. On Monday 11 August 2014 15:45:50 Olav Haugan wrote: Mapping and unmapping are more often than not in the critical path. map_sg and unmap_sg allows IOMMU driver implementations to optimize the process of mapping and unmapping buffers into the IOMMU page

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-12 Thread Olav Haugan
On 8/12/2014 3:48 AM, Rob Clark wrote: On Mon, Aug 11, 2014 at 9:51 PM, Hiroshi Doyu hd...@nvidia.com wrote: Hi Olav, Olav Haugan ohau...@codeaurora.org writes: @@ -93,6 +94,10 @@ enum iommu_attr { * @detach_dev: detach device from an iommu domain * @map: map a physically contiguous

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-12 Thread Olav Haugan
Hi Laurent, On 8/12/2014 9:55 AM, Laurent Pinchart wrote: Hi Olav, Thank you for the patch. On Monday 11 August 2014 15:45:50 Olav Haugan wrote: Mapping and unmapping are more often than not in the critical path. map_sg and unmap_sg allows IOMMU driver implementations to optimize the

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-11 Thread Konrad Rzeszutek Wilk
On Mon, Aug 11, 2014 at 03:45:50PM -0700, Olav Haugan wrote: Mapping and unmapping are more often than not in the critical path. map_sg and unmap_sg allows IOMMU driver implementations to optimize the process of mapping and unmapping buffers into the IOMMU page tables. Instead of mapping a

Re: [PATCH v5 1/1] iommu-api: Add map_sg/unmap_sg functions

2014-08-11 Thread Hiroshi Doyu
Hi Olav, Olav Haugan ohau...@codeaurora.org writes: @@ -93,6 +94,10 @@ enum iommu_attr { * @detach_dev: detach device from an iommu domain * @map: map a physically contiguous memory region to an iommu domain * @unmap: unmap a physically contiguous memory region from an iommu domain +