Re: [PATCH v3 4/6] iommu: Move IOMMU pagesize check to attach_device

2021-10-21 Thread Lu Baolu
On 10/21/21 4:10 PM, Marc Zyngier wrote: On Thu, 21 Oct 2021 03:22:30 +0100, Lu Baolu wrote: On 10/20/21 10:22 PM, Marc Zyngier wrote: On Wed, 20 Oct 2021 06:21:44 +0100, Lu Baolu wrote: On 2021/10/20 0:37, Sven Peter via iommu wrote: + /* +* Check that CPU pages can

Re: [PATCH v3 4/6] iommu: Move IOMMU pagesize check to attach_device

2021-10-20 Thread Lu Baolu
On 10/20/21 10:22 PM, Marc Zyngier wrote: On Wed, 20 Oct 2021 06:21:44 +0100, Lu Baolu wrote: On 2021/10/20 0:37, Sven Peter via iommu wrote: The iova allocator is capable of handling any granularity which is a power of two. Remove the much stronger condition that the granularity must

Re: [PATCH v3 4/6] iommu: Move IOMMU pagesize check to attach_device

2021-10-19 Thread Lu Baolu
On 2021/10/20 0:37, Sven Peter via iommu wrote: The iova allocator is capable of handling any granularity which is a power of two. Remove the much stronger condition that the granularity must be smaller or equal to the CPU page size from a BUG_ON there. Instead, check this condition during

[PATCH 9/9] iommu/vt-d: Avoid duplicate removing in __domain_mapping()

2021-10-13 Thread Lu Baolu
: 0x1c, end_pfn: 0x1f iov_pfn: 0x20, end_pfn: 0x23 ... it only need 9ms now. This also removes a meaningless BUG_ON() in __domain_mapping(). Signed-off-by: Longpeng(Mike) Tested-by: Liujunjie Link: https://lore.kernel.org/r/20211008000433.1115-1-longpe...@huawei.com Signed-

[PATCH 8/9] iommu/vt-d: Convert the return type of first_pte_in_page to bool

2021-10-13 Thread Lu Baolu
huawei.com Signed-off-by: Lu Baolu --- include/linux/intel-iommu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h index 65b15af3cf1a..52481625838c 100644 --- a/include/linux/intel-iommu.h +++ b/include/linux/int

[PATCH 7/9] iommu/vt-d: Clean up unused PASID updating functions

2021-10-13 Thread Lu Baolu
functions. Signed-off-by: Fenghua Yu Reviewed-by: Tony Luck Link: https://lore.kernel.org/r/20210920192349.2602141-1-fenghua...@intel.com Signed-off-by: Lu Baolu --- arch/x86/include/asm/fpu/api.h | 2 -- drivers/iommu/intel/svm.c | 24 +--- 2 files changed, 1 insertion

[PATCH 6/9] iommu/vt-d: Delete dev_has_feat callback

2021-10-13 Thread Lu Baolu
The commit 262948f8ba573 ("iommu: Delete iommu_dev_has_feature()") has deleted the iommu_dev_has_feature() interface. Remove the dev_has_feat callback to avoid dead code. Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210929072030.1330225-1-baolu...@linux.intel.com --- dri

[PATCH 5/9] iommu/vt-d: Use second level for GPA->HPA translation

2021-10-13 Thread Lu Baolu
we can provide a consistent hardware interface for use cases like dirty page tracking for live migration. Signed-off-by: Lu Baolu Reviewed-by: Kevin Tian Link: https://lore.kernel.org/r/20210926114535.923263-1-baolu...@linux.intel.com --- drivers/iommu/intel/iommu.c | 15 --- 1 file chang

[PATCH 4/9] iommu/vt-d: Check FL and SL capability sanity in scalable mode

2021-10-13 Thread Lu Baolu
on all IOMMU's. This adds a check for this and aborts IOMMU probing if it doesn't meet this requirement. Signed-off-by: Lu Baolu Reviewed-by: Kevin Tian Link: https://lore.kernel.org/r/20210926114535.923263-1-baolu...@linux.intel.com --- drivers/iommu/intel/cap_audit.h | 1 + drivers/iommu/intel

[PATCH 3/9] iommu/vt-d: Remove duplicate identity domain flag

2021-10-13 Thread Lu Baolu
The iommu_domain data structure already has the "type" field to keep the type of a domain. It's unnecessary to have the DOMAIN_FLAG_STATIC_IDENTITY flag in the vt-d implementation. This cleans it up with no functionality change. Signed-off-by: Lu Baolu Reviewed-by: Kevin Tian L

[PATCH 0/9] [PULL REQUEST] Intel IOMMU Updates for Linux v5.16

2021-10-13 Thread Lu Baolu
ing() Lu Baolu (4): iommu/vt-d: Remove duplicate identity domain flag iommu/vt-d: Check FL and SL capability sanity in scalable mode iommu/vt-d: Use second level for GPA->HPA translation iommu/vt-d: Delete dev_has_feat callback Tvrtko Ursulin (1): iommu/vt-d: Do not falsely log intel

[PATCH 2/9] iommu/vt-d: Dump DMAR translation structure when DMA fault occurs

2021-10-13 Thread Lu Baolu
://lore.kernel.org/r/20210815203845.31287-1-kyung.min.p...@intel.com Signed-off-by: Lu Baolu --- include/linux/dmar.h| 8 +++ drivers/iommu/intel/dmar.c | 10 +++- drivers/iommu/intel/iommu.c | 113 drivers/iommu/intel/Kconfig | 4 ++ 4 files changed, 133

[PATCH 1/9] iommu/vt-d: Do not falsely log intel_iommu is unsupported kernel option

2021-10-13 Thread Lu Baolu
Reported-by: Eero Tamminen Signed-off-by: Tvrtko Ursulin Link: https://lore.kernel.org/r/20210831112947.310080-1-tvrtko.ursu...@linux.intel.com Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/iommu.c

Re: [PATCH v1 1/2] iommu/vt-d: Move intel_iommu_ops to header file

2021-10-08 Thread Lu Baolu
Hi Andy, On 2021/10/7 0:14, Andy Shevchenko wrote: On Fri, Jul 30, 2021 at 10:20:08AM +0800, Lu Baolu wrote: Hi Andy, On 7/30/21 12:35 AM, Andy Shevchenko wrote: Compiler is not happy about hidden declaration of intel_iommu_ops. .../drivers/iommu/intel/iommu.c:414:24: warning: symbol

Re: [PATCH v1 1/2] iommu/vt-d: Move intel_iommu_ops to header file

2021-10-07 Thread Lu Baolu
Hi Andy, On 10/7/21 12:14 AM, Andy Shevchenko wrote: On Fri, Jul 30, 2021 at 10:20:08AM +0800, Lu Baolu wrote: Hi Andy, On 7/30/21 12:35 AM, Andy Shevchenko wrote: Compiler is not happy about hidden declaration of intel_iommu_ops. .../drivers/iommu/intel/iommu.c:414:24: warning: symbol

Re: [PATCH v3 2/2] iommu/vt-d: avoid duplicated removing in __domain_mapping

2021-10-07 Thread Lu Baolu
On 10/8/21 10:07 AM, Lu Baolu wrote: On 10/8/21 8:04 AM, Longpeng(Mike) wrote: __domain_mapping() always removes the pages in the range from 'iov_pfn' to 'end_pfn', but the 'end_pfn' is always the last pfn of the range that the caller wants to map. This would introduce too many duplicated

Re: [PATCH v3 2/2] iommu/vt-d: avoid duplicated removing in __domain_mapping

2021-10-07 Thread Lu Baolu
On 10/8/21 8:04 AM, Longpeng(Mike) wrote: __domain_mapping() always removes the pages in the range from 'iov_pfn' to 'end_pfn', but the 'end_pfn' is always the last pfn of the range that the caller wants to map. This would introduce too many duplicated removing and leads the map operation take

Re: [PATCH v2 1/2] iommu/vt-d: convert the return type of first_pte_in_page to bool

2021-10-07 Thread Lu Baolu
On 2021/10/5 23:23, Longpeng(Mike) wrote: first_pte_in_page() returns boolean value, so let's convert its return type to bool. Signed-off-by: Longpeng(Mike) --- include/linux/intel-iommu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/intel-iommu.h

Re: [PATCH] iommu: intel: remove flooding of non-error logs, when new-DMA-PTE is the same as old-DMA-PTE.

2021-10-02 Thread Lu Baolu
On 2021/10/2 20:40, Ajay Garg wrote: Taking a SD-MMC controller (over PCI) as an example, following is an example sequencing, where the log-flooding happened : 0. We have a host and a guest, both running latest x86_64 kernels. 1. Host-machine is booted up (with intel_iommu=on), and the

Re: [PATCH v1 2/2] iommu/vt-d: avoid duplicated removing in __domain_mapping

2021-09-30 Thread Lu Baolu
Hi Longpeng, On 2021/9/15 23:21, Longpeng(Mike) wrote: __domain_mapping() always removes the pages in the range from 'iov_pfn' to 'end_pfn', but the 'end_pfn' is always the last pfn of the range that the caller wants to map. This would introduce too many duplicated removing and leads the map

Re: [RFC 10/20] iommu/iommufd: Add IOMMU_DEVICE_GET_INFO

2021-09-30 Thread Lu Baolu
On 2021/9/30 16:49, Tian, Kevin wrote: From: Jason Gunthorpe Sent: Thursday, September 23, 2021 8:22 PM These are different things and need different bits. Since the ARM path has a lot more code supporting it, I'd suggest Intel should change their code to use IOMMU_BLOCK_NO_SNOOP and abandon

Re: [RFC 04/20] iommu: Add iommu_device_get_info interface

2021-09-29 Thread Lu Baolu
On 2021/9/29 17:25, Lu Baolu wrote: Hi David, On 2021/9/29 10:52, David Gibson wrote: On Sun, Sep 19, 2021 at 02:38:32PM +0800, Liu Yi L wrote: From: Lu Baolu This provides an interface for upper layers to get the per-device iommu attributes. int iommu_device_get_info(struct device

Re: [RFC 04/20] iommu: Add iommu_device_get_info interface

2021-09-29 Thread Lu Baolu
Hi David, On 2021/9/29 10:52, David Gibson wrote: On Sun, Sep 19, 2021 at 02:38:32PM +0800, Liu Yi L wrote: From: Lu Baolu This provides an interface for upper layers to get the per-device iommu attributes. int iommu_device_get_info(struct device *dev

Re: [PATCH 1/8] iommu/vt-d: Clean up unused PASID updating functions

2021-09-29 Thread Lu Baolu
Hi Fenghua, On 2021/9/21 3:23, Fenghua Yu wrote: update_pasid() and its call chain are currently unused in the tree because Thomas disabled the ENQCMD feature. The feature will be re-enabled shortly using a different approach and update_pasid() and its call chain will not be used in the new

[PATCH 1/1] iommu/vt-d: Delete dev_has_feat callback

2021-09-29 Thread Lu Baolu
The commit 262948f8ba573 ("iommu: Delete iommu_dev_has_feature()") has deleted the iommu_dev_has_feature() interface. Remove the dev_has_feat callback to avoid dead code. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 59 - 1 file

Re: [RFC 06/20] iommu: Add iommu_device_init[exit]_user_dma interfaces

2021-09-28 Thread Lu Baolu
On 9/29/21 10:29 AM, Tian, Kevin wrote: From: Lu Baolu Sent: Wednesday, September 29, 2021 10:22 AM On 9/28/21 10:07 PM, Jason Gunthorpe wrote: On Tue, Sep 28, 2021 at 09:35:05PM +0800, Lu Baolu wrote: Another issue is, when putting a device into user-dma mode, all devices belonging

Re: [RFC 06/20] iommu: Add iommu_device_init[exit]_user_dma interfaces

2021-09-28 Thread Lu Baolu
On 9/28/21 10:07 PM, Jason Gunthorpe wrote: On Tue, Sep 28, 2021 at 09:35:05PM +0800, Lu Baolu wrote: Another issue is, when putting a device into user-dma mode, all devices belonging to the same iommu group shouldn't be bound with a kernel-dma driver. Kevin's prototype checks this by READ_ONCE

Re: [PATCH v2 9/9] iommu/vt-d: Use pci core's DVSEC functionality

2021-09-28 Thread Lu Baolu
Hi Dan, On 9/29/21 1:54 AM, Dan Williams wrote: On Thu, Sep 23, 2021 at 10:27 AM Ben Widawsky wrote: Reduce maintenance burden of DVSEC query implementation by using the centralized PCI core implementation. Cc: iommu@lists.linux-foundation.org Cc: David Woodhouse Cc: Lu Baolu Signed-off

Re: [RFC 06/20] iommu: Add iommu_device_init[exit]_user_dma interfaces

2021-09-28 Thread Lu Baolu
Hi Jason, On 2021/9/28 19:57, Jason Gunthorpe wrote: On Tue, Sep 28, 2021 at 07:30:41AM +, Tian, Kevin wrote: Also, don't call it "hint", there is nothing hinty about this, it has definitive functional impacts. possibly dma_mode (too broad?) or dma_usage You just need a flag to

Re: [RFC 06/20] iommu: Add iommu_device_init[exit]_user_dma interfaces

2021-09-27 Thread Lu Baolu
On 2021/9/27 17:42, Tian, Kevin wrote: +int iommu_device_set_dma_hint(struct device *dev, enum dma_hint hint) +{ + struct iommu_group *group; + int ret; + + group = iommu_group_get(dev); + /* not an iommu-probed device */ + if (!group) + return 0; + +

Re: [PATCH v2 2/3] iommu/vt-d: Check FL and SL capability sanity in scalable mode

2021-09-26 Thread Lu Baolu
On 9/27/21 9:33 AM, Tian, Kevin wrote: From: Tian, Kevin Sent: Monday, September 27, 2021 9:30 AM From: Tian, Kevin Sent: Monday, September 27, 2021 9:12 AM From: Lu Baolu Sent: Sunday, September 26, 2021 7:46 PM An iommu domain could be allocated and mapped before it's attached to any

[PATCH v2 1/3] iommu/vt-d: Remove duplicate identity domain flag

2021-09-26 Thread Lu Baolu
The iommu_domain data structure already has the "type" field to keep the type of a domain. It's unnecessary to have the DOMAIN_FLAG_STATIC_IDENTITY flag in the vt-d implementation. This cleans it up with no functionality change. Signed-off-by: Lu Baolu --- include/linux/intel-i

[PATCH v2 3/3] iommu/vt-d: Use second level for GPA->HPA translation

2021-09-26 Thread Lu Baolu
we can provide a consistent hardware interface for use cases like dirty page tracking for live migration. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c

[PATCH v2 2/3] iommu/vt-d: Check FL and SL capability sanity in scalable mode

2021-09-26 Thread Lu Baolu
on all IOMMU's. This adds a check for this and aborts IOMMU probing if it doesn't meet this requirement. Signed-off-by: Lu Baolu --- drivers/iommu/intel/cap_audit.h | 1 + drivers/iommu/intel/cap_audit.c | 13 + 2 files changed, 14 insertions(+) diff --git a/drivers/iommu/intel

[PATCH v2 0/3] iommu/t-d: Use SL for GPA->HPA translation

2021-09-26 Thread Lu Baolu
v1: https://lore.kernel.org/linux-iommu/20210924022931.780963-1-baolu...@linux.intel.com/ Change log: v1->v2: - Split the cleanup into a separated patch - Add a patch to check sanity of capabilities - Consider capabilities when determining FL or SL Best regards, Baolu Lu Baolu (3): io

Re: [PATCH 1/1] iommu/vt-d: Use second level for GPA->HPA translation

2021-09-25 Thread Lu Baolu
Hi Kevin, Thanks for reviewing my patch. On 9/24/21 11:16 AM, Tian, Kevin wrote: From: Lu Baolu Sent: Friday, September 24, 2021 10:30 AM The IOMMU VT-d implementation uses the first level for GPA->HPA translation by default. Although both the first level and the second level could han

[PATCH 1/1] iommu/vt-d: Use second level for GPA->HPA translation

2021-09-23 Thread Lu Baolu
age tracking and the page-level forcing snoop. With first level translation, there're no such controls. This uses the second level for GPA->HPA translation so that it could provide a consistent hardware interface for use cases like dirty page tracking during the VM live migration. Signed-off-by: Lu

Re: [PATCH 5/8] x86/mmu: Add mm-based PASID refcounting

2021-09-22 Thread Lu Baolu
Hi Fenghua, On 9/21/21 3:23 AM, Fenghua Yu wrote: PASIDs are fundamentally hardware resources in a shared address space. There is a limited number of them to use ENQCMD on shared workqueue. They must be shared and managed. They can not, for instance, be statically allocated to processes. Free

Re: [PATCH] iommu/vt-d: Drop "0x" prefix from PCI bus & device addresses

2021-09-21 Thread Lu Baolu
Hi Bjorn, On 9/4/21 3:37 AM, Bjorn Helgaas wrote: From: Bjorn Helgaas 719a19335692 ("iommu/vt-d: Tweak the description of a DMA fault") changed the DMA fault reason from hex to decimal. It also added "0x" prefixes to the PCI bus/device, e.g., - DMAR: [INTR-REMAP] Request device [00:00.5]

[PATCH 1/1] iommu/vt-d: Drop "0x" prefix from PCI bus & device addresses

2021-09-21 Thread Lu Baolu
igned-off-by: Bjorn Helgaas Link: https://lore.kernel.org/r/20210903193711.483999-1-helg...@kernel.org Signed-off-by: Lu Baolu --- drivers/iommu/intel/dmar.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c index 0ec5514

[PATCH 0/1] iommu/vt-d: A fix for v5.15-rc3

2021-09-21 Thread Lu Baolu
Hi Joerg, A fix is queued for v5.15. It aims to fix: - Drop "0x" prefix from PCI bus & device addresses Please consider it for the iommu/fix branch. Best regards, Lu Baolu Bjorn Helgaas (1): iommu/vt-d: Drop "0x" prefix from PCI bus & device addresses dr

Re: [RFC 04/20] iommu: Add iommu_device_get_info interface

2021-09-21 Thread Lu Baolu
Hi Jason, On 9/22/21 12:19 AM, Jason Gunthorpe wrote: On Sun, Sep 19, 2021 at 02:38:32PM +0800, Liu Yi L wrote: From: Lu Baolu This provides an interface for upper layers to get the per-device iommu attributes. int iommu_device_get_info(struct device *dev

[PATCH 2/2] iommu/vt-d: Fix a deadlock in intel_svm_drain_prq()

2021-08-28 Thread Lu Baolu
d-and-tested-by: Dave Jiang Signed-off-by: Fenghua Yu Link: https://lore.kernel.org/r/20210826215918.4073446-1-fenghua...@intel.com Signed-off-by: Lu Baolu --- drivers/iommu/intel/svm.c | 12 1 file changed, 12 insertions(+) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.

[PATCH 1/2] iommu/vt-d: Fix PASID leak in intel_svm_unbind_mm()

2021-08-28 Thread Lu Baolu
igned-off-by: Jacob Pan Signed-off-by: Fenghua Yu Link: https://lore.kernel.org/r/20210826215918.4073446-1-fenghua...@intel.com Signed-off-by: Lu Baolu --- drivers/iommu/intel/svm.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c

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

2021-08-28 Thread Lu Baolu
Hi Joerg, Two small fixes are queued for v5.15. They aim to fix: - PASID leakage in intel_svm_unbind_mm(); - Deadlock in intel_svm_drain_prq(). Please consider them for the iommu/fix branch. Best regards, Lu Baolu Fenghua Yu (2): iommu/vt-d: Fix PASID leak in intel_svm_unbind_mm() iommu

Re: [PATCH 1/2] iommu/vt-d: Fix PASID leak

2021-08-27 Thread Lu Baolu
Hi Fenghua, On 2021/8/27 5:59, Fenghua Yu wrote: mm->pasid will be used in intel_svm_free_pasid() after load_pasid() during unbinding mm. Clearing it in load_pasid() will cause PASID cannot be freed in intel_svm_free_pasid(). Additionally mm->pasid was updated already before load_pasid()

Re: [PATCH 2/2] iommu/vt-d: Fix a deadlock in SVM

2021-08-27 Thread Lu Baolu
Hi Fenghua, On 2021/8/27 5:59, Fenghua Yu wrote: pasid_mutex and dev->iommu->param->lock are held while unbinding mm is flushing IO page fault workqueue and waiting for all page fault works to finish. But an in-flight page fault work also need to hold the two locks while unbinding mm are

[PATCH 9/9] iommu/vt-d: Add present bit check in pasid entry setup helpers

2021-08-18 Thread Lu Baolu
From: Liu Yi L The helper functions should not modify the pasid entries which are still in use. Add a check against present bit. Signed-off-by: Liu Yi L Link: https://lore.kernel.org/r/20210817042425.1784279-1-yi.l@intel.com Signed-off-by: Lu Baolu --- drivers/iommu/intel/pasid.c | 16

[PATCH 8/9] iommu/vt-d: Use pasid_pte_is_present() helper function

2021-08-18 Thread Lu Baolu
From: Liu Yi L Use the pasid_pte_is_present() helper for present bit check in the intel_pasid_tear_down_entry(). Signed-off-by: Liu Yi L Link: https://lore.kernel.org/r/20210817042425.1784279-1-yi.l@intel.com Signed-off-by: Lu Baolu --- drivers/iommu/intel/pasid.c | 2 +- 1 file changed

[PATCH 7/9] iommu/vt-d: Drop the kernel doc annotation

2021-08-18 Thread Lu Baolu
doc annotation since the top comment is not in the required format. Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210729163538.40101-1-andriy.shevche...@linux.intel.com Signed-off-by: Lu Baolu --- drivers/iommu/intel/perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion

[PATCH 6/9] iommu/vt-d: Allow devices to have more than 32 outstanding PRs

2021-08-18 Thread Lu Baolu
IOMMU PRQ queue, but far from optimal for customized use case. This extends the per-IOMMU PRQ queue size to four 4K pages and let the devices have as many outstanding page requests as they can. Signed-off-by: Jacob Pan Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r

[PATCH 5/9] iommu/vt-d: Preset A/D bits for user space DMA usage

2021-08-18 Thread Lu Baolu
it to minimize the overhead. Suggested-by: Sanjay Kumar Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210720013856.4143880-1-baolu...@linux.intel.com --- drivers/iommu/intel/iommu.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b

[PATCH 4/9] iommu/vt-d: Enable Intel IOMMU scalable mode by default

2021-08-18 Thread Lu Baolu
ss have been enabled. This enables the scalable mode by default if the hardware advertises the support and adds kernel options of "intel_iommu=sm_on/sm_off" for end users to configure it through the kernel parameters. Suggested-by: Ashok Raj Suggested-by: Sanjay Kumar Signed-off-by: Lu Baolu

[PATCH 2/9] iommu/vt-d: Remove unnecessary oom message

2021-08-18 Thread Lu Baolu
From: Zhen Lei Fixes scripts/checkpatch.pl warning: WARNING: Possible unnecessary 'out of memory' message Remove it can help us save a bit of memory. Signed-off-by: Zhen Lei Link: https://lore.kernel.org/r/20210609124937.14260-1-thunder.leiz...@huawei.com Signed-off-by: Lu Baolu

[PATCH 3/9] iommu/vt-d: Refactor Kconfig a bit

2021-08-18 Thread Lu Baolu
Put all sub-options inside a "if INTEL_IOMMU" so that they don't need to always depend on INTEL_IOMMU. Use IS_ENABLED() instead of #ifdef as well. Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20210720013856.4143880-1-baolu...@linux.intel.com --- drivers/iommu/intel/io

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

2021-08-18 Thread Lu Baolu
driver accordingly. Fixes: 24f27d32ab6b7 ("iommu/vt-d: Enlightened PASID allocation") Signed-off-by: Lu Baolu Cc: Ashok Raj Cc: Sanjay Kumar Cc: Kevin Tian Link: https://lore.kernel.org/r/20210713042649.3547403-1-baolu...@linux.intel.com --- include/linux/intel-iommu.h | 6 +++--

[PATCH 0/9] [PULL REQUEST] Intel IOMMU Updates for Linux v5.15

2021-08-18 Thread Lu Baolu
pull. Best regards, Baolu Andy Shevchenko (1): iommu/vt-d: Drop the kernel doc annotation Liu Yi L (2): iommu/vt-d: Use pasid_pte_is_present() helper function iommu/vt-d: Add present bit check in pasid entry setup helpers Lu Baolu (5): iommu/vt-d: Update the virtual command related

Re: [PATCH] iommu/vt-d: Fix PASID reference leak

2021-08-17 Thread Lu Baolu
On 2021/8/14 2:13, Fenghua Yu wrote: A PASID reference is increased whenever a device is bound to an mm (and its PASID) successfully (i.e. the device's sdev user count is increased). But the reference is not dropped every time the device is unbound successfully from the mm (i.e. the device's

Re: [PATCH v1 3/3] iommu/vt-d: Fix Unexpected page request in Privilege Mode

2021-08-17 Thread Lu Baolu
or PT using PASID-based IOTLB flush is enough. Fixes: 1c4f88b7f1f9 ("iommu/vt-d: Shared virtual address in scalable mode") Cc: Lu Baolu Signed-off-by: Kumar Sanjay K Signed-off-by: Liu Yi L Tested-by: Yi Sun Good catch! Thanks! It has been queued for iommu/fix. Best rega

[PATCH 2/2] iommu/vt-d: Fix incomplete cache flush in intel_pasid_tear_down_entry()

2021-08-17 Thread Lu Baolu
25.1784279-1-yi.l@intel.com Signed-off-by: Lu Baolu --- drivers/iommu/intel/pasid.h | 6 ++ drivers/iommu/intel/pasid.c | 10 -- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/intel/pasid.h b/drivers/iommu/intel/pasid.h index 5ff61c3d401f..c11bc8b83

[PATCH 1/2] iommu/vt-d: Fix PASID reference leak

2021-08-17 Thread Lu Baolu
on successful unbinding the device by calling intel_svm_free_pasid() . Fixes: 4048377414162 ("iommu/vt-d: Use iommu_sva_alloc(free)_pasid() helpers") Signed-off-by: Fenghua Yu Link: https://lore.kernel.org/r/20210813181345.1870742-1-fenghua...@intel.com Signed-off-by: Lu Baolu --- dri

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

2021-08-17 Thread Lu Baolu
Hi Joerg, Two small fixes are queued for v5.14. They aim to fix: - PASID reference leakage in intel_svm_unbind_mm(); - An improper iotlb invalidation in intel_pasid_tear_down_entry(). Please consider it for your iommu/fix branch. Best regards, Lu Baolu Fenghua Yu (1): iommu/vt-d: Fix

Re: [PATCH] iommu/vt-d: Fix PASID reference leak

2021-08-14 Thread Lu Baolu
when no reference on successful unbinding the device by calling intel_svm_free_pasid() . Signed-off-by: Fenghua Yu Nice catch! Thanks! Fixes: 4048377414162 ("iommu/vt-d: Use iommu_sva_alloc(free)_pasid() helpers") Acked-by: Lu Baolu Best regards, baolu --- drivers/iommu/intel

Re: [PATCH v1 1/2] iommu/vt-d: Move intel_iommu_ops to header file

2021-08-11 Thread Lu Baolu
On 2021/8/11 21:49, Andy Shevchenko wrote: On Fri, Jul 30, 2021 at 09:01:41PM +0800, Lu Baolu wrote: On 2021/7/30 16:05, Andy Shevchenko wrote: On Fri, Jul 30, 2021 at 10:20:08AM +0800, Lu Baolu wrote: On 7/30/21 12:35 AM, Andy Shevchenko wrote: Compiler is not happy about hidden declaration

Re: [PATCH v1 1/2] iommu/vt-d: Move intel_iommu_ops to header file

2021-07-30 Thread Lu Baolu
On 2021/7/30 16:05, Andy Shevchenko wrote: On Fri, Jul 30, 2021 at 10:20:08AM +0800, Lu Baolu wrote: On 7/30/21 12:35 AM, Andy Shevchenko wrote: Compiler is not happy about hidden declaration of intel_iommu_ops. .../drivers/iommu/intel/iommu.c:414:24: warning: symbol 'intel_iommu_ops

Re: [PATCH v2 24/24] iommu: Only log strictness for DMA domains

2021-07-30 Thread Lu Baolu
alidation policy: %s mode %s\n", + iommu_dma_strict ? "strict" : "lazy", + (iommu_cmd_line & IOMMU_CMD_LINE_STRICT) ? + "(set via kernel command line)" : ""); return 0; }

Re: [PATCH v2 22/24] iommu: Allow enabling non-strict mode dynamically

2021-07-30 Thread Lu Baolu
->default_domain->type == IOMMU_DOMAIN_DMA)) { pr_err_ratelimited("Device is still bound to driver\n"); ret = -EBUSY; goto out; Reviewed-by: Lu Baolu Best regards, baolu ___ iommu mailing list iommu@lists.linu

Re: [PATCH v2 21/24] iommu/dma: Factor out flush queue init

2021-07-30 Thread Lu Baolu
ookie(struct iommu_domain *domain) { return -ENODEV; Reviewed-by: Lu Baolu Best regards, baolu ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v2 20/24] iommu: Merge strictness and domain type configs

2021-07-30 Thread Lu Baolu
et *iommu_group_kset; static DEFINE_IDA(iommu_group_ida); static unsigned int iommu_def_domain_type __read_mostly; -static bool iommu_dma_strict __read_mostly = IS_ENABLED(CONFIG_IOMMU_DEFAULT_STRICT); +static bool iommu_dma_strict __read_mostly = IS_ENABLED(CONFIG_IOMMU_DEFAULT_

Re: [PATCH v2 19/24] iommu: Expose DMA domain strictness via sysfs

2021-07-30 Thread Lu Baolu
, "DMA")) req_type = IOMMU_DOMAIN_DMA; + else if (sysfs_streq(buf, "DMA-FQ")) + req_type = IOMMU_DOMAIN_DMA_FQ; else if (sysfs_streq(buf, "auto")) req_type = 0; else Reviewed-by:

Re: [PATCH v2 18/24] iommu: Express DMA strictness via the domain type

2021-07-30 Thread Lu Baolu
On 7/29/21 5:36 PM, Robin Murphy wrote: On 2021-07-29 08:13, Lu Baolu wrote: Hi Robin, On 7/28/21 11:58 PM, Robin Murphy wrote: diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 982545234cf3..eecb5657de69 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -136,6

Re: [PATCH v2 17/24] iommu/vt-d: Prepare for multiple DMA domain types

2021-07-30 Thread Lu Baolu
ops(dev, 0, U64_MAX); } static void intel_iommu_get_resv_regions(struct device *device, Reviewed-by: Lu Baolu Best regards, baolu ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v2 14/24] iommu: Introduce explicit type for non-strict DMA domains

2021-07-30 Thread Lu Baolu
struct iommu_domain *domain) +{ + return domain->type & __IOMMU_DOMAIN_DMA_API; +} + enum iommu_cap { IOMMU_CAP_CACHE_COHERENCY, /* IOMMU can enforce cache coherent DMA transactions */ Reviewed-by: Lu Baolu Best regar

Re: [PATCH v2 13/24] iommu/dma: Remove redundant "!dev" checks

2021-07-30 Thread Lu Baolu
= domain; } - if (!dev) - return 0; - return iova_reserve_iommu_regions(dev, domain); } Reviewed-by: Lu Baolu Best regards, baolu ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v2 12/24] iommu/dma: Unexport IOVA cookie management

2021-07-30 Thread Lu Baolu
if (type == IOMMU_DOMAIN_DMA && iommu_get_dma_cookie(domain) == -ENOMEM) { + if (type == IOMMU_DOMAIN_DMA && iommu_get_dma_cookie(domain)) { iommu_domain_free(domain); domain = NULL; } Reviewed-by:

Re: [PATCH v2 04/24] iommu/vt-d: Drop IOVA cookie management

2021-07-30 Thread Lu Baolu
ain->geometry.aperture_end = Reviewed-by: Lu Baolu Best regards, baolu ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v2 01/24] iommu: Pull IOVA cookie management into the core

2021-07-30 Thread Lu Baolu
dler; void *handler_token; struct iommu_domain_geometry geometry; - void *iova_cookie; + struct iommu_dma_cookie *iova_cookie; }; enum iommu_cap { Reviewed-by: Lu Baolu Best regards, baolu ___ iommu mailing list iommu

Re: [PATCH v1 1/2] iommu/vt-d: Move intel_iommu_ops to header file

2021-07-29 Thread Lu Baolu
Hi Andy, On 7/30/21 12:35 AM, Andy Shevchenko wrote: Compiler is not happy about hidden declaration of intel_iommu_ops. .../drivers/iommu/intel/iommu.c:414:24: warning: symbol 'intel_iommu_ops' was not declared. Should it be static? Move declaration to header file to make compiler happy.

Re: [PATCH v2 18/24] iommu: Express DMA strictness via the domain type

2021-07-29 Thread Lu Baolu
On 2021/7/29 17:36, Robin Murphy wrote: On 2021-07-29 08:13, Lu Baolu wrote: Hi Robin, On 7/28/21 11:58 PM, Robin Murphy wrote: diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 982545234cf3..eecb5657de69 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -136,6

Re: [PATCH v2 18/24] iommu: Express DMA strictness via the domain type

2021-07-29 Thread Lu Baolu
Hi Robin, On 7/28/21 11:58 PM, Robin Murphy wrote: diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 982545234cf3..eecb5657de69 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -136,6 +136,9 @@ static int __init iommu_subsys_init(void) } }

Re: [PATCH 18/23] iommu: Express DMA strictness via the domain type

2021-07-26 Thread Lu Baolu
On 2021/7/26 16:27, Robin Murphy wrote: On 2021-07-24 06:29, Lu Baolu wrote: Hi Robin, On 2021/7/22 2:20, Robin Murphy wrote: Eliminate the iommu_get_dma_strict() indirection and pipe the information through the domain type from the beginning. Besides the flow simplification this also has

Re: [PATCH 18/23] iommu: Express DMA strictness via the domain type

2021-07-26 Thread Lu Baolu
On 2021/7/26 16:27, Robin Murphy wrote: On 2021-07-24 06:29, Lu Baolu wrote: Hi Robin, On 2021/7/22 2:20, Robin Murphy wrote: Eliminate the iommu_get_dma_strict() indirection and pipe the information through the domain type from the beginning. Besides the flow simplification this also has

Re: [PATCH 18/23] iommu: Express DMA strictness via the domain type

2021-07-23 Thread Lu Baolu
Hi Robin, On 2021/7/22 2:20, Robin Murphy wrote: Eliminate the iommu_get_dma_strict() indirection and pipe the information through the domain type from the beginning. Besides the flow simplification this also has several nice side-effects: - Automatically implies strict mode for untrusted

Re: [PATCH 17/23] iommu/vt-d: Prepare for multiple DMA domain types

2021-07-23 Thread Lu Baolu
Hi Robin, On 2021/7/22 2:20, Robin Murphy wrote: In preparation for the strict vs. non-strict decision for DMA domains to be expressed in the domain type, make sure we expose our flush queue awareness by accepting the new domain type, and test the specific feature flag where we want to identify

Re: [PATCH 4/5] iommu/vt-d: Disallow SVA if devices don't support 64-bit address

2021-07-21 Thread Lu Baolu
On 2021/7/21 19:12, Robin Murphy wrote: On 2021-07-21 02:50, Lu Baolu wrote: Hi Robin, Thanks a lot for reviewing my patch! On 7/20/21 5:27 PM, Robin Murphy wrote: On 2021-07-20 02:38, Lu Baolu wrote: When the device and CPU share an address space (such as SVA), the device must support

Re: [PATCH 4/5] iommu/vt-d: Disallow SVA if devices don't support 64-bit address

2021-07-20 Thread Lu Baolu
Hi Robin, Thanks a lot for reviewing my patch! On 7/20/21 5:27 PM, Robin Murphy wrote: On 2021-07-20 02:38, Lu Baolu wrote: When the device and CPU share an address space (such as SVA), the device must support the same addressing capability as the CPU. The CPU does not consider the addressing

[PATCH 3/3] iommu/vt-d: Move clflush'es from iotlb_sync_map() to map_pages()

2021-07-19 Thread Lu Baolu
As the Intel VT-d driver has switched to use the iommu_ops.map_pages() callback, multiple pages of the same size will be mapped in a call. There's no need to put the clflush'es in iotlb_sync_map() callback. Move them back into __domain_mapping() to simplify the code. Signed-off-by: Lu Baolu

[PATCH 2/3] iommu/vt-d: Implement map/unmap_pages() iommu_ops callback

2021-07-19 Thread Lu Baolu
Implement the map_pages() and unmap_pages() callback for the Intel IOMMU driver to allow calls from iommu core to map and unmap multiple pages of the same size in one call. With map/unmap_pages() implemented, the prior map/unmap callbacks are deprecated. Signed-off-by: Lu Baolu --- drivers

[PATCH 1/3] iommu/vt-d: Report real pgsize bitmap to iommu core

2021-07-19 Thread Lu Baolu
the real page sizes we support. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 38 ++--- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 741d25ded717..240af636d51e 100644

[PATCH 0/3] iommu/vt-d: Implement [map/unmap]_pages callbacks

2021-07-19 Thread Lu Baolu
callbacks. This series introduces the implementation of those new callbacks in Intel IOMMU implementation. Note: This series depends on above series. It can only be taken after above series get merged. Best regards, baolu Lu Baolu (3): iommu/vt-d: Report real pgsize bitmap to iommu core

[PATCH 5/5] iommu/vt-d: Allow devices to have more than 32 outstanding PRs

2021-07-19 Thread Lu Baolu
IOMMU PRQ queue, but far from optimal for customized use case. This extends the per-IOMMU PRQ queue size to four 4K pages and let the devices have as many outstanding page requests as they can. Signed-off-by: Jacob Pan Signed-off-by: Lu Baolu --- include/linux/intel-svm.h | 5 + drivers

[PATCH 4/5] iommu/vt-d: Disallow SVA if devices don't support 64-bit address

2021-07-19 Thread Lu Baolu
the page table of the process. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index f45c80ce2381..f3cca1dd384d 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel

[PATCH 2/5] iommu/vt-d: Enable Intel IOMMU scalable mode by default

2021-07-19 Thread Lu Baolu
ss have been enabled. This enables the scalable mode by default if the hardware advertises the support and adds kernel options of "intel_iommu=sm_on/sm_off" for end users to configure it through the kernel parameters. Suggested-by: Ashok Raj Suggested-by: Sanjay Kumar Cc: Kevin

[PATCH 3/5] iommu/vt-d: Preset A/D bits for user space DMA usage

2021-07-19 Thread Lu Baolu
it to minimize the overhead. Suggested-by: Sanjay Kumar Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 1131b8efb050..f45c80ce2381 100644 --- a/drivers

[PATCH 1/5] iommu/vt-d: Refactor Kconfig a bit

2021-07-19 Thread Lu Baolu
Put all sub-options inside a "if INTEL_IOMMU" so that they don't need to always depend on INTEL_IOMMU. Use IS_ENABLED() instead of #ifdef as well. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 13 ++--- drivers/iommu/intel/Kconfig | 18 ++ 2 files c

[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

  1   2   3   4   5   6   7   8   9   10   >