Re: [PATCH v3 6/6] iommu: mtk_iommu: Lookup phandle to retrieve syscon to pericfg

2022-06-15 Thread AngeloGioacchino Del Regno
Il 15/06/22 14:09, Matthias Brugger ha scritto: On 09/06/2022 12:08, AngeloGioacchino Del Regno wrote: On some SoCs (of which only MT8195 is supported at the time of writing), the "R" and "W" (I/O) enable bits for the IOMMUs are in the pericfg_ao register space and not in the IOMMU space: as

Re: [RESEND PATCH v8 01/11] iommu: Add DMA ownership management interfaces

2022-06-15 Thread Steven Price
On 15/06/2022 11:57, Robin Murphy wrote: > On 2022-06-15 10:53, Steven Price wrote: >> On 18/04/2022 01:49, Lu Baolu wrote: >>> Multiple devices may be placed in the same IOMMU group because they >>> cannot be isolated from each other. These devices must either be >>> entirely under kernel control

[PATCH v13 9/9] iommu/arm-smmu: Get associated RMR info and install bypass SMR

2022-06-15 Thread Shameer Kolothum via iommu
From: Jon Nettleton Check if there is any RMR info associated with the devices behind the SMMU and if any, install bypass SMRs for them. This is to keep any ongoing traffic associated with these devices alive when we enable/reset SMMU during probe(). Signed-off-by: Jon Nettleton Signed-off-by:

Re: [PATCH v2 01/12] iommu/vt-d: debugfs: Remove device_domain_lock usage

2022-06-15 Thread Baolu Lu
On 2022/6/15 14:13, Tian, Kevin wrote: From: Baolu Lu Sent: Wednesday, June 15, 2022 9:54 AM On 2022/6/14 14:43, Tian, Kevin wrote: From: Lu Baolu Sent: Tuesday, June 14, 2022 10:51 AM The domain_translation_struct debugfs node is used to dump the DMAR page tables for the PCI devices. It

Re: [RESEND PATCH v8 01/11] iommu: Add DMA ownership management interfaces

2022-06-15 Thread Robin Murphy
On 2022-06-15 10:53, Steven Price wrote: On 18/04/2022 01:49, Lu Baolu wrote: Multiple devices may be placed in the same IOMMU group because they cannot be isolated from each other. These devices must either be entirely under kernel control or userspace control, never a mixture. This adds dma

helping with remapping vmem for dma

2022-06-15 Thread Frank Wunderlich
Hi, i have upported a wifi-driver (mt6625l for armhf) for some time and fall now (at least 5.18) in the "rejecting DMA map of vmalloc memory" error [1]. maybe anybody here can guide me on how to nail it down and maybe fix it. as far as i have debugged it, it uses dma_map_single [2] to get dma

Re: helping with remapping vmem for dma

2022-06-15 Thread Frank Wunderlich
Am 15. Juni 2022 15:17:00 MESZ schrieb Christoph Hellwig : >On Wed, Jun 15, 2022 at 02:15:33PM +0100, Robin Murphy wrote: >> Put simply, if you want to call dma_map_single() on a buffer, then that >> buffer needs to be allocated with kmalloc() (or technically alloc_pages(), >> but then

[PATCH v13 0/9] ACPI/IORT: Support for IORT RMR node

2022-06-15 Thread Shameer Kolothum via iommu
Hi v12 --> v13 -No changes. Rebased to 5.19-rc1. -Picked up tags received from Laurentiu, Hanjun and Will. Thanks!. Thanks, Shameer From old: We have faced issues with 3408iMR RAID controller cards which fail to boot when SMMU is enabled. This is because these controllers make use of host

[PATCH v13 1/9] iommu: Introduce a callback to struct iommu_resv_region

2022-06-15 Thread Shameer Kolothum via iommu
A callback is introduced to struct iommu_resv_region to free memory allocations associated with the reserved region. This will be useful when we introduce support for IORT RMR based reserved regions. Reviewed-by: Christoph Hellwig Tested-by: Steven Price Tested-by: Laurentiu Tudor Tested-by:

[PATCH v13 4/9] ACPI/IORT: Add support to retrieve IORT RMR reserved regions

2022-06-15 Thread Shameer Kolothum via iommu
Parse through the IORT RMR nodes and populate the reserve region list corresponding to a given IOMMU and device(optional). Also, go through the ID mappings of the RMR node and retrieve all the SIDs associated with it. Reviewed-by: Lorenzo Pieralisi Tested-by: Steven Price Tested-by: Laurentiu

[PATCH v13 2/9] ACPI/IORT: Make iort_iommu_msi_get_resv_regions() return void

2022-06-15 Thread Shameer Kolothum via iommu
At present iort_iommu_msi_get_resv_regions() returns the number of MSI reserved regions on success and there are no users for this. The reserved region list will get populated anyway for platforms that require the HW MSI region reservation. Hence, change the function to return void instead.

[PATCH v13 3/9] ACPI/IORT: Provide a generic helper to retrieve reserve regions

2022-06-15 Thread Shameer Kolothum via iommu
Currently IORT provides a helper to retrieve HW MSI reserve regions. Change this to a generic helper to retrieve any IORT related reserve regions. This will be useful when we add support for RMR nodes in subsequent patches. [Lorenzo: For ACPI IORT] Reviewed-by: Lorenzo Pieralisi Reviewed-by:

Re: [PATCH v3 6/6] iommu: mtk_iommu: Lookup phandle to retrieve syscon to pericfg

2022-06-15 Thread Matthias Brugger
On 09/06/2022 12:08, AngeloGioacchino Del Regno wrote: On some SoCs (of which only MT8195 is supported at the time of writing), the "R" and "W" (I/O) enable bits for the IOMMUs are in the pericfg_ao register space and not in the IOMMU space: as it happened already with infracfg, it is

Re: helping with remapping vmem for dma

2022-06-15 Thread Christoph Hellwig
On Wed, Jun 15, 2022 at 02:15:33PM +0100, Robin Murphy wrote: > Put simply, if you want to call dma_map_single() on a buffer, then that > buffer needs to be allocated with kmalloc() (or technically alloc_pages(), > but then dma_map_page() would make more sense when dealing with entire > pages.

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

2022-06-15 Thread yf.wang--- via iommu
On Tue, 2022-06-14 at 13:56 +0100, Will Deacon wrote: > Hi, > > For some reason, this series has landed in my spam folder so > apologies > for the delay :/ > > > > +static arm_v7s_iopte paddr_to_iopte(phys_addr_t paddr, int lvl, > > + struct io_pgtable_cfg *cfg) >

[PATCH v13 6/9] iommu/arm-smmu-v3: Introduce strtab init helper

2022-06-15 Thread Shameer Kolothum via iommu
Introduce a helper to check the sid range and to init the l2 strtab entries(bypass). This will be useful when we have to initialize the l2 strtab with bypass for RMR SIDs. Tested-by: Hanjun Guo Acked-by: Will Deacon Signed-off-by: Shameer Kolothum ---

[PATCH v13 5/9] ACPI/IORT: Add a helper to retrieve RMR info directly

2022-06-15 Thread Shameer Kolothum via iommu
This will provide a way for SMMU drivers to retrieve StreamIDs associated with IORT RMR nodes and use that to set bypass settings for those IDs. Tested-by: Steven Price Tested-by: Laurentiu Tudor Tested-by: Hanjun Guo Reviewed-by: Hanjun Guo Signed-off-by: Shameer Kolothum ---

[PATCH v13 8/9] iommu/arm-smmu-v3: Get associated RMR info and install bypass STE

2022-06-15 Thread Shameer Kolothum via iommu
Check if there is any RMR info associated with the devices behind the SMMUv3 and if any, install bypass STEs for them. This is to keep any ongoing traffic associated with these devices alive when we enable/reset SMMUv3 during probe(). Tested-by: Hanjun Guo Signed-off-by: Shameer Kolothum ---

[PATCH v13 7/9] iommu/arm-smmu-v3: Refactor arm_smmu_init_bypass_stes() to force bypass

2022-06-15 Thread Shameer Kolothum via iommu
By default, disable_bypass flag is set and any dev without an iommu domain installs STE with CFG_ABORT during arm_smmu_init_bypass_stes(). Introduce a "force" flag and move the STE update logic to arm_smmu_init_bypass_stes() so that we can force it to install CFG_BYPASS STE for specific SIDs.

Re: helping with remapping vmem for dma

2022-06-15 Thread Robin Murphy
On 2022-06-15 13:11, Frank Wunderlich wrote: Hi, i have upported a wifi-driver (mt6625l for armhf) for some time and fall now (at least 5.18) in the "rejecting DMA map of vmalloc memory" error [1]. maybe anybody here can guide me on how to nail it down and maybe fix it. as far as i have

Re: [PATCH 1/2] iommu: arm-smmu-impl: Add 8250 display compatible to the client list.

2022-06-15 Thread Dmitry Baryshkov
On Wed, 15 Jun 2022 at 02:01, Emma Anholt wrote: > > Required for turning on per-process page tables for the GPU. > > Signed-off-by: Emma Anholt Reviewed-by: Dmitry Baryshkov > --- > > drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git

Re: [PATCH 2/2] arm64: dts: qcom: sm8250: Enable per-process page tables.

2022-06-15 Thread Dmitry Baryshkov
On Wed, 15 Jun 2022 at 02:01, Emma Anholt wrote: > > This is an SMMU for the adreno gpu, and adding this compatible lets > the driver use per-fd page tables, which are required for security > between GPU clients. > > Signed-off-by: Emma Anholt > --- > > Tested with a full deqp-vk run on RB5,

Re: [PATCH v2 03/12] iommu/vt-d: Remove clearing translation data in disable_dmar_iommu()

2022-06-15 Thread Baolu Lu
On 2022/6/15 14:22, Tian, Kevin wrote: From: Baolu Lu Sent: Tuesday, June 14, 2022 3:21 PM On 2022/6/14 14:49, Tian, Kevin wrote: From: Lu Baolu Sent: Tuesday, June 14, 2022 10:51 AM The disable_dmar_iommu() is called when IOMMU initialization fails or the IOMMU is hot-removed from the

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

2022-06-15 Thread Steve Wahl
On Wed, Jun 15, 2022 at 09:38:35AM +0800, Baolu Lu wrote: > On 2022/6/15 05:12, Steve Wahl wrote: > > On Tue, Jun 14, 2022 at 12:01:45PM -0700, Jerry Snitselaar wrote: > > > On Tue, Jun 14, 2022 at 11:45:35AM -0500, Steve Wahl wrote: > > > > On Tue, Jun 14, 2022 at 10:21:29AM +0800, Baolu Lu

Re: [PATCH] uacce: fix concurrency of fops_open and uacce_remove

2022-06-15 Thread Jean-Philippe Brucker
Hi, On Fri, Jun 10, 2022 at 08:34:23PM +0800, Zhangfei Gao wrote: > The uacce parent's module can be removed when uacce is working, > which may cause troubles. > > If rmmod/uacce_remove happens just after fops_open: bind_queue, > the uacce_remove can not remove the bound queue since it is not >

Re: [RFC PATCHES 1/2] iommu: Add RCU-protected page free support

2022-06-15 Thread Jason Gunthorpe via iommu
On Fri, Jun 10, 2022 at 01:37:20PM +0800, Baolu Lu wrote: > On 2022/6/9 20:49, Jason Gunthorpe wrote: > > > +void iommu_free_pgtbl_pages(struct iommu_domain *domain, > > > + struct list_head *pages) > > > +{ > > > + struct page *page, *next; > > > + > > > + if

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

2022-06-15 Thread Jerry Snitselaar
On Wed, Jun 15, 2022 at 01:36:50PM -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

[PATCH v7 12/21] RDMA/rw: drop pci_p2pdma_[un]map_sg()

2022-06-15 Thread Logan Gunthorpe
dma_map_sg() now supports the use of P2PDMA pages so pci_p2pdma_map_sg() is no longer necessary and may be dropped. This means the rdma_rw_[un]map_sg() helpers are no longer necessary. Remove it all. Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe --- drivers/infiniband/core/rw.c |

[PATCH v7 18/21] block: set FOLL_PCI_P2PDMA in __bio_iov_iter_get_pages()

2022-06-15 Thread Logan Gunthorpe
When a bio's queue supports PCI P2PDMA, set FOLL_PCI_P2PDMA for iov_iter_get_pages_flags(). This allows PCI P2PDMA pages to be passed from userspace and enables the O_DIRECT path in iomap based filesystems and direct to block devices. Signed-off-by: Logan Gunthorpe --- block/bio.c | 8 +++-

Re: [PATCH v9 2/3] iommu/mediatek: Rename MTK_IOMMU_TLB_ADDR to MTK_IOMMU_ADDR

2022-06-15 Thread Robin Murphy
On 2022-06-15 17:12, yf.wang--- via iommu wrote: From: Yunfei Wang Rename MTK_IOMMU_TLB_ADDR to MTK_IOMMU_ADDR, and update MTK_IOMMU_ADDR definition for better generality. Signed-off-by: Ning Li Signed-off-by: Yunfei Wang --- drivers/iommu/mtk_iommu.c | 8 1 file changed, 4

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

2022-06-15 Thread Robin Murphy
On 2022-06-15 17:12, yf.w...@mediatek.com wrote: From: Yunfei Wang Single memory zone feature will remove ZONE_DMA32 and ZONE_DMA and cause pgtable PA size larger than 32bit. Since Mediatek IOMMU hardware support at most 35bit PA in pgtable, so add a quirk to allow the PA of pgtables support

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

2022-06-15 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

[PATCH v7 11/21] RDMA/core: introduce ib_dma_pci_p2p_dma_supported()

2022-06-15 Thread Logan Gunthorpe
Introduce the helper function ib_dma_pci_p2p_dma_supported() to check if a given ib_device can be used in P2PDMA transfers. This ensures the ib_device is not using virt_dma and also that the underlying dma_device supports P2PDMA. Use the new helper in nvme-rdma to replace the existing check for

[PATCH v7 21/21] nvme-pci: allow mmaping the CMB in userspace

2022-06-15 Thread Logan Gunthorpe
Allow userspace to obtain CMB memory by mmaping the controller's char device. The mmap call allocates and returns a hunk of CMB memory, (the offset is ignored) so userspace does not have control over the address within the CMB. A VMA allocated in this way will only be usable by drivers that set

[PATCH v7 00/21] Userspace P2PDMA with O_DIRECT NVMe devices

2022-06-15 Thread Logan Gunthorpe
Hi, This patchset continues my work to add userspace P2PDMA access using O_DIRECT NVMe devices. This posting cleans up the way the pages are stored in the VMA and relies on proper reference counting that was fixed up recently in the kernel. The new method uses vm_insert_page() in

[PATCH v7 07/21] dma-mapping: add flags to dma_map_ops to indicate PCI P2PDMA support

2022-06-15 Thread Logan Gunthorpe
Add a flags member to the dma_map_ops structure with one flag to indicate support for PCI P2PDMA. Also, add a helper to check if a device supports PCI P2PDMA. Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe --- include/linux/dma-map-ops.h | 10 ++

[PATCH v7 02/21] PCI/P2PDMA: Attempt to set map_type if it has not been set

2022-06-15 Thread Logan Gunthorpe
Attempt to find the mapping type for P2PDMA pages on the first DMA map attempt if it has not been done ahead of time. Previously, the mapping type was expected to be calculated ahead of time, but if pages are to come from userspace then there's no way to ensure the path was checked ahead of time.

[PATCH v7 13/21] PCI/P2PDMA: Remove pci_p2pdma_[un]map_sg()

2022-06-15 Thread Logan Gunthorpe
This interface is superseded by support in dma_map_sg() which now supports heterogeneous scatterlists. There are no longer any users, so remove it. Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe Reviewed-by: Max Gurtovoy --- drivers/pci/p2pdma.c |

[PATCH v7 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-06-15 Thread Logan Gunthorpe
Introduce pci_mmap_p2pmem() which is a helper to allocate and mmap a hunk of p2pmem into userspace. Pages are allocated from the genalloc in bulk with their reference count set to one. They are returned to the genalloc when the page is put through p2pdma_page_free() (the reference count is once

[PATCH v7 19/21] block: set FOLL_PCI_P2PDMA in bio_map_user_iov()

2022-06-15 Thread Logan Gunthorpe
When a bio's queue supports PCI P2PDMA, set FOLL_PCI_P2PDMA for iov_iter_get_pages_flags(). This allows PCI P2PDMA pages to be passed from userspace and enables the NVMe passthru requests to use P2PDMA pages. Signed-off-by: Logan Gunthorpe --- block/blk-map.c | 7 ++- 1 file changed, 6

[PATCH v7 14/21] mm: introduce FOLL_PCI_P2PDMA to gate getting PCI P2PDMA pages

2022-06-15 Thread Logan Gunthorpe
GUP Callers that expect PCI P2PDMA pages can now set FOLL_PCI_P2PDMA to allow obtaining P2PDMA pages. If GUP is called without the flag and a P2PDMA page is found, it will return an error. FOLL_PCI_P2PDMA cannot be set if FOLL_LONGTERM is set. Signed-off-by: Logan Gunthorpe ---

[PATCH v7 04/21] PCI/P2PDMA: Introduce helpers for dma_map_sg implementations

2022-06-15 Thread Logan Gunthorpe
Add pci_p2pdma_map_segment() as a helper for simple dma_map_sg() implementations. It takes an scatterlist segment that must point to a pci_p2pdma struct page and will map it if the mapping requires a bus address. The return value indicates whether the mapping required a bus address or whether the

[PATCH v7 08/21] iommu/dma: support PCI P2PDMA pages in dma-iommu map_sg

2022-06-15 Thread Logan Gunthorpe
When a PCI P2PDMA page is seen, set the IOVA length of the segment to zero so that it is not mapped into the IOVA. Then, in finalise_sg(), apply the appropriate bus address to the segment. The IOVA is not created if the scatterlist only consists of P2PDMA pages. A P2PDMA page may have three

[PATCH v7 17/21] lib/scatterlist: add check when merging zone device pages

2022-06-15 Thread Logan Gunthorpe
Consecutive zone device pages should not be merged into the same sgl or bvec segment with other types of pages or if they belong to different pgmaps. Otherwise getting the pgmap of a given segment is not possible without scanning the entire segment. This helper returns true either if both pages

[PATCH v7 06/21] dma-direct: support PCI P2PDMA pages in dma-direct map_sg

2022-06-15 Thread Logan Gunthorpe
Add PCI P2PDMA support for dma_direct_map_sg() so that it can map PCI P2PDMA pages directly without a hack in the callers. This allows for heterogeneous SGLs that contain both P2PDMA and regular pages. A P2PDMA page may have three possible outcomes when being mapped: 1) If the data path between

[PATCH v7 09/21] nvme-pci: check DMA ops when indicating support for PCI P2PDMA

2022-06-15 Thread Logan Gunthorpe
Introduce a supports_pci_p2pdma() operation in nvme_ctrl_ops to replace the fixed NVME_F_PCI_P2PDMA flag such that the dma_map_ops flags can be checked for PCI P2PDMA support. Signed-off-by: Logan Gunthorpe Reviewed-by: Chaitanya Kulkarni --- drivers/nvme/host/core.c | 3 ++-

[PATCH v7 10/21] nvme-pci: convert to using dma_map_sgtable()

2022-06-15 Thread Logan Gunthorpe
The dma_map operations now support P2PDMA pages directly. So remove the calls to pci_p2pdma_[un]map_sg_attrs() and replace them with calls to dma_map_sgtable(). dma_map_sgtable() returns more complete error codes than dma_map_sg() and allows differentiating EREMOTEIO errors in case an unsupported

[PATCH v7 15/21] iov_iter: introduce iov_iter_get_pages_[alloc_]flags()

2022-06-15 Thread Logan Gunthorpe
Add iov_iter_get_pages_flags() and iov_iter_get_pages_alloc_flags() which take a flags argument that is passed to get_user_pages_fast(). This is so that FOLL_PCI_P2PDMA can be passed when appropriate. Signed-off-by: Logan Gunthorpe --- include/linux/uio.h | 6 ++ lib/iov_iter.c | 25

[PATCH v7 03/21] PCI/P2PDMA: Expose pci_p2pdma_map_type()

2022-06-15 Thread Logan Gunthorpe
pci_p2pdma_map_type() will be needed by the dma-iommu map_sg implementation because it will need to determine the mapping type ahead of actually doing the mapping to create the actual IOMMU mapping. Prototypes for this helper are added to dma-map-ops.h as they are only useful to dma map

[PATCH v7 16/21] block: add check when merging zone device pages

2022-06-15 Thread Logan Gunthorpe
Consecutive zone device pages should not be merged into the same sgl or bvec segment with other types of pages or if they belong to different pgmaps. Otherwise getting the pgmap of a given segment is not possible without scanning the entire segment. This helper returns true either if both pages

[PATCH v7 05/21] dma-mapping: allow EREMOTEIO return code for P2PDMA transfers

2022-06-15 Thread Logan Gunthorpe
Add EREMOTEIO error return to dma_map_sgtable() which will be used by .map_sg() implementations that detect P2PDMA pages that the underlying DMA device cannot access. Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe --- kernel/dma/mapping.c | 4 +++- 1 file changed, 3 insertions(+),

[PATCH v7 01/21] lib/scatterlist: add flag for indicating P2PDMA segments in an SGL

2022-06-15 Thread Logan Gunthorpe
Make use of the third free LSB in scatterlist's page_link on 64bit systems. The extra bit will be used by dma_[un]map_sg_p2pdma() to determine when a given SGL segments dma_address points to a PCI bus address. dma_unmap_sg_p2pdma() will need to perform different cleanup when a segment is marked

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

2022-06-15 Thread yf.wang--- via iommu
From: Yunfei Wang Single memory zone feature will remove ZONE_DMA32 and ZONE_DMA and cause pgtable PA size larger than 32bit. 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. Signed-off-by: Ning Li

[PATCH v9 2/3] iommu/mediatek: Rename MTK_IOMMU_TLB_ADDR to MTK_IOMMU_ADDR

2022-06-15 Thread yf.wang--- via iommu
From: Yunfei Wang Rename MTK_IOMMU_TLB_ADDR to MTK_IOMMU_ADDR, and update MTK_IOMMU_ADDR definition for better generality. Signed-off-by: Ning Li Signed-off-by: Yunfei Wang --- drivers/iommu/mtk_iommu.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git

[PATCH v9 3/3] iommu/mediatek: Allow page table PA up to 35bit

2022-06-15 Thread yf.wang--- via iommu
From: Yunfei Wang Single memory zone feature will remove ZONE_DMA32 and ZONE_DMA. So add the quirk IO_PGTABLE_QUIRK_ARM_MTK_TTBR_EXT to let level 1 and level 2 pgtable support at most 35bit PA. Signed-off-by: Ning Li Signed-off-by: Yunfei Wang --- drivers/iommu/mtk_iommu.c | 14

Re: [PATCH v9 3/3] iommu/mediatek: Allow page table PA up to 35bit

2022-06-15 Thread Robin Murphy
On 2022-06-15 17:12, yf.wang--- via iommu wrote: From: Yunfei Wang Single memory zone feature will remove ZONE_DMA32 and ZONE_DMA. So add the quirk IO_PGTABLE_QUIRK_ARM_MTK_TTBR_EXT to let level 1 and level 2 pgtable support at most 35bit PA. I'm not sure how this works in practice, given

Re: [PATCH 3/5] vfio/iommu_type1: Prefer to reuse domains vs match enforced cache coherency

2022-06-15 Thread Nicolin Chen via iommu
On Wed, Jun 15, 2022 at 07:35:00AM +, Tian, Kevin wrote: > External email: Use caution opening links or attachments > > > > From: Nicolin Chen > > Sent: Wednesday, June 15, 2022 4:45 AM > > > > Hi Kevin, > > > > On Wed, Jun 08, 2022 at 11:48:27PM +, Tian, Kevin wrote: > > > > > > The

[PATCH v2 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group

2022-06-15 Thread Nicolin Chen via iommu
Cases like VFIO wish to attach a device to an existing domain that was not allocated specifically from the device. This raises a condition where the IOMMU driver can fail the domain attach because the domain and device are incompatible with each other. This is a soft failure that can be resolved

[PATCH v2 3/5] vfio/iommu_type1: Remove the domain->ops comparison

2022-06-15 Thread Nicolin Chen via iommu
The domain->ops validation was added, as a precaution, for mixed-driver systems. However, at this moment only one iommu driver is possible. So remove it. Per discussion with Robin, in future when many can be permitted we will rely on the IOMMU core code to check the domain->ops:

[PATCH v2 4/5] vfio/iommu_type1: Clean up update_dirty_scope in detach_group()

2022-06-15 Thread Nicolin Chen via iommu
All devices in emulated_iommu_groups have pinned_page_dirty_scope set, so the update_dirty_scope in the first list_for_each_entry is always false. Clean it up, and move the "if update_dirty_scope" part from the detach_group_done routine to the domain_list part. Rename the "detach_group_done" goto

[PATCH v2 5/5] vfio/iommu_type1: Simplify group attachment

2022-06-15 Thread Nicolin Chen via iommu
Un-inline the domain specific logic from the attach/detach_group ops into two paired functions vfio_iommu_alloc_attach_domain() and vfio_iommu_detach_destroy_domain() that strictly deal with creating and destroying struct vfio_domains. Add the logic to check for EMEDIUMTYPE return code of

[PATCH v2 0/5] Simplify vfio_iommu_type1 attach/detach routine

2022-06-15 Thread Nicolin Chen via iommu
This is a preparatory series for IOMMUFD v2 patches. It enforces error code -EMEDIUMTYPE in iommu_attach_device() and iommu_attach_group() when an IOMMU domain and a device/group are incompatible. It also drops the useless domain->ops check since it won't fail in current environment. These allow

[PATCH v2 2/5] vfio/iommu_type1: Prefer to reuse domains vs match enforced cache coherency

2022-06-15 Thread Nicolin Chen via iommu
From: Jason Gunthorpe The KVM mechanism for controlling wbinvd is based on OR of the coherency property of all devices attached to a guest, no matter those devices are attached to a single domain or multiple domains. So, there is no value in trying to push a device that could do enforced cache

[PATCH v2 0/7] iommu/amd: Enforce IOMMU restrictions for SNP-enabled system

2022-06-15 Thread Suravee Suthikulpanit via iommu
SNP-enabled system requires IOMMU v1 page table to be configured with non-zero DTE[Mode] for DMA-capable devices. This effects a number of usecases such as IOMMU pass-through mode and AMD IOMMUv2 APIs for binding/unbinding pasid. The series introduce a global variable to check SNP-enabled state

[PATCH v2 1/7] iommu/amd: Warn when found inconsistency EFR mask

2022-06-15 Thread Suravee Suthikulpanit via iommu
The function check_feature_on_all_iommus() checks to ensure if an IOMMU feature support bit is set on the Extended Feature Register (EFR). Current logic iterates through all IOMMU, and returns false when it found the first unset bit. To provide more thorough checking, modify the logic to iterate

[PATCH v2 3/7] iommu/amd: Introduce an iommu variable for tracking SNP support status

2022-06-15 Thread Suravee Suthikulpanit via iommu
EFR[SNPSup] needs to be checked early in the boot process, since it is used to determine how IOMMU driver configures other IOMMU features and data structures. This check can be done as soon as the IOMMU driver finishes parsing IVHDs. Introduce a variable for tracking the SNP support status, which

[PATCH v2 5/7] iommu/amd: Set translation valid bit only when IO page tables are in use

2022-06-15 Thread Suravee Suthikulpanit via iommu
On AMD system with SNP enabled, IOMMU hardware checks the host translation valid (TV) and guest translation valid (GV) bits in the device table entry (DTE) before accessing the corresponded page tables. However, current IOMMU driver sets the TV bit for all devices regardless of whether the host

[PATCH v2 2/7] iommu/amd: Process all IVHDs before enabling IOMMU features

2022-06-15 Thread Suravee Suthikulpanit via iommu
The ACPI IVRS table can contain multiple IVHD blocks. Each block contains information used to initialize each IOMMU instance. Currently, init_iommu_all sequentially process IVHD block and initialize IOMMU instance one-by-one. However, certain features require all IOMMUs to be configured in the

[PATCH v2 7/7] iommu/amd: Do not support IOMMUv2 APIs when SNP is enabled

2022-06-15 Thread Suravee Suthikulpanit via iommu
The IOMMUv2 APIs (for supporting shared virtual memory with PASID) configures the domain with IOMMU v2 page table, and sets DTE[Mode]=0. This configuration cannot be supported on SNP-enabled system. Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/init.c | 7 ++- 1 file changed, 6

[PATCH v2 6/7] iommu/amd: Do not support IOMMU_DOMAIN_IDENTITY after SNP is enabled

2022-06-15 Thread Suravee Suthikulpanit via iommu
Once SNP is enabled (by executing SNP_INIT command), IOMMU can no longer support the passthrough domain (i.e. IOMMU_DOMAIN_IDENTITY). The SNP_INIT command is called early in the boot process, and would fail if the kernel is configure to default to passthrough mode. After the system is already

[PATCH v2 4/7] iommu/amd: Introduce function to check and enable SNP

2022-06-15 Thread Suravee Suthikulpanit via iommu
From: Brijesh Singh To support SNP, IOMMU needs to be enabled, and prohibits IOMMU configurations where DTE[Mode]=0, which means it cannot be supported with IOMMU passthrough domain (a.k.a IOMMU_DOMAIN_IDENTITY), and when AMD IOMMU driver is configured to not use the IOMMU host (v1) page table.

Re: [PATCH v2 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group

2022-06-15 Thread Baolu Lu
On 2022/6/16 08:03, Nicolin Chen wrote: diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 44016594831d..0dd13330fe12 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4323,7 +4323,7 @@ static int prepare_domain_attach_device(struct

RE: [PATCH v2 03/12] iommu/vt-d: Remove clearing translation data in disable_dmar_iommu()

2022-06-15 Thread Tian, Kevin
> From: Baolu Lu > Sent: Wednesday, June 15, 2022 9:10 PM > > On 2022/6/15 14:22, Tian, Kevin wrote: > >> From: Baolu Lu > >> Sent: Tuesday, June 14, 2022 3:21 PM > >> > >> On 2022/6/14 14:49, Tian, Kevin wrote: > From: Lu Baolu > Sent: Tuesday, June 14, 2022 10:51 AM > >

Re: [PATCH] uacce: fix concurrency of fops_open and uacce_remove

2022-06-15 Thread Zhangfei Gao
Hi, Jean On 2022/6/15 下午11:16, Jean-Philippe Brucker wrote: Hi, On Fri, Jun 10, 2022 at 08:34:23PM +0800, Zhangfei Gao wrote: The uacce parent's module can be removed when uacce is working, which may cause troubles. If rmmod/uacce_remove happens just after fops_open: bind_queue, the

Re: [RFC PATCHES 1/2] iommu: Add RCU-protected page free support

2022-06-15 Thread Baolu Lu
On 2022/6/15 23:40, Jason Gunthorpe wrote: On Fri, Jun 10, 2022 at 01:37:20PM +0800, Baolu Lu wrote: On 2022/6/9 20:49, Jason Gunthorpe wrote: +void iommu_free_pgtbl_pages(struct iommu_domain *domain, + struct list_head *pages) +{ + struct page *page, *next; + +

[PATCH v2 1/5] iommu/mediatek: Use dev_err_probe to mute probe_defer err log

2022-06-15 Thread Yong Wu via iommu
Mute the probe defer log: [2.654806] mtk-iommu 14018000.iommu: mm dts parse fail(-517). [2.656168] mtk-iommu 1c01f000.iommu: mm dts parse fail(-517). Fixes: d2e9a1102cfc ("iommu/mediatek: Contain MM IOMMU flow with the MM TYPE") Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del

[PATCH v2 4/5] iommu/mediatek: Improve safety for mediatek, smi property in larb nodes

2022-06-15 Thread Yong Wu via iommu
No functional change. Just improve safety from dts. All the larbs that connect to one IOMMU must connect with the same smi-common. This patch checks all the mediatek,smi property for each larb, If their mediatek,smi are different, it will return fails. Also avoid there is no available smi-larb

[PATCH v2 3/5] iommu/mediatek: Validate number of phandles associated with "mediatek, larbs"

2022-06-15 Thread Yong Wu via iommu
From: Guenter Roeck Fix the smatch warnings: drivers/iommu/mtk_iommu.c:878 mtk_iommu_mm_dts_parse() error: uninitialized symbol 'larbnode'. If someone abuse the dtsi node(Don't follow the definition of dt-binding), for example "mediatek,larbs" is provided as boolean property, "larb_nr" will be

[PATCH v2 5/5] iommu/mediatek: Remove a unused "mapping" which is only for v1

2022-06-15 Thread Yong Wu via iommu
Just remove a unused variable that only is for mtk_iommu_v1. Fixes: 9485a04a5bb9 ("iommu/mediatek: Separate mtk_iommu_data for v1 and v2") Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c

[PATCH v2 0/5] iommu/mediatek: Improve safety from dts

2022-06-15 Thread Yong Wu via iommu
This patchset contains misc improve patches: [1/5] When mt8195 v7, I added a error log for dts parse fail, but it doesn't ignore probe_defer case.(v6 doesn't have this err log.) [2/5] Add a error path for MM dts parse. [3/5][4/5] To improve safety from dts. Base on this:

[PATCH v2 2/5] iommu/mediatek: Add error path for loop of mm_dts_parse

2022-06-15 Thread Yong Wu via iommu
The mtk_iommu_mm_dts_parse will parse the smi larbs nodes. if the i+1 larb is parsed fail(return -EINVAL), we should of_node_put for the 0..i larbs. In the fail path, one of_node_put matches with of_parse_phandle in it. Fixes: d2e9a1102cfc ("iommu/mediatek: Contain MM IOMMU flow with the MM

Re: [PATCH v2 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group

2022-06-15 Thread Nicolin Chen via iommu
On Thu, Jun 16, 2022 at 10:09:49AM +0800, Baolu Lu wrote: > External email: Use caution opening links or attachments > > > On 2022/6/16 08:03, Nicolin Chen wrote: > > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c > > index 44016594831d..0dd13330fe12 100644 > > ---

Re: [PATCH v9 3/3] iommu/mediatek: Allow page table PA up to 35bit

2022-06-15 Thread kernel test robot
Hi, Thank you for the patch! Yet something to improve: [auto build test ERROR on joro-iommu/next] [also build test ERROR on linus/master v5.19-rc2 next-20220615] [cannot apply to arm-perf/for-next/perf] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting

Re: [RESEND PATCH v8 01/11] iommu: Add DMA ownership management interfaces

2022-06-15 Thread Steven Price
On 18/04/2022 01:49, Lu Baolu wrote: > Multiple devices may be placed in the same IOMMU group because they > cannot be isolated from each other. These devices must either be > entirely under kernel control or userspace control, never a mixture. > > This adds dma ownership management in iommu core

RE: [PATCH v2 01/12] iommu/vt-d: debugfs: Remove device_domain_lock usage

2022-06-15 Thread Tian, Kevin
> From: Baolu Lu > Sent: Wednesday, June 15, 2022 9:54 AM > > On 2022/6/14 14:43, Tian, Kevin wrote: > >> From: Lu Baolu > >> Sent: Tuesday, June 14, 2022 10:51 AM > >> > >> The domain_translation_struct debugfs node is used to dump the DMAR > >> page > >> tables for the PCI devices. It

RE: [PATCH v2 03/12] iommu/vt-d: Remove clearing translation data in disable_dmar_iommu()

2022-06-15 Thread Tian, Kevin
> From: Baolu Lu > Sent: Tuesday, June 14, 2022 3:21 PM > > On 2022/6/14 14:49, Tian, Kevin wrote: > >> From: Lu Baolu > >> Sent: Tuesday, June 14, 2022 10:51 AM > >> > >> The disable_dmar_iommu() is called when IOMMU initialization fails or > >> the IOMMU is hot-removed from the system. In both

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

2022-06-15 Thread Yong Wu via iommu
On Tue, 2022-06-14 at 13:56 +0100, Will Deacon wrote: > > @@ -74,17 +74,22 @@ struct io_pgtable_cfg { > > * to support up to 35 bits PA where the bit32, bit33 and > > bit34 are > > * encoded in the bit9, bit4 and bit5 of the PTE respectively. > > * > > +*

RE: [PATCH 3/5] vfio/iommu_type1: Prefer to reuse domains vs match enforced cache coherency

2022-06-15 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Wednesday, June 15, 2022 4:45 AM > > Hi Kevin, > > On Wed, Jun 08, 2022 at 11:48:27PM +, Tian, Kevin wrote: > > > > > The KVM mechanism for controlling wbinvd is only triggered during > > > > > kvm_vfio_group_add(), meaning it is a one-shot test done once the >