Re: [PATCH 09/15] device core: Add ability to handle multiple dma offsets

2020-05-19 Thread Greg Kroah-Hartman
On Tue, May 19, 2020 at 04:34:07PM -0400, Jim Quinlan wrote: > diff --git a/include/linux/device.h b/include/linux/device.h > index ac8e37cd716a..6cd916860b5f 100644 > --- a/include/linux/device.h > +++ b/include/linux/device.h > @@ -493,6 +493,8 @@ struct dev_links_info { > * @bus_dma_limit:

Re: [PATCH v7 03/24] iommu/sva: Add PASID helpers

2020-05-19 Thread Lu Baolu
On 5/20/20 1:54 AM, Jean-Philippe Brucker wrote: Let IOMMU drivers allocate a single PASID per mm. Store the mm in the IOASID set to allow refcounting and searching mm by PASID, when handling an I/O page fault. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/Kconfig | 5 +++

Re: [PATCH v7 02/24] iommu/ioasid: Add ioasid references

2020-05-19 Thread Lu Baolu
On 5/20/20 1:54 AM, Jean-Philippe Brucker wrote: Let IOASID users take references to existing ioasids with ioasid_get(). ioasid_put() drops a reference and only frees the ioasid when its reference number is zero. It returns true if the ioasid was freed. For drivers that don't call ioasid_get(),

Re: [PATCH v6 2/5] iommu/arm-smmu: Add support for TTBR1

2020-05-19 Thread Jordan Crouse
On Mon, May 18, 2020 at 03:59:59PM +0100, Will Deacon wrote: > On Thu, Apr 09, 2020 at 05:33:47PM -0600, Jordan Crouse wrote: > > Add support to enable TTBR1 if the domain requests it via the > > DOMAIN_ATTR_SPLIT_TABLES attribute. If enabled by the hardware > > and pagetable configuration the

[PATCH 09/15] device core: Add ability to handle multiple dma offsets

2020-05-19 Thread Jim Quinlan via iommu
The device variable 'dma_pfn_offset' is used to do a single linear map between cpu addrs and dma addrs. The variable 'dma_map' is added to struct device to point to an array of multiple offsets which is required for some devices. Signed-off-by: Jim Quinlan --- drivers/of/address.c| 50

[PATCH 00/15] PCI: brcmstb: enable PCIe for STB chips

2020-05-19 Thread Jim Quinlan via iommu
This patchset expands the usefulness of the Broadcom Settop Box PCIe controller by building upon the PCIe driver used currently by the Raspbery Pi. Other forms of this patchset were submitted by me years ago and not accepted; the major sticking point was the code required for the DMA remapping

[PATCH 10/15] dma-direct: Invoke dma offset func if needed

2020-05-19 Thread Jim Quinlan via iommu
Just like dma_pfn_offset, another offset is added to the dma/phys translation if there happen to be multiple regions that have different mapping offsets. Signed-off-by: Jim Quinlan --- include/linux/dma-direct.h | 16 1 file changed, 16 insertions(+) diff --git

Re: [git pull] IOMMU Fixes for Linux v5.7-rc6

2020-05-19 Thread pr-tracker-bot
The pull request you sent on Tue, 19 May 2020 17:40:45 +0200: > git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git > tags/iommu-fixes-v5.7-rc6 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/c2b00cbda9f92820ddbe2ae8f97628dae84ccc37 Thank you! --

[PATCH v7 11/24] iommu/arm-smmu-v3: Seize private ASID

2020-05-19 Thread Jean-Philippe Brucker
The SMMU has a single ASID space, the union of shared and private ASID sets. This means that the SMMU driver competes with the arch allocator for ASIDs. Shared ASIDs are those of Linux processes, allocated by the arch, and contribute in broadcast TLB maintenance. Private ASIDs are allocated by the

[PATCH v7 02/24] iommu/ioasid: Add ioasid references

2020-05-19 Thread Jean-Philippe Brucker
Let IOASID users take references to existing ioasids with ioasid_get(). ioasid_put() drops a reference and only frees the ioasid when its reference number is zero. It returns true if the ioasid was freed. For drivers that don't call ioasid_get(), ioasid_put() is the same as ioasid_free().

[PATCH v7 14/24] iommu/arm-smmu-v3: Add SVA feature checking

2020-05-19 Thread Jean-Philippe Brucker
Aggregate all sanity-checks for sharing CPU page tables with the SMMU under a single ARM_SMMU_FEAT_SVA bit. For PCIe SVA, users also need to check FEAT_ATS and FEAT_PRI. For platform SVA, they will most likely have to check FEAT_STALLS. Cc: Suzuki K Poulose Signed-off-by: Jean-Philippe Brucker

[PATCH v7 09/24] arm64: cpufeature: Export symbol read_sanitised_ftr_reg()

2020-05-19 Thread Jean-Philippe Brucker
The SMMUv3 driver would like to read the MMFR0 PARANGE field in order to share CPU page tables with devices. Allow the driver to be built as module by exporting the read_sanitized_ftr_reg() cpufeature symbol. Acked-by: Suzuki K Poulose Signed-off-by: Jean-Philippe Brucker ---

[PATCH v7 24/24] iommu/arm-smmu-v3: Add support for PRI

2020-05-19 Thread Jean-Philippe Brucker
For PCI devices that support it, enable the PRI capability and handle PRI Page Requests with the generic fault handler. It is enabled on demand by iommu_sva_device_init(). Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 286 +--- 1 file

[PATCH v7 12/24] iommu/arm-smmu-v3: Add support for VHE

2020-05-19 Thread Jean-Philippe Brucker
ARMv8.1 extensions added Virtualization Host Extensions (VHE), which allow to run a host kernel at EL2. When using normal DMA, Device and CPU address spaces are dissociated, and do not need to implement the same capabilities, so VHE hasn't been used in the SMMU until now. With shared address

[PATCH v7 16/24] iommu/arm-smmu-v3: Implement iommu_sva_bind/unbind()

2020-05-19 Thread Jean-Philippe Brucker
The sva_bind() function allows devices to access process address spaces using a PASID (aka SSID). (1) bind() allocates or gets an existing MMU notifier tied to the (domain, mm) pair. Each mm gets one PASID. (2) Any change to the address space calls invalidate_range() which sends ATC

[PATCH v7 10/24] iommu/arm-smmu-v3: Share process page tables

2020-05-19 Thread Jean-Philippe Brucker
With Shared Virtual Addressing (SVA), we need to mirror CPU TTBR, TCR, MAIR and ASIDs in SMMU contexts. Each SMMU has a single ASID space split into two sets, shared and private. Shared ASIDs correspond to those obtained from the arch ASID allocator, and private ASIDs are used for "classic"

[PATCH v7 04/24] iommu: Add a page fault handler

2020-05-19 Thread Jean-Philippe Brucker
Some systems allow devices to handle I/O Page Faults in the core mm. For example systems implementing the PCIe PRI extension or Arm SMMU stall model. Infrastructure for reporting these recoverable page faults was added to the IOMMU core by commit 0c830e6b3282 ("iommu: Introduce device fault report

[PATCH v7 01/24] mm: Add a PASID field to mm_struct

2020-05-19 Thread Jean-Philippe Brucker
Some devices can tag their DMA requests with a 20-bit Process Address Space ID (PASID), allowing them to access multiple address spaces. In combination with recoverable I/O page faults (for example PCIe PRI), PASID allows the IOMMU to share page tables with the MMU. To make sure that a single

[PATCH v7 13/24] iommu/arm-smmu-v3: Enable broadcast TLB maintenance

2020-05-19 Thread Jean-Philippe Brucker
The SMMUv3 can handle invalidation targeted at TLB entries with shared ASIDs. If the implementation supports broadcast TLB maintenance, enable it and keep track of it in a feature bit. The SMMU will then be affected by inner-shareable TLB invalidations from other agents. A major side-effect of

[PATCH v7 15/24] iommu/arm-smmu-v3: Add SVA device feature

2020-05-19 Thread Jean-Philippe Brucker
Implement the IOMMU device feature callbacks to support the SVA feature. At the moment dev_has_feat() returns false since I/O Page Faults isn't yet implemented. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 124 1 file changed, 124

[PATCH v7 00/24] iommu: Shared Virtual Addressing for SMMUv3

2020-05-19 Thread Jean-Philippe Brucker
Shared Virtual Addressing (SVA) allows to share process page tables with devices using the IOMMU, PASIDs and I/O page faults. Add SVA support to the Arm SMMUv3 driver. Since v6 [1]: * Rename ioasid_free() to ioasid_put() in patch 02, requiring changes to the Intel drivers. * Use

[PATCH v7 03/24] iommu/sva: Add PASID helpers

2020-05-19 Thread Jean-Philippe Brucker
Let IOMMU drivers allocate a single PASID per mm. Store the mm in the IOASID set to allow refcounting and searching mm by PASID, when handling an I/O page fault. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/Kconfig | 5 +++ drivers/iommu/Makefile| 1 +

[PATCH v7 23/24] PCI/ATS: Export PRI functions

2020-05-19 Thread Jean-Philippe Brucker
The SMMUv3 driver uses pci_{enable,disable}_pri() and related functions. Export those functions to allow the driver to be built as a module. Acked-by: Bjorn Helgaas Reviewed-by: Kuppuswamy Sathyanarayanan Signed-off-by: Jean-Philippe Brucker --- drivers/pci/ats.c | 4 1 file changed, 4

[PATCH v7 07/24] iommu/io-pgtable-arm: Move some definitions to a header

2020-05-19 Thread Jean-Philippe Brucker
Extract some of the most generic TCR defines, so they can be reused by the page table sharing code. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/io-pgtable-arm.h | 30 ++ drivers/iommu/io-pgtable-arm.c | 27 ++- MAINTAINERS

[PATCH v7 22/24] PCI/ATS: Add PRI stubs

2020-05-19 Thread Jean-Philippe Brucker
The SMMUv3 driver, which can be built without CONFIG_PCI, will soon gain support for PRI. Partially revert commit c6e9aefbf9db ("PCI/ATS: Remove unused PRI and PASID stubs") to re-introduce the PRI stubs, and avoid adding more #ifdefs to the SMMU driver. Acked-by: Bjorn Helgaas Reviewed-by:

[PATCH v7 18/24] iommu/arm-smmu-v3: Add support for Hardware Translation Table Update

2020-05-19 Thread Jean-Philippe Brucker
If the SMMU supports it and the kernel was built with HTTU support, enable hardware update of access and dirty flags. This is essential for shared page tables, to reduce the number of access faults on the fault queue. Normal DMA with io-pgtables doesn't currently use the access or dirty flags. We

[PATCH v7 20/24] dt-bindings: document stall property for IOMMU masters

2020-05-19 Thread Jean-Philippe Brucker
On ARM systems, some platform devices behind an IOMMU may support stall, which is the ability to recover from page faults. Let the firmware tell us when a device supports stall. Reviewed-by: Rob Herring Signed-off-by: Jean-Philippe Brucker --- .../devicetree/bindings/iommu/iommu.txt|

[PATCH v7 19/24] iommu/arm-smmu-v3: Maintain a SID->device structure

2020-05-19 Thread Jean-Philippe Brucker
When handling faults from the event or PRI queue, we need to find the struct device associated to a SID. Add a rb_tree to keep track of SIDs. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 175 +--- 1 file changed, 145 insertions(+), 30

[PATCH v7 08/24] iommu/arm-smmu-v3: Manage ASIDs with xarray

2020-05-19 Thread Jean-Philippe Brucker
In preparation for sharing some ASIDs with the CPU, use a global xarray to store ASIDs and their context. ASID#0 is now reserved, and the ASID space is global. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 27 ++- 1 file changed, 18

[PATCH v7 06/24] arm64: mm: Pin down ASIDs for sharing mm with devices

2020-05-19 Thread Jean-Philippe Brucker
To enable address space sharing with the IOMMU, introduce mm_context_get() and mm_context_put(), that pin down a context and ensure that it will keep its ASID after a rollover. Export the symbols to let the modular SMMUv3 driver use them. Pinning is necessary because a device constantly needs a

[PATCH v7 21/24] iommu/arm-smmu-v3: Add stall support for platform devices

2020-05-19 Thread Jean-Philippe Brucker
The SMMU provides a Stall model for handling page faults in platform devices. It is similar to PCI PRI, but doesn't require devices to have their own translation cache. Instead, faulting transactions are parked and the OS is given a chance to fix the page tables and retry the transaction. Enable

[PATCH v7 05/24] arm64: mm: Add asid_gen_match() helper

2020-05-19 Thread Jean-Philippe Brucker
Add a macro to check if an ASID is from the current generation, since a subsequent patch will introduce a third user for this test. Signed-off-by: Jean-Philippe Brucker --- arch/arm64/mm/context.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git

[PATCH v7 17/24] iommu/arm-smmu-v3: Hook up ATC invalidation to mm ops

2020-05-19 Thread Jean-Philippe Brucker
The invalidate_range() notifier is called for any change to the address space. Perform the required ATC invalidations. Signed-off-by: Jean-Philippe Brucker --- v6->v7: invalidate() doesn't need RCU protection anymore. --- drivers/iommu/arm-smmu-v3.c | 29 +++-- 1 file

[git pull] IOMMU Fixes for Linux v5.7-rc6

2020-05-19 Thread Joerg Roedel
Hi Linus, The following changes since commit 2ef96a5bb12be62ef75b5828c0aab838ebb29cb8: Linux 5.7-rc5 (2020-05-10 15:16:58 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git tags/iommu-fixes-v5.7-rc6 for you to fetch changes up to

Re: [PATCH] iomm/arm-smmu: Add stall implementation hook

2020-05-19 Thread Rob Clark
On Tue, May 19, 2020 at 2:26 AM Sai Prakash Ranjan wrote: > > Hi Will, > > On 2020-05-18 21:15, Will Deacon wrote: > > On Mon, May 11, 2020 at 11:30:08AM -0600, Jordan Crouse wrote: > >> On Fri, May 08, 2020 at 08:40:40AM -0700, Rob Clark wrote: > >> > On Fri, May 8, 2020 at 8:32 AM Rob Clark

[PATCH] iommu: Don't call .probe_finalize() under group->mutex

2020-05-19 Thread Joerg Roedel
From: Joerg Roedel The .probe_finalize() call-back of some IOMMU drivers calls into arm_iommu_attach_device(). This function will call back into the IOMMU core code, where it tries to take group->mutex again, resulting in a deadlock. As there is no reason why .probe_finalize() needs to be

[PATCH] iommu: Fix deferred domain attachment

2020-05-19 Thread Joerg Roedel
From: Joerg Roedel The IOMMU core code has support for deferring the attachment of a domain to a device. This is needed in kdump kernels where the new domain must not be attached to a device before the device driver takes it over. When the AMD IOMMU driver got converted to use the dma-iommu

Re: [PATCH 1/1] iommu/vt-d: Fix pointer cast warnings on 32 bit

2020-05-19 Thread Lu Baolu
On 2020/5/19 20:09, Joerg Roedel wrote: On Tue, May 19, 2020 at 09:34:23AM +0800, Lu Baolu wrote: Pointers should be casted to unsigned long to avoid "cast from pointer to integer of different size" warnings. drivers/iommu/intel-pasid.c:818:6: warning: cast from pointer to integer of

Re: [PATCH v2] iommu/qcom: add optional 'tbu' clock for TLB invalidate

2020-05-19 Thread Joerg Roedel
On Mon, May 18, 2020 at 10:16:56PM +0800, Shawn Guo wrote: > On some SoCs like MSM8939 with A405 adreno, there is a gfx_tbu clock > needs to be on while doing TLB invalidate. Otherwise, TLBSYNC status > will not be correctly reflected, causing the system to go into a bad > state. Add it as an

Re: [PATCH] iommu/mediatek-v1: Fix a build warning for a unused variable 'data'

2020-05-19 Thread Joerg Roedel
On Tue, May 19, 2020 at 03:57:44PM +0800, Yong Wu wrote: > This patch fixes a build warning: > drivers/iommu/mtk_iommu_v1.c: In function 'mtk_iommu_release_device': > >> drivers/iommu/mtk_iommu_v1.c:467:25: warning: variable 'data' set but > >> not used [-Wunused-but-set-variable] > 467 | struct

Re: [PATCH 1/1] iommu/vt-d: Fix pointer cast warnings on 32 bit

2020-05-19 Thread Joerg Roedel
On Tue, May 19, 2020 at 09:34:23AM +0800, Lu Baolu wrote: > Pointers should be casted to unsigned long to avoid "cast from pointer > to integer of different size" warnings. > > drivers/iommu/intel-pasid.c:818:6: warning: > cast from pointer to integer of different size [-Wpointer-to-int-cast]

Re: [PATCH -next] iommu/sun50i: Fix return value check in sun50i_iommu_probe()

2020-05-19 Thread Joerg Roedel
On Tue, May 19, 2020 at 09:18:57AM +, Wei Yongjun wrote: > In case of error, the function devm_platform_ioremap_resource() returns > ERR_PTR() not NULL. The NULL test in the return value check must be > replaced with IS_ERR(). > > Fixes: 4100b8c229b3 ("iommu: Add Allwinner H6 IOMMU driver") >

Re: [PATCH] iomm/arm-smmu: Add stall implementation hook

2020-05-19 Thread Sai Prakash Ranjan
Hi Will, On 2020-05-18 21:15, Will Deacon wrote: On Mon, May 11, 2020 at 11:30:08AM -0600, Jordan Crouse wrote: On Fri, May 08, 2020 at 08:40:40AM -0700, Rob Clark wrote: > On Fri, May 8, 2020 at 8:32 AM Rob Clark wrote: > > > > On Thu, May 7, 2020 at 5:54 AM Will Deacon wrote: > > > > > >

Re: [PATCH -next] iommu/sun50i: Fix return value check in sun50i_iommu_probe()

2020-05-19 Thread Maxime Ripard
On Tue, May 19, 2020 at 09:18:57AM +, Wei Yongjun wrote: > In case of error, the function devm_platform_ioremap_resource() returns > ERR_PTR() not NULL. The NULL test in the return value check must be > replaced with IS_ERR(). > > Fixes: 4100b8c229b3 ("iommu: Add Allwinner H6 IOMMU driver") >

[PATCH -next] iommu/sun50i: Fix return value check in sun50i_iommu_probe()

2020-05-19 Thread Wei Yongjun
In case of error, the function devm_platform_ioremap_resource() returns ERR_PTR() not NULL. The NULL test in the return value check must be replaced with IS_ERR(). Fixes: 4100b8c229b3 ("iommu: Add Allwinner H6 IOMMU driver") Reported-by: Hulk Robot Signed-off-by: Wei Yongjun ---

Re: [RFC/RFT][PATCH v2] dma-mapping: set default segment_boundary_mask to ULONG_MAX

2020-05-19 Thread Nicolin Chen
Hi Robin/Christoph, This v2 was sent a while ago. I know that we had a concern, yet will we have a closure whether merging it or not? Thanks! Nic On Mon, Apr 06, 2020 at 02:06:43PM -0700, Nicolin Chen wrote: > The default segment_boundary_mask was set to DMA_BIT_MAKS(32) > a decade ago by

[PATCH] iommu/mediatek-v1: Fix a build warning for a unused variable 'data'

2020-05-19 Thread Yong Wu
This patch fixes a build warning: drivers/iommu/mtk_iommu_v1.c: In function 'mtk_iommu_release_device': >> drivers/iommu/mtk_iommu_v1.c:467:25: warning: variable 'data' set but >> not used [-Wunused-but-set-variable] 467 | struct mtk_iommu_data *data; | ^~~~ It's reported

Re: [PATCH] iommu: Implement deferred domain attachment

2020-05-19 Thread Jerry Snitselaar
On Mon May 18 20, Joerg Roedel wrote: On Fri, May 15, 2020 at 08:23:13PM +0100, Robin Murphy wrote: But that's not what this is; this is (supposed to be) the exact same "don't actually perform the attach yet" logic as before, just restricting it to default domains in the one place that it

[iommu:x86/vt-d 23/44] drivers/iommu/mtk_iommu_v1.c:467:25: warning: variable 'data' set but not used

2020-05-19 Thread kbuild test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git x86/vt-d head: 69cf449166987d9a041020be6422ee7bf94a7228 commit: 57dbf81f50c82a0ad895a57828ad1ab539785a25 [23/44] iommu/mediatek-v1 Convert to probe/release_device() call-backs config: arm-allyesconfig (attached as .config)