Re: [PATCH v9 16/17] vduse: Introduce VDUSE - vDPA Device in Userspace

2021-07-13 Thread Michael S. Tsirkin
On Wed, Jul 14, 2021 at 01:45:39PM +0800, Jason Wang wrote: > > +static int vduse_dev_msg_sync(struct vduse_dev *dev, > > + struct vduse_dev_msg *msg) > > +{ > > + int ret; > > + > > + init_waitqueue_head(>waitq); > > + spin_lock(>msg_lock); > > +

Re: [PATCH v9 03/17] vdpa: Fix code indentation

2021-07-13 Thread Yongji Xie
On Wed, Jul 14, 2021 at 12:20 PM Joe Perches wrote: > > On Tue, 2021-07-13 at 16:46 +0800, Xie Yongji wrote: > > Use tabs to indent the code instead of spaces. > > There are a lot more of these in this file. > > $ ./scripts/checkpatch.pl --fix-inplace --strict include/linux/vdpa.h > > and a

Re: [PATCH v9 16/17] vduse: Introduce VDUSE - vDPA Device in Userspace

2021-07-13 Thread Jason Wang
在 2021/7/13 下午4:46, Xie Yongji 写道: This VDUSE driver enables implementing software-emulated vDPA devices in userspace. The vDPA device is created by ioctl(VDUSE_CREATE_DEV) on /dev/vduse/control. Then a char device interface (/dev/vduse/$NAME) is exported to userspace for device emulation. In

Re: [PATCH v9 16/17] vduse: Introduce VDUSE - vDPA Device in Userspace

2021-07-13 Thread Yongji Xie
On Wed, Jul 14, 2021 at 10:54 AM Jason Wang wrote: > > > 在 2021/7/13 下午9:27, Dan Carpenter 写道: > > On Tue, Jul 13, 2021 at 04:46:55PM +0800, Xie Yongji wrote: > >> +static int vduse_dev_init_vdpa(struct vduse_dev *dev, const char *name) > >> +{ > >> +struct vduse_vdpa *vdev; > >> +int

Re: [PATCH v9 13/17] vdpa: factor out vhost_vdpa_pa_map() and vhost_vdpa_pa_unmap()

2021-07-13 Thread Yongji Xie
On Tue, Jul 13, 2021 at 7:31 PM Dan Carpenter wrote: > > On Tue, Jul 13, 2021 at 04:46:52PM +0800, Xie Yongji wrote: > > @@ -613,37 +618,28 @@ static void vhost_vdpa_unmap(struct vhost_vdpa *v, > > u64 iova, u64 size) > > } > > } > > > > -static int vhost_vdpa_process_iotlb_update(struct

Re: [PATCH] iommu/amd: Enable swiotlb if any device supports iommu v2 and uses identity mapping

2021-07-13 Thread Kai-Heng Feng
On Wed, Jul 14, 2021 at 7:57 AM Konrad Rzeszutek Wilk wrote: > > On Thu, Jul 08, 2021 at 03:43:42PM +0100, Robin Murphy wrote: > > On 2021-07-08 14:57, Kai-Heng Feng wrote: > > > On Thu, Jul 8, 2021 at 6:18 PM Robin Murphy wrote: > > > > > > > > On 2021-07-08 10:28, Joerg Roedel wrote: > > > > >

[PATCH v6 11/11] arm64: dts: mediatek: Get rid of mediatek, larb for MM nodes

2021-07-13 Thread Yong Wu
After adding device_link between the IOMMU consumer and smi, the mediatek,larb is unnecessary now. CC: Matthias Brugger Signed-off-by: Yong Wu Reviewed-by: Evan Green --- arch/arm64/boot/dts/mediatek/mt8173.dtsi | 16 arch/arm64/boot/dts/mediatek/mt8183.dtsi | 6 -- 2

[PATCH v6 10/11] arm: dts: mediatek: Get rid of mediatek, larb for MM nodes

2021-07-13 Thread Yong Wu
After adding device_link between the IOMMU consumer and smi, the mediatek,larb is unnecessary now. CC: Matthias Brugger Signed-off-by: Yong Wu Reviewed-by: Evan Green --- arch/arm/boot/dts/mt2701.dtsi | 2 -- arch/arm/boot/dts/mt7623n.dtsi | 5 - 2 files changed, 7 deletions(-) diff

[PATCH v6 09/11] memory: mtk-smi: Get rid of mtk_smi_larb_get/put

2021-07-13 Thread Yong Wu
After adding device_link between the iommu consumer and smi-larb, the pm_runtime_get(_sync) of smi-larb and smi-common will be called automatically. we can get rid of mtk_smi_larb_get/put. CC: Matthias Brugger Signed-off-by: Yong Wu Reviewed-by: Evan Green Acked-by: Krzysztof Kozlowski

[PATCH v6 08/11] media: mtk-vcodec: Get rid of mtk_smi_larb_get/put

2021-07-13 Thread Yong Wu
MediaTek IOMMU has already added the device_link between the consumer and smi-larb device. If the vcodec device call the pm_runtime_get_sync, the smi-larb's pm_runtime_get_sync also be called automatically. CC: Tiffany Lin CC: Irui Wang Signed-off-by: Yong Wu Reviewed-by: Evan Green Acked-by:

[PATCH v6 07/11] drm/mediatek: Get rid of mtk_smi_larb_get/put

2021-07-13 Thread Yong Wu
MediaTek IOMMU has already added the device_link between the consumer and smi-larb device. If the drm device call the pm_runtime_get_sync, the smi-larb's pm_runtime_get_sync also be called automatically. CC: CK Hu CC: Philipp Zabel Signed-off-by: Yong Wu Reviewed-by: Evan Green Acked-by:

[PATCH v6 06/11] drm/mediatek: Add pm runtime support for ovl and rdma

2021-07-13 Thread Yong Wu
From: Yongqiang Niu Prepare for smi cleaning up "mediatek,larb". Display use the dispsys device to call pm_rumtime_get_sync before. This patch add pm_runtime_xx with ovl and rdma device whose nodes has "iommus" property, then display could help pm_runtime_get for smi via ovl or rdma device.

[PATCH v6 05/11] media: mtk-mdp: Get rid of mtk_smi_larb_get/put

2021-07-13 Thread Yong Wu
MediaTek IOMMU has already added the device_link between the consumer and smi-larb device. If the mdp device call the pm_runtime_get_sync, the smi-larb's pm_runtime_get_sync also be called automatically. CC: Minghsiu Tsai CC: Houlong Wei Signed-off-by: Yong Wu Reviewed-by: Evan Green

[PATCH v6 04/11] media: mtk-jpeg: Get rid of mtk_smi_larb_get/put

2021-07-13 Thread Yong Wu
MediaTek IOMMU has already added device_link between the consumer and smi-larb device. If the jpg device call the pm_runtime_get_sync, the smi-larb's pm_runtime_get_sync also be called automatically. After removing the larb_get operations, then mtk_jpeg_clk_init is also unnecessary. Remove it

[PATCH v6 03/11] iommu/mediatek: Add device_link between the consumer and the larb devices

2021-07-13 Thread Yong Wu
MediaTek IOMMU-SMI diagram is like below. all the consumer connect with smi-larb, then connect with smi-common. M4U | smi-common | - | |... | | larb1 larb2 | | vdec venc When the consumer works, it should

[PATCH v6 02/11] iommu/mediatek: Add probe_defer for smi-larb

2021-07-13 Thread Yong Wu
Prepare for adding device_link. The iommu consumer should use device_link to connect with the smi-larb(supplier). then the smi-larb should run before the iommu consumer. Here we delay the iommu driver until the smi driver is ready, then all the iommu consumer always is after the smi driver. When

[PATCH v6 01/11] dt-binding: mediatek: Get rid of mediatek, larb for multimedia HW

2021-07-13 Thread Yong Wu
After adding device_link between the consumer with the smi-larbs, if the consumer call its owner pm_runtime_get(_sync), the pm_runtime_get(_sync) of smi-larb and smi-common will be called automatically. Thus, the consumer don't need the property. And IOMMU also know which larb this consumer

[PATCH v6 00/11] Clean up "mediatek,larb"

2021-07-13 Thread Yong Wu
MediaTek IOMMU block diagram always like below: M4U | smi-common | - | | ... | | larb1 larb2 | | vdec venc All the consumer connect with smi-larb, then connect with smi-common. When the consumer works, it

Re: [PATCH v9 16/17] vduse: Introduce VDUSE - vDPA Device in Userspace

2021-07-13 Thread Jason Wang
在 2021/7/13 下午9:27, Dan Carpenter 写道: On Tue, Jul 13, 2021 at 04:46:55PM +0800, Xie Yongji wrote: +static int vduse_dev_init_vdpa(struct vduse_dev *dev, const char *name) +{ + struct vduse_vdpa *vdev; + int ret; + + if (dev->vdev) + return -EEXIST; + +

Re: [PATCH v9 13/17] vdpa: factor out vhost_vdpa_pa_map() and vhost_vdpa_pa_unmap()

2021-07-13 Thread Jason Wang
在 2021/7/13 下午7:31, Dan Carpenter 写道: On Tue, Jul 13, 2021 at 04:46:52PM +0800, Xie Yongji wrote: @@ -613,37 +618,28 @@ static void vhost_vdpa_unmap(struct vhost_vdpa *v, u64 iova, u64 size) } } -static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v, -

Re: [PATCH 1/4] iommu/vt-d: Disable superpage for Geminilake igfx

2021-07-13 Thread Lu Baolu
On 7/14/21 4:30 AM, Ville Syrjälä wrote: On Tue, Jul 13, 2021 at 09:34:09AM +0800, Lu Baolu wrote: On 7/12/21 11:47 PM, Ville Syrjälä wrote: On Mon, Jul 12, 2021 at 07:23:07AM +0800, Lu Baolu wrote: On 7/10/21 12:47 AM, Ville Syrjala wrote: From: Ville Syrjälä While running "gem_exec_big

Re: [PATCH v2] dma-mapping: use vmalloc_to_page for vmalloc addresses

2021-07-13 Thread Stefano Stabellini
On Tue, 22 Jun 2021, Roman Skakun wrote: > This commit is dedicated to fix incorrect conversion from > cpu_addr to page address in cases when we get virtual > address which allocated in the vmalloc range. > As the result, virt_to_page() cannot convert this address > properly and return incorrect

Re: [PATCH v2] dma-mapping: use vmalloc_to_page for vmalloc addresses

2021-07-13 Thread Konrad Rzeszutek Wilk
On Tue, Jun 22, 2021 at 04:34:14PM +0300, Roman Skakun wrote: > This commit is dedicated to fix incorrect conversion from > cpu_addr to page address in cases when we get virtual > address which allocated in the vmalloc range. > As the result, virt_to_page() cannot convert this address > properly

Re: [PATCH v15 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing

2021-07-13 Thread Konrad Rzeszutek Wilk
..snip.. > > > I think the main question I have is how would you like to see patches for > > > 5.15? i.e. as patches on top of devel/for-linus-5.14 or something else? > > > > Yes that would be perfect. If there are any dependencies on the rc1, I > > can rebase it on top of that. > > Yes, please,

Re: [PATCH] iommu/amd: Enable swiotlb if any device supports iommu v2 and uses identity mapping

2021-07-13 Thread Konrad Rzeszutek Wilk
On Thu, Jul 08, 2021 at 03:43:42PM +0100, Robin Murphy wrote: > On 2021-07-08 14:57, Kai-Heng Feng wrote: > > On Thu, Jul 8, 2021 at 6:18 PM Robin Murphy wrote: > > > > > > On 2021-07-08 10:28, Joerg Roedel wrote: > > > > On Thu, Jul 08, 2021 at 03:42:32PM +0800, Kai-Heng Feng wrote: > > > > >

Re: [PATCH] swiotlb: add overflow checks to swiotlb_bounce

2021-07-13 Thread Konrad Rzeszutek Wilk
On Wed, Jul 07, 2021 at 02:12:54PM +0900, Dominique Martinet wrote: > This is a follow-up on 5f89468e2f06 ("swiotlb: manipulate orig_addr > when tlb_addr has offset") which fixed unaligned dma mappings, > making sure the following overflows are caught: > > - offset of the start of the slot within

RE: [RFC v2] /dev/iommu uAPI proposal

2021-07-13 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Wednesday, July 14, 2021 7:23 AM > > On Tue, Jul 13, 2021 at 11:20:12PM +, Tian, Kevin wrote: > > > From: Jason Gunthorpe > > > Sent: Wednesday, July 14, 2021 7:03 AM > > > > > > On Tue, Jul 13, 2021 at 10:48:38PM +, Tian, Kevin wrote: > > > > > > > We

Re: [PATCH v4 3/3] iommu: dart: Add DART iommu driver

2021-07-13 Thread Robin Murphy
^^ Nit: the subsystem style for the subject format should be "iommu/dart: Add..." - similarly on patch #1, which I just realised I missed (sorry!) On 2021-06-27 15:34, Sven Peter wrote: Apple's new SoCs use iommus for almost all peripherals. These Device Address Resolution Tables must be

Re: [RFC v2] /dev/iommu uAPI proposal

2021-07-13 Thread Jason Gunthorpe
On Tue, Jul 13, 2021 at 11:20:12PM +, Tian, Kevin wrote: > > From: Jason Gunthorpe > > Sent: Wednesday, July 14, 2021 7:03 AM > > > > On Tue, Jul 13, 2021 at 10:48:38PM +, Tian, Kevin wrote: > > > > > We can still bind to the parent with cookie, but with > > > iommu_register_

RE: [RFC v2] /dev/iommu uAPI proposal

2021-07-13 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Wednesday, July 14, 2021 7:03 AM > > On Tue, Jul 13, 2021 at 10:48:38PM +, Tian, Kevin wrote: > > > We can still bind to the parent with cookie, but with > > iommu_register_ sw_device() IOMMU fd knows that this binding doesn't > > need to establish any

Re: [RFC v2] /dev/iommu uAPI proposal

2021-07-13 Thread Jason Gunthorpe
On Tue, Jul 13, 2021 at 10:48:38PM +, Tian, Kevin wrote: > We can still bind to the parent with cookie, but with > iommu_register_ sw_device() IOMMU fd knows that this binding doesn't > need to establish any security context via IOMMU API. AFAIK there is no reason to involve the parent PCI

RE: [RFC v2] /dev/iommu uAPI proposal

2021-07-13 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Wednesday, July 14, 2021 12:33 AM > > On Tue, Jul 13, 2021 at 10:26:07AM -0600, Alex Williamson wrote: > > Quoting this proposal again: > > > > > 1) A successful binding call for the first device in the group creates > > > the security context for the entire

Re: [PATCH v5 5/7] iommu/amd: Tailored gather logic for AMD

2021-07-13 Thread Nadav Amit
> On Jul 13, 2021, at 11:40 AM, Robin Murphy wrote: > > On 2021-07-13 10:41, Nadav Amit wrote: >> From: Nadav Amit >> AMD's IOMMU can flush efficiently (i.e., in a single flush) any range. >> This is in contrast, for instnace, to Intel IOMMUs that have a limit on >> the number of pages that

Re: [PATCH 1/4] iommu/vt-d: Disable superpage for Geminilake igfx

2021-07-13 Thread Ville Syrjälä
On Tue, Jul 13, 2021 at 09:34:09AM +0800, Lu Baolu wrote: > On 7/12/21 11:47 PM, Ville Syrjälä wrote: > > On Mon, Jul 12, 2021 at 07:23:07AM +0800, Lu Baolu wrote: > >> On 7/10/21 12:47 AM, Ville Syrjala wrote: > >>> From: Ville Syrjälä > >>> > >>> While running "gem_exec_big --r single" from

[PATCH] dt-bindings: More dropping redundant minItems/maxItems

2021-07-13 Thread Rob Herring
Another round of removing redundant minItems/maxItems from new schema in the recent merge window. If a property has an 'items' list, then a 'minItems' or 'maxItems' with the same size as the list is redundant and can be dropped. Note that is DT schema specific behavior and not standard

Re: [PATCH v4 1/3] iommu: io-pgtable: add DART pagetable format

2021-07-13 Thread Robin Murphy
On 2021-06-27 15:34, Sven Peter wrote: Apple's DART iommu uses a pagetable format that shares some similarities with the ones already implemented by io-pgtable.c. Add a new format variant to support the required differences so that we don't have to duplicate the pagetable handling code.

Re: [PATCH v5 5/7] iommu/amd: Tailored gather logic for AMD

2021-07-13 Thread Robin Murphy
On 2021-07-13 10:41, Nadav Amit wrote: From: Nadav Amit AMD's IOMMU can flush efficiently (i.e., in a single flush) any range. This is in contrast, for instnace, to Intel IOMMUs that have a limit on the number of pages that can be flushed in a single flush. In addition, AMD's IOMMU do not

Re: [PATCH v5 4/7] iommu: Factor iommu_iotlb_gather_is_disjoint() out

2021-07-13 Thread Robin Murphy
On 2021-07-13 10:41, Nadav Amit wrote: From: Nadav Amit Refactor iommu_iotlb_gather_add_page() and factor out the logic that detects whether IOTLB gather range and a new range are disjoint. To be used by the next patch that implements different gathering logic for AMD. Note that updating

Re: [PATCH v2 0/3] iommu: Enable non-strict DMA on QCom SD/MMC

2021-07-13 Thread Robin Murphy
On 2021-07-08 15:36, Doug Anderson wrote: [...] Or document for the users that want performance how to change the setting, so that they can decide. Pushing this to the users can make sense for a Linux distribution but probably less sense for an embedded platform. So I'm happy to make some way

[PATCH v5 7/7] iommu/amd: Use only natural aligned flushes in a VM

2021-07-13 Thread Nadav Amit
From: Nadav Amit When running on an AMD vIOMMU, it is better to avoid TLB flushes of unmodified PTEs. vIOMMUs require the hypervisor to synchronize the virtualized IOMMU's PTEs with the physical ones. This process induce overheads. AMD IOMMU allows us to flush any range that is aligned to the

[PATCH v5 6/7] iommu/amd: Sync once for scatter-gather operations

2021-07-13 Thread Nadav Amit
From: Nadav Amit On virtual machines, software must flush the IOTLB after each page table entry update. The iommu_map_sg() code iterates through the given scatter-gather list and invokes iommu_map() for each element in the scatter-gather list, which calls into the vendor IOMMU driver through

[PATCH v5 5/7] iommu/amd: Tailored gather logic for AMD

2021-07-13 Thread Nadav Amit
From: Nadav Amit AMD's IOMMU can flush efficiently (i.e., in a single flush) any range. This is in contrast, for instnace, to Intel IOMMUs that have a limit on the number of pages that can be flushed in a single flush. In addition, AMD's IOMMU do not care about the page-size, so changes of the

[PATCH v5 4/7] iommu: Factor iommu_iotlb_gather_is_disjoint() out

2021-07-13 Thread Nadav Amit
From: Nadav Amit Refactor iommu_iotlb_gather_add_page() and factor out the logic that detects whether IOTLB gather range and a new range are disjoint. To be used by the next patch that implements different gathering logic for AMD. Note that updating gather->pgsize unconditionally does not

[PATCH v5 3/7] iommu: Improve iommu_iotlb_gather helpers

2021-07-13 Thread Nadav Amit
From: Robin Murphy The Mediatek driver is not the only one which might want a basic address-based gathering behaviour, so although it's arguably simple enough to open-code, let's factor it out for the sake of cleanliness. Let's also take this opportunity to document the intent of these helpers

[PATCH v5 2/7] iommu/amd: Do not use flush-queue when NpCache is on

2021-07-13 Thread Nadav Amit
From: Nadav Amit Do not use flush-queue on virtualized environments, where the NpCache capability of the IOMMU is set. This is required to reduce virtualization overheads. This change follows a similar change to Intel's VT-d and a detailed explanation as for the rationale is described in commit

[PATCH v5 1/7] iommu/amd: Selective flush on unmap

2021-07-13 Thread Nadav Amit
From: Nadav Amit Recent patch attempted to enable selective page flushes on AMD IOMMU but neglected to adapt amd_iommu_iotlb_sync() to use the selective flushes. Adapt amd_iommu_iotlb_sync() to use selective flushes and change amd_iommu_unmap() to collect the flushes. As a defensive measure, to

[PATCH v5 0/7] iommu/amd: Enable page-selective flushes

2021-07-13 Thread Nadav Amit
From: Nadav Amit The previous patch, commit 268aa4548277 ("iommu/amd: Page-specific invalidations for more than one page") was supposed to enable page-selective IOTLB flushes on AMD. Besides the bug that was already fixed by commit a017c567915f ("iommu/amd: Fix wrong parentheses on

Re: [RFC v2] /dev/iommu uAPI proposal

2021-07-13 Thread Jason Gunthorpe
On Tue, Jul 13, 2021 at 10:26:07AM -0600, Alex Williamson wrote: > Quoting this proposal again: > > > 1) A successful binding call for the first device in the group creates > > the security context for the entire group, by: > > > > * Verifying group viability in a similar way as VFIO

Re: [RFC v2] /dev/iommu uAPI proposal

2021-07-13 Thread Alex Williamson
On Tue, 13 Jul 2021 09:55:03 -0300 Jason Gunthorpe wrote: > On Mon, Jul 12, 2021 at 11:56:24PM +, Tian, Kevin wrote: > > > Maybe I misunderstood your question. Are you specifically worried > > about establishing the security context for a mdev vs. for its > > parent? > > The way to think

Re: [PATCH v9 16/17] vduse: Introduce VDUSE - vDPA Device in Userspace

2021-07-13 Thread Dan Carpenter
On Tue, Jul 13, 2021 at 04:46:55PM +0800, Xie Yongji wrote: > +static int vduse_dev_init_vdpa(struct vduse_dev *dev, const char *name) > +{ > + struct vduse_vdpa *vdev; > + int ret; > + > + if (dev->vdev) > + return -EEXIST; > + > + vdev = vdpa_alloc_device(struct

Re: [RFC v2] /dev/iommu uAPI proposal

2021-07-13 Thread Jason Gunthorpe
On Mon, Jul 12, 2021 at 11:56:24PM +, Tian, Kevin wrote: > Maybe I misunderstood your question. Are you specifically worried > about establishing the security context for a mdev vs. for its > parent? The way to think about the cookie, and the device bind/attach in general, is as taking

Re: [PATCH v9 13/17] vdpa: factor out vhost_vdpa_pa_map() and vhost_vdpa_pa_unmap()

2021-07-13 Thread Dan Carpenter
On Tue, Jul 13, 2021 at 04:46:52PM +0800, Xie Yongji wrote: > @@ -613,37 +618,28 @@ static void vhost_vdpa_unmap(struct vhost_vdpa *v, u64 > iova, u64 size) > } > } > > -static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v, > -struct

Re: [PATCH v9 07/17] virtio: Don't set FAILED status bit on device index allocation failure

2021-07-13 Thread Yongji Xie
On Tue, Jul 13, 2021 at 7:02 PM Dan Carpenter wrote: > > On Tue, Jul 13, 2021 at 04:46:46PM +0800, Xie Yongji wrote: > > We don't need to set FAILED status bit on device index allocation > > failure since the device initialization hasn't been started yet. > > The commit message should say what

Re: [PATCH v9 07/17] virtio: Don't set FAILED status bit on device index allocation failure

2021-07-13 Thread Dan Carpenter
On Tue, Jul 13, 2021 at 04:46:46PM +0800, Xie Yongji wrote: > We don't need to set FAILED status bit on device index allocation > failure since the device initialization hasn't been started yet. The commit message should say what the effect of this change is to the user. Is this a bugfix? Will

[PATCH v9 16/17] vduse: Introduce VDUSE - vDPA Device in Userspace

2021-07-13 Thread Xie Yongji
This VDUSE driver enables implementing software-emulated vDPA devices in userspace. The vDPA device is created by ioctl(VDUSE_CREATE_DEV) on /dev/vduse/control. Then a char device interface (/dev/vduse/$NAME) is exported to userspace for device emulation. In order to make the device emulation

[PATCH v9 17/17] Documentation: Add documentation for VDUSE

2021-07-13 Thread Xie Yongji
VDUSE (vDPA Device in Userspace) is a framework to support implementing software-emulated vDPA devices in userspace. This document is intended to clarify the VDUSE design and usage. Signed-off-by: Xie Yongji --- Documentation/userspace-api/index.rst | 1 +

[PATCH v9 15/17] vduse: Implement an MMU-based IOMMU driver

2021-07-13 Thread Xie Yongji
This implements an MMU-based IOMMU driver to support mapping kernel dma buffer into userspace. The basic idea behind it is treating MMU (VA->PA) as IOMMU (IOVA->PA). The driver will set up MMU mapping instead of IOMMU mapping for the DMA transfer so that the userspace process is able to use its

[PATCH v9 14/17] vdpa: Support transferring virtual addressing during DMA mapping

2021-07-13 Thread Xie Yongji
This patch introduces an attribute for vDPA device to indicate whether virtual address can be used. If vDPA device driver set it, vhost-vdpa bus driver will not pin user page and transfer userspace virtual address instead of physical address during DMA mapping. And corresponding vma->vm_file and

[PATCH v9 13/17] vdpa: factor out vhost_vdpa_pa_map() and vhost_vdpa_pa_unmap()

2021-07-13 Thread Xie Yongji
The upcoming patch is going to support VA mapping/unmapping. So let's factor out the logic of PA mapping/unmapping firstly to make the code more readable. Suggested-by: Jason Wang Signed-off-by: Xie Yongji Acked-by: Jason Wang --- drivers/vhost/vdpa.c | 53

[PATCH v9 12/17] vdpa: Add an opaque pointer for vdpa_config_ops.dma_map()

2021-07-13 Thread Xie Yongji
Add an opaque pointer for DMA mapping. Suggested-by: Jason Wang Signed-off-by: Xie Yongji Acked-by: Jason Wang --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 6 +++--- drivers/vhost/vdpa.c | 2 +- include/linux/vdpa.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)

[PATCH v9 09/17] virtio-vdpa: Handle the failure of vdpa_reset()

2021-07-13 Thread Xie Yongji
The vpda_reset() may fail now. This adds check to its return value and fail the virtio_vdpa_reset(). Signed-off-by: Xie Yongji --- drivers/virtio/virtio_vdpa.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c

[PATCH v9 11/17] vhost-iotlb: Add an opaque pointer for vhost IOTLB

2021-07-13 Thread Xie Yongji
Add an opaque pointer for vhost IOTLB. And introduce vhost_iotlb_add_range_ctx() to accept it. Suggested-by: Jason Wang Signed-off-by: Xie Yongji Acked-by: Jason Wang --- drivers/vhost/iotlb.c | 20 include/linux/vhost_iotlb.h | 3 +++ 2 files changed, 19

[PATCH v9 10/17] virtio: Handle device reset failure in register_virtio_device()

2021-07-13 Thread Xie Yongji
The device reset may fail in virtio-vdpa case now, so add checks to its return value and fail the register_virtio_device(). Signed-off-by: Xie Yongji --- drivers/virtio/virtio.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/virtio/virtio.c

[PATCH v9 08/17] virtio_config: Add a return value to reset function

2021-07-13 Thread Xie Yongji
This adds a return value to reset function so that we can handle the reset failure later. No functional changes. Signed-off-by: Xie Yongji --- arch/um/drivers/virtio_uml.c | 4 +++- drivers/platform/mellanox/mlxbf-tmfifo.c | 4 +++- drivers/remoteproc/remoteproc_virtio.c | 4 +++-

[PATCH v9 06/17] vhost-vdpa: Handle the failure of vdpa_reset()

2021-07-13 Thread Xie Yongji
The vdpa_reset() may fail now. This adds check to its return value and fail the vhost_vdpa_open(). Signed-off-by: Xie Yongji --- drivers/vhost/vdpa.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index

[PATCH v9 07/17] virtio: Don't set FAILED status bit on device index allocation failure

2021-07-13 Thread Xie Yongji
We don't need to set FAILED status bit on device index allocation failure since the device initialization hasn't been started yet. Signed-off-by: Xie Yongji --- drivers/virtio/virtio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/virtio/virtio.c

[PATCH v9 05/17] vhost-vdpa: Fail the vhost_vdpa_set_status() on reset failure

2021-07-13 Thread Xie Yongji
Re-read the device status to ensure it's set to zero during resetting. Otherwise, fail the vhost_vdpa_set_status() after timeout. Signed-off-by: Xie Yongji --- drivers/vhost/vdpa.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/vdpa.c

[PATCH v9 04/17] vdpa: Fail the vdpa_reset() if fail to set device status to zero

2021-07-13 Thread Xie Yongji
Re-read the device status to ensure it's set to zero during resetting. Otherwise, fail the vdpa_reset() after timeout. Signed-off-by: Xie Yongji --- include/linux/vdpa.h | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/include/linux/vdpa.h

[PATCH v9 03/17] vdpa: Fix code indentation

2021-07-13 Thread Xie Yongji
Use tabs to indent the code instead of spaces. Signed-off-by: Xie Yongji --- include/linux/vdpa.h | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index 7c49bc5a2b71..f822490db584 100644 --- a/include/linux/vdpa.h +++

[PATCH v9 02/17] file: Export receive_fd() to modules

2021-07-13 Thread Xie Yongji
Export receive_fd() so that some modules can use it to pass file descriptor between processes without missing any security stuffs. Signed-off-by: Xie Yongji --- fs/file.c| 6 ++ include/linux/file.h | 7 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git

[PATCH v9 01/17] iova: Export alloc_iova_fast() and free_iova_fast()

2021-07-13 Thread Xie Yongji
Export alloc_iova_fast() and free_iova_fast() so that some modules can use it to improve iova allocation efficiency. Signed-off-by: Xie Yongji --- drivers/iommu/iova.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c index

[PATCH v9 00/17] Introduce VDUSE - vDPA Device in Userspace

2021-07-13 Thread Xie Yongji
This series introduces a framework that makes it possible to implement software-emulated vDPA devices in userspace. And to make the device emulation more secure, the emulated vDPA device's control path is handled in the kernel and only the data path is implemented in the userspace. Since the

Re: [PATCH] dt-bindings: arm-smmu: Fix json-schema syntax

2021-07-13 Thread Krzysztof Kozlowski
On Mon, 12 Jul 2021 at 16:14, Rob Herring wrote: > > On Tue, Jun 22, 2021 at 11:56 PM Krzysztof Kozlowski > wrote: > > > > On Mon, 21 Jun 2021 16:00:36 +0200, Thierry Reding wrote: > > > Commit 4287861dca9d ("dt-bindings: arm-smmu: Add Tegra186 compatible > > > string") introduced a jsonschema