Re: [PATCH] Changing the AMD IOMMU API path to work in an atomic context which is necessary for any custom drivers using the IOMMU API while holding a spinlock.

2018-08-24 Thread Tom Murphy
the existing calls to . On 24 August 2018 at 16:24, Robin Murphy wrote: > On 24/08/18 15:53, Christoph Hellwig wrote: > >> On Fri, Aug 24, 2018 at 02:28:49PM +, murph...@tcd.ie wrote: >> >>> From: Tom Murphy >>> >>> --- >>> >>> This patc

Re: [PATCH] Changing the AMD IOMMU API path to work in an atomic context which is necessary for any custom drivers using the IOMMU API while holding a spinlock.

2018-08-24 Thread Tom Murphy
-safe. On 24 August 2018 at 16:24, Robin Murphy wrote: > On 24/08/18 15:53, Christoph Hellwig wrote: > >> On Fri, Aug 24, 2018 at 02:28:49PM +, murph...@tcd.ie wrote: >> >>> From: Tom Murphy >>> >>> --- >>> >>> This patc

Re: [PATCH] Changing the AMD IOMMU API path to work in an atomic context which is necessary for any custom drivers using the IOMMU API while holding a spinlock.

2018-08-24 Thread Tom Murphy
-safe. On 24 August 2018 at 23:51, Tom Murphy wrote: > The reason we want this change is so we can use iommu_group's to force our > pcie devices to have the same IOMMU mappings. For legacy reasons we require > a bunch of our pcie devices to have the same address translation. > > We w

Re: [PATCH] Fix typo. Change tlb_range_add to iotlb_range_add and tlb_sync to iotlb_sync

2018-12-20 Thread Tom Murphy
Ah shoot, it looks like I forgot to change flush_tlb_all -> flush_iotlb_all Should I submit another patch? On Wed, 5 Dec 2018 at 16:04, Joerg Roedel wrote: > > On Tue, Dec 04, 2018 at 06:27:34PM +0000, Tom Murphy wrote: > > From: tom > > > > Someone fo

[PATCH] Fix typo. Change tlb_range_add to iotlb_range_add and tlb_sync to iotlb_sync

2018-12-04 Thread Tom Murphy
From: tom Someone forgot to update this comment. Signed-off-by: Tom Murphy --- include/linux/iommu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index a1d28f42cb77..11db18b9ffe8 100644 --- a/include/linux/iommu.h +++ b

Re: [PATCH v2 0/3] iommu: Avoid DMA ops domain refcount contention

2018-09-18 Thread Tom Murphy
>Not sure how fast Tom needs the common dma-iommu code for the x86 AMD iommu >conversion. I am currently busy working on something else and won't be able to do/test the x86 AMD iommu conversion anytime soon. So I don't need the common dma-iommu code anytime soon. On 17 September 2018 at 14:33,

[PATCH] fix flush_tlb_all typo

2019-02-08 Thread Tom Murphy
--- include/linux/iommu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index a1d28f42cb77..bb4bf1269e5d 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -167,7 +167,7 @@ struct iommu_resv_region { *

[PATCH] remove unused end_pfn

2019-02-08 Thread Tom Murphy
This variable is useless. --- drivers/iommu/dma-iommu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 8e04b0603a4a..eff301d5e496 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -291,7

[PATCH] fix flush_tlb_all typo

2019-02-11 Thread Tom Murphy
Fix typo, flush_tlb_all should be flush_iotlb_all Signed-off-by: Tom Murphy --- include/linux/iommu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index a1d28f42cb77..bb4bf1269e5d 100644 --- a/include/linux/iommu.h +++ b

Re: [PATCH v3 1/4] iommu: Add gfp parameter to iommu_ops::map

2019-06-04 Thread Tom Murphy
On Tue, Jun 4, 2019 at 7:11 PM Robin Murphy wrote: > > On 06/05/2019 19:52, Tom Murphy wrote: > > Add a gfp_t parameter to the iommu_ops::map function. > > Remove the needless locking in the AMD iommu driver. > > > > The iommu_ops::map function (or the

Re: [PATCH -next v2] iommu/amd: fix a null-ptr-deref in map_sg()

2019-06-06 Thread Tom Murphy
Hi Joerg, Is there anything I need to do to get this patch into linux-next? My patch to convert the amd iommu driver to use the dma-iommu ops depends on this patch. Thanks, Tom On Tue, May 7, 2019 at 8:39 AM Joerg Roedel wrote: > > Hi Qian, > > On Mon, May 06, 2019 at 12:44:40PM -0400, Qian

[PATCH v3] iommu/amd: Flush not present cache in iommu_map_page

2019-06-13 Thread Tom Murphy
check if there is a not-present cache present and flush it if there is. Signed-off-by: Tom Murphy --- v3: --applied Qian Cai's "iommu/amd: fix a null-ptr-deref in map_sg()" fix drivers/iommu/amd_iommu.c | 20 1 file changed, 16 insertions(+), 4 deletions(-)

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

2019-06-13 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

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

2019-06-13 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 5/5] iommu/amd: Convert AMD iommu driver to the dma-iommu api

2019-06-13 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 1/5] iommu/amd: Remove unnecessary locking from AMD iommu driver

2019-06-13 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 2/5] iommu: Add gfp parameter to iommu_ops::map

2019-06-13 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 3/5] iommu/dma-iommu: Handle deferred devices

2019-06-13 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

Re: [PATCH v3 2/4] iommu/dma-iommu: Handle deferred devices

2019-05-15 Thread Tom Murphy
like this? In that case we need to add a call to iommu_dma_alloc_remap. >From 862aeebb601008cf863e3aff4ff8ed7cefebeefa Mon Sep 17 00:00:00 2001 From: Tom Murphy Date: Wed, 15 May 2019 05:43:25 -0700 Subject: [PATCH] iommu/dma-iommu: Handle deferred devices Handle devices which de

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

2019-08-17 Thread Tom Murphy
On Sat, 17 Aug 2019 at 04:39, Hillf Danton wrote: > > > On Thu, 15 Aug 2019 12:09:41 +0100 Tom Murphy wrote: > > > > Handle devices which defer their attach to the iommu in the dma-iommu api > > > > Signed-off-by: Tom Murphy > >

[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 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

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 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 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

[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

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] Remove wrong default domain comments

2019-08-25 Thread Tom Murphy
These comments are wrong. request_default_domain_for_dev doesn't just handle direct mapped domains. Signed-off-by: Tom Murphy --- drivers/iommu/iommu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index ea95080372e7

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

[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-

[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 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 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 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 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 8/9] iommu/amd: Clean up unused functions

2019-04-11 Thread Tom Murphy via iommu
Now that we are using the dma-iommu api we have a lot of unused code. This patch removes all that unused code. Signed-off-by: Tom Murphy --- drivers/iommu/amd_iommu.c | 209 -- 1 file changed, 209 deletions(-) diff --git a/drivers/iommu/amd_iommu.c b/drivers

Re: [PATCH 9/9] iommu/amd: Add allocated domain to global list earlier

2019-04-15 Thread Tom Murphy via iommu
>This seems like a fix to the existing code and should probably go out first. I'll send this patch out on it's own now. On Mon, Apr 15, 2019 at 7:23 AM Christoph Hellwig wrote: > > On Thu, Apr 11, 2019 at 07:47:38PM +0100, Tom Murphy via iommu wrote: > > dma_ops_domain_free()

[PATCH] iommu/amd: Add allocated domain to global list earlier

2019-04-15 Thread Tom Murphy via iommu
dma_ops_domain_free() expects domain to be in a global list. Arguably, could be called before protection_domain_init(). Signed-off-by: Dmitry Safonov Signed-off-by: Tom Murphy --- drivers/iommu/amd_iommu.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers

Re: [PATCH 5/9] iommu/amd: Implement .flush_np_cache

2019-04-15 Thread Tom Murphy via iommu
This is a cut and paste from the current amd_iommu driver. I really have no idea if it's a good idea or not. It looks like joerg.roe...@amd.com might be the person to ask. @Joerg Roedel should we keep this? On Mon, Apr 15, 2019 at 7:33 AM Christoph Hellwig wrote: > > > +static void

Re: [PATCH 3/9] iommu/dma-iommu: Add iommu_dma_copy_reserved_iova, iommu_dma_apply_resv_region to the dma-iommu api

2019-04-16 Thread Tom Murphy via iommu
I hoped this could be an exception, it's easier to grok without the line break and isn't crazy long. Because you mentioned it I'll fix it. On Mon, Apr 15, 2019 at 7:31 AM Christoph Hellwig wrote: > > On Thu, Apr 11, 2019 at 07:47:32PM +0100, Tom Murphy via iommu

Re: [PATCH 2/9] iommu/dma-iommu: Add function to flush any cached not present IOTLB entries

2019-04-16 Thread Tom Murphy via iommu
rote: > > On 11/04/2019 19:47, Tom Murphy wrote: > > Both the AMD and Intel drivers can cache not present IOTLB entries. To > > convert these drivers to the dma-iommu api we need a generic way to > > flush the NP cache. IOMMU drivers which have a NP cache can implement > &g

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

2019-06-03 Thread Tom Murphy via iommu
On Mon, Jun 3, 2019 at 11:52 AM Joerg Roedel wrote: > > Hi Tom, > > On Mon, May 06, 2019 at 07:52:02PM +0100, Tom Murphy wrote: > > Convert the AMD iommu driver to the dma-iommu api. Remove the iova > > handling and reserve region code from the AMD iommu driver. >

Re: [PATCH v1] iommu/amd: flush not present cache in iommu_map_page

2019-04-29 Thread Tom Murphy via iommu
On Mon, Apr 29, 2019 at 12:59 PM Christoph Hellwig wrote: > > On Sat, Apr 27, 2019 at 03:20:35PM +0100, Tom Murphy wrote: > > I am working on another patch to improve the intel iotlb flushing in > > the iommu ops patch which should cover this too. > > So are you looking i

[PATCH v2 4/4] iommu/amd: Convert the AMD iommu driver to the dma-iommu api

2019-04-29 Thread Tom Murphy via iommu
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 | 680 -- 2 files changed, 70 insertions

[PATCH v2 1/4] iommu: Add gfp parameter to iommu_ops::map

2019-04-29 Thread Tom Murphy via iommu
table page allocations without locks so we can safely remove the locks. Signed-off-by: Tom Murphy --- drivers/iommu/amd_iommu.c | 14 --- drivers/iommu/arm-smmu-v3.c| 2 +- drivers/iommu/arm-smmu.c | 2 +- drivers/iommu/dma-iommu.c | 6 ++--- drivers/iommu/exynos-iomm

[PATCH v2 3/4] iommu/dma-iommu: Use the dev->coherent_dma_mask

2019-04-29 Thread Tom Murphy via iommu
Use the dev->coherent_dma_mask when allocating in the dma-iommu ops api. Signed-off-by: Tom Murphy --- drivers/iommu/dma-iommu.c | 16 +--- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index c18f74ad1

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

2019-04-29 Thread Tom Murphy via iommu
::map function. -Made use of the reserve region code inside the dma-iommu api Tom Murphy (4): iommu: Add gfp parameter to iommu_ops::map iommu/dma-iommu: Handle deferred devices iommu/dma-iommu: Use the dev->coherent_dma_mask iommu/amd: Convert the AMD iommu driver to the dma-iommu

[PATCH v2 2/4] iommu/dma-iommu: Handle deferred devices

2019-04-29 Thread Tom Murphy via iommu
Handle devices which defer their attach to the iommu in the dma-iommu api Signed-off-by: Tom Murphy --- drivers/iommu/dma-iommu.c | 30 ++ 1 file changed, 30 insertions(+) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 7a96c2c8f56b

Re: [PATCH v2 2/4] iommu/dma-iommu: Handle deferred devices

2019-04-30 Thread Tom Murphy via iommu
On Tue, Apr 30, 2019 at 2:42 PM Robin Murphy wrote: > > On 30/04/2019 01:29, Tom Murphy wrote: > > Handle devices which defer their attach to the iommu in the dma-iommu api > > I've just spent a while trying to understand what this is about... > > AFAICS it's a kdump

Re: [PATCH v2 3/4] iommu/dma-iommu: Use the dev->coherent_dma_mask

2019-05-06 Thread Tom Murphy via iommu
Just to make this clear, I won't apply Christoph's patch (the one in this email thread) and instead the only change I will make is to rename dma_limit to dma_mask. On Tue, Apr 30, 2019 at 1:05 PM Robin Murphy wrote: > > On 30/04/2019 12:32, Christoph Hellwig wrote: > > On Tue, Apr 30, 2019 at

[PATCH v3 2/4] iommu/dma-iommu: Handle deferred devices

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

[PATCH v3 4/4] iommu/amd: Convert AMD iommu driver to the dma-iommu api

2019-05-06 Thread Tom Murphy via iommu
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 | 680 -- 2 files changed, 70 insertions

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

2019-05-06 Thread Tom Murphy via iommu
on top of this series: http://git.infradead.org/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 (4): iommu: Add gfp parameter to iommu_ops::map iommu/dma-iommu

[PATCH v3 3/4] iommu/dma-iommu: Use the dev->coherent_dma_mask

2019-05-06 Thread Tom Murphy via iommu
Use the dev->coherent_dma_mask when allocating in the dma-iommu ops api. Signed-off-by: Tom Murphy --- drivers/iommu/dma-iommu.c | 16 +--- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index b383498e2

[PATCH v3 1/4] iommu: Add gfp parameter to iommu_ops::map

2019-05-06 Thread Tom Murphy via iommu
table page allocations without locks so we can safely remove the locks. Signed-off-by: Tom Murphy --- drivers/iommu/amd_iommu.c | 14 --- drivers/iommu/arm-smmu-v3.c| 2 +- drivers/iommu/arm-smmu.c | 2 +- drivers/iommu/dma-iommu.c | 6 ++--- drivers/iommu/exynos-iomm

[RFC 5/7] iommu/dma-iommu: add wrapper for iommu_dma_free_cpu_cached_iovas

2019-05-04 Thread Tom Murphy via iommu
Add a wrapper for iommu_dma_free_cpu_cached_iovas in the dma-iommu api path to help with the intel-iommu driver conversion to the dma-iommu api path Signed-off-by: Tom Murphy --- drivers/iommu/dma-iommu.c | 9 + include/linux/dma-iommu.h | 3 +++ 2 files changed, 12 insertions(+) diff

[RFC 6/7] iommu/vt-d: convert the intel iommu driver to the dma-iommu ops api

2019-05-04 Thread Tom Murphy via iommu
Convert the intel iommu driver to the dma-iommu api to allow us to remove the iova handling code and the reserved region code Signed-off-by: Tom Murphy --- drivers/iommu/Kconfig | 1 + drivers/iommu/intel-iommu.c | 405 ++-- include/linux/intel-iommu.h

[RFC 7/7] iommu/vt-d: Always set DMA_PTE_READ if the iommu doens't support zero length reads

2019-05-04 Thread Tom Murphy via iommu
To match the dma-ops api path the DMA_PTE_READ should be set if ZLR isn't supported in the iommu Signed-off-by: Tom Murphy --- drivers/iommu/intel-iommu.c | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c

[RFC 3/7] iommu: improve iommu iotlb flushing

2019-05-04 Thread Tom Murphy via iommu
Add a new iommu_ops::flush_iotlb_range function which allows us to flush the entire range of an iommu_unmap and implement it for the amd and intel iommu drivers. remove the iotlb_range_add because it isn't used anywhere. Signed-off-by: Tom Murphy --- drivers/iommu/amd_iommu.c | 14

[RFC 2/7] iommu/vt-d: Remove iova handling code from non-dma ops path

2019-05-04 Thread Tom Murphy via iommu
There is no reason to keep track of the iovas in the non-dma ops path. All this code seems to be pointless and can be removed. Signed-off-by: Tom Murphy --- drivers/iommu/intel-iommu.c | 94 + 1 file changed, 33 insertions(+), 61 deletions(-) diff --git

[RFC 4/7] iommu/dma-iommu: Handle freelists in the dma-iommu api path

2019-05-04 Thread Tom Murphy via iommu
Currently the iova flush queue implementation in the dma-iommu api path doesn't handle freelists. Change the unmap_fast code to allow it to return any freelists which need to be handled. Signed-off-by: Tom Murphy --- drivers/iommu/dma-iommu.c | 39

[RFC 0/7] Convert the Intel iommu driver to the dma-ops api

2019-05-04 Thread Tom Murphy via iommu
aven't yet merged so this is just a RFC to get some feedback before I do more testing. Tom Murphy (7): iommu/vt-d: Set the dma_ops per device so we can remove the iommu_no_mapping code iommu/vt-d: Remove iova handling code from non-dma ops path iommu: improve iommu iotlb flushing iommu/dma-iom

[RFC 1/7] iommu/vt-d: Set the dma_ops per device so we can remove the iommu_no_mapping code

2019-05-04 Thread Tom Murphy via iommu
Set the dma_ops per device so we can remove the iommu_no_mapping code. Signed-off-by: Tom Murphy --- drivers/iommu/intel-iommu.c | 85 +++-- 1 file changed, 6 insertions(+), 79 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c

Re: [PATCH v3 5/8] iommu/vt-d: Implement def_domain_type iommu ops entry

2019-05-06 Thread Tom Murphy via iommu
It looks like there is a bug in this code. The behavior before this patch in __intel_map_single was that iommu_no_mapping would call remove the attached si_domain for 32 bit devices (in the dmar_remove_one_dev_info(dev) call in iommu_no_mapping) and then allocate a new domain in

Re: [RFC 1/7] iommu/vt-d: Set the dma_ops per device so we can remove the iommu_no_mapping code

2019-05-06 Thread Tom Murphy via iommu
On Mon, May 6, 2019 at 2:48 AM Lu Baolu wrote: > > Hi, > > On 5/4/19 9:23 PM, Tom Murphy wrote: > > Set the dma_ops per device so we can remove the iommu_no_mapping code. > > > > Signed-off-by: Tom Murphy > > --- > > drivers/iommu/intel-iommu.c | 85 +++

Re: [PATCH v3 1/8] iommu: Add ops entry for supported default domain type

2019-05-06 Thread Tom Murphy via iommu
The AMD driver already solves this problem and uses the generic iommu_request_dm_for_dev function. It seems like both drivers have the same problem and could use the same solution. Is there any reason we can't have use the same solution for the intel and amd driver? Could we just copy the

Re: [PATCH v1] iommu/amd: flush not present cache in iommu_map_page

2019-04-27 Thread Tom Murphy via iommu
> The iommu_map_page function is called once per physical page that is > mapped, so in the worst case for every 4k mapping established. So it is > not the right place to put this check in. Ah, you're right, that was careless of me. > From a quick glance this check belongs into the map_sg() and

[PATCH v2] iommu/amd: flush not present cache in iommu_map_page

2019-04-28 Thread Tom Murphy via iommu
check if there is a not-present cache present and flush it if there is. Signed-off-by: Tom Murphy --- drivers/iommu/amd_iommu.c | 19 +++ 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index f7cdd2ab7f11

Re: [RFC 6/7] iommu/vt-d: convert the intel iommu driver to the dma-iommu ops api

2019-05-05 Thread Tom Murphy via iommu
On Sun, May 5, 2019 at 3:44 AM Lu Baolu wrote: > > Hi, > > On 5/4/19 9:23 PM, Tom Murphy wrote: > > static int intel_iommu_add_device(struct device *dev) > > { > > + struct dmar_domain *dmar_domain; > > + struct iommu_domain *domain; > > s

Re: [PATCH] iommu/amd: flush not present cache in iommu_map_page

2019-04-24 Thread Tom Murphy via iommu
oph Hellwig wrote: > > On Wed, Apr 24, 2019 at 03:18:59PM +0100, Tom Murphy via iommu wrote: > > check if there is a not-present cache present and flush it if there is. > > > > Signed-off-by: Tom Murphy > > --- > > drivers/iommu/amd_iommu.c | 6 ++ > >

Re: [PATCH v2 3/7] iommu/vt-d: Expose ISA direct mapping region via iommu_get_resv_regions

2019-04-24 Thread Tom Murphy via iommu
I can see two potential problems with these patches that should be addressed: The default domain of a group can be changed to type IOMMU_DOMAIN_IDENTITY via the command line. With these patches we are returning the si_domain for type IOMMU_DOMAIN_IDENTITY. There's a chance the shared si_domain

[PATCH] iommu/amd: flush not present cache in iommu_map_page

2019-04-24 Thread Tom Murphy via iommu
check if there is a not-present cache present and flush it if there is. Signed-off-by: Tom Murphy --- drivers/iommu/amd_iommu.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index f7cdd2ab7f11..8ef43224aae0 100644 --- a/drivers

[PATCH v1] iommu/amd: flush not present cache in iommu_map_page

2019-04-24 Thread Tom Murphy via iommu
check if there is a not-present cache present and flush it if there is. Signed-off-by: Tom Murphy --- drivers/iommu/amd_iommu.c | 5 + 1 file changed, 5 insertions(+) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index f7cdd2ab7f11..91fe5cb10f50 100644 --- a/drivers

Re: [PATCH] iommu/amd: flush not present cache in iommu_map_page

2019-04-24 Thread Tom Murphy via iommu
On Wed, Apr 24, 2019 at 4:55 PM Joerg Roedel wrote: > > On Wed, Apr 24, 2019 at 07:58:19AM -0700, Christoph Hellwig wrote: > > I'd be tempted to do that. But lets just ask Joerg if he has > > any opinion.. > > The reason was that it is an unlikely path, as hardware implementations > are not

[PATCH 7/9] iommu/amd: Use the dma-iommu api

2019-04-11 Thread Tom Murphy via iommu
Convert the AMD iommu driver to use the dma-iommu api. Signed-off-by: Tom Murphy --- drivers/iommu/Kconfig | 1 + drivers/iommu/amd_iommu.c | 217 +- 2 files changed, 77 insertions(+), 141 deletions(-) diff --git a/drivers/iommu/Kconfig b/drivers/iommu

[PATCH 2/9] iommu/dma-iommu: Add function to flush any cached not present IOTLB entries

2019-04-11 Thread Tom Murphy via iommu
-09.pdf#page=63 Signed-off-by: Tom Murphy --- drivers/iommu/dma-iommu.c | 10 ++ include/linux/iommu.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 1a4bff3f8427..cc5da30d6e58 100644 --- a/drivers/iommu/dma

[PATCH 3/9] iommu/dma-iommu: Add iommu_dma_copy_reserved_iova, iommu_dma_apply_resv_region to the dma-iommu api

2019-04-11 Thread Tom Murphy via iommu
To convert the AMD iommu driver to the dma-iommu we need to wrap some of the iova reserve functions. Signed-off-by: Tom Murphy --- drivers/iommu/dma-iommu.c | 27 +++ include/linux/dma-iommu.h | 7 +++ 2 files changed, 34 insertions(+) diff --git a/drivers/iommu

[PATCH 6/9] iommu/amd: Implement map_atomic

2019-04-11 Thread Tom Murphy via iommu
in amd_iommu_map and amd_iommu_unmap doesn't add any real protection. The solution to this is for whatever manages the allocated iova’s externally to make sure iommu_map isn’t called twice on the same region at the same time. Signed-off-by: Tom Murphy --- drivers/iommu/amd_iommu.c | 25

[PATCH 1/9] iommu/dma-iommu: Add iommu_map_atomic

2019-04-11 Thread Tom Murphy via iommu
Signed-off-by: Tom Murphy --- drivers/iommu/arm-smmu-v3.c| 1 + drivers/iommu/arm-smmu.c | 1 + drivers/iommu/dma-iommu.c | 6 ++--- drivers/iommu/exynos-iommu.c | 1 + drivers/iommu/iommu.c | 46 +- drivers/iommu/ipmmu-vmsa.c | 1

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

2019-04-11 Thread Tom Murphy via iommu
Convert the AMD iommu driver to the dma-iommu api and remove the iova handling code from the AMD iommu driver. Tom Murphy (9): iommu/dma-iommu: Add iommu_map_atomic iommu/dma-iommu: Add function to flush any cached not present IOTLB entries iommu/dma-iommu: Add

[PATCH 5/9] iommu/amd: Implement .flush_np_cache

2019-04-11 Thread Tom Murphy via iommu
Implement flush_np_cache for the AMD iommu driver. This allows the amd iommu non present cache to be flushed if amd_iommu_np_cache is set. Signed-off-by: Tom Murphy --- drivers/iommu/amd_iommu.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/iommu/amd_iommu.c b

[PATCH 4/9] iommu/dma-iommu: Add iommu_dma_map_page_coherent

2019-04-11 Thread Tom Murphy via iommu
Add iommu_dma_map_page_coherent function to allow mapping pages through the dma-iommu api using the dev->coherent_dma_mask mask instead of the dev->dma_mask mask Signed-off-by: Tom Murphy --- drivers/iommu/dma-iommu.c | 25 - include/linux/dma-iommu.h | 3 +++ 2

[PATCH 9/9] iommu/amd: Add allocated domain to global list earlier

2019-04-11 Thread Tom Murphy via iommu
dma_ops_domain_free() expects domain to be in a global list. Arguably, could be called before protection_domain_init(). Signed-off-by: Dmitry Safonov Signed-off-by: Tom Murphy --- drivers/iommu/amd_iommu.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers

[PATCH] Remove old no iommu direct mapping code

2019-04-23 Thread Tom Murphy via iommu
These checks were intended to handle devices not mapped by the IOMMU. Since the AMD IOMMU driver uses per-device dma_ops these functions can no longer be called by direct mapped devices. So these checks aren't needed anymore. Signed-off-by: Tom Murphy --- drivers/iommu/amd_iommu.c | 10