Re: [PATCH] iommu: check for the deferred attach when attaching a device

2021-01-18 Thread lijiang
在 2021年01月15日 23:15, Robin Murphy 写道: > On 2021-01-15 14:26, lijiang wrote: >> Hi, Robin >> >> Thank you for the comment. >> >> 在 2021年01月13日 01:29, Robin Murphy 写道: >>> On 2021-01-05 07:52, lijiang wrote: 在 2021年01月05日 11:55, lijiang 写道: > Hi, > > Also add Joerg to cc list. >

Re: [PATCH 1/6] vfio/iommu_type1: Make an explicit "promote" semantic

2021-01-18 Thread Keqian Zhu
On 2021/1/16 6:42, Alex Williamson wrote: > On Thu, 7 Jan 2021 12:43:56 +0800 > Keqian Zhu wrote: > >> When we want to promote the pinned_page_dirty_scope of vfio_iommu, >> we call the "update" function to visit all vfio_group, but when we >> want to downgrade this, we can set the flag as

Re: [PATCH v4 2/3] iommu/iova: Avoid double-negatives in magazine helpers

2021-01-18 Thread Robin Murphy
On 2021-01-18 10:55, John Garry wrote: On 18/01/2021 10:08, Jean-Philippe Brucker wrote: Any idea why that's happening?  This fix seems ok but if we're expecting allocation failures for the loaded magazine then we could easily get it for cpu_rcaches too, and get a similar abort at runtime.

Re: [PATCH 6/6] vfio/iommu_type1: Drop parameter "pgsize" of update_user_bitmap

2021-01-18 Thread Keqian Zhu
On 2021/1/16 7:44, Alex Williamson wrote: > On Thu, 7 Jan 2021 12:44:01 +0800 > Keqian Zhu wrote: > >> We always use the smallest supported page size of vfio_iommu as >> pgsize. Drop parameter "pgsize" of update_user_bitmap. >> >> Signed-off-by: Keqian Zhu >> --- >>

Re: [PATCH v4 2/3] iommu/iova: Avoid double-negatives in magazine helpers

2021-01-18 Thread John Garry
On 18/01/2021 12:59, Robin Murphy wrote: for cpu_rcaches too, and get a similar abort at runtime. It's not specifically that we expect them (allocation failures for the loaded magazine), rather we should make safe against it. So could you be more specific in your concern for the cpu_rcache

Re: [PATCH] swiotlb: Validate bounce size in the sync/unmap path

2021-01-18 Thread Konrad Rzeszutek Wilk
On Mon, Jan 18, 2021 at 12:44:58PM +0100, Martin Radev wrote: > On Wed, Jan 13, 2021 at 12:30:17PM +0100, Christoph Hellwig wrote: > > On Tue, Jan 12, 2021 at 04:07:29PM +0100, Martin Radev wrote: > > > The size of the buffer being bounced is not checked if it happens > > > to be larger than the

Re: [PATCH v6 06/33] of/device: Move dma_range_map before of_iommu_configure

2021-01-18 Thread Robin Murphy
On 2021-01-15 05:30, Yong Wu wrote: On Thu, 2021-01-14 at 13:27 -0600, Rob Herring wrote: On Mon, Jan 11, 2021 at 07:18:47PM +0800, Yong Wu wrote: "dev->dma_range_map" contains the devices' dma_ranges information, This patch moves dma_range_map before of_iommu_configure. The iommu driver may

Re: [PATCH v3 5/7] iommu: Allow io_pgtable_tlb ops optional

2021-01-18 Thread Robin Murphy
On 2020-12-16 10:36, Yong Wu wrote: This patch allows io_pgtable_tlb ops could be null since the IOMMU drivers may use the tlb ops from iommu framework. There's not much in it, but I guess this does make more sense overall than just making .tlb_flush_all optional and drivers having to provide

Re: performance regression noted in v5.11-rc after c062db039f40

2021-01-18 Thread Chuck Lever
> On Jan 12, 2021, at 9:38 AM, Will Deacon wrote: > > [Expanding cc list to include DMA-IOMMU and intel IOMMU folks] > > On Fri, Jan 08, 2021 at 04:18:36PM -0500, Chuck Lever wrote: >> Hi- >> >> [ Please cc: me on replies, I'm not currently subscribed to >> iommu@lists ]. >> >> I'm running

Re: [PATCH v3 6/7] iommu/mediatek: Gather iova in iommu_unmap to achieve tlb sync once

2021-01-18 Thread Robin Murphy
On 2020-12-16 10:36, Yong Wu wrote: In current iommu_unmap, this code is: iommu_iotlb_gather_init(_gather); ret = __iommu_unmap(domain, iova, size, _gather); iommu_iotlb_sync(domain, _gather); We could gather the whole iova range in __iommu_unmap, and then do tlb

Re: [PATCH v3 7/7] iommu/mediatek: Remove the tlb-ops for v7s

2021-01-18 Thread Robin Murphy
On 2020-12-16 10:36, Yong Wu wrote: Until now, we have already used the tlb operations from iommu framework, then the tlb operations for v7s can be removed. Correspondingly, Switch the paramenter "cookie" to internal structure. FWIW, Reviewed-by: Robin Murphy Signed-off-by: Yong Wu ---

Re: [PATCH v3 6/7] iommu/mediatek: Gather iova in iommu_unmap to achieve tlb sync once

2021-01-18 Thread Will Deacon
On Mon, Jan 18, 2021 at 04:35:22PM +, Robin Murphy wrote: > On 2020-12-16 10:36, Yong Wu wrote: > > In current iommu_unmap, this code is: > > > > iommu_iotlb_gather_init(_gather); > > ret = __iommu_unmap(domain, iova, size, _gather); > > iommu_iotlb_sync(domain, _gather); > > > >

Re: [PATCH v3 6/7] iommu/mediatek: Gather iova in iommu_unmap to achieve tlb sync once

2021-01-18 Thread Robin Murphy
On 2021-01-18 16:58, Will Deacon wrote: On Mon, Jan 18, 2021 at 04:35:22PM +, Robin Murphy wrote: On 2020-12-16 10:36, Yong Wu wrote: In current iommu_unmap, this code is: iommu_iotlb_gather_init(_gather); ret = __iommu_unmap(domain, iova, size, _gather);

Re: performance regression noted in v5.11-rc after c062db039f40

2021-01-18 Thread Robin Murphy
On 2021-01-18 16:18, Chuck Lever wrote: On Jan 12, 2021, at 9:38 AM, Will Deacon wrote: [Expanding cc list to include DMA-IOMMU and intel IOMMU folks] On Fri, Jan 08, 2021 at 04:18:36PM -0500, Chuck Lever wrote: Hi- [ Please cc: me on replies, I'm not currently subscribed to iommu@lists

Re: [PATCH v4 7/7] iommu/mediatek: Remove the tlb-ops for v7s

2021-01-18 Thread Robin Murphy
On 2021-01-07 12:29, Yong Wu wrote: Until now, we have already used the tlb operations from iommu framework, then the tlb operations for v7s can be removed. Correspondingly, Switch the paramenter "cookie" to the internal structure. Reviewed-by: Robin Murphy Signed-off-by: Yong Wu ---

Re: [PATCH v2 5/7] drm/msm: Add dependency on io-pgtable-arm format module

2021-01-18 Thread Rob Clark
On Mon, Dec 21, 2020 at 4:44 PM Isaac J. Manjarres wrote: > > The MSM DRM driver depends on the availability of the ARM LPAE io-pgtable > format code to work properly. In preparation for having the io-pgtable > formats as modules, add a "pre" dependency with MODULE_SOFTDEP() to > ensure that the

Re: [PATCH v4 6/7] iommu/mediatek: Gather iova in iommu_unmap to achieve tlb sync once

2021-01-18 Thread Robin Murphy
On 2021-01-07 12:29, Yong Wu wrote: In current iommu_unmap, this code is: iommu_iotlb_gather_init(_gather); ret = __iommu_unmap(domain, iova, size, _gather); iommu_iotlb_sync(domain, _gather); We could gather the whole iova range in __iommu_unmap, and then do tlb

dma_mmap_coherent() breakage with mem_encrypt on AMD Ryzen

2021-01-18 Thread Takashi Iwai
Hi, we've got a bug report recently about the garbage playback sound from a PCI sound device with mem_encrypt on AMD Ryzen: https://bugzilla.kernel.org/show_bug.cgi?id=27 The debug session showed that this happens only with the mmap using dma_mmap_coherent() and mem_encrypt. The mmap

Re: performance regression noted in v5.11-rc after c062db039f40

2021-01-18 Thread Chuck Lever
> On Jan 18, 2021, at 1:00 PM, Robin Murphy wrote: > > On 2021-01-18 16:18, Chuck Lever wrote: >>> On Jan 12, 2021, at 9:38 AM, Will Deacon wrote: >>> >>> [Expanding cc list to include DMA-IOMMU and intel IOMMU folks] >>> >>> On Fri, Jan 08, 2021 at 04:18:36PM -0500, Chuck Lever wrote:

Re: [PATCH v2 5/7] drm/msm: Add dependency on io-pgtable-arm format module

2021-01-18 Thread Will Deacon
On Mon, Jan 18, 2021 at 01:16:03PM -0800, Rob Clark wrote: > On Mon, Dec 21, 2020 at 4:44 PM Isaac J. Manjarres > wrote: > > > > The MSM DRM driver depends on the availability of the ARM LPAE io-pgtable > > format code to work properly. In preparation for having the io-pgtable > > formats as

Re: [PATCH v4 4/7] iommu: Switch gather->end to the inclusive end

2021-01-18 Thread Robin Murphy
On 2021-01-07 12:29, Yong Wu wrote: Currently gather->end is "unsigned long" which may be overflow in arch32 in the corner case: 0xfff0 + 0x10(iova + size). Although it doesn't affect the size(end - start), it affects the checking "gather->end < end" This patch changes this "end" to the

Re: [PATCH v4 5/7] iommu/io-pgtable: Allow io_pgtable_tlb ops optional

2021-01-18 Thread Robin Murphy
On 2021-01-07 12:29, Yong Wu wrote: This patch allows io_pgtable_tlb ops could be null since the IOMMU drivers may use the tlb ops from iommu framework. For the reasons I gave on v3, Reviewed-by: Robin Murphy Signed-off-by: Yong Wu --- include/linux/io-pgtable.h | 8 +--- 1 file

[PATCH 1/1] iommu/vt-d: Correctly check addr alignment in qi_flush_dev_iotlb_pasid()

2021-01-18 Thread Lu Baolu
An incorrect address mask is being used in the qi_flush_dev_iotlb_pasid() to check the address alignment. This leads to a lot of spurious kernel warnings: [ 485.837093] DMAR: Invalidate non-aligned address 7f76f47f9000, order 0 [ 485.837098] DMAR: Invalidate non-aligned address 7f76f47f9000,

Re: [PATCH v4 1/3] iommu/vt-d: Audit IOMMU Capabilities and add helper functions

2021-01-18 Thread Lu Baolu
Hi, On 1/6/21 9:30 AM, Kyung Min Park wrote: Audit IOMMU Capability/Extended Capability and check if the IOMMUs have the consistent value for features. Report out or scale to the lowest supported when IOMMU features have incompatibility among IOMMUs. Report out features when below features are

[PATCH 0/2] Use another method to avoid resource conflicts between the SMMU and PMCG drivers

2021-01-18 Thread Zhen Lei
Since the PMCG may implement its resigters space(4KB Page0 and 4KB Page1) within the SMMUv3 64KB Page0. In this case, when the SMMUv3 driver reserves the 64KB Page0 resource in advance, the PMCG driver try to reserve its Page0 and Page1 resources, a resource conflict occurs. commit

[PATCH 1/2] perf/smmuv3: Don't reserve the register space that overlaps with the SMMUv3

2021-01-18 Thread Zhen Lei
Some SMMUv3 implementation embed the Perf Monitor Group Registers (PMCG) inside the first 64kB region of the SMMU. Since SMMU and PMCG are managed by two separate drivers, and this driver depends on ARM_SMMU_V3, so the SMMU driver reserves the corresponding resource first, this driver should not

[PATCH 2/2] Revert "iommu/arm-smmu-v3: Don't reserve implementation defined register space"

2021-01-18 Thread Zhen Lei
This reverts commit 52f3fab0067d6fa9e99c1b7f63265dd48ca76046. This problem has been fixed by another patch. The original method had side effects, it was not mapped to the user-specified resource size. The code will become more complex when ECMDQ is supported later. Signed-off-by: Zhen Lei ---

Re: performance regression noted in v5.11-rc after c062db039f40

2021-01-18 Thread Lu Baolu
Hi Chuck, On 1/19/21 4:09 AM, Chuck Lever wrote: On Jan 18, 2021, at 1:00 PM, Robin Murphy wrote: On 2021-01-18 16:18, Chuck Lever wrote: On Jan 12, 2021, at 9:38 AM, Will Deacon wrote: [Expanding cc list to include DMA-IOMMU and intel IOMMU folks] On Fri, Jan 08, 2021 at 04:18:36PM

Re: [PATCH v2 1/2] vfio/iommu_type1: Populate full dirty when detach non-pinned group

2021-01-18 Thread Keqian Zhu
On 2021/1/16 2:01, Alex Williamson wrote: > On Fri, 15 Jan 2021 17:26:42 +0800 > Keqian Zhu wrote: > >> If a group with non-pinned-page dirty scope is detached with dirty >> logging enabled, we should fully populate the dirty bitmaps at the >> time it's removed since we don't know the extent

Re: [PATCH v4 3/3] iommu/iova: Flush CPU rcache for when a depot fills

2021-01-18 Thread John Garry
On 15/01/2021 19:21, Robin Murphy wrote: It would be good to understand why the rcache doesn't stabilize. Could be a bug, or just need some tuning In strict mode, if a driver does Alloc-Free-Alloc and the first alloc misses the rcache, the second allocation hits it. The same sequence in

Re: [PATCH v4 2/3] iommu/iova: Avoid double-negatives in magazine helpers

2021-01-18 Thread Jean-Philippe Brucker
On Mon, Jan 18, 2021 at 10:55:52AM +, John Garry wrote: > On 18/01/2021 10:08, Jean-Philippe Brucker wrote: > > > > Any idea why that's happening? This fix seems ok but if we're expecting > > > > allocation failures for the loaded magazine then we could easily get it > > > > for cpu_rcaches

Re: [PATCH v4 2/3] iommu/iova: Avoid double-negatives in magazine helpers

2021-01-18 Thread Jean-Philippe Brucker
On Mon, Jan 18, 2021 at 09:24:17AM +, John Garry wrote: > On 15/01/2021 17:30, Jean-Philippe Brucker wrote: > > On Thu, Dec 10, 2020 at 02:23:08AM +0800, John Garry wrote: > > > A similar crash to the following could be observed if initial CPU rcache > > > magazine allocations fail in

Re: [PATCH v4 2/3] iommu/iova: Avoid double-negatives in magazine helpers

2021-01-18 Thread John Garry
On 15/01/2021 17:30, Jean-Philippe Brucker wrote: On Thu, Dec 10, 2020 at 02:23:08AM +0800, John Garry wrote: A similar crash to the following could be observed if initial CPU rcache magazine allocations fail in init_iova_rcaches(): thanks for having a look Any idea why that's happening?

Re: [PATCH v4 2/3] iommu/iova: Avoid double-negatives in magazine helpers

2021-01-18 Thread John Garry
On 18/01/2021 10:08, Jean-Philippe Brucker wrote: Any idea why that's happening? This fix seems ok but if we're expecting allocation failures for the loaded magazine then we could easily get it for cpu_rcaches too, and get a similar abort at runtime. It's not specifically that we expect them

Re: [PATCH v2 0/6] IOMMU: Some more IOVA and core code tidy-up

2021-01-18 Thread Will Deacon
On Wed, Jan 06, 2021 at 09:35:05PM +0800, John Garry wrote: > Just some tidy-up to IOVA and core code. > > Based on v5.11-rc2 > > Differences to v1: > - Add core IOMMU patches > > John Garry (6): > iova: Make has_iova_flush_queue() private > iova: Delete copy_reserved_iova() > iova: Stop

Re: [PATCH] swiotlb: Validate bounce size in the sync/unmap path

2021-01-18 Thread Martin Radev
On Wed, Jan 13, 2021 at 12:30:17PM +0100, Christoph Hellwig wrote: > On Tue, Jan 12, 2021 at 04:07:29PM +0100, Martin Radev wrote: > > The size of the buffer being bounced is not checked if it happens > > to be larger than the size of the mapped buffer. Because the size > > can be controlled by a

Re: [RESEND PATCH 1/1] iommu/amd: Remove unnecessary assignment

2021-01-18 Thread Will Deacon
On Thu, Dec 10, 2020 at 10:13:30AM +0800, Adrian Huang wrote: > From: Adrian Huang > > From: Adrian Huang > > The values of local variables are assigned after local variables > are declared, so no need to assign the initial value during the > variable declaration. > > And, no need to assign

Re: [PATCH v2 2/2] vfio/iommu_type1: Sanity check pfn_list when remove vfio_dma

2021-01-18 Thread Keqian Zhu
On 2021/1/16 3:14, Alex Williamson wrote: > On Fri, 15 Jan 2021 17:26:43 +0800 > Keqian Zhu wrote: > >> vfio_sanity_check_pfn_list() is used to check whether pfn_list of >> vfio_dma is empty when remove the external domain, so it makes a >> wrong assumption that only external domain will add

Re: [PATCH 3/6] vfio/iommu_type1: Initially set the pinned_page_dirty_scope

2021-01-18 Thread Keqian Zhu
On 2021/1/16 7:30, Alex Williamson wrote: > On Thu, 7 Jan 2021 12:43:58 +0800 > Keqian Zhu wrote: > >> For now there are 3 ways to promote the pinned_page_dirty_scope >> status of vfio_iommu: >> >> 1. Through vfio pin interface. >> 2. Detach a group without pinned_dirty_scope. >> 3. Attach a