Re: [PATCH 1/1] dma-contiguous: return early for dt case in dma_contiguous_reserve

2021-05-18 Thread Dong Aisheng
On Wed, May 19, 2021 at 2:51 AM Robin Murphy wrote: > > On 2021-05-18 12:28, Dong Aisheng wrote: > > dma_contiguous_reserve() aims to support cmdline case for CMA memory > > reserve. But if users define reserved memory in DT, > > 'dma_contiguous_default_area' will not be 0, then it's meaningless >

Re: [PATCH 0/2] [PULL REQUEST] iommu/vt-d: Fixes for v5.13-rc3

2021-05-18 Thread Joerg Roedel
On Wed, May 19, 2021 at 09:50:25AM +0800, Lu Baolu wrote: > Hi Joerg, > > Two small fixes are queued in this series. It includes: > > - Use user privilege for RID2PASID translation > - Check memory allocation return value > > Please consider them for v5.13. > > Best regards, > Lu Baolu > > D

[PATCH] iommu/amd: Remove redundant assignment of err

2021-05-18 Thread Shaokun Zhang
'err' will be initialized and cleanup the redundant initialization. Cc: Joerg Roedel Signed-off-by: Shaokun Zhang --- drivers/iommu/amd/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 80e8e1916dd1..bea91cc7

[PATCH 1/2] iommu/vt-d: Check for allocation failure in aux_detach_device()

2021-05-18 Thread Lu Baolu
From: Dan Carpenter In current kernels small allocations never fail, but checking for allocation failure is the correct thing to do. Fixes: 18abda7a2d55 ("iommu/vt-d: Fix general protection fault in aux_detach_device()") Signed-off-by: Dan Carpenter Acked-by: Lu Baolu Link: https://lore.kerne

[PATCH 2/2] iommu/vt-d: Use user privilege for RID2PASID translation

2021-05-18 Thread Lu Baolu
When first-level page tables are used for IOVA translation, we use user privilege by setting U/S bit in the page table entry. This is to make it consistent with the second level translation, where the U/S enforcement is not available. Clear the SRE (Supervisor Request Enable) field in the pasid tab

[PATCH 0/2] [PULL REQUEST] iommu/vt-d: Fixes for v5.13-rc3

2021-05-18 Thread Lu Baolu
Hi Joerg, Two small fixes are queued in this series. It includes: - Use user privilege for RID2PASID translation - Check memory allocation return value Please consider them for v5.13. Best regards, Lu Baolu Dan Carpenter (1): iommu/vt-d: Check for allocation failure in aux_detach_device()

[PATCH 1/2] irqchip/qcom-pdc: Switch to IRQCHIP_PLATFORM_DRIVER and allow as a module

2021-05-18 Thread John Stultz
From: Saravana Kannan This patch revives changes from Saravana Kannan to switch the qcom-pdc driver to use IRQCHIP_PLATFORM_DRIVER helper macros, and allows qcom-pdc driver to be loaded as a permanent module. Earlier attempts at this ran into trouble with loading dependencies, but with Saravana'

[PATCH 2/2] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module

2021-05-18 Thread John Stultz
Allow the qcom_scm driver to be loadable as a permenent module. This still uses the "depends on QCOM_SCM || !QCOM_SCM" bit to ensure that drivers that call into the qcom_scm driver are also built as modules. While not ideal in some cases its the only safe way I can find to avoid build errors witho

Re: [RFC PATCH v3 5/8] vfio/type1: VFIO_IOMMU_ENABLE_IOPF

2021-05-18 Thread Alex Williamson
On Fri, 9 Apr 2021 11:44:17 +0800 Shenming Lu wrote: > Since enabling IOPF for devices may lead to a slow ramp up of performance, > we add an ioctl VFIO_IOMMU_ENABLE_IOPF to make it configurable. And the > IOPF enabling of a VFIO device includes setting IOMMU_DEV_FEAT_IOPF and > registering the V

Re: [RFC PATCH v3 0/8] Add IOPF support for VFIO passthrough

2021-05-18 Thread Alex Williamson
On Fri, 9 Apr 2021 11:44:12 +0800 Shenming Lu wrote: > Hi, > > Requesting for your comments and suggestions. :-) > > The static pinning and mapping problem in VFIO and possible solutions > have been discussed a lot [1, 2]. One of the solutions is to add I/O > Page Fault support for VFIO devices

Re: [RFC PATCH v3 6/8] vfio/type1: No need to statically pin and map if IOPF enabled

2021-05-18 Thread Alex Williamson
On Fri, 9 Apr 2021 11:44:18 +0800 Shenming Lu wrote: > If IOPF enabled for the VFIO container, there is no need to statically > pin and map the entire DMA range, we can do it on demand. And unmap > according to the IOPF mapped bitmap when removing vfio_dma. > > Note that we still mark all pages

Re: [RFC PATCH v3 3/8] vfio/type1: Add an MMU notifier to avoid pinning

2021-05-18 Thread Alex Williamson
On Fri, 9 Apr 2021 11:44:15 +0800 Shenming Lu wrote: > To avoid pinning pages when they are mapped in IOMMU page tables, we > add an MMU notifier to tell the addresses which are no longer valid > and try to unmap them. > > Signed-off-by: Shenming Lu > --- > drivers/vfio/vfio_iommu_type1.c | 11

Re: [RFC PATCH v3 4/8] vfio/type1: Pre-map more pages than requested in the IOPF handling

2021-05-18 Thread Alex Williamson
On Fri, 9 Apr 2021 11:44:16 +0800 Shenming Lu wrote: > To optimize for fewer page fault handlings, we can pre-map more pages > than requested at once. > > Note that IOPF_PREMAP_LEN is just an arbitrary value for now, which we > could try further tuning. I'd prefer that the series introduced ful

Re: [RFC PATCH v3 1/8] iommu: Evolve the device fault reporting framework

2021-05-18 Thread Alex Williamson
On Fri, 9 Apr 2021 11:44:13 +0800 Shenming Lu wrote: > This patch follows the discussion here: > > https://lore.kernel.org/linux-acpi/YAaxjmJW+ZMvrhac@myrica/ > > Besides SVA/vSVA, such as VFIO may also enable (2nd level) IOPF to remove > pinning restriction. In order to better support more sce

Re: [RFC PATCH v3 8/8] vfio: Add nested IOPF support

2021-05-18 Thread Alex Williamson
On Fri, 9 Apr 2021 11:44:20 +0800 Shenming Lu wrote: > To set up nested mode, drivers such as vfio_pci need to register a > handler to receive stage/level 1 faults from the IOMMU, but since > currently each device can only have one iommu dev fault handler, > and if stage 2 IOPF is already enabled

Re: [RFC PATCH v3 2/8] vfio/type1: Add a page fault handler

2021-05-18 Thread Alex Williamson
On Fri, 9 Apr 2021 11:44:14 +0800 Shenming Lu wrote: > VFIO manages the DMA mapping itself. To support IOPF (on-demand paging) > for VFIO (IOMMU capable) devices, we add a VFIO page fault handler to > serve the reported page faults from the IOMMU driver. > > Signed-off-by: Shenming Lu > --- >

Re: [RFC PATCH v3 7/8] vfio/type1: Add selective DMA faulting support

2021-05-18 Thread Alex Williamson
On Fri, 9 Apr 2021 11:44:19 +0800 Shenming Lu wrote: > Some devices only allow selective DMA faulting. Similar to the selective > dirty page tracking, the vendor driver can call vfio_pin_pages() to > indicate the non-faultable scope, we add a new struct vfio_range to > record it, then when the IO

Re: [PATCH 1/1] dma-contiguous: return early for dt case in dma_contiguous_reserve

2021-05-18 Thread Robin Murphy
On 2021-05-18 12:28, Dong Aisheng wrote: dma_contiguous_reserve() aims to support cmdline case for CMA memory reserve. But if users define reserved memory in DT, 'dma_contiguous_default_area' will not be 0, then it's meaningless to continue to run dma_contiguous_reserve(). So we return early if d

[PATCH] dma debug: report -EEXIST errors in add_dma_entry

2021-05-18 Thread Hamza Mahfooz
Since, overlapping mappings are not supported by the DMA API we should report an error if active_cacheline_insert returns -EEXIST. Suggested-by: Dan Williams Signed-off-by: Hamza Mahfooz --- kernel/dma/debug.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/dma/

[PATCH 1/1] dma-contiguous: return early for dt case in dma_contiguous_reserve

2021-05-18 Thread Dong Aisheng
dma_contiguous_reserve() aims to support cmdline case for CMA memory reserve. But if users define reserved memory in DT, 'dma_contiguous_default_area' will not be 0, then it's meaningless to continue to run dma_contiguous_reserve(). So we return early if detect 'dma_contiguous_default_area' is unze

Re: [PATCH v3] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock

2021-05-18 Thread Joerg Roedel
On Tue, May 18, 2021 at 11:08:47AM +0200, Joerg Roedel wrote: > Looks good to me, but I'll wait for Robins opinion before applying. Nevermind, just found the new version which Robin already acked. ___ iommu mailing list iommu@lists.linux-foundation.org h

Re: [PATCH v3] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock

2021-05-18 Thread Robin Murphy
On 2021-05-18 10:08, Joerg Roedel wrote: On Mon, Apr 19, 2021 at 03:13:35PM +0800, chenxiang wrote: From: Xiang Chen It is not necessary to put free_iova_mem() inside of spinlock/unlock iova_rbtree_lock which only leads to more completion for the spinlock. It has a small promote on the perform

Re: [PATCH v3] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock

2021-05-18 Thread chenxiang (M)
Hi Joerg, 在 2021/5/18 17:08, Joerg Roedel 写道: On Mon, Apr 19, 2021 at 03:13:35PM +0800, chenxiang wrote: From: Xiang Chen It is not necessary to put free_iova_mem() inside of spinlock/unlock iova_rbtree_lock which only leads to more completion for the spinlock. It has a small promote on the p

Re: [PATCH -next] iommu/virtio: Add missing MODULE_DEVICE_TABLE

2021-05-18 Thread Joerg Roedel
On Sat, May 08, 2021 at 11:14:51AM +0800, Bixuan Cui wrote: > This patch adds missing MODULE_DEVICE_TABLE definition which generates > correct modalias for automatic loading of this driver when it is built > as an external module. > > Reported-by: Hulk Robot > Signed-off-by: Bixuan Cui > --- >

Re: [PATCH 1/4] iommu/amd: Fix wrong parentheses on page-specific invalidations

2021-05-18 Thread Joerg Roedel
On Sat, May 01, 2021 at 11:59:56PM -0700, Nadav Amit wrote: > From: Nadav Amit > > The logic to determine the mask of page-specific invalidations was > tested in userspace. As the code was copied into the kernel, the > parentheses were mistakenly set in the wrong place, resulting in the > wrong m

Re: [PATCH] iommu/amd: Clear DMA ops when switching domain

2021-05-18 Thread Joerg Roedel
On Thu, Apr 22, 2021 at 11:42:19AM +0200, Jean-Philippe Brucker wrote: > Since commit 08a27c1c3ecf ("iommu: Add support to change default domain > of an iommu group") a user can switch a device between IOMMU and direct > DMA through sysfs. This doesn't work for AMD IOMMU at the moment because > dev

Re: [PATCH v3] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock

2021-05-18 Thread Joerg Roedel
On Mon, Apr 19, 2021 at 03:13:35PM +0800, chenxiang wrote: > From: Xiang Chen > > It is not necessary to put free_iova_mem() inside of spinlock/unlock > iova_rbtree_lock which only leads to more completion for the spinlock. > It has a small promote on the performance after the change. And also >

Re: [PATCH v4 2/8] iommu/dma: Introduce generic helper to retrieve RMR info

2021-05-18 Thread Joerg Roedel
On Thu, May 13, 2021 at 02:45:44PM +0100, Shameer Kolothum wrote: > +/** > + * struct iommu_rmr - Reserved Memory Region details per IOMMU > + * @list: Linked list pointers to hold RMR region info > + * @base_address: base address of Reserved Memory Region > + * @length: length of memory region > +

Re: [PATCH v6 00/15] Restricted DMA

2021-05-18 Thread Claire Chang
v7: https://lore.kernel.org/patchwork/cover/1431031/ On Mon, May 10, 2021 at 5:50 PM Claire Chang wrote: > > From: Claire Chang > > This series implements mitigations for lack of DMA access control on > systems without an IOMMU, which could result in the DMA accessing the > system memory at unex