Re: [patch RFC 38/38] irqchip: Add IMS array driver - NOT FOR MERGING

2020-08-21 Thread Jason Gunthorpe
On Fri, Aug 21, 2020 at 02:25:02AM +0200, Thomas Gleixner wrote: > +static void ims_mask_irq(struct irq_data *data) > +{ > + struct msi_desc *desc = irq_data_get_msi_desc(data); > + struct ims_array_slot __iomem *slot = desc->device_msi.priv_iomem; > + u32 __iomem *ctrl = >ctrl; > + >

[PATCH AUTOSEL 5.4 15/48] iommu/iova: Don't BUG on invalid PFNs

2020-08-21 Thread Sasha Levin
From: Robin Murphy [ Upstream commit d3e3d2be688b4b5864538de61e750721a311e4fc ] Unlike the other instances which represent a complete loss of consistency within the rcache mechanism itself, or a fundamental and obvious misconfiguration by an IOMMU driver, the BUG_ON() in

[PATCH AUTOSEL 4.14 09/30] iommu/iova: Don't BUG on invalid PFNs

2020-08-21 Thread Sasha Levin
From: Robin Murphy [ Upstream commit d3e3d2be688b4b5864538de61e750721a311e4fc ] Unlike the other instances which represent a complete loss of consistency within the rcache mechanism itself, or a fundamental and obvious misconfiguration by an IOMMU driver, the BUG_ON() in

[PATCH AUTOSEL 5.8 19/62] iommu/iova: Don't BUG on invalid PFNs

2020-08-21 Thread Sasha Levin
From: Robin Murphy [ Upstream commit d3e3d2be688b4b5864538de61e750721a311e4fc ] Unlike the other instances which represent a complete loss of consistency within the rcache mechanism itself, or a fundamental and obvious misconfiguration by an IOMMU driver, the BUG_ON() in

[PATCH AUTOSEL 4.9 06/26] iommu/iova: Don't BUG on invalid PFNs

2020-08-21 Thread Sasha Levin
From: Robin Murphy [ Upstream commit d3e3d2be688b4b5864538de61e750721a311e4fc ] Unlike the other instances which represent a complete loss of consistency within the rcache mechanism itself, or a fundamental and obvious misconfiguration by an IOMMU driver, the BUG_ON() in

Re: [PATCH 10/20] dt-bindings: arm-smmu: Add compatible string for Adreno GPU SMMU

2020-08-21 Thread Jordan Crouse
On Wed, Aug 19, 2020 at 10:36:38AM -0700, Rob Clark wrote: > On Wed, Aug 19, 2020 at 10:03 AM Doug Anderson wrote: > > > > Hi, > > > > On Mon, Aug 17, 2020 at 3:03 PM Rob Clark wrote: > > > > > > From: Jordan Crouse > > > > > > Every Qcom Adreno GPU has an embedded SMMU for its own use. These >

[PATCH AUTOSEL 5.7 19/61] iommu/iova: Don't BUG on invalid PFNs

2020-08-21 Thread Sasha Levin
From: Robin Murphy [ Upstream commit d3e3d2be688b4b5864538de61e750721a311e4fc ] Unlike the other instances which represent a complete loss of consistency within the rcache mechanism itself, or a fundamental and obvious misconfiguration by an IOMMU driver, the BUG_ON() in

Re: [PATCH] MAINTAINERS: update QUALCOMM IOMMU after Arm SSMU drivers move

2020-08-21 Thread Will Deacon
On Sun, Aug 02, 2020 at 08:53:20AM +0200, Lukas Bulwahn wrote: > Commit e86d1aa8b60f ("iommu/arm-smmu: Move Arm SMMU drivers into their own > subdirectory") moved drivers/iommu/qcom_iommu.c to > drivers/iommu/arm/arm-smmu/qcom_iommu.c amongst other moves, adjusted some > sections in MAINTAINERS,

[PATCH AUTOSEL 4.19 11/38] iommu/iova: Don't BUG on invalid PFNs

2020-08-21 Thread Sasha Levin
From: Robin Murphy [ Upstream commit d3e3d2be688b4b5864538de61e750721a311e4fc ] Unlike the other instances which represent a complete loss of consistency within the rcache mechanism itself, or a fundamental and obvious misconfiguration by an IOMMU driver, the BUG_ON() in

Re: [Regression] "iommu/amd: Relax locking in dma_ops path" makes tg3 ethernet transmit queue timeout

2020-08-21 Thread Joerg Roedel
On Fri, Aug 21, 2020 at 09:50:33PM +0800, Kai-Heng Feng wrote: > Of course, I still have the system at my side. > > The offending commit is 92d420ec028d ("iommu/amd: Relax locking in > dma_ops path"), however be62dbf554c5 ("iommu/amd: Convert AMD iommu > driver to the dma-iommu api") removed

Re: [PATCH v7 1/3] dma-contiguous: provide the ability to reserve per-numa CMA

2020-08-21 Thread Randy Dunlap
On 8/21/20 4:33 AM, Barry Song wrote: > --- > -v7: with respect to Will's comments > * move to use for_each_online_node > * add description if users don't specify pernuma_cma > * provide default value for CONFIG_DMA_PERNUMA_CMA > > .../admin-guide/kernel-parameters.txt | 11 ++ >

Re: [PATCH v7 1/3] dma-contiguous: provide the ability to reserve per-numa CMA

2020-08-21 Thread Mike Rapoport
On Fri, Aug 21, 2020 at 11:33:53PM +1200, Barry Song wrote: > Right now, drivers like ARM SMMU are using dma_alloc_coherent() to get > coherent DMA buffers to save their command queues and page tables. As > there is only one default CMA in the whole system, SMMUs on nodes other > than node0 will

Re: [Regression] "iommu/amd: Relax locking in dma_ops path" makes tg3 ethernet transmit queue timeout

2020-08-21 Thread Joerg Roedel
Hi Kai, On Mon, Jun 29, 2020 at 08:33:22PM +0800, Kai-Heng Feng wrote: > I am still seeing the issue on v5.8-rc3. The issue goes away as soon > as "iommu=off" is added. Can you probably help with debugging this issue? I've had no luck so far getting my hands on a machine with tg3 hardware and an

[PATCH v2 2/2] iommu/arm-smmu-v3: Remove cmpxchg() in arm_smmu_cmdq_issue_cmdlist()

2020-08-21 Thread John Garry
It has been shown that the cmpxchg() for finding space in the cmdq can be a bottleneck: - for more CPUs contending the cmdq, the cmpxchg() will fail more often - since the software-maintained cons pointer is updated on the same 64b memory region, the chance of cmpxchg() failure increases again

[PATCH v2 1/2] iommu/arm-smmu-v3: Calculate max commands per batch

2020-08-21 Thread John Garry
Calculate the batch size limit such that all CPUs in the system cannot issue so many commands as to fill the command queue. Signed-off-by: John Garry --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 46 +++-- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git

[PATCH v2 0/2] iommu/arm-smmu-v3: Improve cmdq lock efficiency

2020-08-21 Thread John Garry
As mentioned in [0], the CPU may consume many cycles processing arm_smmu_cmdq_issue_cmdlist(). One issue we find is the cmpxchg() loop to get space on the queue takes a lot of time once we start getting many CPUs contending - from experiment, for 64 CPUs contending the cmdq, success rate is ~ 1 in

Re: [PATCH v6 08/15] iommu: Pass domain to sva_unbind_gpasid()

2020-08-21 Thread Auger Eric
Hi, On 8/20/20 11:06 PM, Alex Williamson wrote: > On Mon, 27 Jul 2020 23:27:37 -0700 > Liu Yi L wrote: > >> From: Yi Sun >> >> Current interface is good enough for SVA virtualization on an assigned >> physical PCI device, but when it comes to mediated devices, a physical >> device may attached

Re: [Regression] "iommu/amd: Relax locking in dma_ops path" makes tg3 ethernet transmit queue timeout

2020-08-21 Thread Kai-Heng Feng
Hi Joerg, > On Aug 21, 2020, at 21:43, Joerg Roedel wrote: > > Hi Kai, > > On Mon, Jun 29, 2020 at 08:33:22PM +0800, Kai-Heng Feng wrote: >> I am still seeing the issue on v5.8-rc3. The issue goes away as soon >> as "iommu=off" is added. > > Can you probably help with debugging this issue?

[PATCH v7 3/3] mm: cma: use CMA_MAX_NAME to define the length of cma name array

2020-08-21 Thread Barry Song
CMA_MAX_NAME should be visible to CMA's users as they might need it to set the name of CMA areas and avoid hardcoding the size locally. So this patch moves CMA_MAX_NAME from local header file to include/linux header file and removes the magic number in hugetlb.c and contiguous.c. Cc: Mike Kravetz

[PATCH v7 1/3] dma-contiguous: provide the ability to reserve per-numa CMA

2020-08-21 Thread Barry Song
Right now, drivers like ARM SMMU are using dma_alloc_coherent() to get coherent DMA buffers to save their command queues and page tables. As there is only one default CMA in the whole system, SMMUs on nodes other than node0 will get remote memory. This leads to significant latency. This patch

[PATCH v7 0/3] make dma_alloc_coherent NUMA-aware by per-NUMA CMA

2020-08-21 Thread Barry Song
Ganapatrao Kulkarni has put some effort on making arm-smmu-v3 use local memory to save command queues[1]. I also did similar job in patch "iommu/arm-smmu-v3: allocate the memory of queues in local numa node" [2] while not realizing Ganapatrao has done that before. But it seems it is much better

RE: [PATCH v6 1/2] dma-contiguous: provide the ability to reserve per-numa CMA

2020-08-21 Thread Song Bao Hua (Barry Song)
> -Original Message- > From: Will Deacon [mailto:w...@kernel.org] > Sent: Friday, August 21, 2020 8:47 PM > To: Song Bao Hua (Barry Song) > Cc: h...@lst.de; m.szyprow...@samsung.com; robin.mur...@arm.com; > ganapatrao.kulka...@cavium.com; catalin.mari...@arm.com; >

[PATCH v3 2/6] iommu/virtio: Add topology helpers

2020-08-21 Thread Jean-Philippe Brucker
To support topology description from ACPI and from the builtin description, add helpers to keep track of I/O topology descriptors. To ease re-use of the helpers by other drivers and future ACPI extensions, use the "virt_" prefix rather than "virtio_" when naming structs and functions.

[PATCH v3 1/6] iommu/virtio: Move to drivers/iommu/virtio/

2020-08-21 Thread Jean-Philippe Brucker
Before adding new files to the virtio-iommu driver, move it to its own subfolder, similarly to other IOMMU drivers. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/Makefile| 3 +-- drivers/iommu/virtio/Makefile | 2 ++ drivers/iommu/{ =>

[PATCH v3 5/6] iommu/virtio: Support topology description in config space

2020-08-21 Thread Jean-Philippe Brucker
Platforms without device-tree nor ACPI can provide a topology description embedded into the virtio config space. Parse it. Use PCI FIXUP to probe the config space early, because we need to discover the topology before any DMA configuration takes place, and the virtio driver may be loaded much

[PATCH v3 6/6] iommu/virtio: Enable x86 support

2020-08-21 Thread Jean-Philippe Brucker
With the built-in topology description in place, x86 platforms can now use the virtio-iommu. Architectures that use the generic iommu_dma_ops should normally select CONFIG_IOMMU_DMA themselves (from arch/*/Kconfig). Since not all x86 drivers have been converted yet, it's currently up to the IOMMU

[PATCH v3 0/6] Add virtio-iommu built-in topology

2020-08-21 Thread Jean-Philippe Brucker
Add a topology description to the virtio-iommu driver and enable x86 platforms. Since [v2] we have made some progress on adding ACPI support for virtio-iommu, which is the preferred boot method on x86. It will be a new vendor-agnostic table describing para-virtual topologies in a minimal format.

[PATCH v3 3/6] PCI: Add DMA configuration for virtual platforms

2020-08-21 Thread Jean-Philippe Brucker
Hardware platforms usually describe the IOMMU topology using either device-tree pointers or vendor-specific ACPI tables. For virtual platforms that don't provide a device-tree, the virtio-iommu device contains a description of the endpoints it manages. That information allows us to probe

[PATCH v3 4/6] iommu/virtio: Add topology definitions

2020-08-21 Thread Jean-Philippe Brucker
Add struct definitions for describing endpoints managed by the virtio-iommu. When VIRTIO_IOMMU_F_TOPOLOGY is offered, an array of virtio_iommu_topo_* structures in config space describes the endpoints, identified either by their PCI BDF or their physical MMIO address. Signed-off-by: Jean-Philippe

Re: [PATCH v6 1/2] dma-contiguous: provide the ability to reserve per-numa CMA

2020-08-21 Thread Will Deacon
On Fri, Aug 21, 2020 at 09:13:39AM +, Song Bao Hua (Barry Song) wrote: > > > > -Original Message- > > From: Will Deacon [mailto:w...@kernel.org] > > Sent: Friday, August 21, 2020 8:47 PM > > To: Song Bao Hua (Barry Song) > > Cc: h...@lst.de; m.szyprow...@samsung.com;

RE: [PATCH v6 1/2] dma-contiguous: provide the ability to reserve per-numa CMA

2020-08-21 Thread Song Bao Hua (Barry Song)
> -Original Message- > From: Will Deacon [mailto:w...@kernel.org] > Sent: Friday, August 21, 2020 9:27 PM > To: Song Bao Hua (Barry Song) > Cc: h...@lst.de; m.szyprow...@samsung.com; robin.mur...@arm.com; > ganapatrao.kulka...@cavium.com; catalin.mari...@arm.com; >

[PATCH v7 2/3] arm64: mm: reserve per-numa CMA to localize coherent dma buffers

2020-08-21 Thread Barry Song
Right now, smmu is using dma_alloc_coherent() to get memory to save queues and tables. Typically, on ARM64 server, there is a default CMA located at node0, which could be far away from node2, node3 etc. with this patch, smmu will get memory from local numa node to save command queues and page

Re: [PATCH v7 0/3] make dma_alloc_coherent NUMA-aware by per-NUMA CMA

2020-08-21 Thread Mike Kravetz
Hi Barry, Sorry for jumping in so late. On 8/21/20 4:33 AM, Barry Song wrote: > > with per-numa CMA, smmu will get memory from local numa node to save command > queues and page tables. that means dma_unmap latency will be shrunk much. Since per-node CMA areas for hugetlb was introduced, I have

Re: [PATCH v7 0/3] make dma_alloc_coherent NUMA-aware by per-NUMA CMA

2020-08-21 Thread Mike Kravetz
On 8/21/20 1:47 PM, Song Bao Hua (Barry Song) wrote: > > >> -Original Message- >> From: Song Bao Hua (Barry Song) >> Sent: Saturday, August 22, 2020 7:27 AM >> To: 'Mike Kravetz' ; h...@lst.de; >> m.szyprow...@samsung.com; robin.mur...@arm.com; w...@kernel.org; >>

Re: [patch RFC 38/38] irqchip: Add IMS array driver - NOT FOR MERGING

2020-08-21 Thread Jason Gunthorpe
On Fri, Aug 21, 2020 at 09:47:43PM +0200, Thomas Gleixner wrote: > On Fri, Aug 21 2020 at 09:45, Jason Gunthorpe wrote: > > On Fri, Aug 21, 2020 at 02:25:02AM +0200, Thomas Gleixner wrote: > >> +static void ims_mask_irq(struct irq_data *data) > >> +{ > >> + struct msi_desc *desc =

Re: [patch RFC 38/38] irqchip: Add IMS array driver - NOT FOR MERGING

2020-08-21 Thread Thomas Gleixner
On Fri, Aug 21 2020 at 17:17, Jason Gunthorpe wrote: > On Fri, Aug 21, 2020 at 09:47:43PM +0200, Thomas Gleixner wrote: >> So if I understand correctly then the queue memory where the MSI >> descriptor sits is in RAM. > > Yes, IMHO that is the whole point of this 'IMS' stuff. If devices > could

Re: [PATCH v4 07/15] iommu/vt-d: Delegate the dma domain to upper layer

2020-08-21 Thread Chris Wilson
Quoting Lu Baolu (2019-05-25 06:41:28) > This allows the iommu generic layer to allocate a dma domain and > attach it to a device through the iommu api's. With all types of > domains being delegated to upper layer, we can remove an internal > flag which was used to distinguish domains mananged

RE: [PATCH v7 0/3] make dma_alloc_coherent NUMA-aware by per-NUMA CMA

2020-08-21 Thread Song Bao Hua (Barry Song)
> -Original Message- > From: Mike Kravetz [mailto:mike.krav...@oracle.com] > Sent: Saturday, August 22, 2020 5:53 AM > To: Song Bao Hua (Barry Song) ; h...@lst.de; > m.szyprow...@samsung.com; robin.mur...@arm.com; w...@kernel.org; > ganapatrao.kulka...@cavium.com;

RE: [PATCH v7 0/3] make dma_alloc_coherent NUMA-aware by per-NUMA CMA

2020-08-21 Thread Song Bao Hua (Barry Song)
> -Original Message- > From: Song Bao Hua (Barry Song) > Sent: Saturday, August 22, 2020 7:27 AM > To: 'Mike Kravetz' ; h...@lst.de; > m.szyprow...@samsung.com; robin.mur...@arm.com; w...@kernel.org; > ganapatrao.kulka...@cavium.com; catalin.mari...@arm.com; > a...@linux-foundation.org

RE: [PATCH v7 1/3] dma-contiguous: provide the ability to reserve per-numa CMA

2020-08-21 Thread Song Bao Hua (Barry Song)
> -Original Message- > From: Mike Rapoport [mailto:r...@linux.ibm.com] > Sent: Saturday, August 22, 2020 2:28 AM > To: Song Bao Hua (Barry Song) > Cc: h...@lst.de; m.szyprow...@samsung.com; robin.mur...@arm.com; > w...@kernel.org; ganapatrao.kulka...@cavium.com; >

Re: [patch RFC 38/38] irqchip: Add IMS array driver - NOT FOR MERGING

2020-08-21 Thread Thomas Gleixner
On Fri, Aug 21 2020 at 09:45, Jason Gunthorpe wrote: > On Fri, Aug 21, 2020 at 02:25:02AM +0200, Thomas Gleixner wrote: >> +static void ims_mask_irq(struct irq_data *data) >> +{ >> +struct msi_desc *desc = irq_data_get_msi_desc(data); >> +struct ims_array_slot __iomem *slot =

RE: [PATCH v7 1/3] dma-contiguous: provide the ability to reserve per-numa CMA

2020-08-21 Thread Song Bao Hua (Barry Song)
> -Original Message- > From: Randy Dunlap [mailto:rdun...@infradead.org] > Sent: Saturday, August 22, 2020 4:08 AM > To: Song Bao Hua (Barry Song) ; h...@lst.de; > m.szyprow...@samsung.com; robin.mur...@arm.com; w...@kernel.org; > ganapatrao.kulka...@cavium.com; catalin.mari...@arm.com;

Re: [patch RFC 38/38] irqchip: Add IMS array driver - NOT FOR MERGING

2020-08-21 Thread Thomas Gleixner
Jason, On Fri, Aug 21 2020 at 21:51, Jason Gunthorpe wrote: > On Sat, Aug 22, 2020 at 01:47:12AM +0200, Thomas Gleixner wrote: >> > If the device has died the driver has code to detect and trigger a >> > PCI function reset which will definitely stop the interrupt. >> >> If that interrupt is gone

Re: [patch RFC 38/38] irqchip: Add IMS array driver - NOT FOR MERGING

2020-08-21 Thread Jason Gunthorpe
On Sat, Aug 22, 2020 at 01:47:12AM +0200, Thomas Gleixner wrote: > On Fri, Aug 21 2020 at 17:17, Jason Gunthorpe wrote: > > On Fri, Aug 21, 2020 at 09:47:43PM +0200, Thomas Gleixner wrote: > >> So if I understand correctly then the queue memory where the MSI > >> descriptor sits is in RAM. > > > >

RE: [PATCH v6 1/2] dma-contiguous: provide the ability to reserve per-numa CMA

2020-08-21 Thread Song Bao Hua (Barry Song)
> -Original Message- > From: linux-kernel-ow...@vger.kernel.org > [mailto:linux-kernel-ow...@vger.kernel.org] On Behalf Of Randy Dunlap > Sent: Friday, August 21, 2020 2:50 PM > To: Song Bao Hua (Barry Song) ; h...@lst.de; > m.szyprow...@samsung.com; robin.mur...@arm.com;

Re: [PATCH RESEND v10 07/11] device-mapping: Introduce DMA range map, supplanting dma_pfn_offset

2020-08-21 Thread Andy Shevchenko
On Thu, Aug 20, 2020 at 09:37:12AM -0400, Jim Quinlan wrote: > On Tue, Aug 18, 2020 at 4:14 AM Andy Shevchenko > wrote: > > On Mon, Aug 17, 2020 at 05:53:09PM -0400, Jim Quinlan wrote: ... > > > +static inline u64 dma_offset_from_dma_addr(struct device *dev, > > > dma_addr_t dma_addr) > > > +{

Re: [PATCH v2 1/3] iommu/virtio: Add topology description to virtio-iommu config space

2020-08-21 Thread Jean-Philippe Brucker
Hi, While preparing the next version I noticed I forgot to send this reply. Better late than never I suppose... On Tue, Apr 21, 2020 at 07:31:12AM +, Tian, Kevin wrote: > > From: Jean-Philippe Brucker > > Sent: Saturday, February 29, 2020 1:26 AM > > > > Platforms without device-tree do not

Re: [PATCH v6 1/2] dma-contiguous: provide the ability to reserve per-numa CMA

2020-08-21 Thread Will Deacon
On Fri, Aug 21, 2020 at 02:26:14PM +1200, Barry Song wrote: > diff --git a/Documentation/admin-guide/kernel-parameters.txt > b/Documentation/admin-guide/kernel-parameters.txt > index bdc1f33fd3d1..3f33b89aeab5 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++

Re: [PATCH v6 2/2] arm64: mm: reserve per-numa CMA to localize coherent dma buffers

2020-08-21 Thread Will Deacon
On Fri, Aug 21, 2020 at 02:26:15PM +1200, Barry Song wrote: > Right now, smmu is using dma_alloc_coherent() to get memory to save queues > and tables. Typically, on ARM64 server, there is a default CMA located at > node0, which could be far away from node2, node3 etc. > with this patch, smmu will

Re: [PATCH v6 0/2] make dma_alloc_coherent NUMA-aware by per-NUMA CMA

2020-08-21 Thread Christoph Hellwig
FYI, as of the last one I'm fine now, bit I really need an ACK from the arm64 maintainers. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH 07/18] iommu/arm-smmu: Remove arch/arm workaround

2020-08-21 Thread Will Deacon
On Thu, Aug 20, 2020 at 04:08:26PM +0100, Robin Murphy wrote: > Now that arch/arm is wired up for default domains and iommu-dma, remove > the add_device workaround. > > Signed-off-by: Robin Murphy > --- > drivers/iommu/arm/arm-smmu/arm-smmu.c | 10 -- > 1 file changed, 10 deletions(-) >

Re: [PATCH v6 0/2] make dma_alloc_coherent NUMA-aware by per-NUMA CMA

2020-08-21 Thread Will Deacon
On Fri, Aug 21, 2020 at 08:19:18AM +0200, Christoph Hellwig wrote: > FYI, as of the last one I'm fine now, bit I really need an ACK from > the arm64 maintainers. Going through the dreaded backlog this morning... Will ___ iommu mailing list