[PATCH 0/5] iommu/vt-d: Several minor adjustments

2021-07-19 Thread Lu Baolu
outstanding PRs Best regards, baolu Lu Baolu (5): iommu/vt-d: Refactor Kconfig a bit iommu/vt-d: Enable Intel IOMMU scalable mode by default iommu/vt-d: Preset A/D bits for user space DMA usage iommu/vt-d: Disallow SVA if devices don't support 64-bit address iommu/vt-d: Allow devices to have

Re: [PATCH] iommu: Unify iova_to_phys for identity domains

2021-07-14 Thread Lu Baolu
_DOMAIN_BLOCKED || unlikely(domain->ops->iova_to_phys == NULL)) return 0; Anyway, Reviewed-by: Lu Baolu Best regards, baolu return domain->ops->iova_to_phys(domain, iova); ___ iommu

Re: [PATCH v7 00/15] Optimizing iommu_[map/unmap] performance

2021-07-14 Thread Lu Baolu
On 7/14/21 10:24 PM, Georgi Djakov wrote: On 16.06.21 16:38, Georgi Djakov wrote: When unmapping a buffer from an IOMMU domain, the IOMMU framework unmaps the buffer at a granule of the largest page size that is supported by the IOMMU hardware and fits within the buffer. For every block that is

Re: [PATCH 1/4] iommu/vt-d: Disable superpage for Geminilake igfx

2021-07-13 Thread Lu Baolu
On 7/14/21 4:30 AM, Ville Syrjälä wrote: On Tue, Jul 13, 2021 at 09:34:09AM +0800, Lu Baolu wrote: On 7/12/21 11:47 PM, Ville Syrjälä wrote: On Mon, Jul 12, 2021 at 07:23:07AM +0800, Lu Baolu wrote: On 7/10/21 12:47 AM, Ville Syrjala wrote: From: Ville Syrjälä While running "gem_exe

[PATCH 1/1] iommu/vt-d: Update the virtual command related registers

2021-07-12 Thread Lu Baolu
driver accordingly. Fixes: 24f27d32ab6b7 ("iommu/vt-d: Enlightened PASID allocation") Cc: Ashok Raj Cc: Sanjay Kumar Cc: Kevin Tian Signed-off-by: Lu Baolu --- include/linux/intel-iommu.h | 6 +++--- drivers/iommu/intel/pasid.h | 10 +- 2 files changed, 8 insertions(+), 8

Re: [PATCH 1/4] iommu/vt-d: Disable superpage for Geminilake igfx

2021-07-12 Thread Lu Baolu
On 7/12/21 11:47 PM, Ville Syrjälä wrote: On Mon, Jul 12, 2021 at 07:23:07AM +0800, Lu Baolu wrote: On 7/10/21 12:47 AM, Ville Syrjala wrote: From: Ville Syrjälä While running "gem_exec_big --r single" from igt-gpu-tools on Geminilake as soon as a 2M mapping is made I tend to get a

[PATCH 1/1] iommu/vt-d: Fix clearing real DMA device's scalable-mode context entries

2021-07-12 Thread Lu Baolu
creases the coverage of scalable mode. Suggested-by: Sanjay Kumar Fixes: 8038bdb855331 ("iommu/vt-d: Only clear real DMA device's context entries") Fixes: 2b0140c69637e ("iommu/vt-d: Use pci_real_dma_dev() for mapping") Cc: sta...@vger.kernel.org # v5.6+ Cc: Jon Derrick Signed-of

[PATCH 1/1] iommu/vt-d: Global devTLB flush when present context entry changed

2021-07-12 Thread Lu Baolu
, the domain ID is in PASID table entry, not context entry. Fixes: 7373a8cc38197 ("iommu/vt-d: Setup context and enable RID2PASID support") Cc: sta...@vger.kernel.org # v5.0+ Signed-off-by: Sanjay Kumar Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 31 ++--

Re: [PATCH 1/4] iommu/vt-d: Disable superpage for Geminilake igfx

2021-07-11 Thread Lu Baolu
nes. Best regards, baolu TODO: would be nice to use the macros from include/drm/i915_pciids.h, but can't do that with DECLARE_PCI_FIXUP_HEADER() Cc: David Woodhouse Cc: Lu Baolu Cc: iommu@lists.linux-foundation.org Signed-off-by: Ville Syrjälä --- drivers/iommu/intel/iommu.c | 10 +

Re: [RFC v1 4/8] intel/vt-d: export intel_iommu_get_resv_regions

2021-07-09 Thread Lu Baolu
On 2021/7/9 19:43, Wei Liu wrote: When Microsoft Hypervisor runs on Intel platforms it needs to know the reserved regions to program devices correctly. There is no reason to duplicate intel_iommu_get_resv_regions. Export it. Why not using iommu_get_resv_regions()? Best regards, baolu

Re: [PATCH 0/4] Add dynamic iommu backed bounce buffers

2021-07-08 Thread Lu Baolu
Hi David, I like this idea. Thanks for proposing this. On 2021/7/7 15:55, David Stevens wrote: Add support for per-domain dynamic pools of iommu bounce buffers to the dma-iommu API. This allows iommu mappings to be reused while still maintaining strict iommu protection. Allocating buffers

Re: Plan for /dev/ioasid RFC v2

2021-06-24 Thread Lu Baolu
On 2021/6/24 12:03, David Gibson wrote: On Fri, Jun 18, 2021 at 01:21:47PM +0800, Lu Baolu wrote: Hi David, On 6/17/21 1:22 PM, David Gibson wrote: The iommu_group can guarantee the isolation among different physical devices (represented by RIDs). But when it comes to sub-devices (ex. mdev

Re: Plan for /dev/ioasid RFC v2

2021-06-24 Thread Lu Baolu
On 2021/6/24 12:26, David Gibson wrote: On Fri, Jun 18, 2021 at 04:57:40PM +, Tian, Kevin wrote: From: Jason Gunthorpe Sent: Friday, June 18, 2021 8:20 AM On Thu, Jun 17, 2021 at 03:14:52PM -0600, Alex Williamson wrote: I've referred to this as a limitation of type1, that we can't put

Re: [PATCH v14 6/6] iommu: Remove mode argument from iommu_set_dma_strict()

2021-06-23 Thread Lu Baolu
On 6/23/21 6:25 AM, Robin Murphy wrote: On 2021-06-21 15:32, Lu Baolu wrote: Hi Robin, On 2021/6/21 19:59, Robin Murphy wrote: On 2021-06-21 11:34, John Garry wrote: On 21/06/2021 11:00, Lu Baolu wrote: void iommu_set_dma_strict(bool force) {   if (force == true

Re: [PATCH 4/6] iommu: Combine device strictness requests with the global default

2021-06-21 Thread Lu Baolu
On 6/22/21 7:52 AM, Douglas Anderson wrote: @@ -1519,7 +1542,8 @@ static int iommu_get_def_domain_type(struct device *dev) static int iommu_group_alloc_default_domain(struct bus_type *bus, struct iommu_group *group, -

Re: [PATCH v14 6/6] iommu: Remove mode argument from iommu_set_dma_strict()

2021-06-21 Thread Lu Baolu
Hi Robin, On 2021/6/21 19:59, Robin Murphy wrote: On 2021-06-21 11:34, John Garry wrote: On 21/06/2021 11:00, Lu Baolu wrote: void iommu_set_dma_strict(bool force) {   if (force == true) iommu_dma_strict = true;  else if (!(iommu_cmd_line & IOMMU_CMD_LINE_ST

Re: [PATCH v14 6/6] iommu: Remove mode argument from iommu_set_dma_strict()

2021-06-21 Thread Lu Baolu
On 2021/6/21 16:12, John Garry wrote: On 21/06/2021 06:17, Lu Baolu wrote: On 2021/6/18 19:34, John Garry wrote: diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 60b1ec42e73b..ff221d3ddcbc 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -349,10 +349,9

Re: [PATCH v14 6/6] iommu: Remove mode argument from iommu_set_dma_strict()

2021-06-20 Thread Lu Baolu
On 2021/6/18 19:34, John Garry wrote: diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 60b1ec42e73b..ff221d3ddcbc 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -349,10 +349,9 @@ static int __init iommu_dma_setup(char *str) } early_param("iommu.strict",

Re: [PATCH v14 6/6] iommu: Remove mode argument from iommu_set_dma_strict()

2021-06-18 Thread Lu Baolu
); int iommu_set_pgtable_quirks(struct iommu_domain *domain, unsigned long quirks); -void iommu_set_dma_strict(bool val); +void iommu_set_dma_strict(void); bool iommu_get_dma_strict(struct iommu_domain *domain); extern int repor

Re: [PATCH v14 4/6] iommu/vt-d: Add support for IOMMU default DMA mode build options

2021-06-18 Thread Lu Baolu
- } + iommu_set_dma_strict(true); + } } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x0040, quirk_calpella_no_shadow_gtt); DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x0044, quirk_calpella_no_shadow_gtt); Reviewed-by: Lu Baolu Best regar

Re: [PATCH v14 3/6] iommu: Enhance IOMMU default DMA mode build options

2021-06-18 Thread Lu Baolu
iommu_group_ida); static unsigned int iommu_def_domain_type __read_mostly; -static bool iommu_dma_strict __read_mostly = true; +static bool iommu_dma_strict __read_mostly = IS_ENABLED(CONFIG_IOMMU_DEFAULT_STRICT); static u32 iommu_cmd_line __read_mostly; struct iommu_group { Revie

Re: [PATCH v14 2/6] iommu: Print strict or lazy mode at init time

2021-06-18 Thread Lu Baolu
t; : "lazy", + (iommu_cmd_line & IOMMU_CMD_LINE_STRICT) ? + "(set via kernel command line)" : ""); + return 0; } subsys_initcall(iommu_subsys_init); Reviewed-by: Lu Baolu Best regards, baolu _

Re: [PATCH v14 1/6] iommu: Deprecate Intel and AMD cmdline methods to enable strict mode

2021-06-18 Thread Lu Baolu
strncmp(str, "strict", 6)) { + pr_warn("intel_iommu=strict deprecated; use iommu.strict=1 instead\n"); pr_info("Disable batched IOTLB flush\n"); intel_iommu_strict = 1;

Re: [bug report] iommu/vt-d: Allocate/register iopf queue for sva devices

2021-06-18 Thread Lu Baolu
Signed-off-by: Colin Ian King Addresses-Coverity: ("Dereference before null check") Link: https://lore.kernel.org/r/20210611135024.32781-1-colin.k...@canonical.com Signed-off-by: Lu Baolu Best regards, baolu On 2021/6/18 14:55, Dan Carpenter wrote: Hello Lu Baolu, T

Re: Plan for /dev/ioasid RFC v2

2021-06-17 Thread Lu Baolu
Hi David, On 6/17/21 1:22 PM, David Gibson wrote: The iommu_group can guarantee the isolation among different physical devices (represented by RIDs). But when it comes to sub-devices (ex. mdev or vDPA devices represented by RID + SSID), we have to rely on the device driver for isolation. The

Re: [PATCH v13 6/6] iommu: Remove mode argument from iommu_set_dma_strict()

2021-06-17 Thread Lu Baolu
On 6/17/21 3:41 PM, John Garry wrote: @@ -349,10 +349,9 @@ static int __init iommu_dma_setup(char *str)   }   early_param("iommu.strict", iommu_dma_setup); -void iommu_set_dma_strict(bool strict) +void iommu_set_dma_strict(void)   { -    if (strict || !(iommu_cmd_line & IOMMU_CMD_LINE_STRICT))

Re: [PATCH v13 6/6] iommu: Remove mode argument from iommu_set_dma_strict()

2021-06-17 Thread Lu Baolu
Hi Robin, On 6/18/21 2:56 AM, Robin Murphy wrote: diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 60b1ec42e73b..ff221d3ddcbc 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -349,10 +349,9 @@ static int __init iommu_dma_setup(char *str)   }  

Re: [PATCH v13 4/6] iommu/vt-d: Add support for IOMMU default DMA mode build options

2021-06-17 Thread Lu Baolu
Hi John, On 6/17/21 4:00 PM, John Garry wrote: On 17/06/2021 08:32, Lu Baolu wrote: On 6/16/21 7:03 PM, John Garry wrote: @@ -4382,9 +4380,9 @@ int __init intel_iommu_init(void)    * is likely to be much lower than the overhead of synchronizing    * the virtual and physical

Re: [PATCH v13 6/6] iommu: Remove mode argument from iommu_set_dma_strict()

2021-06-17 Thread Lu Baolu
On 6/16/21 7:03 PM, John Garry wrote: We only ever now set strict mode enabled in iommu_set_dma_strict(), so just remove the argument. Signed-off-by: John Garry Reviewed-by: Robin Murphy --- drivers/iommu/amd/init.c| 2 +- drivers/iommu/intel/iommu.c | 6 +++--- drivers/iommu/iommu.c

Re: [PATCH v13 4/6] iommu/vt-d: Add support for IOMMU default DMA mode build options

2021-06-17 Thread Lu Baolu
On 6/16/21 7:03 PM, John Garry wrote: @@ -4382,9 +4380,9 @@ int __init intel_iommu_init(void) * is likely to be much lower than the overhead of synchronizing * the virtual and physical IOMMU page-tables. */ - if

Re: [PATCH v7 08/15] iommu: Add support for the map_pages() callback

2021-06-17 Thread Lu Baolu
if (ret) break; - iova += pgsize; - paddr += pgsize; - size -= pgsize; + iova += mapped; + paddr += mapped; } /* unroll mapping in case something went wrong */ Reviewed-by: Lu Baolu Best r

Re: [PATCH v7 07/15] iommu: Hook up '->unmap_pages' driver callback

2021-06-17 Thread Lu Baolu
iotlb_gather); if (!unmapped_page) break; Reviewed-by: Lu Baolu Best regards, baolu ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v7 06/15] iommu: Split 'addr_merge' argument to iommu_pgsize() into separate parts

2021-06-17 Thread Lu Baolu
n, iova, iova, size - unmapped); unmapped_page = ops->unmap(domain, iova, pgsize, iotlb_gather); if (!unmapped_page) break; Reviewed-by: Lu Baolu Best regards, baolu ___ iommu mailing list iommu

Re: [PATCH v7 05/15] iommu: Use bitmap to calculate page size in iommu_pgsize()

2021-06-17 Thread Lu Baolu
/* Pick the biggest page size remaining */ + pgsize_idx = __fls(pgsizes); + pgsize = BIT(pgsize_idx); return pgsize; } Reviewed-by: Lu Baolu Best regards, baolu ___ iommu mailing list iommu@lists.linux-foundation.org https://lis

Re: [PATCH v12 3/5] iommu/vt-d: Add support for IOMMU default DMA mode build options

2021-06-16 Thread Lu Baolu
On 2021/6/15 16:25, Robin Murphy wrote: On 2021-06-15 08:26, Lu Baolu wrote: Hi John, On 6/14/21 4:03 PM, John Garry wrote: On 12/06/2021 03:14, Lu Baolu wrote: On 2021/6/11 20:20, John Garry wrote: diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index 2a71347611d4..4467353f981b

Re: [PATCH v12 3/5] iommu/vt-d: Add support for IOMMU default DMA mode build options

2021-06-15 Thread Lu Baolu
Hi John, On 6/14/21 4:03 PM, John Garry wrote: On 12/06/2021 03:14, Lu Baolu wrote: On 2021/6/11 20:20, John Garry wrote: diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index 2a71347611d4..4467353f981b 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -94,6 +94,7

Re: [PATCH] iommu: Update "iommu.strict" documentation

2021-06-15 Thread Lu Baolu
ut a strict + mode explicitly specified by either method takes + precedence. iommu.passthrough= [ARM64, X86] Configure DMA to bypass the IOMMU by default. Reviewed-by: Lu Baolu Best regards, baolu __

Re: [PATCH v12 5/5] iommu: Remove mode argument from iommu_set_dma_strict()

2021-06-11 Thread Lu Baolu
On 2021/6/11 20:20, John Garry wrote: diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index ccbd5d4c1a50..146cb71c7441 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -350,10 +350,9 @@ static int __init iommu_dma_setup(char *str) } early_param("iommu.strict",

Re: [PATCH v12 3/5] iommu/vt-d: Add support for IOMMU default DMA mode build options

2021-06-11 Thread Lu Baolu
On 2021/6/11 20:20, John Garry wrote: @@ -453,8 +452,7 @@ static int __init intel_iommu_setup(char *str) pr_warn("intel_iommu=forcedac deprecated; use iommu.forcedac instead\n"); iommu_dma_forcedac = true; } else if (!strncmp(str,

Re: [PATCH v12 3/5] iommu/vt-d: Add support for IOMMU default DMA mode build options

2021-06-11 Thread Lu Baolu
On 2021/6/11 20:20, John Garry wrote: diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index 2a71347611d4..4467353f981b 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -94,6 +94,7 @@ choice prompt "IOMMU default DMA mode" depends on IOMMU_DMA +

Re: [PATCH v12 2/5] iommu: Enhance IOMMU default DMA mode build options

2021-06-11 Thread Lu Baolu
On 2021/6/11 20:20, John Garry wrote: +choice + prompt "IOMMU default DMA mode" This is not explicit. How about "IOMMU DMA default cache invalidation policy" ? Best regards, baolu + depends on IOMMU_DMA + + default IOMMU_DEFAULT_STRICT + help + This option

Re: [PATCH v12 2/5] iommu: Enhance IOMMU default DMA mode build options

2021-06-11 Thread Lu Baolu
On 2021/6/11 20:20, John Garry wrote: +config IOMMU_DEFAULT_LAZY + bool "lazy" + help + Support lazy mode, where for every IOMMU DMA unmap operation, the + flush operation of IOTLB and the free operation of IOVA are deferred. + They are only guaranteed to be

Re: [RFC PATCH v5 00/15] Optimizing iommu_[map/unmap] performance

2021-06-10 Thread Lu Baolu
Hi Isaac, Any update for this series? The iommu core part looks good to me and I also have some patches for Intel IOMMU implementation of [un]map_pages. Just wonder when could iommu core have this optimization. Best regards, baolu On 4/9/21 1:13 AM, Isaac J. Manjarres wrote: When unmapping a

Re: Plan for /dev/ioasid RFC v2

2021-06-09 Thread Lu Baolu
On 6/9/21 8:39 PM, Jason Gunthorpe wrote: On Wed, Jun 09, 2021 at 02:24:03PM +0200, Joerg Roedel wrote: On Mon, Jun 07, 2021 at 02:58:18AM +, Tian, Kevin wrote: - Device-centric (Jason) vs. group-centric (David) uAPI. David is not fully convinced yet. Based on discussion v2 will

[PATCH 23/23] iommu/vt-d: No need to typecast

2021-06-09 Thread Lu Baolu
From: Parav Pandit Page directory assignment by alloc_pgtable_page() or phys_to_virt() doesn't need typecasting as both routines return void*. Hence, remove typecasting from both the calls. Signed-off-by: Parav Pandit Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r

[PATCH 22/23] iommu/vt-d: Define counter explicitly as unsigned int

2021-06-09 Thread Lu Baolu
From: Parav Pandit Avoid below checkpatch warning. WARNING: Prefer 'unsigned int' to bare use of 'unsigned' + unsignediommu_refcnt[DMAR_UNITS_SUPPORTED]; Fixes: 29a27719abaa ("iommu/vt-d: Replace iommu_bmp with a refcount") Signed-off-by: Parav Pandit Signed-off-by

[PATCH 21/23] iommu/vt-d: Remove unnecessary braces

2021-06-09 Thread Lu Baolu
From: Parav Pandit No need for braces for single line statement under if() block. Signed-off-by: Parav Pandit Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210530075053.264218-1-pa...@nvidia.com --- drivers/iommu/intel/iommu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions

[PATCH 20/23] iommu/vt-d: Removed unused iommu_count in dmar domain

2021-06-09 Thread Lu Baolu
() by returning void. Signed-off-by: Parav Pandit Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210530075053.264218-1-pa...@nvidia.com --- include/linux/intel-iommu.h | 1 - drivers/iommu/intel/iommu.c | 11 +++ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/include/linux

[PATCH 19/23] iommu/vt-d: Use bitfields for DMAR capabilities

2021-06-09 Thread Lu Baolu
*/ /* forced alignments: 1 */ /* last cacheline: 48 bytes */ } __attribute__((__aligned__(8))); Signed-off-by: Parav Pandit Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210530075053.264218-1-pa...@nvidia.com --- include/linux/intel-iommu.h | 8 drivers

[PATCH 18/23] iommu/vt-d: Use DEVICE_ATTR_RO macro

2021-06-09 Thread Lu Baolu
From: YueHaibing Use DEVICE_ATTR_RO() helper instead of plain DEVICE_ATTR(), which makes the code a bit shorter and easier to read. Signed-off-by: YueHaibing Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210528130229.22108-1-yuehaib...@huawei.com --- drivers/iommu/intel/iommu.c

[PATCH 17/23] iommu/vt-d: Fix out-bounds-warning in intel/svm.c

2021-06-09 Thread Lu Baolu
the length of and , respectively. This helps with the ongoing efforts to globally enable -Warray-bounds and get us closer to being able to tighten the FORTIFY_SOURCE routines on memcpy(). Link: https://github.com/KSPP/linux/issues/109 Signed-off-by: Gustavo A. R. Silva Signed-off-by: Lu Baolu L

[PATCH 16/23] iommu/vt-d: Add PRQ handling latency sampling

2021-06-09 Thread Lu Baolu
The execution time for page fault request handling is performance critical and needs to be monitored. This adds code to sample the execution time of page fault request handling. Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210520031531.712333-1-baolu...@linux.intel.com --- drivers

[PATCH 15/23] iommu/vt-d: Add cache invalidation latency sampling

2021-06-09 Thread Lu Baolu
Queued invalidation execution time is performance critical and needs to be monitored. This adds code to sample the execution time of IOTLB/ devTLB/ICE cache invalidation. Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210520031531.712333-1-baolu...@linux.intel.com --- drivers/iommu

[PATCH 14/23] iommu/vt-d: Expose latency monitor data through debugfs

2021-06-09 Thread Lu Baolu
Read /sys/kernel/debug/iommu/intel/dmar_perf_latency gives a snapshot of sampling result of all enabled monitors. Signed-off-by: Fenghua Yu Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210520031531.712333-1-baolu...@linux.intel.com --- drivers/iommu/intel/debugfs.c | 111

[PATCH 13/23] iommu/vt-d: Add common code for dmar latency performance monitors

2021-06-09 Thread Lu Baolu
and providing a common string format for users. Signed-off-by: Fenghua Yu Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210520031531.712333-1-baolu...@linux.intel.com --- include/linux/intel-iommu.h | 1 + drivers/iommu/intel/perf.h | 73 +++ drivers/iommu/intel/perf.c | 166

[PATCH 12/23] iommu/vt-d: Add prq_report trace event

2021-06-09 Thread Lu Baolu
--l pasid=0x2 index=0x1 This will be helpful for I/O page fault related debugging. Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210520031531.712333-1-baolu...@linux.intel.com --- include/linux/intel-iommu.h| 29 +++ include/trace/events/intel_iommu.h

[PATCH 11/23] iommu/vt-d: Report prq to io-pgfault framework

2021-06-09 Thread Lu Baolu
Let the IO page fault requests get handled through the io-pgfault framework. Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210520031531.712333-1-baolu...@linux.intel.com --- drivers/iommu/intel/iommu.c | 14 ++- drivers/iommu/intel/svm.c | 84

[PATCH 10/23] iommu/vt-d: Allocate/register iopf queue for sva devices

2021-06-09 Thread Lu Baolu
This allocates and registers the iopf queue infrastructure for devices which want to support IO page fault for SVA. Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210520031531.712333-1-baolu...@linux.intel.com --- include/linux/intel-iommu.h | 2 ++ drivers/iommu/intel/iommu.c | 66

[PATCH 09/23] iommu/vt-d: Refactor prq_event_thread()

2021-06-09 Thread Lu Baolu
Refactor prq_event_thread() by moving handling single prq event out of the main loop. Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210520031531.712333-1-baolu...@linux.intel.com --- drivers/iommu/intel/svm.c | 239 ++ 1 file changed, 136

[PATCH 08/23] iommu/vt-d: Use common helper to lookup svm devices

2021-06-09 Thread Lu Baolu
It's common to iterate the svm device list and find a matched device. Add common helpers to do this and consolidate the code. Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210520031531.712333-1-baolu...@linux.intel.com --- drivers/iommu/intel/svm.c | 68

[PATCH 07/23] iommu/vt-d: Use iommu_sva_alloc(free)_pasid() helpers

2021-06-09 Thread Lu Baolu
Align the pasid alloc/free code with the generic helpers defined in the iommu core. This also refactored the SVA binding code to improve the readability. Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210520031531.712333-1-baolu...@linux.intel.com --- include/linux/intel-iommu.h

[PATCH 06/23] iommu/vt-d: Add pasid private data helpers

2021-06-09 Thread Lu Baolu
We are about to use iommu_sva_alloc/free_pasid() helpers in iommu core. That means the pasid life cycle will be managed by iommu core. Use a local array to save the per pasid private data instead of attaching it the real pasid. Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r

[PATCH 05/23] iommu/vt-d: Support asynchronous IOMMU nested capabilities

2021-06-09 Thread Lu Baolu
attached to a nested mode iommu_domain should support nested capabilility. Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210517065701.5078-1-baolu...@linux.intel.com --- drivers/iommu/intel/iommu.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers

[PATCH 04/23] iommu/vt-d: Select PCI_ATS explicitly

2021-06-09 Thread Lu Baolu
The Intel VT-d implementation supports device TLB management. Select PCI_ATS explicitly so that the pci_ats helpers are always available. Signed-off-by: Lu Baolu Acked-by: Will Deacon Link: https://lore.kernel.org/r/20210512065313.3441309-1-baolu...@linux.intel.com --- drivers/iommu/intel

[PATCH 02/23] iommu/vt-d: Fix kernel-doc syntax in file header

2021-06-09 Thread Lu Baolu
. '/*', to prevent kernel-doc from parsing it. Signed-off-by: Aditya Srivastava Acked-by: Randy Dunlap Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210523143245.19040-1-yashsri...@gmail.com --- drivers/iommu/intel/pasid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers

[PATCH 03/23] iommu/vt-d: Tweak the description of a DMA fault

2021-06-09 Thread Lu Baolu
0x as PASID for DMA requests w/o PASID. This is confusing. Tweak this by adding "NO_PASID" explicitly. Reviewed-by: Ashok Raj Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210517065425.4953-1-baolu...@linux.intel.com --- drivers/iommu/intel/dmar.c | 23 +++--

[PATCH 01/23] iommu/vt-d: Remove redundant assignment to variable agaw

2021-06-09 Thread Lu Baolu
Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210416171826.64091-1-colin.k...@canonical.com --- drivers/iommu/intel/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index be35284a2016..65c2ed760

[PATCH 00/23] [PULL REQUEST] Intel IOMMU Updates for Linux v5.14

2021-06-09 Thread Lu Baolu
Aditya Srivastava (1): iommu/vt-d: Fix kernel-doc syntax in file header Colin Ian King (1): iommu/vt-d: Remove redundant assignment to variable agaw Gustavo A. R. Silva (1): iommu/vt-d: Fix out-bounds-warning in intel/svm.c Lu Baolu (14): iommu/vt-d: Tweak the description of a DMA fault

Re: [PATCH] iommu/vt-d: Dump DMAR translation structure

2021-06-09 Thread Lu Baolu
On 5/27/21 7:35 AM, Kyung Min Park wrote: When the dmar translation fault happens, the kernel prints a single line fault reason with corresponding hexadecimal code defined in the Intel VT-d specification. Currently, when user wants to debug the translation fault in detail, debugfs is used for

Re: [PATCH 0/5] Short cleanups around DMAR

2021-06-09 Thread Lu Baolu
On 5/30/21 3:50 PM, Parav Pandit wrote: Hi David, Lu, This short series contains small cleanup patches for Intel iommu in DMAR area. Patch summary: Patch-1 uses bitfields for few DMAR capabilities Patch-2 removes unused iommu_count Patch-3 removed unnecessary braces Patch-4 define count data

Re: [PATCH -next] iommu/vt-d: use DEVICE_ATTR_RO macro

2021-06-09 Thread Lu Baolu
On 5/28/21 9:02 PM, YueHaibing wrote: Use DEVICE_ATTR_RO() helper instead of plain DEVICE_ATTR(), which makes the code a bit shorter and easier to read. Signed-off-by: YueHaibing Queued for v5.14. Thanks! Best regards, baolu ___ iommu mailing list

Re: [PATCH v2][next] iommu/vt-d: Fix out-bounds-warning in intel_svm_page_response()

2021-06-09 Thread Lu Baolu
On 4/15/21 4:14 AM, Gustavo A. R. Silva wrote: Replace a couple of calls to memcpy() with simple assignments in order to fix the following out-of-bounds warning: drivers/iommu/intel/svm.c:1198:4: warning: 'memcpy' offset [25, 32] from the object at 'desc' is out of the bounds of referenced

Re: [PATCH] iommu/vt-d: fix kernel-doc syntax in file header

2021-06-09 Thread Lu Baolu
On 5/23/21 10:32 PM, Aditya Srivastava wrote: The opening comment mark '/**' is used for highlighting the beginning of kernel-doc comments. The header for drivers/iommu/intel/pasid.c follows this syntax, but the content inside does not comply with kernel-doc. This line was probably not meant

Re: [PATCH] iommu: remove redundant assignment to variable agaw

2021-06-09 Thread Lu Baolu
On 4/17/21 1:18 AM, Colin King wrote: From: Colin Ian King The variable agaw is initialized with a value that is never read and it is being updated later with a new value as a counter in a for-loop. The initialization is redundant and can be removed. Addresses-Coverity: ("Unused value")

Re: [RFC] /dev/ioasid uAPI proposal

2021-06-03 Thread Lu Baolu
Hi David, On 6/3/21 1:54 PM, David Gibson wrote: On Tue, Jun 01, 2021 at 07:09:21PM +0800, Lu Baolu wrote: Hi Jason, On 2021/5/29 7:36, Jason Gunthorpe wrote: /* * Bind an user-managed I/O page table with the IOMMU * * Because user page table is untrusted, IOASID nesting must

Re: [RFC] /dev/ioasid uAPI proposal

2021-06-02 Thread Lu Baolu
On 6/3/21 7:23 AM, Jason Gunthorpe wrote: On Wed, Jun 02, 2021 at 12:01:57PM +0800, Lu Baolu wrote: On 6/2/21 1:26 AM, Jason Gunthorpe wrote: On Tue, Jun 01, 2021 at 07:09:21PM +0800, Lu Baolu wrote: This version only covers 1) and 4). Do you think we need to support 2), 3) and beyond? Yes

Re: [PATCH v3 0/7] iommu: Allow IOVA rcache range be configured

2021-06-02 Thread Lu Baolu
On 6/2/21 3:48 PM, John Garry wrote: On 02/06/2021 05:37, Lu Baolu wrote: On 6/1/21 10:29 PM, John Garry wrote: For streaming DMA mappings involving an IOMMU and whose IOVA len regularly exceeds the IOVA rcache upper limit (meaning that they are not cached), performance can be reduced

Re: [PATCH v3 0/7] iommu: Allow IOVA rcache range be configured

2021-06-01 Thread Lu Baolu
On 6/1/21 10:29 PM, John Garry wrote: For streaming DMA mappings involving an IOMMU and whose IOVA len regularly exceeds the IOVA rcache upper limit (meaning that they are not cached), performance can be reduced. This is much more pronounced from commit 4e89dce72521 ("iommu/iova: Retry from

Re: [RFC] /dev/ioasid uAPI proposal

2021-06-01 Thread Lu Baolu
On 6/2/21 1:26 AM, Jason Gunthorpe wrote: On Tue, Jun 01, 2021 at 07:09:21PM +0800, Lu Baolu wrote: This version only covers 1) and 4). Do you think we need to support 2), 3) and beyond? Yes aboslutely. The API should be flexable enough to specify the creation of all future page table

Re: [RFC] /dev/ioasid uAPI proposal

2021-06-01 Thread Lu Baolu
On 2021/6/1 15:15, Shenming Lu wrote: On 2021/6/1 13:10, Lu Baolu wrote: Hi Shenming, On 6/1/21 12:31 PM, Shenming Lu wrote: On 2021/5/27 15:58, Tian, Kevin wrote: /dev/ioasid provides an unified interface for managing I/O page tables for devices assigned to userspace. Device passthrough

Re: [RFC] /dev/ioasid uAPI proposal

2021-06-01 Thread Lu Baolu
Hi Jason, On 2021/5/29 7:36, Jason Gunthorpe wrote: /* * Bind an user-managed I/O page table with the IOMMU * * Because user page table is untrusted, IOASID nesting must be enabled * for this ioasid so the kernel can enforce its DMA isolation policy * through the parent ioasid.

Re: [RFC] /dev/ioasid uAPI proposal

2021-05-31 Thread Lu Baolu
Hi Jason W, On 6/1/21 1:08 PM, Jason Wang wrote: 2) If yes, what's the reason for not simply use the fd opened from /dev/ioas. (This is the question that is not answered) and what happens if we call GET_INFO for the ioasid_fd? 3) If not, how GET_INFO work? oh, missed this question in prior

Re: [RFC] /dev/ioasid uAPI proposal

2021-05-31 Thread Lu Baolu
Hi Shenming, On 6/1/21 12:31 PM, Shenming Lu wrote: On 2021/5/27 15:58, Tian, Kevin wrote: /dev/ioasid provides an unified interface for managing I/O page tables for devices assigned to userspace. Device passthrough frameworks (VFIO, vDPA, etc.) are expected to use this interface instead of

Re: [RFC] /dev/ioasid uAPI proposal

2021-05-31 Thread Lu Baolu
On 6/1/21 2:09 AM, Jason Gunthorpe wrote: device bind should fail if the device somehow isn't compatible with the scheme the user is tring to use. yeah, I guess you mean to fail the device attach when the IOASID is a nesting IOASID but the device is behind an iommu without nesting support.

Re: [RFC] /dev/ioasid uAPI proposal

2021-05-31 Thread Lu Baolu
On 5/31/21 7:31 PM, Liu Yi L wrote: On Fri, 28 May 2021 20:36:49 -0300, Jason Gunthorpe wrote: On Thu, May 27, 2021 at 07:58:12AM +, Tian, Kevin wrote: 2.1. /dev/ioasid uAPI + [---cut for short---] /* * Allocate an IOASID. * * IOASID is the FD-local software

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

2021-05-27 Thread Lu Baolu
Hi Shenming and Alex, On 5/27/21 7:03 PM, Shenming Lu wrote: I haven't fully read all the references, but who imposes the fact that there's only one fault handler per device? If type1 could register one handler and the vfio-pci bus driver another for the other level, would we need this path

[PATCH 1/1] iommu/vt-d: Fix sysfs leak in alloc_iommu()

2021-05-25 Thread Lu Baolu
From: Rolf Eike Beer iommu_device_sysfs_add() is called before, so is has to be cleaned on subsequent errors. Fixes: 39ab9555c2411 ("iommu: Add sysfs bindings for struct iommu_device") Cc: sta...@vger.kernel.org # 4.11.x Signed-off-by: Rolf Eike Beer Acked-by: Lu Baolu L

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

2021-05-25 Thread Lu Baolu
Hi Joerg, A small fix is queued for v5.13. It fixes: - sysfs leak in alloc_iommu. Please consider it for v5.13. Best regards, Lu Baolu Rolf Eike Beer (1): iommu/vt-d: Fix sysfs leak in alloc_iommu() drivers/iommu/intel/dmar.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion

Re: [PATCH 01/11] iommu/vt-d: Add pasid private data helpers

2021-05-23 Thread Lu Baolu
Hi Jacob, Thanks for reviewing my patch. On 5/22/21 5:25 AM, Jacob Pan wrote: Hi BaoLu, On Thu, 20 May 2021 11:15:21 +0800, Lu Baolu wrote: We are about to use iommu_sva_alloc/free_pasid() helpers in iommu core. That means the pasid life cycle will be managed by iommu core. Use a local

Re: [PATCH] iommu/vt-d: Fix sysfs leak in alloc_domain()

2021-05-21 Thread Lu Baolu
Hi Joerg, On 5/21/21 2:53 PM, Rolf Eike Beer wrote: Am Donnerstag, 22. April 2021, 07:34:17 CEST schrieb Lu Baolu: Hi Rolf, On 4/22/21 1:39 PM, Rolf Eike Beer wrote: iommu_device_sysfs_add() is called before, so is has to be cleaned on subsequent errors. Fixes: 39ab9555c2411 ("iommu

[PATCH 11/11] iommu/vt-d: Add PRQ handling latency sampling

2021-05-19 Thread Lu Baolu
The execution time for page fault request handling is performance critical and needs to be monitored. This adds code to sample the execution time of page fault request handling. Signed-off-by: Lu Baolu --- drivers/iommu/intel/svm.c | 16 +--- 1 file changed, 13 insertions(+), 3

[PATCH 10/11] iommu/vt-d: Add cache invalidation latency sampling

2021-05-19 Thread Lu Baolu
Queued invalidation execution time is performance critical and needs to be monitored. This adds code to sample the execution time of IOTLB/ devTLB/ICE cache invalidation. Signed-off-by: Lu Baolu --- drivers/iommu/intel/dmar.c | 31 +++ 1 file changed, 31 insertions

[PATCH 09/11] iommu/vt-d: Expose latency monitor data through debugfs

2021-05-19 Thread Lu Baolu
Read /sys/kernel/debug/iommu/intel/dmar_perf_latency gives a snapshot of sampling result of all enabled monitors. Signed-off-by: Fenghua Yu Signed-off-by: Lu Baolu --- drivers/iommu/intel/debugfs.c | 111 ++ drivers/iommu/intel/Kconfig | 1 + 2 files changed

[PATCH 08/11] iommu/vt-d: Add common code for dmar latency performance monitors

2021-05-19 Thread Lu Baolu
and providing a common string format for users. Signed-off-by: Fenghua Yu Signed-off-by: Lu Baolu --- include/linux/intel-iommu.h | 1 + drivers/iommu/intel/perf.h | 73 +++ drivers/iommu/intel/perf.c | 166 +++ drivers/iommu/intel/Kconfig | 3

[PATCH 07/11] iommu/vt-d: Add prq_report trace event

2021-05-19 Thread Lu Baolu
--l pasid=0x2 index=0x1 This will be helpful for I/O page fault related debugging. Signed-off-by: Lu Baolu --- include/linux/intel-iommu.h| 29 +++ include/trace/events/intel_iommu.h | 37 ++ drivers/iommu/intel/svm.c | 7

[PATCH 06/11] iommu/vt-d: Report prq to io-pgfault framework

2021-05-19 Thread Lu Baolu
Let the IO page fault requests get handled through the io-pgfault framework. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 14 ++- drivers/iommu/intel/svm.c | 84 +++-- 2 files changed, 17 insertions(+), 81 deletions(-) diff --git a/drivers

[PATCH 05/11] iommu/vt-d: Allocate/register iopf queue for sva devices

2021-05-19 Thread Lu Baolu
This allocates and registers the iopf queue infrastructure for devices which want to support IO page fault for SVA. Signed-off-by: Lu Baolu --- include/linux/intel-iommu.h | 2 ++ drivers/iommu/intel/iommu.c | 66 ++--- drivers/iommu/intel/svm.c | 37

[PATCH 04/11] iommu/vt-d: Refactor prq_event_thread()

2021-05-19 Thread Lu Baolu
Refactor prq_event_thread() by moving handling single prq event out of the main loop. Signed-off-by: Lu Baolu --- drivers/iommu/intel/svm.c | 239 ++ 1 file changed, 136 insertions(+), 103 deletions(-) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu

[PATCH 02/11] iommu/vt-d: Use iommu_sva_alloc(free)_pasid() helpers

2021-05-19 Thread Lu Baolu
Align the pasid alloc/free code with the generic helpers defined in the iommu core. This also refactored the SVA binding code to improve the readability. Signed-off-by: Lu Baolu --- include/linux/intel-iommu.h | 1 - drivers/iommu/intel/iommu.c | 3 + drivers/iommu/intel/svm.c | 278

[PATCH 03/11] iommu/vt-d: Use common helper to lookup svm devices

2021-05-19 Thread Lu Baolu
It's common to iterate the svm device list and find a matched device. Add common helpers to do this and consolidate the code. Signed-off-by: Lu Baolu --- drivers/iommu/intel/svm.c | 68 +++ 1 file changed, 40 insertions(+), 28 deletions(-) diff --git

<    4   5   6   7   8   9   10   11   12   13   >