Re: [PATCH v6 03/12] iommu: Add attach/detach_dev_pasid domain ops

2022-05-12 Thread Jean-Philippe Brucker
On Wed, May 11, 2022 at 09:02:40AM -0300, Jason Gunthorpe wrote: > On Wed, May 11, 2022 at 08:54:39AM +0100, Jean-Philippe Brucker wrote: > > > > > Then 'detach pasid' is: > > > > > > > > > > iommu_ops->blocking_domain->ops->attach_dev_pasid(domain, dev, > > > > pasid); > > > > > > > > > > And we m

Re: [PATCH] vfio: Remove VFIO_TYPE1_NESTING_IOMMU

2022-05-12 Thread Zhangfei Gao
Hi, Jason On 2022/5/11 上午2:13, Jason Gunthorpe via iommu wrote: On Tue, May 10, 2022 at 06:52:06PM +0100, Robin Murphy wrote: On 2022-05-10 17:55, Jason Gunthorpe via iommu wrote: This control causes the ARM SMMU drivers to choose a stage 2 implementation for the IO pagetable (vs the stage 1 u

Re: [PATCH] vfio: Remove VFIO_TYPE1_NESTING_IOMMU

2022-05-12 Thread Jason Gunthorpe via iommu
On Thu, May 12, 2022 at 03:07:09PM +0800, Zhangfei Gao wrote: > > > I can't help feeling a little wary about removing this until IOMMUFD > > > can actually offer a functional replacement - is it in the way of > > > anything upcoming? > > From an upstream perspective if someone has a patched kernel

Re: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-12 Thread Jason Gunthorpe via iommu
On Thu, May 12, 2022 at 01:17:08PM +0800, Baolu Lu wrote: > On 2022/5/12 13:01, Tian, Kevin wrote: > > > From: Baolu Lu > > > Sent: Thursday, May 12, 2022 11:03 AM > > > > > > On 2022/5/11 22:53, Jason Gunthorpe wrote: > > > > > > Also, given the current arrangement it might make sense to have a

Re: [PATCH v6 03/12] iommu: Add attach/detach_dev_pasid domain ops

2022-05-12 Thread Jason Gunthorpe via iommu
On Thu, May 12, 2022 at 08:00:59AM +0100, Jean-Philippe Brucker wrote: > > It is not "missing" it is just renamed to > > blocking_domain->ops->set_dev_pasid() > > > > The implementation of that function would be identical to > > detach_dev_pasid. > > attach(dev, pasid, sva_domain) > detach(

Re: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-12 Thread Jason Gunthorpe via iommu
On Thu, May 12, 2022 at 11:02:39AM +0800, Baolu Lu wrote: > > > + mutex_lock(&group->mutex); > > > + domain = xa_load(&group->pasid_array, pasid); > > > + if (domain && domain->type != type) > > > + domain = NULL; > > > + mutex_unlock(&group->mutex); > > > +

Re: [PATCH v3 1/4] iommu/vt-d: Implement domain ops for attach_dev_pasid

2022-05-12 Thread Jason Gunthorpe via iommu
On Thu, May 12, 2022 at 02:22:03PM +0800, Baolu Lu wrote: > Hi Jason, > > On 2022/5/12 01:00, Jason Gunthorpe wrote: > > > Consolidate pasid programming into dev_set_pasid() then called by both > > > intel_svm_attach_dev_pasid() and intel_iommu_attach_dev_pasid(), right? > > I was only suggesting

Re: [PATCH] vfio: Remove VFIO_TYPE1_NESTING_IOMMU

2022-05-12 Thread zhangfei....@foxmail.com
On 2022/5/12 下午7:32, Jason Gunthorpe via iommu wrote: On Thu, May 12, 2022 at 03:07:09PM +0800, Zhangfei Gao wrote: I can't help feeling a little wary about removing this until IOMMUFD can actually offer a functional replacement - is it in the way of anything upcoming? From an upstream pers

Re: [PATCH] vfio: Remove VFIO_TYPE1_NESTING_IOMMU

2022-05-12 Thread Jason Gunthorpe via iommu
On Thu, May 12, 2022 at 07:57:26PM +0800, zhangfei@foxmail.com wrote: > > > On 2022/5/12 下午7:32, Jason Gunthorpe via iommu wrote: > > On Thu, May 12, 2022 at 03:07:09PM +0800, Zhangfei Gao wrote: > > > > > I can't help feeling a little wary about removing this until IOMMUFD > > > > > can actu

Re: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-12 Thread Baolu Lu
On 2022/5/12 19:48, Jason Gunthorpe wrote: On Thu, May 12, 2022 at 01:17:08PM +0800, Baolu Lu wrote: On 2022/5/12 13:01, Tian, Kevin wrote: From: Baolu Lu Sent: Thursday, May 12, 2022 11:03 AM On 2022/5/11 22:53, Jason Gunthorpe wrote: Also, given the current arrangement it might make sense

Re: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-12 Thread Jason Gunthorpe via iommu
On Thu, May 12, 2022 at 07:59:41PM +0800, Baolu Lu wrote: > On 2022/5/12 19:48, Jason Gunthorpe wrote: > > On Thu, May 12, 2022 at 01:17:08PM +0800, Baolu Lu wrote: > > > On 2022/5/12 13:01, Tian, Kevin wrote: > > > > > From: Baolu Lu > > > > > Sent: Thursday, May 12, 2022 11:03 AM > > > > > > >

Re: [PATCH] vfio: Remove VFIO_TYPE1_NESTING_IOMMU

2022-05-12 Thread zhangfei....@foxmail.com
On 2022/5/12 下午7:59, Jason Gunthorpe wrote: On Thu, May 12, 2022 at 07:57:26PM +0800, zhangfei@foxmail.com wrote: On 2022/5/12 下午7:32, Jason Gunthorpe via iommu wrote: On Thu, May 12, 2022 at 03:07:09PM +0800, Zhangfei Gao wrote: I can't help feeling a little wary about removing this un

Re: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-12 Thread Baolu Lu
On 2022/5/12 19:51, Jason Gunthorpe wrote: On Thu, May 12, 2022 at 11:02:39AM +0800, Baolu Lu wrote: + mutex_lock(&group->mutex); + domain = xa_load(&group->pasid_array, pasid); + if (domain && domain->type != type) + domain = NULL; + mutex_unlock(&group->mu

Re: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-12 Thread Baolu Lu
On 2022/5/12 20:03, Jason Gunthorpe wrote: On Thu, May 12, 2022 at 07:59:41PM +0800, Baolu Lu wrote: On 2022/5/12 19:48, Jason Gunthorpe wrote: On Thu, May 12, 2022 at 01:17:08PM +0800, Baolu Lu wrote: On 2022/5/12 13:01, Tian, Kevin wrote: From: Baolu Lu Sent: Thursday, May 12, 2022 11:03 A

[PATCH v2 2/2] iomm/mediatek: Allow page table PA up to 35bit

2022-05-12 Thread yf.wang--- via iommu
From: Yunfei Wang Add the quirk IO_PGTABLE_QUIRK_ARM_MTK_TTBR_EXT support, so that allows page table PA up to 35bit, not only in ZONE_DMA32. Signed-off-by: Ning Li Signed-off-by: Yunfei Wang --- drivers/iommu/mtk_iommu.c | 29 + 1 file changed, 25 insertions(+), 4

[PATCH v2 1/2] iommu/io-pgtable-arm-v7s: Add a quirk to allow pgtable PA up to 35bit

2022-05-12 Thread yf.wang--- via iommu
From: Yunfei Wang The calling to kmem_cache_alloc for level 2 pgtable allocation may run in atomic context, and it fails sometimes when DMA32 zone runs out of memory. Since Mediatek IOMMU hardware support at most 35bit PA in pgtable, so add a quirk to allow the PA of pgtables support up to bit35

[PATCH v3 1/2] iommu/io-pgtable-arm-v7s: Add a quirk to allow pgtable PA up to 35bit

2022-05-12 Thread yf.wang--- via iommu
From: Yunfei Wang The calling to kmem_cache_alloc for level 2 pgtable allocation may run in atomic context, and it fails sometimes when DMA32 zone runs out of memory. Since Mediatek IOMMU hardware support at most 35bit PA in pgtable, so add a quirk to allow the PA of pgtables support up to bit35

[PATCH v3 2/2] iomm/mediatek: Allow page table PA up to 35bit

2022-05-12 Thread yf.wang--- via iommu
From: Yunfei Wang Add the quirk IO_PGTABLE_QUIRK_ARM_MTK_TTBR_EXT support, so that allows page table PA up to 35bit, not only in ZONE_DMA32. Signed-off-by: Ning Li Signed-off-by: Yunfei Wang --- drivers/iommu/mtk_iommu.c | 29 + 1 file changed, 25 insertions(+), 4

[PATCH v2] iommu/vt-d: Make DMAR_UNITS_SUPPORTED a config setting

2022-05-12 Thread Steve Wahl
To support up to 64 sockets with 10 DMAR units each (640), make the value of DMAR_UNITS_SUPPORTED adjustable by a config variable, CONFIG_DMAR_UNITS_SUPPORTED, and make it's default 1024 when MAXSMP is set. If the available hardware exceeds DMAR_UNITS_SUPPORTED (previously set to MAX_IO_APICS, or

Re: [PATCH] vfio: Remove VFIO_TYPE1_NESTING_IOMMU

2022-05-12 Thread Eric Auger
Hi, On 5/10/22 20:13, Jason Gunthorpe wrote: > On Tue, May 10, 2022 at 06:52:06PM +0100, Robin Murphy wrote: >> On 2022-05-10 17:55, Jason Gunthorpe via iommu wrote: >>> This control causes the ARM SMMU drivers to choose a stage 2 >>> implementation for the IO pagetable (vs the stage 1 usual defau

Re: [PATCH] vfio: Stop using iommu_present()

2022-05-12 Thread Alex Williamson
On Tue, 5 Apr 2022 13:11:54 +0100 Robin Murphy wrote: > IOMMU groups have been mandatory for some time now, so a device without > one is necessarily a device without any usable IOMMU, therefore the > iommu_present() check is redundant (or at best unhelpful). > > Signed-off-by: Robin Murphy > -

[PATCH v5 0/5] iommu: Support mappings/reservations in reserved-memory regions

2022-05-12 Thread Thierry Reding
From: Thierry Reding Hi, this is another attempt at solving the problem of passing IOMMU configuration via device tree. It has significantly evolved since the last attempt, based on the discussion that followed. The discussion can be found here: https://lore.kernel.org/all/20210423163234.3651

[PATCH v5 1/5] dt-bindings: reserved-memory: Document iommu-addresses

2022-05-12 Thread Thierry Reding
From: Thierry Reding This adds the "iommu-addresses" property to reserved-memory nodes, which allow describing the interaction of memory regions with IOMMUs. Two use- cases are supported: 1. Static mappings can be described by pairing the "iommu-addresses" property with a "reg" property.

[PATCH v5 3/5] iommu: dma: Use of_iommu_get_resv_regions()

2022-05-12 Thread Thierry Reding
From: Thierry Reding For device tree nodes, use the standard of_iommu_get_resv_regions() implementation to obtain the reserved memory regions associated with a device. Signed-off-by: Thierry Reding --- drivers/iommu/dma-iommu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iom

[PATCH v5 2/5] iommu: Implement of_iommu_get_resv_regions()

2022-05-12 Thread Thierry Reding
From: Thierry Reding This is an implementation that IOMMU drivers can use to obtain reserved memory regions from a device tree node. It uses the reserved-memory DT bindings to find the regions associated with a given device. If these regions are marked accordingly, identity mappings will be creat

[PATCH v5 4/5] iommu/tegra-smmu: Add support for reserved regions

2022-05-12 Thread Thierry Reding
From: Thierry Reding The Tegra DRM driver currently uses the IOMMU API explicitly. This means that it has fine-grained control over when exactly the translation through the IOMMU is enabled. This currently happens after the driver probes, so the driver is in a DMA quiesced state when the IOMMU tr

[PATCH v5 5/5] iommu/tegra-smmu: Support managed domains

2022-05-12 Thread Thierry Reding
From: Navneet Kumar Allow creating identity and DMA API compatible IOMMU domains. When creating a DMA API compatible domain, make sure to also create the required cookie. Signed-off-by: Navneet Kumar Signed-off-by: Thierry Reding --- Changes in v5: - remove DMA cookie initialization that's now

Re: [PATCH v2] iommu/vt-d: Make DMAR_UNITS_SUPPORTED a config setting

2022-05-12 Thread Steve Wahl
On Thu, May 12, 2022 at 10:13:09AM -0500, Steve Wahl wrote: > To support up to 64 sockets with 10 DMAR units each (640), make the > value of DMAR_UNITS_SUPPORTED adjustable by a config variable, > CONFIG_DMAR_UNITS_SUPPORTED, and make it's default 1024 when MAXSMP is > set. > > If the available ha

Re: [PATCH v2 01/26] dma-direct: take dma-ranges/offsets into account in resource mapping

2022-05-12 Thread Serge Semin
On Mon, May 09, 2022 at 08:15:52AM +0200, Christoph Hellwig wrote: > So I think the big problem pointed out by Robin is that existing DTs > might not take this into account. I'd say that the biggest problem isn't in the DT part but in the drivers using the dma_map_resource() method since they don

[PATCH] iommu/vt-d: Try info->iommu in device_to_iommu()

2022-05-12 Thread Nicolin Chen via iommu
Local boot test and VFIO sanity test show that info->iommu can be used in device_to_iommu() as a fast path. So this patch adds it. Signed-off-by: Nicolin Chen --- drivers/iommu/intel/iommu.c | 5 + 1 file changed, 5 insertions(+) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/inte

Re: [PATCH 1/3] swiotlb: don't panic when the swiotlb buffer can't be allocated

2022-05-12 Thread Stefano Stabellini
On Wed, 11 May 2022, Christoph Hellwig wrote: > For historical reasons the switlb code paniced when the metadata could > not be allocated, but just printed a warning when the actual main > swiotlb buffer could not be allocated. Restore this somewhat unexpected > behavior as changing it caused a bo

Re: [PATCH 2/3] swiotlb: use the right nslabs value in swiotlb_init_remap

2022-05-12 Thread Stefano Stabellini
On Wed, 11 May 2022, Christoph Hellwig wrote: > default_nslabs should only be used to initialize nslabs, after that we > need to use the local variable that can shrink when allocations or the > remap don't succeed. > > Fixes: 6424e31b1c05 ("swiotlb: remove swiotlb_init_with_tbl and > swiotlb_init

Re: [PATCH 3/3] swiotlb: use the right nslabs-derived sizes in swiotlb_init_late

2022-05-12 Thread Stefano Stabellini
On Wed, 11 May 2022, Christoph Hellwig wrote: > nslabs can shrink when allocations or the remap don't succeed, so make > sure to use it for all sizing. For that remove the bytes value that > can get stale and replace it with local calculations and a boolean to > indicate if the originally requeste

Re: [PATCH v2] iommu/vt-d: Make DMAR_UNITS_SUPPORTED a config setting

2022-05-12 Thread Baolu Lu
On 2022/5/13 07:12, Steve Wahl wrote: On Thu, May 12, 2022 at 10:13:09AM -0500, Steve Wahl wrote: To support up to 64 sockets with 10 DMAR units each (640), make the value of DMAR_UNITS_SUPPORTED adjustable by a config variable, CONFIG_DMAR_UNITS_SUPPORTED, and make it's default 1024 when MAXSMP

Re: [PATCH v3 1/2] iommu/io-pgtable-arm-v7s: Add a quirk to allow pgtable PA up to 35bit

2022-05-12 Thread kernel test robot
Hi, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on arm-perf/for-next/perf] [also build test WARNING on linus/master v5.18-rc6 next-20220512] [cannot apply to joro-iommu/next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when

Re: [PATCH v3 1/2] iommu/io-pgtable-arm-v7s: Add a quirk to allow pgtable PA up to 35bit

2022-05-12 Thread kernel test robot
, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/intel-lab-lkp/linux/commits/yf-wang-mediatek-com/iommu-io-pgtable-arm-v7s-Add-a-quirk-to-allow-pgtable-PA-up-to-35bit/20220512-234603 base: https://git.kernel.org/pub

Re: [PATCH] iommu/vt-d: Try info->iommu in device_to_iommu()

2022-05-12 Thread Baolu Lu
On 2022/5/13 08:32, Nicolin Chen wrote: Local boot test and VFIO sanity test show that info->iommu can be used in device_to_iommu() as a fast path. So this patch adds it. Signed-off-by: Nicolin Chen --- drivers/iommu/intel/iommu.c | 5 + 1 file changed, 5 insertions(+) diff --git a/driv

Re: [PATCH] iommu/vt-d: Try info->iommu in device_to_iommu()

2022-05-12 Thread Nicolin Chen via iommu
On Fri, May 13, 2022 at 11:32:11AM +0800, Baolu Lu wrote: > External email: Use caution opening links or attachments > > > On 2022/5/13 08:32, Nicolin Chen wrote: > > Local boot test and VFIO sanity test show that info->iommu can be > > used in device_to_iommu() as a fast path. So this patch adds

Re: [PATCH RFC 11/12] iommufd: vfio container FD ioctl compatibility

2022-05-12 Thread David Gibson
On Wed, May 11, 2022 at 03:15:22AM +, Tian, Kevin wrote: > > From: Jason Gunthorpe > > Sent: Wednesday, May 11, 2022 3:00 AM > > > > On Tue, May 10, 2022 at 05:12:04PM +1000, David Gibson wrote: > > > Ok... here's a revised version of my proposal which I think addresses > > > your concerns an