Re: [GIT PULL] iommu/arm-smmu: fixes for 3.14

2014-02-18 Thread Joerg Roedel
On Mon, Feb 10, 2014 at 06:32:32PM +, Will Deacon wrote: > The following changes since commit b28a960c42fcd9cfc987441fa6d1c1a471f0f9ed: > > Linux 3.14-rc2 (2014-02-09 18:15:47 -0800) > > are available in the git repository at: > > git://git.kernel.org/pub/scm/linux/kernel/git/will/linux.

Re: [GIT PULL] iommu/arm-smmu: fixes for 3.14

2014-02-18 Thread Joerg Roedel
On Mon, Feb 10, 2014 at 06:32:32PM +, Will Deacon wrote: > - Andreas Herrmann took the driver for a run with a real SATA > controller, which caused the new mutex-based locking to explode > since we require mappings in atomic context I just did quick review of the changes. Was the SAT

Re: [GIT PULL] iommu/arm-smmu: fixes for 3.14

2014-02-18 Thread Will Deacon
Hi Joerg, On Tue, Feb 18, 2014 at 05:50:27PM +, Joerg Roedel wrote: > On Mon, Feb 10, 2014 at 06:32:32PM +, Will Deacon wrote: > > - Andreas Herrmann took the driver for a run with a real SATA > > controller, which caused the new mutex-based locking to explode > > since we requir

Re: [GIT PULL] iommu/arm-smmu: fixes for 3.14

2014-02-18 Thread Will Deacon
On Tue, Feb 18, 2014 at 06:36:26PM +, Will Deacon wrote: > On Tue, Feb 18, 2014 at 05:50:27PM +, Joerg Roedel wrote: > > I just did quick review of the changes. Was the SATA controller using > > the IOMMU through the DMA-API? In this case you would need the IRQ-safe > > spinlocks to avoid d

[PATCH v2 0/4] Remove dead code

2014-02-18 Thread Bjorn Helgaas
This is v2 of my rework of part of Stephen's patch [1]. My v1 posting, with a little discussion, is here [2]. This removes SR-IOV migration support, which seems to be unused. Changes since v1: - Drop the removal of MMIO exclusivity. - Add a few includes of . The SR-IOV migration support

[PATCH v2 1/4] misc: mic: Add include of

2014-02-18 Thread Bjorn Helgaas
We currently include in , but I'm about to remove that from linux/pci.h, so add explicit includes where needed. Signed-off-by: Bjorn Helgaas --- drivers/misc/mic/card/mic_device.h |1 + drivers/misc/mic/host/mic_device.h |1 + 2 files changed, 2 insertions(+) diff --git a/drivers/misc/

[PATCH v2 2/4] mei: Add include of

2014-02-18 Thread Bjorn Helgaas
We currently include in , but I'm about to remove that from linux/pci.h, so add explicit includes where needed. Signed-off-by: Bjorn Helgaas --- drivers/misc/mei/hw-me.h |1 + 1 file changed, 1 insertion(+) diff --git a/drivers/misc/mei/hw-me.h b/drivers/misc/mei/hw-me.h index 80bd829fbd9a

[PATCH v2 3/4] iommu/amd: Add include of

2014-02-18 Thread Bjorn Helgaas
We currently include in , but I'm about to remove that from linux/pci.h, so add explicit includes where needed. Signed-off-by: Bjorn Helgaas --- drivers/iommu/amd_iommu_types.h |1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types

[PATCH v2 4/4] PCI: Remove unused SR-IOV VF Migration support

2014-02-18 Thread Bjorn Helgaas
This reverts commit 74bb1bcc7dbb ("PCI: handle SR-IOV Virtual Function Migration"), removing this exported interface: pci_sriov_migration() Since pci_sriov_migration() is unused, it is impossible to schedule sriov_migration_task() or use any of the other migration infrastructure. This is based

[Patch Part2 V2 01/17] iommu/vt-d: avoid double free of g_iommus on error recovery path

2014-02-18 Thread Jiang Liu
Array 'g_iommus' may be freed twice on error recovery path in function init_dmars() and free_dmar_iommu(), thus cause random system crash as below. [6.774301] IOMMU: dmar init failed [6.778310] PCI-DMA: Using software bounce buffering for IO (SWIOTLB) [6.785615] software IO TLB [mem 0x

[Patch Part2 V2 02/17] iommu/vt-d: avoid caching stale domain_device_info and fix memory leak

2014-02-18 Thread Jiang Liu
Function device_notifier() in intel-iommu.c fails to remove device_domain_info data structures for PCI devices if they are associated with si_domain because iommu_no_mapping() returns true for those PCI devices. This will cause memory leak and caching of stale information in domain->devices list.

[Patch Part2 V2 04/17] iommu/vt-d: factor out dmar_alloc_dev_scope() for later reuse

2014-02-18 Thread Jiang Liu
Factor out function dmar_alloc_dev_scope() from dmar_parse_dev_scope() for later reuse. Signed-off-by: Jiang Liu --- drivers/iommu/dmar.c | 28 include/linux/dmar.h |1 + 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/iommu/dmar.c b/dr

[Patch Part2 V2 00/17] Enhance DMAR drivers to handle PCI/memory hotplug events

2014-02-18 Thread Jiang Liu
Intel DMA/interrupt remapping drivers scan available PCI/memory devices at startup and cache discovered hardware topologies. They don't update cached information if PCI/memory hotplug event happens at runtime, then the stale information may break DMA/interrupt remapping logic. This patchset first

[Patch Part2 V2 03/17] iommu/vt-d: avoid caching stale domain_device_info when hot-removing PCI device

2014-02-18 Thread Jiang Liu
Function device_notifier() in intel-iommu.c only remove domain_device_info data structure associated with a PCI device when handling PCI device driver unbinding events. If a PCI device has never been bound to a PCI device driver, there won't be BUS_NOTIFY_UNBOUND_DRIVER event when hot-removing the

[Patch Part2 V2 06/17] iommu/vt-d: simplify function get_domain_for_dev()

2014-02-18 Thread Jiang Liu
Function get_domain_for_dev() is a little complex, simplify it by factoring out dmar_search_domain_by_dev_info() and dmar_insert_dev_info(). Signed-off-by: Jiang Liu --- drivers/iommu/intel-iommu.c | 142 --- 1 file changed, 66 insertions(+), 76 deletions

[Patch Part2 V2 07/17] iommu/vt-d: free resources if failed to create domain for PCIe endpoint

2014-02-18 Thread Jiang Liu
Enhance function get_domain_for_dev() to release allocated resources if failed to create domain for PCIe endpoint, otherwise the allocated resources will get lost. Signed-off-by: Jiang Liu --- drivers/iommu/intel-iommu.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) di

[Patch Part2 V2 10/17] iommu/vt-d: check for NULL pointer when freeing IOMMU data structure

2014-02-18 Thread Jiang Liu
Domain id 0 will be assigned to invalid translation without allocating domain data structure if DMAR unit supports caching mode. So in function free_dmar_iommu(), we should check whether the domain pointer is NULL, otherwise it will cause system crash as below: [6.790519] BUG: unable to handle

[Patch Part2 V2 15/17] iommu/vt-d, PCI: update DRHD/RMRR/ATSR device scope caches when PCI hotplug happens

2014-02-18 Thread Jiang Liu
Current Intel DMAR/IOMMU driver assumes that all PCI devices associated with DMAR/RMRR/ATSR device scope arrays are created at boot time and won't change at runtime, so it caches pointers of associated PCI device object. That assumption may be wrong now due to: 1) introduction of PCI host bridge ho

[Patch Part2 V2 09/17] iommu/vt-d: fix incorrect iommu_count for si_domain

2014-02-18 Thread Jiang Liu
The iommu_count field in si_domain(static identity domain) is initialized to zero and never increases. It will underflow when tearing down iommu unit in function free_dmar_iommu() and leak memory. So refine code to correctly manage si_domain->iommu_count. Warning message caused by si_domain memory

[Patch Part2 V2 13/17] iommu/vt-d: introduce a rwsem to protect global data structures

2014-02-18 Thread Jiang Liu
Introduce a global rwsem dmar_global_lock, which will be used to protect DMAR related global data structures from DMAR/PCI/memory device hotplug operations in process context. DMA and interrupt remapping related data structures are read most, and only change when memory/PCI/DMAR hotplug event happ

[Patch Part2 V2 11/17] iommu/vt-d: fix error in detect ATS capability

2014-02-18 Thread Jiang Liu
Current Intel IOMMU driver only matches a PCIe root port with the first DRHD unit with the samge segment number. It will report false result if there are multiple DRHD units with the same segment number, thus fail to detect ATS capability for some PCIe devices. This patch refines function dmar_fin

[Patch Part2 V2 12/17] iommu/vt-d: introduce macro for_each_dev_scope() to walk device scope entries

2014-02-18 Thread Jiang Liu
Introduce for_each_dev_scope()/for_each_active_dev_scope() to walk {active} device scope entries. This will help following RCU lock related patches. Signed-off-by: Jiang Liu --- drivers/iommu/dmar.c| 14 +++--- drivers/iommu/intel-iommu.c | 100 +---

[Patch Part2 V2 05/17] iommu/vt-d: move private structures and variables into intel-iommu.c

2014-02-18 Thread Jiang Liu
Move private structures and variables into intel-iommu.c, which will help to simplify locking policy for hotplug. Also delete redundant declarations. Signed-off-by: Jiang Liu --- drivers/iommu/intel-iommu.c | 31 +-- include/linux/dmar.h| 23 +-

[Patch Part2 V2 14/17] iommu/vt-d: use RCU to protect global resources in interrupt context

2014-02-18 Thread Jiang Liu
Global DMA and interrupt remapping resources may be accessed in interrupt context, so use RCU instead of rwsem to protect them in such cases. Signed-off-by: Jiang Liu --- drivers/iommu/dmar.c| 33 - drivers/iommu/intel-iommu.c | 20

[Patch Part2 V2 16/17] iommu/vt-d, PCI: unify the way to process DMAR device scope array

2014-02-18 Thread Jiang Liu
Now we have a PCI bus notification based mechanism to update DMAR device scope array, we could extend the mechanism to support boot time initialization too, which will help to unify and simplify the implementation. Signed-off-by: Jiang Liu --- drivers/iommu/dmar.c| 163 -

[Patch Part2 V2 08/17] iommu/vt-d: reduce duplicated code to handle virtual machine domains

2014-02-18 Thread Jiang Liu
Reduce duplicated code to handle virtual machine domains, there's no functionality changes. It also improves code readability. Signed-off-by: Jiang Liu --- drivers/iommu/intel-iommu.c | 177 +++ 1 file changed, 45 insertions(+), 132 deletions(-) diff --g

[Patch Part2 V2 17/17] iommu/vt-d: update IOMMU state when memory hotplug happens

2014-02-18 Thread Jiang Liu
If static identity domain is created, IOMMU driver needs to update si_domain page table when memory hotplug event happens. Otherwise PCI device DMA operations can't access the hot-added memory regions. Signed-off-by: Jiang Liu --- drivers/iommu/intel-iommu.c | 71 ++