[PATCH v7 RESEND 11/12] iommu/amd: Don't copy GCR3 table root pointer

2017-01-01 Thread Baoquan He
When in kdump kernel iommu is pre_enabled, 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 rec

[PATCH v7 RESEND 08/12] iommu/amd: Add sanity check of irq remap information of old dev table entry

2017-01-01 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 v7 RESEND 12/12] iommu/amd: Clear out the GV flag when handle deferred domain attach

2017-01-01 Thread Baoquan He
When handle deferred domain attach, we need check if the domain is v2. If not, should try to clear out the GV flag which could be copied from the old device table entry. Signed-off-by: Baoquan He --- drivers/iommu/amd_iommu.c | 18 +- 1 file changed, 17 insertions(+), 1 deletion(

[PATCH v7 RESEND 09/12] iommu: Assign the direct mapped domain to group->domain

2017-01-01 Thread Baoquan He
In iommu_request_dm_for_dev(), devices of group have all been attached to newly created direct mapped domain. We should store the domain into group->domain so that it works for iommu_get_domain_for_dev() and get_domain(). Signed-off-by: Baoquan He --- drivers/iommu/iommu.c | 1 + 1 file changed,

[PATCH v7 RESEND 10/12] iommu/amd: Allocate memory below 4G for dev table if translation pre-enabled

2017-01-01 Thread Baoquan He
AMD pointed out it's unsafe to update the device-table while iommu is enabled. It turns out that device-table pointer update is split up into two 32bit writes in the IOMMU hardware. So updating it while the IOMMU is enabled could have some nasty side effects. The only way to work around this is to

[PATCH v7 RESEND 06/12] iommu: Add is_attach_deferred call-back to iommu-ops

2017-01-01 Thread Baoquan He
This new call-back will be used to check if the domain attach need be deferred for now. If yes, the domain attach/detach will return directly. Suggested-by: Joerg Roedel Signed-off-by: Baoquan He --- drivers/iommu/iommu.c | 8 include/linux/iommu.h | 1 + 2 files changed, 9 insertions(

[PATCH v7 RESEND 07/12] iommu/amd: Use is_attach_deferred call-back

2017-01-01 Thread Baoquan He
Implement call-back is_attach_deferred and use it to defer the domain attach from iommu driver init to device driver init when iommu is pre-enabled in kdump kernel. Suggested-by: Joerg Roedel Signed-off-by: Baoquan He --- drivers/iommu/amd_iommu.c | 23 ++- 1 file changed, 2

[PATCH v7 RESEND 04/12] iommu/amd: Add function copy_dev_tables

2017-01-01 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 v7 RESEND 00/12] Fix kdump faults on system with amd iommu

2017-01-01 Thread Baoquan He
This is v7 post RESENT based on v4.10-rc2 of linus's tree. Just adjust the sequence of several patches and add the Suggested-by forgot in the previous post. The principle of the fix is similar to intel iommu. Just defer the assignment of device to domain to device driver init. In this version of p

[PATCH v7 RESEND 02/12] iommu/amd: add several helper function

2017-01-01 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 v7 RESEND 01/12] iommu/amd: Detect pre enabled translation

2017-01-01 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 v7 RESEND 05/12] iommu/amd: copy old trans table from old kernel

2017-01-01 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, install the copied DTE table to reg, an

[PATCH v7 RESEND 03/12] iommu/amd: Define bit fields for DTE particularly

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

Re: [PATCHv9 6/6] dmaengine: rcar-dmac: add iommu support for slave transfers

2017-01-01 Thread Laurent Pinchart
Hi Niklas, On Monday 05 Sep 2016 12:52:44 Laurent Pinchart wrote: > On Wednesday 10 Aug 2016 13:22:19 Niklas Söderlund wrote: > > Enable slave transfers to a device behind a IPMMU by mapping the slave > > addresses using the dma-mapping API. > > > > Signed-off-by: Niklas Söderlund > > --- > > dr