Re: [PATCH 08/15] iommu/arm-smmu: Abstract context bank accesses

2019-08-15 Thread Robin Murphy
On 15/08/2019 11:56, Will Deacon wrote: On Fri, Aug 09, 2019 at 06:07:45PM +0100, Robin Murphy wrote: Context bank accesses are fiddly enough to deserve a number of extra helpers to keep the callsites looking sane, even though there are only one or two of each. Signed-off-by: Robin Murphy ---

Re: [PATCH 15/15] iommu/arm-smmu: Add context init implementation hook

2019-08-15 Thread Robin Murphy
On 15/08/2019 11:56, Will Deacon wrote: On Fri, Aug 09, 2019 at 06:07:52PM +0100, Robin Murphy wrote: Allocating and initialising a context for a domain is another point where certain implementations are known to want special behaviour. Currently the other half of the Cavium workaround comes

Re: [PATCH 08/10] iommu: Set default domain type at runtime

2019-08-15 Thread Lu Baolu
Hi, On 8/14/19 9:38 PM, Joerg Roedel wrote: From: Joerg Roedel Set the default domain-type at runtime, not at compile-time. This keeps default domain type setting in one place when we have to change it at runtime. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 23

Re: [PATCH 05/15] iommu/arm-smmu: Split arm_smmu_tlb_inv_range_nosync()

2019-08-15 Thread Robin Murphy
On 15/08/2019 11:56, Will Deacon wrote: On Fri, Aug 09, 2019 at 06:07:42PM +0100, Robin Murphy wrote: Since we now use separate iommu_gather_ops for stage 1 and stage 2 contexts, we may as well divide up the monolithic callback into its respective stage 1 and stage 2 parts. Signed-off-by:

[PATCH v2 1/2] iommu/iova: introduce iova_magazine_compact_pfns()

2019-08-15 Thread Zhen Lei
iova_magazine_free_pfns() can only free the whole magazine buffer, add iova_magazine_compact_pfns() to support free part of it. Signed-off-by: Zhen Lei --- drivers/iommu/iova.c | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/iova.c

[PATCH v2 2/2] iommu/iova: enhance the rcache optimization

2019-08-15 Thread Zhen Lei
The rcache method caches the freed IOVAs, to improve the performance of IOVAs allocation and release. This is usually okay, but it maybe declined in some special scenarios. For example, currently the IOVA_RANGE_CACHE_MAX_SIZE is 6, and for ecch size, contains: MAX_GLOBAL_MAGS=32 shareable depot

[PATCH v2 0/2] iommu/iova: enhance the rcache optimization

2019-08-15 Thread Zhen Lei
v1 --> v2 1. I did not chagne the patches but added this cover-letter. 2. Add a batch of reviewers base on 9257b4a206fc ("iommu/iova: introduce per-cpu caching to iova allocation") 3. I described the problem I met in patch 2, but I hope below brief description can help people to quickly

Re: [PATCH 6/6] driver core: initialize a default DMA mask for platform device

2019-08-15 Thread Greg Kroah-Hartman
On Sun, Aug 11, 2019 at 10:05:20AM +0200, Christoph Hellwig wrote: > We still treat devices without a DMA mask as defaulting to 32-bits for > both mask, but a few releases ago we've started warning about such > cases, as they require special cases to work around this sloppyness. > Add a dma_mask

Re: DMA-API: cacheline tracking ENOMEM, dma-debug disabled due to nouveau ?

2019-08-15 Thread Robin Murphy
On 15/08/2019 14:35, Christoph Hellwig wrote: On Wed, Aug 14, 2019 at 07:49:27PM +0200, Daniel Vetter wrote: On Wed, Aug 14, 2019 at 04:50:33PM +0200, Corentin Labbe wrote: Hello Since lot of release (at least since 4.19), I hit the following error message: DMA-API: cacheline tracking ENOMEM,

Re: [PATCH 02/13] iommu/io-pgtable-arm: Remove redundant call to io_pgtable_tlb_sync()

2019-08-15 Thread Will Deacon
Hi Robin, On Thu, Aug 15, 2019 at 01:43:11PM +0100, Robin Murphy wrote: > On 14/08/2019 18:56, Will Deacon wrote: > > Commit b6b65ca20bc9 ("iommu/io-pgtable-arm: Add support for non-strict > > mode") added an unconditional call to io_pgtable_tlb_sync() immediately > > after the case where we

Re: [PATCH 02/13] iommu/io-pgtable-arm: Remove redundant call to io_pgtable_tlb_sync()

2019-08-15 Thread Robin Murphy
On 14/08/2019 18:56, Will Deacon wrote: Commit b6b65ca20bc9 ("iommu/io-pgtable-arm: Add support for non-strict mode") added an unconditional call to io_pgtable_tlb_sync() immediately after the case where we replace a block entry with a table entry during an unmap() call. This is redundant, since

Re: next take at setting up a dma mask by default for platform devices

2019-08-15 Thread Alan Stern
On Thu, 15 Aug 2019, Christoph Hellwig wrote: > On Thu, Aug 15, 2019 at 03:23:18PM +0200, Greg Kroah-Hartman wrote: > > I've taken the first 2 patches for 5.3-final. Given that patch 3 needs > > to be fixed, I'll wait for a respin of these before considering them. > > I have a respun version

Re: next take at setting up a dma mask by default for platform devices

2019-08-15 Thread Christoph Hellwig
On Thu, Aug 15, 2019 at 03:23:18PM +0200, Greg Kroah-Hartman wrote: > I've taken the first 2 patches for 5.3-final. Given that patch 3 needs > to be fixed, I'll wait for a respin of these before considering them. I have a respun version ready, but I'd really like to hear some comments from usb

Re: [PATCH 6/6] driver core: initialize a default DMA mask for platform device

2019-08-15 Thread Christoph Hellwig
On Wed, Aug 14, 2019 at 04:49:13PM +0100, Robin Murphy wrote: >> because we have to support platform_device structures that are >> statically allocated. > > This would be a good point to also get rid of the long-standing bodge in > platform_device_register_full(). platform_device_register_full

Re: next take at setting up a dma mask by default for platform devices

2019-08-15 Thread Greg Kroah-Hartman
On Thu, Aug 15, 2019 at 03:25:31PM +0200, Christoph Hellwig wrote: > On Thu, Aug 15, 2019 at 03:23:18PM +0200, Greg Kroah-Hartman wrote: > > I've taken the first 2 patches for 5.3-final. Given that patch 3 needs > > to be fixed, I'll wait for a respin of these before considering them. > > I have

Re: [PATCH v9 08/21] iommu/io-pgtable-arm-v7s: Extend MediaTek 4GB Mode

2019-08-15 Thread Will Deacon
Ok, I think speaking to Robin helped me a bit with this... On Thu, Aug 15, 2019 at 06:18:38PM +0800, Yong Wu wrote: > On Thu, 2019-08-15 at 10:51 +0100, Will Deacon wrote: > > On Thu, Aug 15, 2019 at 04:47:49PM +0800, Yong Wu wrote: > > > On Wed, 2019-08-14 at 15:41 +0100, Will Deacon wrote: > >

Re: next take at setting up a dma mask by default for platform devices

2019-08-15 Thread Greg Kroah-Hartman
On Sun, Aug 11, 2019 at 10:05:14AM +0200, Christoph Hellwig wrote: > Hi all, > > this is another attempt to make sure the dma_mask pointer is always > initialized for platform devices. Not doing so lead to lots of > boilerplate code, and makes platform devices different from all our > major

Re: [PATCH 6/6] driver core: initialize a default DMA mask for platform device

2019-08-15 Thread Christoph Hellwig
On Thu, Aug 15, 2019 at 03:03:25PM +0200, Greg Kroah-Hartman wrote: > > --- a/include/linux/platform_device.h > > +++ b/include/linux/platform_device.h > > @@ -24,6 +24,7 @@ struct platform_device { > > int id; > > boolid_auto; > > struct device dev; > > +

Re: [PATCH 00/13] Rework IOMMU API to allow for batching of invalidation

2019-08-15 Thread Will Deacon
On Thu, Aug 15, 2019 at 12:19:58PM +0100, John Garry wrote: > On 14/08/2019 18:56, Will Deacon wrote: > > If you'd like to play with the patches, then I've also pushed them here: > > > > > > https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/log/?h=iommu/unmap > > > > but they

Re: [PATCH 00/13] Rework IOMMU API to allow for batching of invalidation

2019-08-15 Thread John Garry
On 14/08/2019 18:56, Will Deacon wrote: Hi everybody, These are the core IOMMU changes that I have posted previously as part of my ongoing effort to reduce the lock contention of the SMMUv3 command queue. I thought it would be better to split this out as a separate series, since I think it's

Re: DMA-API: cacheline tracking ENOMEM, dma-debug disabled due to nouveau ?

2019-08-15 Thread Christoph Hellwig
On Wed, Aug 14, 2019 at 07:49:27PM +0200, Daniel Vetter wrote: > On Wed, Aug 14, 2019 at 04:50:33PM +0200, Corentin Labbe wrote: > > Hello > > > > Since lot of release (at least since 4.19), I hit the following error > > message: > > DMA-API: cacheline tracking ENOMEM, dma-debug disabled > > >

Re: [PATCH 6/6] driver core: initialize a default DMA mask for platform device

2019-08-15 Thread Greg Kroah-Hartman
On Thu, Aug 15, 2019 at 03:38:12PM +0200, Christoph Hellwig wrote: > On Thu, Aug 15, 2019 at 03:03:25PM +0200, Greg Kroah-Hartman wrote: > > > --- a/include/linux/platform_device.h > > > +++ b/include/linux/platform_device.h > > > @@ -24,6 +24,7 @@ struct platform_device { > > > int

Re: [PATCH 02/13] iommu/io-pgtable-arm: Remove redundant call to io_pgtable_tlb_sync()

2019-08-15 Thread Robin Murphy
On 15/08/2019 14:57, Will Deacon wrote: Hi Robin, On Thu, Aug 15, 2019 at 01:43:11PM +0100, Robin Murphy wrote: On 14/08/2019 18:56, Will Deacon wrote: Commit b6b65ca20bc9 ("iommu/io-pgtable-arm: Add support for non-strict mode") added an unconditional call to io_pgtable_tlb_sync()

Re: [PATCH v8 05/14] media: rkisp1: add Rockchip ISP1 subdev driver

2019-08-15 Thread Tomasz Figa
On Thu, Aug 15, 2019 at 5:25 PM Sakari Ailus wrote: > > Hi Helen, > > On Wed, Aug 14, 2019 at 09:58:05PM -0300, Helen Koike wrote: > > ... > > > >> +static int rkisp1_isp_sd_set_fmt(struct v4l2_subdev *sd, > > >> + struct v4l2_subdev_pad_config *cfg, > > >> +

[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

[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 06/10] iommu: Remember when default domain type was set on kernel command line

2019-08-15 Thread Joerg Roedel
Hey Lu Baolu, thanks for your review! On Thu, Aug 15, 2019 at 01:01:57PM +0800, Lu Baolu wrote: > > +#define IOMMU_CMD_LINE_DMA_API (1 << 0) > > Prefer BIT() micro? Yes, I'll change that. > > + iommu_set_cmd_line_dma_api(); > > IOMMU command line is also set in other places,

Re: [PATCH 04/15] iommu/arm-smmu: Rework cb_base handling

2019-08-15 Thread Robin Murphy
On 14/08/2019 19:05, Will Deacon wrote: On Fri, Aug 09, 2019 at 06:07:41PM +0100, Robin Murphy wrote: To keep register-access quirks manageable, we want to structure things to avoid needing too many individual overrides. It seems fairly clean to have a single interface which handles both global

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

2019-08-15 Thread Tom Murphy
Done, I just sent it there. I don't have any AMD hardware to test on while I'm traveling. However the rebase was very straightforward and the code was tested a month ago on the old linux-next. I only have the AMD conversion done. I will work on rebasing the intel one when I get a chance. On Tue,

Re: [PATCH v9 08/21] iommu/io-pgtable-arm-v7s: Extend MediaTek 4GB Mode

2019-08-15 Thread Will Deacon
On Thu, Aug 15, 2019 at 04:47:49PM +0800, Yong Wu wrote: > On Wed, 2019-08-14 at 15:41 +0100, Will Deacon wrote: > > On Sat, Aug 10, 2019 at 03:58:08PM +0800, Yong Wu wrote: > > > MediaTek extend the arm v7s descriptor to support the dram over 4GB. > > > > > > In the mt2712 and mt8173, it's

Re: [PATCH 00/15] Arm SMMU refactoring

2019-08-15 Thread Will Deacon
Hi Robin, On Fri, Aug 09, 2019 at 06:07:37PM +0100, Robin Murphy wrote: > This is a big refactoring of arm-smmu in order to help cope with the > various divergent implementation details currently flying around. So > far we've been accruing various quirks and errata workarounds within > the main

Re: [PATCH 08/15] iommu/arm-smmu: Abstract context bank accesses

2019-08-15 Thread Will Deacon
On Fri, Aug 09, 2019 at 06:07:45PM +0100, Robin Murphy wrote: > Context bank accesses are fiddly enough to deserve a number of extra > helpers to keep the callsites looking sane, even though there are only > one or two of each. > > Signed-off-by: Robin Murphy > --- > drivers/iommu/arm-smmu.c |

Re: [PATCH 15/15] iommu/arm-smmu: Add context init implementation hook

2019-08-15 Thread Will Deacon
On Fri, Aug 09, 2019 at 06:07:52PM +0100, Robin Murphy wrote: > Allocating and initialising a context for a domain is another point > where certain implementations are known to want special behaviour. > Currently the other half of the Cavium workaround comes into play here, > so let's finish the

Re: [PATCH 05/15] iommu/arm-smmu: Split arm_smmu_tlb_inv_range_nosync()

2019-08-15 Thread Will Deacon
On Fri, Aug 09, 2019 at 06:07:42PM +0100, Robin Murphy wrote: > Since we now use separate iommu_gather_ops for stage 1 and stage 2 > contexts, we may as well divide up the monolithic callback into its > respective stage 1 and stage 2 parts. > > Signed-off-by: Robin Murphy > --- >

[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

[PATCH V5 0/5] iommu/amd: Convert the 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. Change-log: V5: -Rebase on top of linux-next V4: -Rebase on top of linux-next -Split the removing of the unnecessary locking in the amd iommu driver into a seperate

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

2019-08-15 Thread Tom Murphy
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 iommu_map function which calls it) was always supposed to be sleepable (according to Joerg's comment in this thread:

[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 v9 0/5] treewide: improve R-Car SDHI performance

2019-08-15 Thread Christoph Hellwig
So, what are we going to do with this series? As said before I'd volunteer to pick this up through the dma-mapping tree, but I'd like to see ACKs from the other maintainers as well. ___ iommu mailing list iommu@lists.linux-foundation.org

Re: [PATCH v3 hmm 08/11] drm/radeon: use mmu_notifier_get/put for struct radeon_mn

2019-08-15 Thread Christian König
Am 07.08.19 um 01:15 schrieb Jason Gunthorpe: From: Jason Gunthorpe radeon is using a device global hash table to track what mmu_notifiers have been registered on struct mm. This is better served with the new get/put scheme instead. radeon has a bug where it was not blocking notifier

Re: [PATCH v9 08/21] iommu/io-pgtable-arm-v7s: Extend MediaTek 4GB Mode

2019-08-15 Thread Yong Wu
On Wed, 2019-08-14 at 15:41 +0100, Will Deacon wrote: > Hi Yong Wu, > > Sorry, but I'm still deeply confused by this patch. Sorry for this. the "4GB mode" really is a bit odd... > > On Sat, Aug 10, 2019 at 03:58:08PM +0800, Yong Wu wrote: > > MediaTek extend the arm v7s descriptor to support

Re: [PATCH v8 05/14] media: rkisp1: add Rockchip ISP1 subdev driver

2019-08-15 Thread Sakari Ailus
On Thu, Aug 15, 2019 at 07:29:59PM +0900, Tomasz Figa wrote: > On Thu, Aug 15, 2019 at 5:25 PM Sakari Ailus > wrote: > > > > Hi Helen, > > > > On Wed, Aug 14, 2019 at 09:58:05PM -0300, Helen Koike wrote: > > > > ... > > > > > >> +static int rkisp1_isp_sd_set_fmt(struct v4l2_subdev *sd, > > > >> +

Re: [PATCH 7/8] parisc: don't set ARCH_NO_COHERENT_DMA_MMAP

2019-08-15 Thread James Bottomley
On Thu, 2019-08-08 at 19:00 +0300, Christoph Hellwig wrote: > parisc is the only architecture that sets ARCH_NO_COHERENT_DMA_MMAP > when an MMU is enabled. AFAIK this is because parisc CPUs use VIVT > caches, We're actually VIPT but the same principle applies. > which means exporting normally

Re: [PATCH 7/8] parisc: don't set ARCH_NO_COHERENT_DMA_MMAP

2019-08-15 Thread Christoph Hellwig
On Thu, Aug 15, 2019 at 10:25:52AM +0100, James Bottomley wrote: > > which means exporting normally cachable memory to userspace is > > relatively dangrous due to cache aliasing. > > > > But normally cachable memory is only allocated by dma_alloc_coherent > > on parisc when using the sba_iommu

Re: [PATCH v6 5/8] iommu: Add bounce page APIs

2019-08-15 Thread Lu Baolu
Hi Joerg, On 8/14/19 4:38 PM, Joerg Roedel wrote: Hi Lu Baolu, On Tue, Jul 30, 2019 at 12:52:26PM +0800, Lu Baolu wrote: * iommu_bounce_map(dev, addr, paddr, size, dir, attrs) - Map a buffer start at DMA address @addr in bounce page manner. For buffer parts that doesn't cross a whole

Re: [PATCH 7/8] parisc: don't set ARCH_NO_COHERENT_DMA_MMAP

2019-08-15 Thread Christoph Hellwig
Helger, or other parisc folks: can you take a look at this patch in particular and the series in general? Thanks!

Re: [PATCH v9 08/21] iommu/io-pgtable-arm-v7s: Extend MediaTek 4GB Mode

2019-08-15 Thread Yong Wu
On Thu, 2019-08-15 at 10:51 +0100, Will Deacon wrote: > On Thu, Aug 15, 2019 at 04:47:49PM +0800, Yong Wu wrote: > > On Wed, 2019-08-14 at 15:41 +0100, Will Deacon wrote: > > > On Sat, Aug 10, 2019 at 03:58:08PM +0800, Yong Wu wrote: > > > > MediaTek extend the arm v7s descriptor to support the

Re: [PATCH v9 08/21] iommu/io-pgtable-arm-v7s: Extend MediaTek 4GB Mode

2019-08-15 Thread Will Deacon
On Thu, Aug 15, 2019 at 06:03:30PM +0800, Yong Wu wrote: > On Thu, 2019-08-15 at 10:51 +0100, Will Deacon wrote: > > On Thu, Aug 15, 2019 at 04:47:49PM +0800, Yong Wu wrote: > > > On Wed, 2019-08-14 at 15:41 +0100, Will Deacon wrote: > > > > On Sat, Aug 10, 2019 at 03:58:08PM +0800, Yong Wu wrote:

Re: [PATCH v9 08/21] iommu/io-pgtable-arm-v7s: Extend MediaTek 4GB Mode

2019-08-15 Thread Yong Wu
On Thu, 2019-08-15 at 10:51 +0100, Will Deacon wrote: > On Thu, Aug 15, 2019 at 04:47:49PM +0800, Yong Wu wrote: > > On Wed, 2019-08-14 at 15:41 +0100, Will Deacon wrote: > > > On Sat, Aug 10, 2019 at 03:58:08PM +0800, Yong Wu wrote: > > > > MediaTek extend the arm v7s descriptor to support the

Re: [PATCH 15/15] iommu/arm-smmu: Add context init implementation hook

2019-08-15 Thread Jordan Crouse
On Thu, Aug 15, 2019 at 01:09:07PM +0100, Robin Murphy wrote: > On 15/08/2019 11:56, Will Deacon wrote: > >On Fri, Aug 09, 2019 at 06:07:52PM +0100, Robin Murphy wrote: > >>Allocating and initialising a context for a domain is another point > >>where certain implementations are known to want

Messages to kexec@ get moderated (was: Crash kernel with 256 MB reserved memory runs into OOM condition)

2019-08-15 Thread Paul Menzel
Dear Dave, On 13.08.19 04:46, Dave Young wrote: > On 08/13/19 at 10:43am, Dave Young wrote: […] > The question is to Paul, also it would be always good to cc kexec mail > list for kexec and kdump issues. kexec@ was CCed in my original mail, but my messages got moderated. It’d great if you

Re: [PATCH v2 2/2] iommu/arm-smmu-v3: add nr_ats_masters for quickly check

2019-08-15 Thread Will Deacon
On Thu, Aug 15, 2019 at 01:44:39PM +0800, Zhen Lei wrote: > When (smmu_domain->smmu->features & ARM_SMMU_FEAT_ATS) is true, even if a > smmu domain does not contain any ats master, the operations of > arm_smmu_atc_inv_to_cmd() and lock protection in arm_smmu_atc_inv_domain() > are always executed.

Re: [PATCH v6 5/8] iommu: Add bounce page APIs

2019-08-15 Thread Joerg Roedel
On Thu, Aug 15, 2019 at 02:15:32PM +0800, Lu Baolu wrote: > iommu_map/unmap() APIs haven't parameters for dma direction and > attributions. These parameters are elementary for DMA APIs. Say, > after map, if the dma direction is TO_DEVICE and a bounce buffer is > used, we must sync the data from

Re: [PATCH v3 1/2] iommu/io-pgtable-arm: Add support for ARM_ADRENO_GPU_LPAE io-pgtable format

2019-08-15 Thread Jordan Crouse
On Wed, Aug 07, 2019 at 04:21:39PM -0600, Jordan Crouse wrote: > Add a new sub-format ARM_ADRENO_GPU_LPAE to set up TTBR0 and TTBR1 for > use by the Adreno GPU. This will allow The GPU driver to map global > buffers in the TTBR1 and leave the TTBR0 configured but unset and > free to be changed

Re: [Freedreno] [PATCH v3 0/2] iommu/arm-smmu: Split pagetable support

2019-08-15 Thread Jordan Crouse
On Wed, Aug 07, 2019 at 04:21:38PM -0600, Jordan Crouse wrote: > (Sigh, resend. I freaked out my SMTP server) > > This is part of an ongoing evolution for enabling split pagetable support for > arm-smmu. Previous versions can be found [1]. > > In the discussion for v2 Robin pointed out that this

Re: [PATCH v3 hmm 08/11] drm/radeon: use mmu_notifier_get/put for struct radeon_mn

2019-08-15 Thread Jason Gunthorpe
On Thu, Aug 15, 2019 at 10:28:21AM +0200, Christian König wrote: > Am 07.08.19 um 01:15 schrieb Jason Gunthorpe: > > From: Jason Gunthorpe > > > > radeon is using a device global hash table to track what mmu_notifiers > > have been registered on struct mm. This is better served with the new > >

Re: [PATCH v5 16/19] iommu/vt-d: Misc macro clean up for SVM

2019-08-15 Thread Andy Shevchenko
On Thu, Aug 15, 2019 at 11:52 PM Jacob Pan wrote: > > Use combined macros for_each_svm_dev() to simplify SVM device iteration > and error checking. > > Suggested-by: Andy Shevchenko > Signed-off-by: Jacob Pan > Reviewed-by: Eric Auger > --- > drivers/iommu/intel-svm.c | 85 >

Re: [PATCH v5 4/7] PCI/ATS: Add PRI support for PCIe VF devices

2019-08-15 Thread Kuppuswamy Sathyanarayanan
On 8/15/19 3:20 PM, Bjorn Helgaas wrote: [+cc Joerg, David, iommu list: because IOMMU drivers are the only callers of pci_enable_pri() and pci_enable_pasid()] On Thu, Aug 01, 2019 at 05:06:01PM -0700, sathyanarayanan.kuppusw...@linux.intel.com wrote: From: Kuppuswamy Sathyanarayanan When

Re: [PATCH v5 16/19] iommu/vt-d: Misc macro clean up for SVM

2019-08-15 Thread Jacob Pan
On Fri, 16 Aug 2019 00:17:44 +0300 Andy Shevchenko wrote: > On Thu, Aug 15, 2019 at 11:52 PM Jacob Pan > wrote: > > > > Use combined macros for_each_svm_dev() to simplify SVM device > > iteration and error checking. > > > > Suggested-by: Andy Shevchenko > > Signed-off-by: Jacob Pan > >

Re: [PATCH v5 4/7] PCI/ATS: Add PRI support for PCIe VF devices

2019-08-15 Thread Bjorn Helgaas
[+cc Joerg, David, iommu list: because IOMMU drivers are the only callers of pci_enable_pri() and pci_enable_pasid()] On Thu, Aug 01, 2019 at 05:06:01PM -0700, sathyanarayanan.kuppusw...@linux.intel.com wrote: > From: Kuppuswamy Sathyanarayanan > > When IOMMU tries to enable Page Request

[PATCH v2 11/17] iommu/arm-smmu: Abstract GR0 accesses

2019-08-15 Thread Robin Murphy
Clean up the remaining accesses to GR0 registers, so that everything is now neatly abstracted. This folds up the Non-Secure alias quirk as the first step towards moving it out of the way entirely. Although GR0 does technically contain some 64-bit registers (sGFAR and the weird SMMUv2 HYPC and MONC

[PATCH v5 04/19] iommu: Use device fault trace event

2019-08-15 Thread Jacob Pan
From: Jean-Philippe Brucker For performance and debugging purposes, these trace events help analyzing device faults that interact with IOMMU subsystem. E.g. IOMMU::00:0a.0 type=2 reason=0 addr=0x007ff000 pasid=1 group=1 last=0 prot=1 Signed-off-by: Jacob Pan [JPB: removed

[PATCH v5 00/19] Shared virtual address IOMMU and VT-d support

2019-08-15 Thread Jacob Pan
Shared virtual address (SVA), a.k.a, Shared virtual memory (SVM) on Intel platforms allow address space sharing between device DMA and applications. SVA can reduce programming complexity and enhance security. This series is intended to enable SVA virtualization, i.e. shared guest application

[PATCH v5 10/19] iommu/vt-d: Enlightened PASID allocation

2019-08-15 Thread Jacob Pan
From: Lu Baolu If Intel IOMMU runs in caching mode, a.k.a. virtual IOMMU, the IOMMU driver should rely on the emulation software to allocate and free PASID IDs. The Intel vt-d spec revision 3.0 defines a register set to support this. This includes a capability register, a virtual command

[PATCH v5 01/19] iommu: Add a timeout parameter for PRQ response

2019-08-15 Thread Jacob Pan
When an I/O page request is processed outside the IOMMU subsystem, response can be delayed or lost. Add a tunable setup parameter such that user can choose the timeout for IOMMU to track pending page requests. This timeout mechanism is a basic safety net which can be implemented in conjunction

[PATCH v5 06/19] iommu: Introduce cache_invalidate API

2019-08-15 Thread Jacob Pan
From: Yi L Liu In any virtualization use case, when the first translation stage is "owned" by the guest OS, the host IOMMU driver has no knowledge of caching structure updates unless the guest invalidation activities are trapped by the virtualizer and passed down to the host. Since the

[PATCH v5 05/19] iommu: Introduce attach/detach_pasid_table API

2019-08-15 Thread Jacob Pan
In virtualization use case, when a guest is assigned a PCI host device, protected by a virtual IOMMU on the guest, the physical IOMMU must be programmed to be consistent with the guest mappings. If the physical IOMMU supports two translation stages it makes sense to program guest mappings onto the

[PATCH v5 15/19] iommu/vt-d: Add nested translation helper function

2019-08-15 Thread Jacob Pan
Nested translation mode is supported in VT-d 3.0 Spec.CH 3.8. With PASID granular translation type set to 0x11b, translation result from the first level(FL) also subject to a second level(SL) page table translation. This mode is used for SVA virtualization, where FL performs guest virtual to guest

[PATCH v5 13/19] iommu/vt-d: Move domain helper to header

2019-08-15 Thread Jacob Pan
Move domain helper to header to be used by SVA code. Signed-off-by: Jacob Pan Reviewed-by: Eric Auger --- drivers/iommu/intel-iommu.c | 6 -- include/linux/intel-iommu.h | 6 ++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/intel-iommu.c

[PATCH v2 15/17] iommu/arm-smmu: Add configuration implementation hook

2019-08-15 Thread Robin Murphy
Probing the ID registers and setting up the SMMU configuration is an area where overrides and workarounds may well be needed. Indeed, the Cavium workaround detection lives there at the moment, so let's break that out. Signed-off-by: Robin Murphy --- drivers/iommu/arm-smmu-impl.c | 34

[PATCH v2 16/17] iommu/arm-smmu: Add reset implementation hook

2019-08-15 Thread Robin Murphy
Reset is an activity rife with implementation-defined poking. Add a corresponding hook, and use it to encapsulate the existing MMU-500 details. Signed-off-by: Robin Murphy --- drivers/iommu/arm-smmu-impl.c | 49 +++ drivers/iommu/arm-smmu.c | 39

[PATCH v2 17/17] iommu/arm-smmu: Add context init implementation hook

2019-08-15 Thread Robin Murphy
Allocating and initialising a context for a domain is another point where certain implementations are known to want special behaviour. Currently the other half of the Cavium workaround comes into play here, so let's finish the job to get the whole thing right out of the way. Signed-off-by: Robin

[PATCH v2 14/17] iommu/arm-smmu: Move Secure access quirk to implementation

2019-08-15 Thread Robin Murphy
Move detection of the Secure access quirk to its new home, trimming it down in the process - time has proven that boolean DT flags are neither ideal nor necessarily sufficient, so it's highly unlikely we'll ever add more, let alone enough to justify the frankly overengineered parsing machinery.

[PATCH v2 13/17] iommu/arm-smmu: Add implementation infrastructure

2019-08-15 Thread Robin Murphy
Add some nascent infrastructure for handling implementation-specific details outside the flow of the architectural code. This will allow us to keep mutually-incompatible vendor-specific hooks in their own files where the respective interested parties can maintain them with minimal chance of

[PATCH v2 10/17] iommu/arm-smmu: Abstract context bank accesses

2019-08-15 Thread Robin Murphy
Context bank accesses are fiddly enough to deserve a number of extra helpers to keep the callsites looking sane, even though there are only one or two of each. Signed-off-by: Robin Murphy --- drivers/iommu/arm-smmu.c | 138 +-- 1 file changed, 73

[PATCH v2 09/17] iommu/arm-smmu: Abstract GR1 accesses

2019-08-15 Thread Robin Murphy
Introduce some register access abstractions which we will later use to encapsulate various quirks. GR1 is the easiest page to start with. Signed-off-by: Robin Murphy --- drivers/iommu/arm-smmu.c | 34 +++--- 1 file changed, 27 insertions(+), 7 deletions(-) diff

[PATCH v2 12/17] iommu/arm-smmu: Rename arm-smmu-regs.h

2019-08-15 Thread Robin Murphy
We're about to start using it for more than just register definitions, so generalise the name. Signed-off-by: Robin Murphy --- drivers/iommu/arm-smmu.c | 2 +- drivers/iommu/{arm-smmu-regs.h => arm-smmu.h} | 6 +++--- drivers/iommu/qcom_iommu.c| 2 +- 3

[PATCH v2 07/17] iommu/arm-smmu: Split arm_smmu_tlb_inv_range_nosync()

2019-08-15 Thread Robin Murphy
Since we now use separate iommu_gather_ops for stage 1 and stage 2 contexts, we may as well divide up the monolithic callback into its respective stage 1 and stage 2 parts. Signed-off-by: Robin Murphy --- drivers/iommu/arm-smmu.c | 66 ++-- 1 file changed, 37

[PATCH v2 03/17] iommu/arm-smmu: Convert GR0 registers to bitfields

2019-08-15 Thread Robin Murphy
FIELD_PREP remains a terrible name, but the overall simplification will make further work on this stuff that much more manageable. This also serves as an audit of the header, wherein we can impose a consistent grouping and ordering of the offset and field definitions Signed-off-by: Robin Murphy

[PATCH v2 02/17] iommu/qcom: Mask TLBI addresses correctly

2019-08-15 Thread Robin Murphy
As with arm-smmu from whence this code was borrowed, the IOVAs passed in here happen to be at least page-aligned anyway, but still; oh dear. Signed-off-by: Robin Murphy --- drivers/iommu/qcom_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/qcom_iommu.c

[PATCH v2 05/17] iommu/arm-smmu: Convert context bank registers to bitfields

2019-08-15 Thread Robin Murphy
Finish the final part of the job, once again updating some names to match the current spec. Signed-off-by: Robin Murphy --- drivers/iommu/arm-smmu-regs.h | 86 ++- drivers/iommu/arm-smmu.c | 16 +++ drivers/iommu/qcom_iommu.c| 13 +++--- 3 files

[PATCH v2 08/17] iommu/arm-smmu: Get rid of weird "atomic" write

2019-08-15 Thread Robin Murphy
The smmu_write_atomic_lq oddity made some sense when the context format was effectively tied to CONFIG_64BIT, but these days it's simpler to just pick an explicit access size based on the format for the one-and-a-half times we actually care. Signed-off-by: Robin Murphy ---

[PATCH v2 06/17] iommu/arm-smmu: Rework cb_base handling

2019-08-15 Thread Robin Murphy
To keep register-access quirks manageable, we want to structure things to avoid needing too many individual overrides. It seems fairly clean to have a single interface which handles both global and context registers in terms of the architectural pages, so the first preparatory step is to rework

[PATCH v2 04/17] iommu/arm-smmu: Convert GR1 registers to bitfields

2019-08-15 Thread Robin Murphy
As for GR0, use the bitfield helpers to make GR1 usage a little cleaner, and use it as an opportunity to audit and tidy the definitions. This tweaks the handling of CBAR types to match what we did for S2CR a while back, and fixes a couple of names which didn't quite match the latest architecture

[PATCH v5 03/19] trace/iommu: Add sva trace events

2019-08-15 Thread Jacob Pan
From: Jean-Philippe Brucker For development only, trace I/O page faults and responses. Signed-off-by: Jacob Pan [JPB: removed the invalidate trace event, that will be added later] Signed-off-by: Jean-Philippe Brucker Signed-off-by: Jacob Pan --- include/trace/events/iommu.h | 84

[PATCH v5 02/19] iommu: handle page response timeout

2019-08-15 Thread Jacob Pan
When IO page faults are reported outside IOMMU subsystem, the page request handler may fail for various reasons. E.g. a guest received page requests but did not have a chance to run for a long time. The irresponsive behavior could hold off limited resources on the pending device. There can be

[PATCH v5 19/19] iommu/vt-d: Add svm/sva invalidate function

2019-08-15 Thread Jacob Pan
When Shared Virtual Address (SVA) is enabled for a guest OS via vIOMMU, we need to provide invalidation support at IOMMU API and driver level. This patch adds Intel VT-d specific function to implement iommu passdown invalidate API for shared virtual address. The use case is for supporting caching

[PATCH v5 07/19] iommu: Add I/O ASID allocator

2019-08-15 Thread Jacob Pan
From: Jean-Philippe Brucker Some devices might support multiple DMA address spaces, in particular those that have the PCI PASID feature. PASID (Process Address Space ID) allows to share process address spaces with devices (SVA), partition a device into VM-assignable entities (VFIO mdev) or

[PATCH v5 09/19] iommu: Introduce guest PASID bind function

2019-08-15 Thread Jacob Pan
Guest shared virtual address (SVA) may require host to shadow guest PASID tables. Guest PASID can also be allocated from the host via enlightened interfaces. In this case, guest needs to bind the guest mm, i.e. cr3 in guest physical address to the actual PASID table in the host IOMMU. Nesting will

[PATCH v5 08/19] iommu/ioasid: Add custom allocators

2019-08-15 Thread Jacob Pan
Custom IOASID allocators can be registered at runtime and take precedence over the default XArray allocator. They have these attributes: - provides platform specific alloc()/free() functions with private data. - allocation results lookup are not provided by the allocator, lookup request must be

[PATCH v5 11/19] iommu/vt-d: Add custom allocator for IOASID

2019-08-15 Thread Jacob Pan
When VT-d driver runs in the guest, PASID allocation must be performed via virtual command interface. This patch registers a custom IOASID allocator which takes precedence over the default XArray based allocator. The resulting IOASID allocation will always come from the host. This ensures that

[PATCH v5 14/19] iommu/vt-d: Avoid duplicated code for PASID setup

2019-08-15 Thread Jacob Pan
After each setup for PASID entry, related translation caches must be flushed. We can combine duplicated code into one function which is less error prone. Signed-off-by: Jacob Pan --- drivers/iommu/intel-pasid.c | 48 + 1 file changed, 18

[PATCH v5 18/19] iommu/vt-d: Support flushing more translation cache types

2019-08-15 Thread Jacob Pan
When Shared Virtual Memory is exposed to a guest via vIOMMU, scalable IOTLB invalidation may be passed down from outside IOMMU subsystems. This patch adds invalidation functions that can be used for additional translation cache types. Signed-off-by: Jacob Pan --- drivers/iommu/dmar.c|

[PATCH v5 17/19] iommu/vt-d: Add bind guest PASID support

2019-08-15 Thread Jacob Pan
When supporting guest SVA with emulated IOMMU, the guest PASID table is shadowed in VMM. Updates to guest vIOMMU PASID table will result in PASID cache flush which will be passed down to the host as bind guest PASID calls. For the SL page tables, it will be harvested from device's default domain

[PATCH v5 12/19] iommu/vt-d: Replace Intel specific PASID allocator with IOASID

2019-08-15 Thread Jacob Pan
Make use of generic IOASID code to manage PASID allocation, free, and lookup. Replace Intel specific code. Signed-off-by: Jacob Pan --- drivers/iommu/intel-iommu.c | 12 ++-- drivers/iommu/intel-pasid.c | 36 drivers/iommu/intel-svm.c | 37

[PATCH v5 16/19] iommu/vt-d: Misc macro clean up for SVM

2019-08-15 Thread Jacob Pan
Use combined macros for_each_svm_dev() to simplify SVM device iteration and error checking. Suggested-by: Andy Shevchenko Signed-off-by: Jacob Pan Reviewed-by: Eric Auger --- drivers/iommu/intel-svm.c | 85 +++ 1 file changed, 41 insertions(+), 44

[PATCH v2 01/17] iommu/arm-smmu: Mask TLBI address correctly

2019-08-15 Thread Robin Murphy
The less said about "~12UL" the better. Oh dear. We get away with it due to calling constraints that mean IOVAs are implicitly at least page-aligned to begin with, but still; oh dear. Signed-off-by: Robin Murphy --- drivers/iommu/arm-smmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)

[PATCH v2 00/17] Arm SMMU refactoring

2019-08-15 Thread Robin Murphy
Hi all, v1 for context: https://patchwork.kernel.org/cover/11087347/ Here's a quick v2 attempting to address all the minor comments; I've tweaked a whole bunch of names, added some verbosity in macros and comments for clarity, and rejigged arm_smmu_impl_init() for a bit more structure. The (new)

Re: [PATCH v6 5/8] iommu: Add bounce page APIs

2019-08-15 Thread Lu Baolu
Hi Joerg, On 8/15/19 11:48 PM, Joerg Roedel wrote: On Thu, Aug 15, 2019 at 02:15:32PM +0800, Lu Baolu wrote: iommu_map/unmap() APIs haven't parameters for dma direction and attributions. These parameters are elementary for DMA APIs. Say, after map, if the dma direction is TO_DEVICE and a

Re: [PATCH v6 5/8] iommu: Add bounce page APIs

2019-08-15 Thread Christoph Hellwig
On Fri, Aug 16, 2019 at 10:45:13AM +0800, Lu Baolu wrote: > Okay. I understand that adding these APIs in iommu.c is not a good idea. > And, I also don't think merging the bounce buffer implementation into > iommu_map() is feasible since iommu_map() is not DMA API centric. > > The bounce buffer

  1   2   >