Re: [PATCH] vfio: Remove VFIO_TYPE1_NESTING_IOMMU

2022-05-20 Thread Joerg Roedel
On Tue, May 17, 2022 at 02:26:56PM -0600, Alex Williamson wrote: > I'd be in favor of applying this, but it seems Robin and Eric are > looking for a stay of execution and I'd also be looking for an ack from > Joerg. Thanks, This is mainly an ARM-SMMU thing, so I defer my ack to Will and Robin. R

Re: [PATCH] iommu/s390: tolerate repeat attach_dev calls

2022-05-20 Thread Joerg Roedel
On Thu, May 19, 2022 at 02:29:29PM -0400, Matthew Rosato wrote: > Since commit 0286300e6045 ("iommu: iommu_group_claim_dma_owner() must > always assign a domain") s390-iommu will get called to allocate multiple > unmanaged iommu domains for a vfio-pci device -- however the current > s390-iommu logi

Re: [PATCH v2] iommu/amd: Set translation valid bit only when IO page tables are in used

2022-05-20 Thread Joerg Roedel
Hi Suravee, On Mon, May 16, 2022 at 07:27:51PM +0700, Suravee Suthikulpanit wrote: > Due to the new restriction (please see the IOMMU spec Rev 3.06-PUB - Apr 2021 > https://www.amd.com/system/files/TechDocs/48882_IOMMU.pdf) where the use of > DTE[Mode]=0 is not supported on systems that are SNP-en

[PATCH 0/4] DMA mapping changes for SCSI core

2022-05-20 Thread John Garry via iommu
As reported in [0], DMA mappings whose size exceeds the IOMMU IOVA caching limit may see a big performance hit. This series introduces a new DMA mapping API, dma_opt_mapping_size(), so that drivers may know this limit when performance is a factor in the mapping. Robin didn't like using dma_max_ma

[PATCH 2/4] dma-iommu: Add iommu_dma_opt_mapping_size()

2022-05-20 Thread John Garry via iommu
Add the IOMMU callback for DMA mapping API dma_opt_mapping_size(), which allows the drivers to know the optimal mapping limit and thus limit the requested IOVA lengths. This value is based on the IOVA rcache range limit, as IOVAs allocated above this limit must always be newly allocated, which may

[PATCH 1/4] dma-mapping: Add dma_opt_mapping_size()

2022-05-20 Thread John Garry via iommu
Streaming DMA mapping involving an IOMMU may be much slower for larger total mapping size. This is because every IOMMU DMA mapping requires an IOVA to be allocated and freed. IOVA sizes above a certain limit are not cached, which can have a big impact on DMA mapping performance. Provide an API for

[PATCH 3/4] scsi: core: Cap shost max_sectors according to DMA optimum mapping limits

2022-05-20 Thread John Garry via iommu
Streaming DMA mappings may be considerably slower when mappings go through an IOMMU and the total mapping length is somewhat long. This is because the IOMMU IOVA code allocates and free an IOVA for each mapping, which may affect performance. For performance reasons set the request_queue max_sector

[PATCH 4/4] libata-scsi: Cap ata_device->max_sectors according to shost->max_sectors

2022-05-20 Thread John Garry via iommu
ATA devices (struct ata_device) have a max_sectors field which is configured internally in libata. This is then used to (re)configure the associated sdev request queue max_sectors value from how it is earlier set in __scsi_init_queue(). In __scsi_init_queue() the max_sectors value is set according

Re: [PATCH 2/5] iommu: Add blocking_domain_ops field in iommu_ops

2022-05-20 Thread Joerg Roedel
On Mon, May 16, 2022 at 09:57:56AM +0800, Lu Baolu wrote: > const struct iommu_domain_ops *default_domain_ops; > + const struct iommu_domain_ops *blocking_domain_ops; I don't understand why extra domain-ops are needed for this. I think it would be more straight-forward to implement alloc

Re: [RFC PATCH] dma-iommu: Add iommu_dma_max_mapping_size()

2022-05-20 Thread Joerg Roedel
On Wed, May 18, 2022 at 03:13:53PM +0200, Christoph Hellwig wrote: > On Tue, May 17, 2022 at 01:02:00PM +0100, Robin Murphy wrote: > >> So how to inform the SCSI driver of this caching limit then so that it may > >> limit the SGL length? > > > > Driver-specific mechanism; block-layer-specific mech

Re: [PATCH v2] iommu/amd: Set translation valid bit only when IO page tables are in used

2022-05-20 Thread Robin Murphy
On 2022-05-20 09:09, Joerg Roedel wrote: Hi Suravee, On Mon, May 16, 2022 at 07:27:51PM +0700, Suravee Suthikulpanit wrote: Due to the new restriction (please see the IOMMU spec Rev 3.06-PUB - Apr 2021 https://www.amd.com/system/files/TechDocs/48882_IOMMU.pdf) where the use of DTE[Mode]=0 is no

Re: [PATCH v2] iommu/amd: Set translation valid bit only when IO page tables are in used

2022-05-20 Thread Joerg Roedel
On Fri, May 20, 2022 at 09:54:51AM +0100, Robin Murphy wrote: > The .def_domain type op already allows drivers to do exactly this sort of > override. You could also conditionally reject IOMMU_DOMAIN_PASSTHROUGH in > .domain_alloc for good measure, provided that (for now at least*) SNP is a > global

Re: [PATCH v2] iommu/amd: Set translation valid bit only when IO page tables are in used

2022-05-20 Thread Robin Murphy
On 2022-05-20 09:58, Joerg Roedel wrote: On Fri, May 20, 2022 at 09:54:51AM +0100, Robin Murphy wrote: The .def_domain type op already allows drivers to do exactly this sort of override. You could also conditionally reject IOMMU_DOMAIN_PASSTHROUGH in .domain_alloc for good measure, provided that

Re: [PATCH v3 00/35] iommu/amd: Add multiple PCI segments support

2022-05-20 Thread Vasant Hegde via iommu
Hello Joerg, On 5/11/2022 12:51 PM, Vasant Hegde wrote: > Newer AMD systems can support multiple PCI segments, where each segment > contains one or more IOMMU instances. However, an IOMMU instance can only > support a single PCI segment. Ping. Did you get a chance to look into this series? -V

Re: [PATCH v3 00/35] iommu/amd: Add multiple PCI segments support

2022-05-20 Thread Joerg Roedel
Hi Vasant, On Fri, May 20, 2022 at 03:25:38PM +0530, Vasant Hegde wrote: > Ping. Did you get a chance to look into this series? Sorry, too late for this round. The changes are pretty invasive and merging them at -rc7 stage would not give them enough testing before being merged. Please send me a r

[PATCH] iommu/amd: Increase timeout waiting for GA log enablement

2022-05-20 Thread Joerg Roedel
From: Joerg Roedel On some systems it can take a long time for the hardware to enable the GA log of the AMD IOMMU. The current wait time is only 0.1ms, but testing showed that it can take up to 14ms for the GA log to enter running state after it has been enabled. Sometimes the long delay happens

Re: [PATCH] iommu/s390: tolerate repeat attach_dev calls

2022-05-20 Thread Niklas Schnelle
On Thu, 2022-05-19 at 14:29 -0400, Matthew Rosato wrote: > Since commit 0286300e6045 ("iommu: iommu_group_claim_dma_owner() must > always assign a domain") s390-iommu will get called to allocate multiple > unmanaged iommu domains for a vfio-pci device -- however the current > s390-iommu logic toler

Re: [PATCH] vfio: Remove VFIO_TYPE1_NESTING_IOMMU

2022-05-20 Thread Robin Murphy
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 default), however this choice has no visible impact to the VFIO user. Oh, I should have read more carefully... this isn't

Re: [PATCH 2/5] iommu: Add blocking_domain_ops field in iommu_ops

2022-05-20 Thread Baolu Lu
On 2022/5/20 16:45, Joerg Roedel wrote: On Mon, May 16, 2022 at 09:57:56AM +0800, Lu Baolu wrote: const struct iommu_domain_ops *default_domain_ops; + const struct iommu_domain_ops *blocking_domain_ops; I don't understand why extra domain-ops are needed for this. I think it would

Re: [PATCH v7 06/10] iommu/sva: Refactoring iommu_sva_bind/unbind_device()

2022-05-20 Thread Jean-Philippe Brucker
On Fri, May 20, 2022 at 02:38:12PM +0800, Baolu Lu wrote: > On 2022/5/20 00:39, Jean-Philippe Brucker wrote: > > > +struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct > > > mm_struct *mm) > > > +{ > > > + struct iommu_sva_domain *sva_domain; > > > + struct iommu_domain *domain; > >

Re: [PATCH] vfio: Remove VFIO_TYPE1_NESTING_IOMMU

2022-05-20 Thread Will Deacon
On Fri, May 20, 2022 at 12:02:23PM +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 default), > > however this choice has no visible impac

Re: [PATCH v3 00/35] iommu/amd: Add multiple PCI segments support

2022-05-20 Thread Vasant Hegde via iommu
Joerg, On 5/20/2022 3:33 PM, Joerg Roedel wrote: > Hi Vasant, > > On Fri, May 20, 2022 at 03:25:38PM +0530, Vasant Hegde wrote: >> Ping. Did you get a chance to look into this series? > > Sorry, too late for this round. The changes are pretty invasive and > merging them at -rc7 stage would not

Re: [PATCH] vfio: Remove VFIO_TYPE1_NESTING_IOMMU

2022-05-20 Thread Jason Gunthorpe via iommu
On Fri, May 20, 2022 at 12:02:23PM +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 default), > > however this choice has no visible impac

Re: [PATCH] vfio: Remove VFIO_TYPE1_NESTING_IOMMU

2022-05-20 Thread Jason Gunthorpe via iommu
On Fri, May 20, 2022 at 01:00:32PM +0100, Will Deacon wrote: > On Fri, May 20, 2022 at 12:02:23PM +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

Re: [PATCH v4 2/6] iommu: Add a helper to do PASID lookup from domain

2022-05-20 Thread Jacob Pan
Hi Christoph, On Wed, 18 May 2022 23:48:44 -0700, Christoph Hellwig wrote: > On Wed, May 18, 2022 at 11:21:16AM -0700, Jacob Pan wrote: > > +ioasid_t iommu_get_pasid_from_domain(struct device *dev, struct > > iommu_domain *domain) > > Overly long line here. will fix, Thanks, Jacob _

[PATCH] dma-direct: Don't over-decrypt memory

2022-05-20 Thread Robin Murphy
The original x86 sev_alloc() only called set_memory_decrypted() on memory returned by alloc_pages_node(), so the page order calculation fell out of that logic. However, the common dma-direct code has several potential allocators, not all of which are guaranteed to round up the underlying allocation

Re: [PATCH v2 1/2] dt-bindings: mediatek: Add bindings for MT6795 M4U

2022-05-20 Thread Rob Herring
On Wed, 18 May 2022 12:18:48 +0200, AngeloGioacchino Del Regno wrote: > Add bindings for the MediaTek Helio X10 (MT6795) IOMMU/M4U. > > Signed-off-by: AngeloGioacchino Del Regno > > --- > .../bindings/iommu/mediatek,iommu.yaml| 4 + > include/dt-bindings/memory/mt6795-larb-port.h | 96

Re: [PATCH v1] driver core: Extend deferred probe timeout on driver registration

2022-05-20 Thread Nathan Chancellor
aul Kocialkowski > Cc: linux-g...@vger.kernel.org > Cc: linux...@vger.kernel.org > Cc: iommu@lists.linux-foundation.org > Signed-off-by: Saravana Kannan I bisected a boot hang with ARCH=s390 defconfig in QEMU down to this change as commit 2b28a1a84a0e ("driver core: Extend deferred prob

Re: [PATCH v1] driver core: Extend deferred probe timeout on driver registration

2022-05-20 Thread Saravana Kannan via iommu
er.kernel.org > > Cc: linux...@vger.kernel.org > > Cc: iommu@lists.linux-foundation.org > > Signed-off-by: Saravana Kannan > > I bisected a boot hang with ARCH=s390 defconfig in QEMU down to this > change as commit 2b28a1a84a0e ("driver core: Extend deferred probe >

Re: [PATCH v1] driver core: Extend deferred probe timeout on driver registration

2022-05-20 Thread Nathan Chancellor
on > > > Cc: Kevin Hilman > > > Cc: Thierry Reding > > > Cc: Mark Brown > > > Cc: Pavel Machek > > > Cc: Geert Uytterhoeven > > > Cc: Yoshihiro Shimoda > > > Cc: Paul Kocialkowski > > > Cc: linux-g...@vger.kernel.org > >

Re: [PATCH 3/4] scsi: core: Cap shost max_sectors according to DMA optimum mapping limits

2022-05-20 Thread Damien Le Moal via iommu
On 5/20/22 17:23, John Garry wrote: > Streaming DMA mappings may be considerably slower when mappings go through > an IOMMU and the total mapping length is somewhat long. This is because the > IOMMU IOVA code allocates and free an IOVA for each mapping, which may > affect performance. > > For perf

Re: [PATCH 2/4] dma-iommu: Add iommu_dma_opt_mapping_size()

2022-05-20 Thread Damien Le Moal via iommu
On 5/20/22 17:23, John Garry wrote: > Add the IOMMU callback for DMA mapping API dma_opt_mapping_size(), which > allows the drivers to know the optimal mapping limit and thus limit the > requested IOVA lengths. > > This value is based on the IOVA rcache range limit, as IOVAs allocated > above this

Re: [PATCH 4/4] libata-scsi: Cap ata_device->max_sectors according to shost->max_sectors

2022-05-20 Thread Damien Le Moal via iommu
On 5/20/22 17:23, John Garry wrote: > ATA devices (struct ata_device) have a max_sectors field which is > configured internally in libata. This is then used to (re)configure the > associated sdev request queue max_sectors value from how it is earlier set > in __scsi_init_queue(). In __scsi_init_que

Re: [PATCH 1/4] dma-mapping: Add dma_opt_mapping_size()

2022-05-20 Thread Damien Le Moal via iommu
On 5/20/22 17:23, John Garry wrote: > Streaming DMA mapping involving an IOMMU may be much slower for larger > total mapping size. This is because every IOMMU DMA mapping requires an > IOVA to be allocated and freed. IOVA sizes above a certain limit are not > cached, which can have a big impact on

Re: [PATCH v1] driver core: Extend deferred probe timeout on driver registration

2022-05-20 Thread Saravana Kannan via iommu
; Cc: Thierry Reding > > > > Cc: Mark Brown > > > > Cc: Pavel Machek > > > > Cc: Geert Uytterhoeven > > > > Cc: Yoshihiro Shimoda > > > > Cc: Paul Kocialkowski > > > > Cc: linux-g...@vger.kernel.org > > > >

[PATCH] iommu/vt-d: Fix PCI bus rescan device hot add

2022-05-20 Thread Yian Chen
Notifier calling chain uses priority to determine the execution order of the notifiers or listeners registered to the chain. PCI bus device hot add utilizes the notification mechanism. The current code sets low priority (INT_MIN) to Intel dmar_pci_bus_notifier and postpones DMAR decoding after add