[RFC,v1,1/2] iommu/arm-smmu: support s2 domain attribute

2016-10-20 Thread Rick Song
Under some condition, user want to use the only stage 2 translation ability, so smmu driver need support setting only s2 domain attribute. Signed-off-by: Rick Song --- drivers/iommu/arm-smmu-v3.c | 12 include/linux/iommu.h | 1 + 2 files changed, 13 insertions(+) diff --git

[RFC,v1,2/2] vfio/iommu-type1: set only stage 2 translation

2016-10-20 Thread Rick Song
Normally, VFIO should use only stage 2 translation of iommu, to create the address mapping. If nesting translation is disabled from VFIO core, enable iommu domain only stage 2 attribute, otherwise, enable iommu domain nesting attribute. Signed-off-by: Rick Song --- drivers/vfio/vfio_iommu_type1.

Re: [PATCH v14 00/16] KVM PCIe/MSI passthrough on ARM/ARM64

2016-10-20 Thread Will Deacon
Hi Eric, Thanks for posting this. On Wed, Oct 12, 2016 at 01:22:08PM +, Eric Auger wrote: > This is the second respin on top of Robin's series [1], addressing Alex' > comments. > > Major changes are: > - MSI-doorbell API now is moved to DMA IOMMU API following Alex suggestion > to put all

[PATCH v6 7/9] iommu/amd: Update domain into to dte entry during device driver init

2016-10-20 Thread Baoquan He
All devices are supposed to reset themselves at device driver initialization stage. At this time if in kdump kernel those on-flight DMA will be stopped because of device reset. It's best time to update the protection domain info, especially pte_root, to dte entry which the device relates to. Signe

[PATCH v6 6/9] iommu/amd: Don't update domain info to dte entry at iommu init stage

2016-10-20 Thread Baoquan He
AMD iommu creates protection domain and assign each device to it during iommu driver initialization stage. This happened just after system pci bus scanning stage, and much earlier than device driver init stage. So at this time if in kdump kernel the domain info, especially pte_root, can't be update

[PATCH v6 9/9] iommu/amd: Don't copy GCR3 table root pointer

2016-10-20 Thread Baoquan He
If a device is set up with guest translations (DTE.GV=1), then don't copy GCR3 table root pointer but move the device over to an empty guest-cr3 table and handle the faults in the PPR log (which answer them with INVALID). After all these PPR faults are recoverable for the device and we should not a

[PATCH v6 5/9] iommu/amd: copy old trans table from old kernel

2016-10-20 Thread Baoquan He
Here several things need be done: - If iommu is pre-enabled in a normal kernel, just disable it and print warning. - If failed to copy dev table of old kernel, continue to proceed as it does in normal kernel. - Disable and Re-enable event/cmd buffer, and install the copied DTE table to reg

[PATCH v6 2/9] iommu/amd: add several helper function

2016-10-20 Thread Baoquan He
Move per iommu enabling code into a wrapper function early_enable_iommu(). This can make later kdump change easier. And also add iommu_disable_command_buffer and iommu_disable_event_buffer for later usage. Signed-off-by: Baoquan He --- drivers/iommu/amd_iommu_init.c | 42 +++

[PATCH v6 3/9] iommu/amd: Define bit fields for DTE particularly

2016-10-20 Thread Baoquan He
In amd-vi spec several bits of IO PTE fields and DTE fields are similar so that both of them can share the same MACRO definition. However defining their respecitve bit fields can make code more read-able. So do it in this patch. Signed-off-by: Baoquan He --- drivers/iommu/amd_iommu.c | 8

[PATCH v6 4/9] iommu/amd: Add function copy_dev_tables

2016-10-20 Thread Baoquan He
Add function copy_dev_tables to copy the old DEV table entries of the panicked kernel to the new allocated DEV table. Since all iommus share the same DTE table the copy only need be done once as long as the physical address of old DEV table is retrieved from iommu reg. Besides, we also need to:

[PATCH v6 8/9] iommu/amd: Add sanity check of irq remap information of old dev table entry

2016-10-20 Thread Baoquan He
Firstly split the dev table entry copy into address translation part and irq remapping part. Because these two parts could be configured to be available indepentently. Secondly check if IntCtl and IntTabLen are 10b and 1000b if they are set. Signed-off-by: Baoquan He --- drivers/iommu/amd_iommu

[PATCH v6 1/9] iommu/amd: Detect pre enabled translation

2016-10-20 Thread Baoquan He
Add functions to check whether translation is already enabled in IOMMU. Signed-off-by: Baoquan He --- drivers/iommu/amd_iommu_init.c | 25 + drivers/iommu/amd_iommu_proto.h | 1 + drivers/iommu/amd_iommu_types.h | 4 3 files changed, 30 insertions(+) diff --git a

[PATCH v6 0/9] Fix kdump faults on system with amd iommu

2016-10-20 Thread Baoquan He
This is v6 post. The principle of the fix is similar to intel iommu. Just defer the assignment of device to domain to device driver init. But there's difference than intel iommu. AMD iommu create protection domain and assign device to domain in iommu driver init stage. So in this patchset I just

[PATCH v5 6/7] iommu/exynos: Add runtime pm support

2016-10-20 Thread Marek Szyprowski
This patch adds runtime pm implementation, which is based on previous suspend/resume code. SYSMMU controller is now being enabled/disabled mainly from the runtime pm callbacks. System sleep callbacks relies on generic pm_runtime_force_suspend/pm_runtime_force_resume helpers. To ensure internal stat

[PATCH v5 0/7] Exynos IOMMU: proper runtime PM support (use device dependencies)

2016-10-20 Thread Marek Szyprowski
Hello, This is another update of the patchset for adding proper runtime PM support to Exynos IOMMU driver. This has been achieved by using recently introduced device links, which lets SYSMMU controller's runtime PM to follow master's device runtime PM state (the device which actually performs DMA

[PATCH v5 7/7] iommu/exynos: Use device dependency links to control runtime pm

2016-10-20 Thread Marek Szyprowski
This patch uses recently introduced device dependency links to track the runtime pm state of the master's device. This way each SYSMMU controller is set to runtime active only when its master's device is active and can restore or save its state instead of being activated all the time when attached

[PATCH v5 3/7] iommu/exynos: Simplify internal enable/disable functions

2016-10-20 Thread Marek Szyprowski
Remove remaining leftovers of the ref-count related code in the __sysmmu_enable/disable functions inline __sysmmu_enable/disable_nocount to them. Suspend/resume callbacks now checks if master device is set for given SYSMMU controller instead of relying on the activation count. Signed-off-by: Marek

[PATCH v5 4/7] iommu/exynos: Set master device once on boot

2016-10-20 Thread Marek Szyprowski
To avoid possible races, set master device pointer in each SYSMMU controller once on boot. Suspend/resume callbacks now properly relies on the configured iommu domain to enable or disable SYSMMU controller. While changing the code, also update the sleep debug messages and make them conditional. Si

[PATCH v5 1/7] iommu/exynos: Remove excessive, useless debug

2016-10-20 Thread Marek Szyprowski
Remove excessive, useless debug about skipping TLB invalidation, which is a normal situation when more aggressive power management is enabled. Signed-off-by: Marek Szyprowski --- drivers/iommu/exynos-iommu.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/dri

[PATCH v5 5/7] iommu/exynos: Rework and fix internal locking

2016-10-20 Thread Marek Szyprowski
This patch reworks locking in the exynos_iommu_attach/detach_device functions to ensure that all entries of the sysmmu_drvdata and exynos_iommu_owner structure are updated under the respective spinlocks, while runtime pm functions are called without any spinlocks held. Signed-off-by: Marek Szyprow

[PATCH v5 2/7] iommu/exynos: Remove dead code

2016-10-20 Thread Marek Szyprowski
__sysmmu_enable/disable functions were designed to do ref-count based operations, but current code always calls them only once, so the code for checking the conditions and invalid conditions can be simply removed without any influence to the driver operation. Signed-off-by: Marek Szyprowski ---