Re: [PATCH v3 1/5] x86/pci: Add a to_pci_sysdata helper

2020-01-14 Thread Christoph Hellwig
On Fri, Jan 10, 2020 at 10:21:09AM -0700, Jon Derrick wrote: > From: Christoph Hellwig > > Various helpers need the pci_sysdata just to dereference a single field > in it. Add a little helper that returns the properly typed sysdata > pointer to require a little less boilerplate code. > > Signed

Re: [PATCH v3 2/5] x86/PCI: Expose VMD's PCI Device in pci_sysdata

2020-01-14 Thread Christoph Hellwig
On Fri, Jan 10, 2020 at 10:21:10AM -0700, Jon Derrick wrote: > To be used by Intel-IOMMU code to find the correct domain. > > CC: Christoph Hellwig > Signed-off-by: Jon Derrick Looks good, modulo the brace bisection issue already pointed out: Reviewed-by: Christoph Hellwig ___

Re: [PATCH v3 3/5] PCI: Introduce pci_direct_dma_alias()

2020-01-14 Thread Christoph Hellwig
On Fri, Jan 10, 2020 at 10:21:11AM -0700, Jon Derrick wrote: > The current DMA alias implementation requires the aliased device be on > the same PCI bus as the requester ID. This introduces an arch-specific > mechanism to point to another PCI device when doing mapping and > PCI DMA alias search. >

Re: [PATCH v3 4/5] PCI: vmd: Stop overriding dma_map_ops

2020-01-14 Thread Christoph Hellwig
On Fri, Jan 10, 2020 at 10:21:12AM -0700, Jon Derrick wrote: > Devices on the VMD domain use the VMD endpoint's requester ID and have > been relying on the VMD endpoint's DMA operations. The problem with this > was that VMD domain devices would use the VMD endpoint's attributes when > doing DMA and

Re: [PATCH 2/2] arm: use swiotlb for bounce buffer on LPAE configs

2020-01-14 Thread Peter Ujfalusi via iommu
Christoph, Robin, On 09/01/2020 16.49, Christoph Hellwig wrote: > On Wed, Jan 08, 2020 at 03:20:07PM +, Robin Murphy wrote: >>> The problem - I think - is that the DMA_BIT_MASK(32) from >>> dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)) is treated as physical >>> address along the call path

Re: [PATCH v4 06/13] iommu/arm-smmu-v3: Add context descriptor tables allocators

2020-01-14 Thread Will Deacon
On Thu, Dec 19, 2019 at 05:30:26PM +0100, Jean-Philippe Brucker wrote: > Support for SSID will require allocating context descriptor tables. Move > the context descriptor allocation to separate functions. > > Reviewed-by: Eric Auger > Reviewed-by: Jonathan Cameron > Signed-off-by: Jean-Philippe

Re: [PATCH v4 06/13] iommu/arm-smmu-v3: Add context descriptor tables allocators

2020-01-14 Thread Jean-Philippe Brucker
On Tue, Jan 14, 2020 at 11:06:52AM +, Will Deacon wrote: > > /* Context descriptor manipulation functions */ > > +static int arm_smmu_alloc_cd_leaf_table(struct arm_smmu_device *smmu, > > + struct arm_smmu_cd_table *table, > > +

Re: [PATCH v4 06/13] iommu/arm-smmu-v3: Add context descriptor tables allocators

2020-01-14 Thread Will Deacon
On Tue, Jan 14, 2020 at 12:52:30PM +0100, Jean-Philippe Brucker wrote: > On Tue, Jan 14, 2020 at 11:06:52AM +, Will Deacon wrote: > > > /* Context descriptor manipulation functions */ > > > +static int arm_smmu_alloc_cd_leaf_table(struct arm_smmu_device *smmu, > > > +

Re: [PATCH v4 07/13] iommu/arm-smmu-v3: Add support for Substream IDs

2020-01-14 Thread Will Deacon
On Thu, Dec 19, 2019 at 05:30:27PM +0100, Jean-Philippe Brucker wrote: > At the moment, the SMMUv3 driver implements only one stage-1 or stage-2 > page directory per device. However SMMUv3 allows more than one address > space for some devices, by providing multiple stage-1 page directories. In > ad

Re: [PATCH v4 09/13] iommu/arm-smmu-v3: Prepare for handling arm_smmu_write_ctx_desc() failure

2020-01-14 Thread Will Deacon
On Thu, Dec 19, 2019 at 05:30:29PM +0100, Jean-Philippe Brucker wrote: > Second-level context descriptor tables will be allocated lazily in > arm_smmu_write_ctx_desc(). Help with handling allocation failure by > moving the CD write into arm_smmu_domain_finalise_s1(). > > Reviewed-by: Eric Auger >

Re: [PATCH v4 13/13] iommu/arm-smmu-v3: Add support for PCI PASID

2020-01-14 Thread Will Deacon
On Thu, Dec 19, 2019 at 05:30:33PM +0100, Jean-Philippe Brucker wrote: > Enable PASID for PCI devices that support it. Since the SSID tables are > allocated by arm_smmu_attach_dev(), PASID has to be enabled early enough. > arm_smmu_dev_feature_enable() would be too late, since by that time the Wha

Re: [PATCH v11 2/4] uacce: add uacce driver

2020-01-14 Thread Greg Kroah-Hartman
On Mon, Jan 13, 2020 at 11:34:55AM +0800, zhangfei wrote: > Hi, Greg > > Thanks for the review. > > On 2020/1/12 上午3:40, Greg Kroah-Hartman wrote: > > On Sat, Jan 11, 2020 at 10:48:37AM +0800, Zhangfei Gao wrote: > > > +static int uacce_fops_open(struct inode *inode, struct file *filep) > > > +{

Re: [PATCH v4 10/13] iommu/arm-smmu-v3: Add second level of context descriptor table

2020-01-14 Thread Will Deacon
On Thu, Dec 19, 2019 at 05:30:30PM +0100, Jean-Philippe Brucker wrote: > The SMMU can support up to 20 bits of SSID. Add a second level of page > tables to accommodate this. Devices that support more than 1024 SSIDs now > have a table of 1024 L1 entries (8kB), pointing to tables of 1024 context > d

[PATCH] iommu: amd: Fix IOMMU perf counter clobbering during init

2020-01-14 Thread Shuah Khan
init_iommu_perf_ctr() clobbers the register when it checks write access to IOMMU perf counters and fails to restore when they are writable. Add save and restore to fix it. Signed-off-by: Shuah Khan --- drivers/iommu/amd_iommu_init.c | 22 -- 1 file changed, 16 insertions(+),

Re: [PATCH v4 11/13] iommu/arm-smmu-v3: Improve add_device() error handling

2020-01-14 Thread Will Deacon
On Thu, Dec 19, 2019 at 05:30:31PM +0100, Jean-Philippe Brucker wrote: > Let add_device() clean up after itself. The iommu_bus_init() function > does call remove_device() on error, but other sites (e.g. of_iommu) do > not. > > Don't free level-2 stream tables because we'd have to track if we > all

Re: [PATCH v4 00/13] iommu: Add PASID support to Arm SMMUv3

2020-01-14 Thread Will Deacon
On Thu, Dec 19, 2019 at 05:30:20PM +0100, Jean-Philippe Brucker wrote: > Add support for Substream ID and PASIDs to the SMMUv3 driver. Since v3 > [1], I added review and tested tags where appropriate and applied the > suggested changes, shown in the diff below. Thanks all! > > I'm testing using th

Re: [PATCH v4 07/13] iommu/arm-smmu-v3: Add support for Substream IDs

2020-01-14 Thread Jean-Philippe Brucker
On Tue, Jan 14, 2020 at 12:38:19PM +, Will Deacon wrote: > > +static void arm_smmu_sync_cd(struct arm_smmu_domain *smmu_domain, > > +int ssid, bool leaf) > > +{ > > + size_t i; > > + unsigned long flags; > > + struct arm_smmu_master *master; > > + struct arm_smmu

Re: [PATCH v4 09/13] iommu/arm-smmu-v3: Prepare for handling arm_smmu_write_ctx_desc() failure

2020-01-14 Thread Jean-Philippe Brucker
On Tue, Jan 14, 2020 at 12:42:47PM +, Will Deacon wrote: > On Thu, Dec 19, 2019 at 05:30:29PM +0100, Jean-Philippe Brucker wrote: > > Second-level context descriptor tables will be allocated lazily in > > arm_smmu_write_ctx_desc(). Help with handling allocation failure by > > moving the CD writ

[PoC] arm: dma-mapping: direct: Apply dma_pfn_offset only when it is valid

2020-01-14 Thread Peter Ujfalusi via iommu
The dma_pfn_offset should only be applied to an address which is within the dma-ranges range. Any address outside should have offset as 0. This is a proof of concept patch which works on k2g where we have dma-ranges = <0x8000 0x8 0x 0x8000>; for the SoC. Without this patch everyth

Re: [PoC] arm: dma-mapping: direct: Apply dma_pfn_offset only when it is valid

2020-01-14 Thread Robin Murphy
On 14/01/2020 4:43 pm, Peter Ujfalusi wrote: The dma_pfn_offset should only be applied to an address which is within the dma-ranges range. Any address outside should have offset as 0. No, that's wrong. If a non-empty dma-ranges is present, then addresses which do not fall within any specified

[PATCH 2/5] iommu/vt-d: Mark firmware tainted if RMRR fails sanity check

2020-01-14 Thread Lu Baolu
From: Barret Rhoden RMRR entries describe memory regions that are DMA targets for devices outside the kernel's control. RMRR entries that fail the sanity check are pointing to regions of memory that the firmware did not tell the kernel are reserved or otherwise should not be used. Instead of ab

[PATCH 5/5] iommu/vt-d: Unnecessary to handle default identity domain

2020-01-14 Thread Lu Baolu
The iommu default domain framework has been designed to take care of setting identity default domain type. It's unnecessary to handle this again in the VT-d driver. Hence, remove it. Signed-off-by: Lu Baolu --- drivers/iommu/intel-iommu.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletio

[PATCH 1/5] iommu/vt-d: Don't reject Host Bridge due to scope mismatch

2020-01-14 Thread Lu Baolu
From: jimyan On a system with two host bridges(:00:00.0,:80:00.0), iommu initialization fails with DMAR: Device scope type does not match for :80:00.0 This is because the DMAR table reports this device as having scope 2 (ACPI_DMAR_SCOPE_TYPE_BRIDGE): but the device has a type 0

[PATCH 4/5] iommu/vt-d: Allow devices with RMRRs to use identity domain

2020-01-14 Thread Lu Baolu
Since commit ea2447f700cab ("intel-iommu: Prevent devices with RMRRs from being placed into SI Domain"), the Intel IOMMU driver doesn't allow any devices with RMRR locked to use the identity domain. This was added to to fix the issue where the RMRR info for devices being placed in and out of the id

[PULL REQUEST] iommu/vt-d: patches for v5.6 - 2nd wave

2020-01-14 Thread Lu Baolu
Hi Joerg, Below patches have been piled up for v5.6 since v5.5-rc3. They are mostly misc changes and cleanups. - Instead of aborting DMAR processing, mark firmware tainted if any RMRRs fail sanity check. - Check host bridge type correctly. - Allow devices with RMRRs to use identity domain.

[PATCH 3/5] iommu/vt-d: Add RMRR base and end addresses sanity check

2020-01-14 Thread Lu Baolu
From: Barret Rhoden The VT-d spec specifies requirements for the RMRR entries base and end (called 'Limit' in the docs) addresses. This commit will cause the DMAR processing to mark the firmware as tainted if any RMRR entries that do not meet these requirements. Signed-off-by: Barret Rhoden Si

Re: [PATCH v4 13/13] iommu/arm-smmu-v3: Add support for PCI PASID

2020-01-14 Thread Jean-Philippe Brucker
On Tue, Jan 14, 2020 at 12:45:42PM +, Will Deacon wrote: > On Thu, Dec 19, 2019 at 05:30:33PM +0100, Jean-Philippe Brucker wrote: > > Enable PASID for PCI devices that support it. Since the SSID tables are > > allocated by arm_smmu_attach_dev(), PASID has to be enabled early enough. > > arm_smm