Re: [PATCH v13 4/8] iommu/vt-d: Add bind guest PASID support

2020-05-13 Thread Christoph Hellwig
> + if (dev_is_pci(dev)) { > + /* VT-d supports devices with full 20 bit PASIDs only */ > + if (pci_max_pasids(to_pci_dev(dev)) != PASID_MAX) > + return -EINVAL; > + } else { > + return -ENOTSUPP; > + } This looks strange. Why no

Re: [PATCH v13 3/8] iommu/vt-d: Add nested translation helper function

2020-05-13 Thread Christoph Hellwig
> + * 1. CPU vs. IOMMU > + * 2. Guest vs. Host. > + */ > + switch (addr_width) { > +#ifdef CONFIG_X86 > + case ADDR_WIDTH_5LEVEL: > + if (cpu_feature_enabled(X86_FEATURE_LA57) && > + cap_5lp_support(iommu->cap)) { > + pasid_set_

Re: [PATCH v13 2/8] iommu/vt-d: Use a helper function to skip agaw for SL

2020-05-13 Thread Christoph Hellwig
On Wed, May 13, 2020 at 04:01:43PM -0700, Jacob Pan wrote: > An Intel iommu domain uses 5-level page table by default. If the > iommu that the domain tries to attach supports less page levels, > the top level page tables should be skipped. Add a helper to do > this so that it could be used in other

amd kdump failure with iommu=nopt

2020-05-13 Thread Jerry Snitselaar
We've seen kdump failures with recent kernels (5.5, 5.6, 5.7-rc1) on amd systems when iommu is enabled in translation mode. In the cases so far there has been mpt3sas involved, but I'm also seeing io page faults for ahci right before mpt3sas has an io page fault: [ 15.156620] ahci :63:00.0:

[PATCH v13 0/8] Nested Shared Virtual Address (SVA) VT-d support

2020-05-13 Thread Jacob Pan
Shared virtual address (SVA), a.k.a, Shared virtual memory (SVM) on Intel platforms allow address space sharing between device DMA and applications. SVA can reduce programming complexity and enhance security. This series is intended to enable SVA virtualization, i.e. enable use of SVA within a gues

[PATCH v13 8/8] iommu/vt-d: Add custom allocator for IOASID

2020-05-13 Thread Jacob Pan
When VT-d driver runs in the guest, PASID allocation must be performed via virtual command interface. This patch registers a custom IOASID allocator which takes precedence over the default XArray based allocator. The resulting IOASID allocation will always come from the host. This ensures that PASI

[PATCH v13 4/8] iommu/vt-d: Add bind guest PASID support

2020-05-13 Thread Jacob Pan
When supporting guest SVA with emulated IOMMU, the guest PASID table is shadowed in VMM. Updates to guest vIOMMU PASID table will result in PASID cache flush which will be passed down to the host as bind guest PASID calls. For the SL page tables, it will be harvested from device's default domain (

[PATCH v13 6/8] iommu/vt-d: Add svm/sva invalidate function

2020-05-13 Thread Jacob Pan
When Shared Virtual Address (SVA) is enabled for a guest OS via vIOMMU, we need to provide invalidation support at IOMMU API and driver level. This patch adds Intel VT-d specific function to implement iommu passdown invalidate API for shared virtual address. The use case is for supporting caching

[PATCH v13 5/8] iommu/vt-d: Support flushing more translation cache types

2020-05-13 Thread Jacob Pan
When Shared Virtual Memory is exposed to a guest via vIOMMU, scalable IOTLB invalidation may be passed down from outside IOMMU subsystems. This patch adds invalidation functions that can be used for additional translation cache types. Signed-off-by: Jacob Pan Reviewed-by: Eric Auger --- drivers

[PATCH v13 2/8] iommu/vt-d: Use a helper function to skip agaw for SL

2020-05-13 Thread Jacob Pan
An Intel iommu domain uses 5-level page table by default. If the iommu that the domain tries to attach supports less page levels, the top level page tables should be skipped. Add a helper to do this so that it could be used in other places. Signed-off-by: Jacob Pan Reviewed-by: Eric Auger Review

[PATCH v13 1/8] iommu/vt-d: Move domain helper to header

2020-05-13 Thread Jacob Pan
Move domain helper to header to be used by SVA code. Signed-off-by: Jacob Pan Reviewed-by: Eric Auger Reviewed-by: Kevin Tian --- drivers/iommu/intel-iommu.c | 6 -- include/linux/intel-iommu.h | 6 ++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/intel-i

[PATCH v13 7/8] iommu/vt-d: Enlightened PASID allocation

2020-05-13 Thread Jacob Pan
From: Lu Baolu Enabling IOMMU in a guest requires communication with the host driver for certain aspects. Use of PASID ID to enable Shared Virtual Addressing (SVA) requires managing PASID's in the host. VT-d 3.0 spec provides a Virtual Command Register (VCMD) to facilitate this. Writes to this re

[PATCH v13 3/8] iommu/vt-d: Add nested translation helper function

2020-05-13 Thread Jacob Pan
Nested translation mode is supported in VT-d 3.0 Spec.CH 3.8. With PASID granular translation type set to 0x11b, translation result from the first level(FL) also subject to a second level(SL) page table translation. This mode is used for SVA virtualization, where FL performs guest virtual to guest

[PATCH] iommu: Remove functions that support private domain

2020-05-13 Thread Sai Praneeth Prakhya
After moving iommu_group setup to iommu core code [1][2] and removing private domain support in vt-d [3], there are no users for functions such as iommu_request_dm_for_dev(), iommu_request_dma_domain_for_dev() and request_default_domain_for_dev(). So, remove these functions. [1] commit dce8d6964eb

Re: next/master bisection: baseline.login on jetson-tk1

2020-05-13 Thread Guillaume Tucker
On 12/05/2020 16:16, Joerg Roedel wrote: > Hi Guillaume, > > thanks for the report! > > On Tue, May 12, 2020 at 07:05:13AM +0100, Guillaume Tucker wrote: >>> Summary: >>> Start: 4b20e7462caa6 Add linux-next specific files for 20200511 >>> Plain log: >>> https://storage.kernelci.org/nex

Re: [PATCH v5 24/38] drm: v3d: fix common struct sg_table related issues

2020-05-13 Thread Eric Anholt
On Wed, May 13, 2020 at 6:33 AM Marek Szyprowski wrote: > > The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function > returns the number of the created entries in the DMA address space. > However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and > dma_unmap_sg must b

RE: [PATCH v11 00/13] SMMUv3 Nested Stage Setup (IOMMU part)

2020-05-13 Thread Shameerali Kolothum Thodi
Hi Eric, > -Original Message- > From: Auger Eric [mailto:eric.au...@redhat.com] > Sent: 13 May 2020 14:29 > To: Shameerali Kolothum Thodi ; > Zhangfei Gao ; eric.auger@gmail.com; > iommu@lists.linux-foundation.org; linux-ker...@vger.kernel.org; > k...@vger.kernel.org; kvm...@lists.cs.c

Re: [PATCH v5 29/38] drm: rcar-du: fix common struct sg_table related issues

2020-05-13 Thread Laurent Pinchart
Hi Marek, Thank you for the patch. On Wed, May 13, 2020 at 03:32:36PM +0200, Marek Szyprowski wrote: > The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function > returns the number of the created entries in the DMA address space. > However the subsequent calls to the dma_sync_sg_

[PATCH v4 1/5] dt-bindings: iommu: Add Allwinner H6 IOMMU bindings

2020-05-13 Thread Maxime Ripard
The Allwinner H6 has introduced an IOMMU. Let's add a device tree binding for it. Reviewed-by: Rob Herring Signed-off-by: Maxime Ripard --- Documentation/devicetree/bindings/iommu/allwinner,sun50i-h6-iommu.yaml | 61 + 1 file changed,

[PATCH v4 5/5] drm/sun4i: mixer: Call of_dma_configure if there's an IOMMU

2020-05-13 Thread Maxime Ripard
The main DRM device is actually a virtual device so it doesn't have the iommus property, which is instead on the DMA masters, in this case the mixers. Add a call to of_dma_configure with the mixers DT node but on the DRM virtual device to configure it in the same way than the mixers. Signed-off-b

[PATCH v4 2/5] dt-bindings: display: sun8i-mixer: Allow for an iommu property

2020-05-13 Thread Maxime Ripard
The H6 mixer is attached to an IOMMU, so let's allow that property to be set in the bindings. Reviewed-by: Rob Herring Signed-off-by: Maxime Ripard --- Documentation/devicetree/bindings/display/allwinner,sun8i-a83t-de2-mixer.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Document

[PATCH v4 4/5] arm64: dts: allwinner: h6: Add IOMMU

2020-05-13 Thread Maxime Ripard
Now that we have a driver for the IOMMU, let's start using it. Signed-off-by: Maxime Ripard --- arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 10 ++ 1 file changed, 10 insertions(+) diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h6.dts

[PATCH v4 3/5] iommu: Add Allwinner H6 IOMMU driver

2020-05-13 Thread Maxime Ripard
The Allwinner H6 has introduced an IOMMU for a few DMA controllers, mostly video related: the display engine, the video decoders / encoders, the camera capture controller, etc. The design is pretty simple compared to other IOMMUs found in SoCs: there's a single instance, controlling all the master

[PATCH v4 0/5] iommu: Add Allwinner H6 IOMMU driver

2020-05-13 Thread Maxime Ripard
Hi, Here's a series adding support for the IOMMU introduced in the Allwinner H6. The driver from Allwinner hints at more SoCs using it in the future (with more masters), so we can bet on that IOMMU becoming pretty much standard in new SoCs from Allwinner. One thing I wasn't really sure about was

Re: [PATCH v3 3/5] iommu: Add Allwinner H6 IOMMU driver

2020-05-13 Thread Maxime Ripard
Hi Jörg, On Wed, May 13, 2020 at 11:53:04AM +0200, Joerg Roedel wrote: > On Tue, May 05, 2020 at 12:09:32PM +0200, Maxime Ripard wrote: > > +static u32 *sun50i_dte_get_page_table(struct sun50i_iommu_domain > > *sun50i_domain, > > + dma_addr_t iova, gfp_t gfp) > > +

Re: [PATCH v5 00/38] DRM: fix struct sg_table nents vs. orig_nents misuse

2020-05-13 Thread Christoph Hellwig
I've pushed out a branch with the first three patches here: git://git.infradead.org/users/hch/dma-mapping.git dma-sg_table-helper Gitweb: http://git.infradead.org/users/hch/dma-mapping.git/shortlog/refs/heads/dma-sg_table-helper and merged it into the dma-mapping for-next tree. Unless s

[PATCH v5 33/38] staging: tegra-vde: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 15/38] drm: mediatek: use common helper for extracting pages array

2020-05-13 Thread Marek Szyprowski
Use common helper for converting a sg_table object into struct page pointer array. Signed-off-by: Marek Szyprowski --- For more information, see '[PATCH v5 00/38] DRM: fix struct sg_table nents vs. orig_nents misuse' thread: https://lore.kernel.org/linux-iommu/20200513132114.6046-1-m.szyprow...@s

[PATCH v5 38/38] videobuf2: use sgtable-based scatterlist wrappers

2020-05-13 Thread Marek Szyprowski
Use recently introduced common wrappers operating directly on the struct sg_table objects and scatterlist page iterators to make the code a bit more compact, robust, easier to follow and copy/paste safe. No functional change, because the code already properly did all the scaterlist related calls.

[PATCH v5 30/38] dmabuf: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 36/38] samples: vfio-mdev/mbochs: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 18/38] drm: omapdrm: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 28/38] drm: host1x: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 20/38] drm: radeon: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 31/38] staging: ion: remove dead code

2020-05-13 Thread Marek Szyprowski
ion_heap_pages_zero() function is not used at all, so remove it to simplify the ion_heap_sglist_zero() function later. Signed-off-by: Marek Szyprowski --- For more information, see '[PATCH v5 00/38] DRM: fix struct sg_table nents vs. orig_nents misuse' thread: https://lore.kernel.org/linux-iommu/

[PATCH v5 32/38] staging: ion: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 07/38] drm: amdgpu: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 21/38] drm: rockchip: use common helper for a scatterlist contiguity check

2020-05-13 Thread Marek Szyprowski
Use common helper for checking the contiguity of the imported dma-buf. Signed-off-by: Marek Szyprowski --- For more information, see '[PATCH v5 00/38] DRM: fix struct sg_table nents vs. orig_nents misuse' thread: https://lore.kernel.org/linux-iommu/20200513132114.6046-1-m.szyprow...@samsung.com/T

[PATCH v5 26/38] drm: vmwgfx: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 37/38] media: pci: fix common ALSA DMA-mapping related codes

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that dma_map_sg returns the numer of the created entries in the DMA address space. However the subsequent calls to dma_sync_sg_for_{device,cpu} and dma_unmap_sg must be called with the original number of entries passed to dma_map_sg. The sg_table->nents in

[PATCH v5 09/38] drm: etnaviv: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 03/38] iommu: add generic helper for mapping sgtable objects

2020-05-13 Thread Marek Szyprowski
struct sg_table is a common structure used for describing a memory buffer. It consists of a scatterlist with memory pages and DMA addresses (sgl entry), as well as the number of scatterlist entries: CPU pages (orig_nents entry) and DMA mapped pages (nents entry). It turned out that it was a common

[PATCH v5 01/38] dma-mapping: add generic helpers for mapping sgtable objects

2020-05-13 Thread Marek Szyprowski
struct sg_table is a common structure used for describing a memory buffer. It consists of a scatterlist with memory pages and DMA addresses (sgl entry), as well as the number of scatterlist entries: CPU pages (orig_nents entry) and DMA mapped pages (nents entry). It turned out that it was a common

[PATCH v5 04/38] drm: prime: add common helper to check scatterlist contiguity

2020-05-13 Thread Marek Szyprowski
It is a common operation done by DRM drivers to check the contiguity of the DMA-mapped buffer described by a scatterlist in the sg_table object. Let's add a common helper for this operation. Signed-off-by: Marek Szyprowski --- For more information, see '[PATCH v5 00/38] DRM: fix struct sg_table n

[PATCH v5 24/38] drm: v3d: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 34/38] misc: fastrpc: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 25/38] drm: virtio: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 17/38] drm: omapdrm: use common helper for extracting pages array

2020-05-13 Thread Marek Szyprowski
Use common helper for converting a sg_table object into struct page pointer array. Signed-off-by: Marek Szyprowski --- For more information, see '[PATCH v5 00/38] DRM: fix struct sg_table nents vs. orig_nents misuse' thread: https://lore.kernel.org/linux-iommu/20200513132114.6046-1-m.szyprow...@s

[PATCH v5 35/38] rapidio: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 23/38] drm: tegra: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 29/38] drm: rcar-du: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 27/38] xen: gntdev: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 10/38] drm: exynos: use common helper for a scatterlist contiguity check

2020-05-13 Thread Marek Szyprowski
Use common helper for checking the contiguity of the imported dma-buf. Signed-off-by: Marek Szyprowski --- For more information, see '[PATCH v5 00/38] DRM: fix struct sg_table nents vs. orig_nents misuse' thread: https://lore.kernel.org/linux-iommu/20200513132114.6046-1-m.szyprow...@samsung.com/T

[PATCH v5 12/38] drm: i915: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 16/38] drm: msm: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 11/38] drm: exynos: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 13/38] drm: lima: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 06/38] drm: core: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 05/38] drm: prime: use sgtable iterators in drm_prime_sg_to_page_addr_arrays()

2020-05-13 Thread Marek Szyprowski
Replace the current hand-crafted code for extracting pages and DMA addresses from the given scatterlist by the much more robust code based on the generic scatterlist iterators and recently introduced sg_table-based wrappers. The resulting code is simple and easy to understand, so the comment descri

[PATCH v5 22/38] drm: rockchip: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 19/38] drm: panfrost: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 02/38] scatterlist: add generic wrappers for iterating over sgtable objects

2020-05-13 Thread Marek Szyprowski
struct sg_table is a common structure used for describing a memory buffer. It consists of a scatterlist with memory pages and DMA addresses (sgl entry), as well as the number of scatterlist entries: CPU pages (orig_nents entry) and DMA mapped pages (nents entry). It turned out that it was a common

[PATCH v5 08/38] drm: armada: fix common struct sg_table related issues

2020-05-13 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_

[PATCH v5 14/38] drm: mediatek: use common helper for a scatterlist contiguity check

2020-05-13 Thread Marek Szyprowski
Use common helper for checking the contiguity of the imported dma-buf and do this check before allocating resources, so the error path is simpler. Signed-off-by: Marek Szyprowski --- For more information, see '[PATCH v5 00/38] DRM: fix struct sg_table nents vs. orig_nents misuse' thread: https://

Re: [PATCH v11 00/13] SMMUv3 Nested Stage Setup (IOMMU part)

2020-05-13 Thread Auger Eric
Hi Shameer, On 5/7/20 8:59 AM, Shameerali Kolothum Thodi wrote: > Hi Eric, > >> -Original Message- >> From: Shameerali Kolothum Thodi >> Sent: 30 April 2020 10:38 >> To: 'Auger Eric' ; Zhangfei Gao >> ; eric.auger@gmail.com; >> iommu@lists.linux-foundation.org; linux-ker...@vger.kerne

Re: [PATCH v4 03/38] iommu: add generic helper for mapping sgtable objects

2020-05-13 Thread Robin Murphy
On 2020-05-12 10:00 am, Marek Szyprowski wrote: struct sg_table is a common structure used for describing a memory buffer. It consists of a scatterlist with memory pages and DMA addresses (sgl entry), as well as the number of scatterlist entries: CPU pages (orig_nents entry) and DMA mapped pages

Re: [PATCH v4 02/38] scatterlist: add generic wrappers for iterating over sgtable objects

2020-05-13 Thread Robin Murphy
On 2020-05-12 10:00 am, Marek Szyprowski wrote: struct sg_table is a common structure used for describing a memory buffer. It consists of a scatterlist with memory pages and DMA addresses (sgl entry), as well as the number of scatterlist entries: CPU pages (orig_nents entry) and DMA mapped pages

Re: [PATCH v4 01/38] dma-mapping: add generic helpers for mapping sgtable objects

2020-05-13 Thread Robin Murphy
On 2020-05-12 10:00 am, Marek Szyprowski wrote: struct sg_table is a common structure used for describing a memory buffer. It consists of a scatterlist with memory pages and DMA addresses (sgl entry), as well as the number of scatterlist entries: CPU pages (orig_nents entry) and DMA mapped pages

[PATCH v5 00/38] DRM: fix struct sg_table nents vs. orig_nents misuse

2020-05-13 Thread Marek Szyprowski
Dear All, During the Exynos DRM GEM rework and fixing the issues in the. drm_prime_sg_to_page_addr_arrays() function [1] I've noticed that most drivers in DRM framework incorrectly use nents and orig_nents entries of the struct sg_table. In case of the most DMA-mapping implementations exchanging

Re: [PATCH v2] iommu/arm-smmu-v3: Don't reserve implementation defined register space

2020-05-13 Thread Robin Murphy
On 2020-05-13 12:02 pm, Jean-Philippe Brucker wrote: Some SMMUv3 implementation embed the Perf Monitor Group Registers (PMCG) inside the first 64kB region of the SMMU. Since PMCG are managed by a separate driver, this layout causes resource reservation conflicts during boot. To avoid this confli

RE: [PATCH v4 38/38] videobuf2: use sgtable-based scatterlist wrappers

2020-05-13 Thread Ruhl, Michael J
>-Original Message- >From: Marek Szyprowski >Sent: Tuesday, May 12, 2020 4:34 PM >To: Ruhl, Michael J ; dri- >de...@lists.freedesktop.org; iommu@lists.linux-foundation.org; linaro-mm- >s...@lists.linaro.org; linux-ker...@vger.kernel.org >Cc: Pawel Osciak ; Bartlomiej Zolnierkiewicz >; Davi

[PATCH v2] iommu/arm-smmu-v3: Don't reserve implementation defined register space

2020-05-13 Thread Jean-Philippe Brucker
Some SMMUv3 implementation embed the Perf Monitor Group Registers (PMCG) inside the first 64kB region of the SMMU. Since PMCG are managed by a separate driver, this layout causes resource reservation conflicts during boot. To avoid this conflict, don't reserve the MMIO regions that are implementat

Re: [EXT] Re: [PATCH v5] iommu/virtio: Use page size bitmap supported by endpoint

2020-05-13 Thread Jean-Philippe Brucker
On Wed, May 13, 2020 at 09:15:22AM +, Bharat Bhushan wrote: > Hi Jean, > > > -Original Message- > > From: Michael S. Tsirkin > > Sent: Wednesday, May 6, 2020 5:53 AM > > To: Bharat Bhushan > > Cc: jean-phili...@linaro.org; j...@8bytes.org; jasow...@redhat.com; > > virtualizat...@list

Re: [PATCH] iommu/arm-smmu-v3: Don't reserve implementation defined register space

2020-05-13 Thread Jean-Philippe Brucker
On Mon, May 11, 2020 at 08:03:05PM +0100, Robin Murphy wrote: > On 2020-05-06 6:46 pm, Jean-Philippe Brucker wrote: > > Some SMMUv3 implementation embed the Perf Monitor Group Registers (PMCG) > > inside the first 64kB region of the SMMU. Since PMCG are managed by a > > separate driver, this layout

Re: [PATCH -next] iommu/msm: Make msm_iommu_lock static

2020-05-13 Thread Joerg Roedel
On Tue, May 12, 2020 at 10:17:19AM +0800, Samuel Zou wrote: > Fix the following sparse warning: > > drivers/iommu/msm_iommu.c:37:1: warning: symbol 'msm_iommu_lock' was not > declared. > > The msm_iommu_lock has only call site within msm_iommu.c > It should be static > > Fixes: 0720d1f052dc ("m

Re: [PATCH v3 3/5] iommu: Add Allwinner H6 IOMMU driver

2020-05-13 Thread Joerg Roedel
On Tue, May 05, 2020 at 12:09:32PM +0200, Maxime Ripard wrote: > +static u32 *sun50i_dte_get_page_table(struct sun50i_iommu_domain > *sun50i_domain, > + dma_addr_t iova, gfp_t gfp) > +{ > + struct sun50i_iommu *iommu = sun50i_domain->iommu; > + unsigned lo

Re: [PATCH v2] iommu/amd: Fix get_acpihid_device_id()

2020-05-13 Thread Joerg Roedel
On Mon, May 11, 2020 at 10:33:36AM -0600, Raul E Rangel wrote: > acpi_dev_hid_uid_match() expects a null pointer for UID if it doesn't > exist. The acpihid_map_entry contains a char buffer for holding the > UID. If no UID was provided in the IVRS table, this buffer will be > zeroed. If we pass in a

RE: [EXT] Re: [PATCH v5] iommu/virtio: Use page size bitmap supported by endpoint

2020-05-13 Thread Bharat Bhushan
Hi Jean, > -Original Message- > From: Michael S. Tsirkin > Sent: Wednesday, May 6, 2020 5:53 AM > To: Bharat Bhushan > Cc: jean-phili...@linaro.org; j...@8bytes.org; jasow...@redhat.com; > virtualizat...@lists.linux-foundation.org; iommu@lists.linux-foundation.org; > linux-ker...@vger.ke

Re: [PATCH] iommu/amd: fix over-read of ACPI UID from IVRS table

2020-05-13 Thread Joerg Roedel
On Mon, May 11, 2020 at 10:23:52AM +, Alexander Monakov wrote: > IVRS parsing code always tries to read 255 bytes from memory when > retrieving ACPI device path, and makes an assumption that firmware > provides a zero-terminated string. Both of those are bugs: the entry > is likely to be shorte

Re: [PATCH v4 03/38] iommu: add generic helper for mapping sgtable objects

2020-05-13 Thread Joerg Roedel
Hi Marek, On Tue, May 12, 2020 at 11:00:23AM +0200, Marek Szyprowski wrote: > --- > include/linux/iommu.h | 16 > 1 file changed, 16 insertions(+) Some nits below, with those fixed: Acked-by: Joerg Roedel > diff --git a/include/linux/iommu.h b/include/linux/iommu.h >

Re: [PATCH] iommu/renesas: fix unused-function warning

2020-05-13 Thread Joerg Roedel
On Sat, May 09, 2020 at 12:02:16AM +0200, Arnd Bergmann wrote: > gcc warns because the only reference to ipmmu_find_group > is inside of an #ifdef: > > drivers/iommu/ipmmu-vmsa.c:878:28: error: 'ipmmu_find_group' defined but not > used [-Werror=unused-function] > > Change the #ifdef to an equiva

Re: [PATCH -next] iommu/amd: Remove set but not used variable 'iommu'

2020-05-13 Thread Joerg Roedel
On Fri, May 08, 2020 at 01:40:36PM +, YueHaibing wrote: > Fixes gcc '-Wunused-but-set-variable' warning: > > drivers/iommu/amd_iommu.c: In function 'amd_iommu_uninit_device': > drivers/iommu/amd_iommu.c:422:20: warning: > variable 'iommu' set but not used [-Wunused-but-set-variable] > > comm

Re: [PATCH v1 1/3] iommu/vt-d: Unify format of the printed messages

2020-05-13 Thread Joerg Roedel
On Thu, May 07, 2020 at 07:18:02PM +0300, Andy Shevchenko wrote: > Unify format of the printed messages, i.e. replace printk(LEVEL ... ) > with pr_level(...). > > Signed-off-by: Andy Shevchenko > --- > drivers/iommu/intel-iommu.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) Applied

Re: [PATCH v4 0/3] Replace private domain with per-group default domain

2020-05-13 Thread Joerg Roedel
On Wed, May 06, 2020 at 09:59:44AM +0800, Lu Baolu wrote: > Lu Baolu (3): > iommu/vt-d: Allow 32bit devices to uses DMA domain > iommu/vt-d: Allow PCI sub-hierarchy to use DMA domain > iommu/vt-d: Apply per-device dma_ops > > drivers/iommu/intel-iommu.c | 396 +++

Re: [PATCH] iommu: Do not probe devices on IOMMU-less busses

2020-05-13 Thread Joerg Roedel
On Mon, May 11, 2020 at 06:10:00PM +0200, Thierry Reding wrote: > From: Thierry Reding > > The host1x bus implemented on Tegra SoCs is primarily an abstraction to > create logical device from multiple platform devices. Since the devices > in such a setup are typically hierarchical, DMA setup stil

Re: [PATCH -next] iommu/amd: fix variable "iommu" set but not used

2020-05-13 Thread Joerg Roedel
On Fri, May 08, 2020 at 09:56:45PM -0400, Qian Cai wrote: > The commit dce8d6964ebd ("iommu/amd: Convert to probe/release_device() > call-backs") introduced an unused variable, > > drivers/iommu/amd_iommu.c: In function 'amd_iommu_uninit_device': > drivers/iommu/amd_iommu.c:422:20: warning: variab

Re: [RFC PATCH] drivers: iommu: reset cached node if dma_mask is changed

2020-05-13 Thread Joerg Roedel
Adding Robin. On Tue, May 05, 2020 at 12:07:59AM +0530, Ajay Kumar wrote: > The current IOVA allocation code stores a cached copy of the > first allocated IOVA address node, and all the subsequent allocations > have no way to get past(higher than) the first allocated IOVA range. > > This causes i