Re: [PATCH v3 5/6] iommu/mediatek: Add mt8173 IOMMU driver

2015-07-28 Thread Yong Wu
On Mon, 2015-07-27 at 14:23 +0100, Robin Murphy wrote: > On 16/07/15 10:04, Yong Wu wrote: > > This patch adds support for mediatek m4u (MultiMedia Memory Management > > Unit). > > > > Signed-off-by: Yong Wu > [...] > > +static void mtk_iommu_flush_pgtable(void *ptr, size_t size, void *cookie) > >

Re: [PATCH v3 5/6] iommu/mediatek: Add mt8173 IOMMU driver

2015-07-28 Thread Yong Wu
On Mon, 2015-07-27 at 16:49 +0100, Robin Murphy wrote: > On 27/07/15 16:31, Russell King - ARM Linux wrote: > > On Mon, Jul 27, 2015 at 02:23:26PM +0100, Robin Murphy wrote: > >> On 16/07/15 10:04, Yong Wu wrote: > >>> This patch adds support for mediatek m4u (MultiMedia Memory Management > >>> Uni

Re: [PATCH char-misc-next 10/19] lib: convert iova.c into a library

2015-07-28 Thread Andrew Morton
On Mon, 27 Jul 2015 16:57:32 -0700 Ashutosh Dixit wrote: > From: Harish Chegondi > > This patch converts iova.c into a library, moving it from > drivers/iommu/ to lib/, and exports its virtual address allocation and > management functions so that other modules can reuse them. >From the follow

[RFC PATCH 1/1] iommu: Detach device from domain when removed from group

2015-07-28 Thread Gerald Schaefer
This patch adds a call to __iommu_detach_device() to the iommu_group_remove_device() function, which will trigger a missing detach_dev callback in (at least) the following scenario: When a user completes the VFIO_SET_IOMMU ioctl for a vfio-pci device, and the corresponding device is removed therea

[RFC PATCH 0/1] iommu: Detach device from domain when removed from group

2015-07-28 Thread Gerald Schaefer
Hi, during IOMMU API function testing on s390 I hit the following scenario: After binding a device to vfio-pci, the user completes the VFIO_SET_IOMMU ioctl and stops, see the sample C program below. Now the device is manually removed via "echo 1 > /sys/bus/pci/devices/.../remove". Although the S

Re: [PATCH v4 4/4] arm64: Hook up IOMMU dma_ops

2015-07-28 Thread Catalin Marinas
On Thu, Jul 16, 2015 at 07:40:15PM +0100, Robin Murphy wrote: > With iommu_dma_ops in place, hook them up to the configuration code, so > IOMMU-fronted devices will get them automatically. > > Signed-off-by: Robin Murphy Acked-by: Catalin Marinas ___

Re: [PATCH v4 3/4] arm64: Add IOMMU dma_ops

2015-07-28 Thread Catalin Marinas
On Thu, Jul 16, 2015 at 07:40:14PM +0100, Robin Murphy wrote: > +static void *__iommu_alloc_attrs(struct device *dev, size_t size, > + dma_addr_t *handle, gfp_t gfp, > + struct dma_attrs *attrs) > +{ > + bool coherent = is_device_dma_coh

Re: [PATCH char-misc-next 10/19] lib: convert iova.c into a library

2015-07-28 Thread Sudeep Dutt
On Tue, 2015-07-28 at 15:38 +0100, David Woodhouse wrote: > On Tue, 2015-07-28 at 11:41 +0100, Robin Murphy wrote: > > On 28/07/15 11:03, Joerg Roedel wrote: > > > On Mon, Jul 27, 2015 at 04:57:32PM -0700, Ashutosh Dixit wrote: > > > > From: Harish Chegondi > > > > > > > > This patch converts iov

Re: [PATCH v4 2/4] iommu: Implement common IOMMU ops for DMA mapping

2015-07-28 Thread Catalin Marinas
On Thu, Jul 16, 2015 at 07:40:13PM +0100, Robin Murphy wrote: > +/** > + * iommu_dma_alloc - Allocate and map a buffer contiguous in IOVA space > + * @dev: Device to allocate memory for. Must be a real device > + *attached to an iommu_dma_domain > + * @size: Size of buffer in bytes > + * @gfp:

Re: [PATCH 3/5] iommu/arm-smmu: Clean up DMA API usage

2015-07-28 Thread Will Deacon
On Tue, Jul 28, 2015 at 04:48:09PM +0100, Robin Murphy wrote: > On 28/07/15 11:18, Will Deacon wrote: > > On Mon, Jul 27, 2015 at 07:18:10PM +0100, Robin Murphy wrote: > >> With the correct DMA API calls now integrated into the io-pgtable code, > >> let that handle the flushing of non-coherent page

Re: [PATCH 1/5] iommu/io-pgtable-arm: Allow appropriate DMA API use

2015-07-28 Thread Will Deacon
On Tue, Jul 28, 2015 at 04:39:23PM +0100, Robin Murphy wrote: > On 28/07/15 11:17, Will Deacon wrote: > >> + if (cfg->tlb->flush_pgtable) > > > > Why would you have both a dev and a flush callback? In which cases is the > > DMA API insufficient? > > a) Bisectability given existing users. You cou

Re: [PATCH 3/5] iommu/arm-smmu: Clean up DMA API usage

2015-07-28 Thread Robin Murphy
On 28/07/15 11:18, Will Deacon wrote: On Mon, Jul 27, 2015 at 07:18:10PM +0100, Robin Murphy wrote: With the correct DMA API calls now integrated into the io-pgtable code, let that handle the flushing of non-coherent page table updates. Signed-off-by: Robin Murphy --- drivers/iommu/arm-smmu.

Re: [PATCH 1/5] iommu/io-pgtable-arm: Allow appropriate DMA API use

2015-07-28 Thread Robin Murphy
On 28/07/15 11:17, Will Deacon wrote: [...] diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index 4e46021..b93a60e 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -200,12 +200,76 @@ typedef u64 arm_lpae_iopte; static bool selftes

Re: [PATCH 2/5] iommu/arm-smmu: Sort out coherency

2015-07-28 Thread Robin Murphy
Hi Will, On 28/07/15 10:43, Will Deacon wrote: Hi Robin, Cheers for doing this. Just a few comments (mainly in relation to being consistent with SMMUv3). Thanks! On Mon, Jul 27, 2015 at 07:18:09PM +0100, Robin Murphy wrote: Currently we detect the whether the SMMU has coherent page table w

Re: [PATCH v2 00/11] PCI: Fix ATS deadlock

2015-07-28 Thread Joerg Roedel
Hi Bjorn, On Mon, Jul 20, 2015 at 07:13:49PM -0500, Bjorn Helgaas wrote: > Bjorn Helgaas (11): > iommu/vt-d: Cache PCI ATS state and Invalidate Queue Depth > PCI: Allocate ATS struct during enumeration > PCI: Embed ATS info directly into struct pci_dev > PCI: Reduce size of

[PATCH 4/5] iommu/amd: Use swiotlb in passthrough mode

2015-07-28 Thread Joerg Roedel
From: Joerg Roedel In passthrough mode (iommu=pt) all devices are identity mapped. If a device does not support 64bit DMA it might still need remapping. Make sure swiotlb is initialized to provide this remapping. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 8 +++- 1 file ch

[PATCH 2/5] iommu/amd: Use iommu core for passthrough mode

2015-07-28 Thread Joerg Roedel
From: Joerg Roedel Remove the AMD IOMMU driver implementation for passthrough mode and rely on the new iommu core features for that. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 58 ++ drivers/iommu/amd_iommu_init.c | 10 +--- 2 f

[PATCH 3/5] iommu/amd: Allow non-IOMMUv2 devices in IOMMUv2 domains

2015-07-28 Thread Joerg Roedel
From: Joerg Roedel Since devices with IOMMUv2 functionality might be in the same group as devices without it, allow those devices in IOMMUv2 domains too. Otherwise attaching the group with the IOMMUv2 device to the domain will fail. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 1

[PATCH 5/5] iommu/amd: Set global dma_ops if swiotlb is disabled

2015-07-28 Thread Joerg Roedel
From: Joerg Roedel Some AMD systems also have non-PCI devices which can do DMA. Those can't be handled by the AMD IOMMU, as the hardware can only handle PCI. These devices would end up with no dma_ops, as neither the per-device nor the global dma_ops will get set. SWIOTLB provides global dma_ops

[PATCH 1/5] iommu/amd: Use iommu_attach_group()

2015-07-28 Thread Joerg Roedel
From: Joerg Roedel Since the conversion to default domains the iommu_attach_device function only works for devices with their own group. But this isn't always true for current IOMMUv2 capable devices, so use iommu_attach_group instead. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu_v2

[PATCH 0/5] AMD IOMMU Fixes for v4.2-rc4

2015-07-28 Thread Joerg Roedel
Hi, here are a couple of fixes for the AMD IOMMU driver for issues found recently. The issues were introduced by the default-domain conversion in this development cycle. I plan to send these fixes upstream by the end of the week. Please review! Thanks, Joerg Joerg Roedel (5): iommu/a

Re: [PATCH char-misc-next 10/19] lib: convert iova.c into a library

2015-07-28 Thread David Woodhouse
On Tue, 2015-07-28 at 11:41 +0100, Robin Murphy wrote: > On 28/07/15 11:03, Joerg Roedel wrote: > > On Mon, Jul 27, 2015 at 04:57:32PM -0700, Ashutosh Dixit wrote: > > > From: Harish Chegondi > > > > > > This patch converts iova.c into a library, moving it from > > > drivers/iommu/ to lib/, and e

Re: [PATCH v3 3/6] iommu: add ARM short descriptor page table allocator.

2015-07-28 Thread Will Deacon
On Tue, Jul 28, 2015 at 02:37:43PM +0100, Yong Wu wrote: > On Tue, 2015-07-28 at 12:00 +0100, Will Deacon wrote: > > On Tue, Jul 28, 2015 at 06:08:14AM +0100, Yong Wu wrote: > > > On Mon, 2015-07-27 at 15:11 +0100, Will Deacon wrote: > > > > On Mon, Jul 27, 2015 at 03:05:38PM +0100, Robin Murphy wr

Re: [PATCH v3 3/6] iommu: add ARM short descriptor page table allocator.

2015-07-28 Thread Yong Wu
On Tue, 2015-07-28 at 12:00 +0100, Will Deacon wrote: > On Tue, Jul 28, 2015 at 06:08:14AM +0100, Yong Wu wrote: > > On Mon, 2015-07-27 at 15:11 +0100, Will Deacon wrote: > > > On Mon, Jul 27, 2015 at 03:05:38PM +0100, Robin Murphy wrote: > > > > On 27/07/15 05:21, Yong Wu wrote: > > > > > +

Re: [PATCH v4 1/4] iommu/iova: Avoid over-allocating when size-aligned

2015-07-28 Thread David Woodhouse
On Thu, 2015-07-16 at 19:40 +0100, Robin Murphy wrote: > Currently, allocating a size-aligned IOVA region quietly adjusts the > actual allocation size in the process, returning a rounded-up > power-of-two-sized allocation. This results in mismatched behaviour in > the IOMMU driver if the original s

Re: [PATCH 0/4] Separate the IOVA library from the intel-iommu driver

2015-07-28 Thread David Woodhouse
On Mon, 2015-07-13 at 14:31 +0300, Sakari Ailus wrote: > Hi folks, > > This set separates the IOVA library from the intel-iommu driver, and makes > it usable for other implementations (such as DMA mapping) as well. Thanks. I've applied patches ##1-3 to my tree. The fourth patch ideally wants to g

Re: [PATCH v3 0/5] iommu/arm-smmu: add support for non-pci devices

2015-07-28 Thread Will Deacon
On Tue, Jul 21, 2015 at 11:30:07AM +0100, Robin Murphy wrote: > On 21/07/15 08:30, Zhen Lei wrote: > > Changelog: > > v2 -> v3: > > 1. add support for pci device hotplug, which missed in patch v2. > > 2. only support #iommu-cells = <1>, add corresponding description in > > arm,smmu-v3.txt. > > 3.

Re: [PATCH v4 0/4] arm64: IOMMU-backed DMA mapping

2015-07-28 Thread Will Deacon
Hi Joerg, Robin, On Mon, Jul 20, 2015 at 06:23:35PM +0100, Robin Murphy wrote: > On 20/07/15 16:26, Joerg Roedel wrote: > > On Thu, Jul 16, 2015 at 07:40:11PM +0100, Robin Murphy wrote: > >> arch/arm64/Kconfig | 1 + > >> arch/arm64/include/asm/dma-mapping.h | 15 +- > >>

Re: [PATCH v3 3/6] iommu: add ARM short descriptor page table allocator.

2015-07-28 Thread Will Deacon
On Tue, Jul 28, 2015 at 06:08:14AM +0100, Yong Wu wrote: > On Mon, 2015-07-27 at 15:11 +0100, Will Deacon wrote: > > On Mon, Jul 27, 2015 at 03:05:38PM +0100, Robin Murphy wrote: > > > On 27/07/15 05:21, Yong Wu wrote: > > > > + } else {/* page or largepage */ > > > > +

Re: [PATCH char-misc-next 10/19] lib: convert iova.c into a library

2015-07-28 Thread Robin Murphy
On 28/07/15 11:03, Joerg Roedel wrote: On Mon, Jul 27, 2015 at 04:57:32PM -0700, Ashutosh Dixit wrote: From: Harish Chegondi This patch converts iova.c into a library, moving it from drivers/iommu/ to lib/, and exports its virtual address allocation and management functions so that other modul

Re: [PATCH 3/5] iommu/arm-smmu: Clean up DMA API usage

2015-07-28 Thread Will Deacon
On Mon, Jul 27, 2015 at 07:18:10PM +0100, Robin Murphy wrote: > With the correct DMA API calls now integrated into the io-pgtable code, > let that handle the flushing of non-coherent page table updates. > > Signed-off-by: Robin Murphy > --- > drivers/iommu/arm-smmu.c | 23 +++

Re: [PATCH 1/5] iommu/io-pgtable-arm: Allow appropriate DMA API use

2015-07-28 Thread Will Deacon
Hi Robin, On Mon, Jul 27, 2015 at 07:18:08PM +0100, Robin Murphy wrote: > Currently, users of the LPAE page table code are (ab)using dma_map_page() > as a means to flush page table updates for non-coherent IOMMUs. Since > from the CPU's point of view, creating IOMMU page tables *is* passing > DMA

Re: [PATCH char-misc-next 10/19] lib: convert iova.c into a library

2015-07-28 Thread Joerg Roedel
On Mon, Jul 27, 2015 at 04:57:32PM -0700, Ashutosh Dixit wrote: > From: Harish Chegondi > > This patch converts iova.c into a library, moving it from > drivers/iommu/ to lib/, and exports its virtual address allocation and > management functions so that other modules can reuse them. > > Cc: Joer

Re: [PATCH 2/5] iommu/arm-smmu: Sort out coherency

2015-07-28 Thread Will Deacon
Hi Robin, Cheers for doing this. Just a few comments (mainly in relation to being consistent with SMMUv3). On Mon, Jul 27, 2015 at 07:18:09PM +0100, Robin Murphy wrote: > Currently we detect the whether the SMMU has coherent page table walk "we detect the whether"? > capability from the IDR0.CT

Re: [PATCH v2 01/11] iommu/vt-d: Cache PCI ATS state and Invalidate Queue Depth

2015-07-28 Thread Joerg Roedel
Hi Bjorn, On Mon, Jul 27, 2015 at 05:54:53PM -0500, Bjorn Helgaas wrote: > > Hmm, this is a place where the relaxed error handling in > > pci_enable_ats() can get problematic. > > By "relaxed error handling," do you mean the fact that in v4.1, > pci_enable_ats() has a BUG_ON(is_enabled), while n