Re: [Intel-gfx] [PATCH 0/8] Convert the intel iommu driver to the dma-iommu api

2020-09-10 Thread Tom Murphy
On Thu, 10 Sep 2020 at 14:33, Tom Murphy wrote: > > On Wed, 9 Sep 2020 at 13:56, Tvrtko Ursulin > wrote: > > > > > > On 09/09/2020 10:16, Tvrtko Ursulin wrote: > > > On 08/09/2020 23:43, Tom Murphy wrote: > > >> On Tue, 8 Sep 2020 at 16:56, Tvrtko

Re: [Intel-gfx] [PATCH 0/8] Convert the intel iommu driver to the dma-iommu api

2020-09-10 Thread Tom Murphy
On Wed, 9 Sep 2020 at 13:56, Tvrtko Ursulin wrote: > > > On 09/09/2020 10:16, Tvrtko Ursulin wrote: > > On 08/09/2020 23:43, Tom Murphy wrote: > >> On Tue, 8 Sep 2020 at 16:56, Tvrtko Ursulin > >> wrote: > >>> On 08/09/2020 16:44, Logan Gunthorpe

Re: [Intel-gfx] [PATCH 0/8] Convert the intel iommu driver to the dma-iommu api

2020-09-08 Thread Tom Murphy
On Tue, 8 Sep 2020 at 16:56, Tvrtko Ursulin wrote: > > > On 08/09/2020 16:44, Logan Gunthorpe wrote: > > On 2020-09-08 9:28 a.m., Tvrtko Ursulin wrote: > >>> > >>> diff --git a/drivers/gpu/drm/i915/i915_scatterlist.h > >>> b/drivers/gpu/drm/i915/i915 > >>> index b7b59328cb76..9367ac801f0c 100644

Re: [PATCH 0/8] Convert the intel iommu driver to the dma-iommu api

2020-09-03 Thread Tom Murphy
On Fri, 28 Aug 2020 at 00:34, Tom Murphy wrote: > > On Thu, 27 Aug 2020 at 22:36, Logan Gunthorpe wrote: > > > > > > > > On 2020-08-23 6:04 p.m., Tom Murphy wrote: > > > I have added a check for the sg_dma_len == 0 : > > > "&qu

Re: [PATCH 0/8] Convert the intel iommu driver to the dma-iommu api

2020-08-27 Thread Tom Murphy
On Thu, 27 Aug 2020 at 22:36, Logan Gunthorpe wrote: > > > > On 2020-08-23 6:04 p.m., Tom Murphy wrote: > > I have added a check for the sg_dma_len == 0 : > > """ > > } __sgt_iter(struct scatterlist *sgl, bool dma) { > > struct s

Re: [PATCH 0/8] Convert the intel iommu driver to the dma-iommu api

2020-08-26 Thread Tom Murphy
That would be great! On Wed., Aug. 26, 2020, 2:14 p.m. Robin Murphy, wrote: > Hi Tom, > > On 2019-12-21 15:03, Tom Murphy wrote: > > This patchset converts the intel iommu driver to the dma-iommu api. > > > > While converting the driver I exposed a bug in the intel

Re: [PATCH 0/8] Convert the intel iommu driver to the dma-iommu api

2020-08-23 Thread Tom Murphy
Hi Logan/All, I have added a check for the sg_dma_len == 0 : """ } __sgt_iter(struct scatterlist *sgl, bool dma) { struct sgt_iter s = { .sgp = sgl }; + if (sgl && sg_dma_len(sgl) == 0) + s.sgp = NULL; if (s.sgp) { . """ at location [1]. but it

Re: [PATCH V2 1/2] Add new flush_iotlb_range and handle freelists when using iommu_unmap_fast

2020-08-18 Thread Tom Murphy
On Tue, 18 Aug 2020 at 16:17, Robin Murphy wrote: > > On 2020-08-18 07:04, Tom Murphy wrote: > > Add a flush_iotlb_range to allow flushing of an iova range instead of a > > full flush in the dma-iommu path. > > > > Allow the iommu_unmap_fast to return newly freed

[PATCH V2 2/2] Handle init_iova_flush_queue failure in dma-iommu path

2020-08-18 Thread Tom Murphy
init_iova_flush_queue can fail if we run out of memory. Fall back to no flush queue if it fails. Signed-off-by: Tom Murphy --- drivers/iommu/dma-iommu.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index

[PATCH V2 1/2] Add new flush_iotlb_range and handle freelists when using iommu_unmap_fast

2020-08-18 Thread Tom Murphy
the intel iommu driver) which need to wait for the ioTLB to be flushed before newly free/unmapped page table pages can be freed. This way we can still batch ioTLB free operations and handle the freelists. Change-log: V2: -fix missing parameter in mtk_iommu_v1.c Signed-off-by: Tom Murphy --- drivers

[PATCH 2/2] Handle init_iova_flush_queue failure in dma-iommu path

2020-08-17 Thread Tom Murphy
init_iova_flush_queue can fail if we run out of memory. Fall back to no flush queue if it fails. Signed-off-by: Tom Murphy --- drivers/iommu/dma-iommu.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index

[PATCH 1/2] Add new flush_iotlb_range and handle freelists when using iommu_unmap_fast

2020-08-17 Thread Tom Murphy
the intel iommu driver) which need to wait for the ioTLB to be flushed before newly free/unmapped page table pages can be freed. This way we can still batch ioTLB free operations and handle the freelists. Signed-off-by: Tom Murphy --- drivers/iommu/amd/iommu.c | 14 - drivers/iommu/arm-smmu

Re: [PATCH V6 4/5] iommu/dma-iommu: Use the dev->coherent_dma_mask

2020-07-10 Thread Tom Murphy
>Btw, what is the current state of converting intel-iommu to the dma-iommu These changes expose a bug in the i915 intel driver which hasn't been fixed yet. I don't think anyone is actively working on it but I plan on merging as many patches as I can so it's easier to do the intel-iommu ->

Re: [PATCH 3/8] iommu/vt-d: Remove IOVA handling code from non-dma_ops path

2020-03-20 Thread Tom Murphy
Could we merge patch 1-3 from this series? it just cleans up weird code and merging these patches will cover some of the work needed to move the intel iommu driver to the dma-iommu api in the future. On Sat, 21 Dec 2019 at 07:04, Tom Murphy wrote: > > Remove all IOVA handling code from t

Re: [PATCH 0/8] Convert the intel iommu driver to the dma-iommu api

2020-03-20 Thread Tom Murphy
Any news on this? Is there anyone who wants to try and fix this possible bug? On Mon, 23 Dec 2019 at 03:41, Jani Nikula wrote: > > On Mon, 23 Dec 2019, Robin Murphy wrote: > > On 2019-12-23 10:37 am, Jani Nikula wrote: > >> On Sat, 21 Dec 2019, Tom Murphy wrote: > &g

[PATCH 6/8] iommu: allow the dma-iommu api to use bounce buffers

2019-12-21 Thread Tom Murphy
Allow the dma-iommu api to use bounce buffers for untrusted devices. This is a copy of the intel bounce buffer code. Signed-off-by: Tom Murphy --- drivers/iommu/dma-iommu.c | 93 --- drivers/iommu/iommu.c | 10 + include/linux/iommu.h | 9 +++- 3

[PATCH 7/8] iommu/vt-d: Convert intel iommu driver to the iommu ops

2019-12-21 Thread Tom Murphy
Convert the intel iommu driver to the dma-iommu api. Remove the iova handling and reserve region code from the intel iommu driver. Signed-off-by: Tom Murphy --- drivers/iommu/Kconfig | 1 + drivers/iommu/intel-iommu.c | 742 +++- include/linux/intel

[PATCH 1/8] iommu/vt-d: clean up 32bit si_domain assignment

2019-12-21 Thread Tom Murphy
of type IOMMU_DOMAIN_IDENTITY from the begging rather than needlessly swapping domains. Signed-off-by: Tom Murphy --- drivers/iommu/intel-iommu.c | 88 + 1 file changed, 31 insertions(+), 57 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu

[PATCH 0/8] Convert the intel iommu driver to the dma-iommu api

2019-12-21 Thread Tom Murphy
at the moment and I want to get these changes out before the iommu code changes any more. Tom Murphy (8): iommu/vt-d: clean up 32bit si_domain assignment iommu/vt-d: Use default dma_direct_* mapping functions for direct mapped devices iommu/vt-d: Remove IOVA handling code from non-dma_ops

[PATCH 8/8] DO NOT MERGE: iommu: disable list appending in dma-iommu

2019-12-21 Thread Tom Murphy
the returned value specifying the number of elements in the list and instead depends on the previous behaviour of the intel iommu driver which would return the same number of elements in the output list as in the input list. Signed-off-by: Tom Murphy --- drivers/iommu/dma-iommu.c | 38

[PATCH 2/8] iommu/vt-d: Use default dma_direct_* mapping functions for direct mapped devices

2019-12-21 Thread Tom Murphy
. Signed-off-by: Tom Murphy --- drivers/iommu/intel-iommu.c | 52 + 1 file changed, 6 insertions(+), 46 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index c1ea66467918..64b1a9793daa 100644 --- a/drivers/iommu/intel-iommu.c

[PATCH 5/8] iommu: Add iommu_dma_free_cpu_cached_iovas function

2019-12-21 Thread Tom Murphy
to dma-iommu ops Add a iommu_dma_free_cpu_cached_iovas function to allow drivers which use the dma-iommu ops to free cached cpu iovas. Signed-off-by: Tom Murphy --- drivers/iommu/dma-iommu.c | 9 + include/linux/dma-iommu.h | 3 +++ 2 files changed, 12 insertions(+) diff --git

[PATCH 4/8] iommu: Handle freelists when using deferred flushing in iommu drivers

2019-12-21 Thread Tom Murphy
be freed. This way we can still batch ioTLB free operations and handle the freelists. Signed-off-by: Tom Murphy --- drivers/iommu/amd_iommu.c | 14 - drivers/iommu/arm-smmu-v3.c | 3 +- drivers/iommu/arm-smmu.c| 3 +- drivers/iommu/dma-iommu.c | 45

[PATCH V6 2/5] iommu: Add gfp parameter to iommu_ops::map

2019-09-08 Thread Tom Murphy
ic in it's iommu_ops::map function. But doing this wastes the memory allocators atomic pools. Signed-off-by: Tom Murphy Reviewed-by: Robin Murphy Reviewed-by: Christoph Hellwig --- drivers/iommu/amd_iommu.c | 3 ++- drivers/iommu/arm-smmu-v3.c| 2 +- drivers/iommu/arm-smmu.c | 2 +

[PATCH V6 1/5] iommu/amd: Remove unnecessary locking from AMD iommu driver

2019-09-08 Thread Tom Murphy
middle pages using "cmpxchg64()". Signed-off-by: Tom Murphy --- drivers/iommu/amd_iommu.c | 10 +- drivers/iommu/amd_iommu_types.h | 1 - 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 00

[PATCH V6 5/5] iommu/amd: Convert AMD iommu driver to the dma-iommu api

2019-09-08 Thread Tom Murphy
Convert the AMD iommu driver to the dma-iommu api. Remove the iova handling and reserve region code from the AMD iommu driver. Signed-off-by: Tom Murphy --- drivers/iommu/Kconfig | 1 + drivers/iommu/amd_iommu.c | 677 -- 2 files changed, 68 insertions

[PATCH V6 4/5] iommu/dma-iommu: Use the dev->coherent_dma_mask

2019-09-08 Thread Tom Murphy
Use the dev->coherent_dma_mask when allocating in the dma-iommu ops api. Signed-off-by: Tom Murphy Reviewed-by: Robin Murphy Reviewed-by: Christoph Hellwig --- drivers/iommu/dma-iommu.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/dma-iomm

[PATCH V6 3/5] iommu/dma-iommu: Handle deferred devices

2019-09-08 Thread Tom Murphy
Handle devices which defer their attach to the iommu in the dma-iommu api Signed-off-by: Tom Murphy Reviewed-by: Robin Murphy --- drivers/iommu/dma-iommu.c | 27 ++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu

[PATCH v6 0/5] iommu/amd: Convert the AMD iommu driver to the dma-iommu api

2019-09-08 Thread Tom Murphy
ops.3 -Add a gfp_t parameter to the iommu_ops::map function. -Made use of the reserve region code inside the dma-iommu api Tom Murphy (5): iommu/amd: Remove unnecessary locking from AMD iommu driver iommu: Add gfp parameter to iommu_ops::map iommu/dma-iommu: Handle deferred devices iommu/dma-

Re: [PATCH V5 1/5] iommu/amd: Remove unnecessary locking from AMD iommu driver

2019-08-24 Thread Tom Murphy
20 Aug 2019 at 10:41, Christoph Hellwig wrote: > > On Thu, Aug 15, 2019 at 12:09:39PM +0100, Tom Murphy wrote: > > We can remove the mutex lock from amd_iommu_map and amd_iommu_unmap. > > iommu_map doesn’t lock while mapping and so no two calls should touch > > the sam

Re: [PATCH v4 0/5] iommu/amd: Convert the AMD iommu driver to the dma-iommu api

2019-08-15 Thread Tom Murphy
, 13 Aug 2019 at 14:07, Christoph Hellwig wrote: > > On Tue, Aug 13, 2019 at 08:09:26PM +0800, Tom Murphy wrote: > > Hi Christoph, > > > > I quit my job and am having a great time traveling South East Asia. > > Enjoy! I just returned from my vacation. > > >

[PATCH V5 5/5] iommu/amd: Convert AMD iommu driver to the dma-iommu api

2019-08-15 Thread Tom Murphy
Convert the AMD iommu driver to the dma-iommu api. Remove the iova handling and reserve region code from the AMD iommu driver. Signed-off-by: Tom Murphy --- drivers/iommu/Kconfig | 1 + drivers/iommu/amd_iommu.c | 677 -- 2 files changed, 68 insertions

[PATCH V5 4/5] iommu/dma-iommu: Use the dev->coherent_dma_mask

2019-08-15 Thread Tom Murphy
Use the dev->coherent_dma_mask when allocating in the dma-iommu ops api. Signed-off-by: Tom Murphy --- drivers/iommu/dma-iommu.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 906b7fa14

[PATCH V5 3/5] iommu/dma-iommu: Handle deferred devices

2019-08-15 Thread Tom Murphy
Handle devices which defer their attach to the iommu in the dma-iommu api Signed-off-by: Tom Murphy --- drivers/iommu/dma-iommu.c | 27 ++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index

[PATCH V5 2/5] iommu: Add gfp parameter to iommu_ops::map

2019-08-15 Thread Tom Murphy
ic in it's iommu_ops::map function. But doing this wastes the memory allocators atomic pools. Signed-off-by: Tom Murphy --- drivers/iommu/amd_iommu.c | 3 ++- drivers/iommu/arm-smmu-v3.c| 2 +- drivers/iommu/arm-smmu.c | 2 +- drivers/iommu/dma-iommu.c | 6 ++--- drivers/io

[PATCH V5 1/5] iommu/amd: Remove unnecessary locking from AMD iommu driver

2019-08-15 Thread Tom Murphy
We can remove the mutex lock from amd_iommu_map and amd_iommu_unmap. iommu_map doesn’t lock while mapping and so no two calls should touch the same iova range. The AMD driver already handles the page table page allocations without locks so we can safely remove the locks. Signed-off-by: Tom Murphy

[PATCH V5 0/5] iommu/amd: Convert the AMD iommu driver to the dma-iommu api

2019-08-15 Thread Tom Murphy
/users/hch/misc.git/shortlog/refs/heads/dma-iommu-ops.3 -Add a gfp_t parameter to the iommu_ops::map function. -Made use of the reserve region code inside the dma-iommu api Tom Murphy (5): iommu/amd: Remove unnecessary locking from AMD iommu driver iommu: Add gfp parameter to iommu_ops::map

Re: [PATCH v4 0/5] iommu/amd: Convert the AMD iommu driver to the dma-iommu api

2019-08-13 Thread Tom Murphy
Hi Christoph, I quit my job and am having a great time traveling South East Asia. I definitely don't want this work to go to waste and I hope to repost it later this week but I can't guarantee it. Let me know if you need this urgently. Thanks, Tom On Sat 10 Aug 2019, 3:20 p.m. Christoph

[PATCH v4 3/5] iommu/dma-iommu: Handle deferred devices

2019-07-24 Thread Tom Murphy
Handle devices which defer their attach to the iommu in the dma-iommu api Signed-off-by: Tom Murphy --- drivers/iommu/dma-iommu.c | 27 ++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index

[PATCH v4 2/5] iommu: Add gfp parameter to iommu_ops::map

2019-07-24 Thread Tom Murphy
ic in it's iommu_ops::map function. But doing this wastes the memory allocators atomic pools. Signed-off-by: Tom Murphy --- drivers/iommu/amd_iommu.c | 3 ++- drivers/iommu/arm-smmu-v3.c| 2 +- drivers/iommu/arm-smmu.c | 2 +- drivers/iommu/dma-iommu.c | 6 ++--- drivers/io

[PATCH v4 5/5] iommu/amd: Convert AMD iommu driver to the dma-iommu api

2019-07-24 Thread Tom Murphy
Convert the AMD iommu driver to the dma-iommu api. Remove the iova handling and reserve region code from the AMD iommu driver. Signed-off-by: Tom Murphy --- drivers/iommu/Kconfig | 1 + drivers/iommu/amd_iommu.c | 677 -- 2 files changed, 68 insertions

[PATCH v4 4/5] iommu/dma-iommu: Use the dev->coherent_dma_mask

2019-07-24 Thread Tom Murphy
Use the dev->coherent_dma_mask when allocating in the dma-iommu ops api. Signed-off-by: Tom Murphy --- drivers/iommu/dma-iommu.c | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index f303bbe20

[PATCH v4 1/5] iommu/amd: Remove unnecessary locking from AMD iommu driver

2019-07-24 Thread Tom Murphy
We can remove the mutex lock from amd_iommu_map and amd_iommu_unmap. iommu_map doesn’t lock while mapping and so no two calls should touch the same iova range. The AMD driver already handles the page table page allocations without locks so we can safely remove the locks. Signed-off-by: Tom Murphy

[PATCH v4 0/5] iommu/amd: Convert the AMD iommu driver to the dma-iommu api

2019-07-24 Thread Tom Murphy
/heads/dma-iommu-ops.3 -Add a gfp_t parameter to the iommu_ops::map function. -Made use of the reserve region code inside the dma-iommu api Tom Murphy (5): iommu/amd: Remove unnecessary locking from AMD iommu driver iommu: Add gfp parameter to iommu_ops::map iommu/dma-iommu: Handle deferr