RE: [PATCH RFC 1/4] iommu/vt-d: Modify device_def_domain_type() to use at runtime

2019-07-25 Thread Prakhya, Sai Praneeth
> On Tue, Jul 02, 2019 at 06:53:59PM -0700, Sai Praneeth Prakhya wrote: > > device_def_domain_type() determines the domain type a device could > > have and it's called only during boot. But, to change the domain of a > > group through sysfs, kernel has to call this function during runtime. > > Henc

RE: [PATCH RFC 0/4] iommu: Add support to change default domain of a group

2019-07-25 Thread Prakhya, Sai Praneeth
> On Tue, Jul 02, 2019 at 06:53:58PM -0700, Sai Praneeth Prakhya wrote: > > Assume a use case where-in the priviliged user would want to use the > > device in pass-through mode when the device is used for host but would > > want to switch to dma protected mode when switching for VFIO in user > > sp

Re: [PATCH 2/2] dma-contiguous: page-align the size in dma_free_contiguous()

2019-07-25 Thread Christoph Hellwig
On Thu, Jul 25, 2019 at 04:39:59PM -0700, Nicolin Chen wrote: > According to the original dma_direct_alloc_pages() code: > { > unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT; > > if (!dma_release_from_contiguous(dev, page, count)) > __free_pages(page, get_order(size)

Re: [PATCH 1/2] dma-contiguous: do not overwrite align in dma_alloc_contiguous()

2019-07-25 Thread Christoph Hellwig
On Thu, Jul 25, 2019 at 04:39:58PM -0700, Nicolin Chen wrote: > The dma_alloc_contiguous() limits align at CONFIG_CMA_ALIGNMENT for > cma_alloc() however it does not restore it for the fallback routine. > This will result in a size mismatch between the allocation and free > when running in the fall

Re: [RFC,v3 6/9] media: platform: Add Mediatek ISP P1 V4L2 functions

2019-07-25 Thread Tomasz Figa
On Wed, Jul 24, 2019 at 1:31 PM Jungo Lin wrote: > > Hi, Tomasz: > > On Tue, 2019-07-23 at 19:21 +0900, Tomasz Figa wrote: > > Hi Jungo, > > > > On Thu, Jul 18, 2019 at 1:39 PM Jungo Lin wrote: > > > > > > Hi, Tomasz: > > > > > > On Wed, 2019-07-10 at 18:54 +0900, Tomasz Figa wrote: > > > > Hi Ju

Re: [RFC, v3 9/9] media: platform: Add Mediatek ISP P1 shared memory device

2019-07-25 Thread Tomasz Figa
On Tue, Jul 23, 2019 at 5:22 PM Jungo Lin wrote: > > Hi, Tomasz: > > On Tue, 2019-07-23 at 16:20 +0900, Tomasz Figa wrote: > > Hi Jungo, > > > > On Fri, Jul 5, 2019 at 4:59 PM Jungo Lin wrote: > > > > > > Hi Tomasz: > > > > > > On Fri, 2019-07-05 at 13:22 +0900, Tomasz Figa wrote: > > > > Hi Jung

Re: [PATCH v5 09/10] iommu/vt-d: Add trace events for device dma map/unmap

2019-07-25 Thread Lu Baolu
Hi, On 7/25/19 8:26 PM, Steven Rostedt wrote: On Thu, 25 Jul 2019 11:17:16 +0800 Lu Baolu wrote: This adds trace support for the Intel IOMMU driver. It also declares some events which could be used to trace the events when an IOVA is being mapped or unmapped in a domain. Cc: Ashok Raj Cc: J

Re: [PATCH v5 06/10] swiotlb: Zero out bounce buffer for untrusted device

2019-07-25 Thread Lu Baolu
Hi, On 7/25/19 7:49 PM, Christoph Hellwig wrote: index 43c88626a1f3..edc84a00b9f9 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -35,6 +35,7 @@ #include #include #include +#include #ifdef CONFIG_DEBUG_FS #include #endif @@ -562,6 +563,11 @@ phys_addr_t swiotlb_t

Re: [PATCH v5 02/10] iommu/vt-d: Use per-device dma_ops

2019-07-25 Thread Lu Baolu
Hi, On 7/25/19 7:43 PM, Christoph Hellwig wrote: On Thu, Jul 25, 2019 at 03:18:03PM +0800, Lu Baolu wrote: Don't we need to keep this bit so that we still allow the IOMMU to act if the device has a too small DMA mask to address all memory in the system, even if if it should otherwise be identit

Re: [PATCH v3 1/2] dma-contiguous: Abstract dma_{alloc,free}_contiguous()

2019-07-25 Thread Nicolin Chen
On Thu, Jul 25, 2019 at 07:31:05PM +0200, Dafna Hirschfeld wrote: > On Thu, 2019-07-25 at 09:50 -0700, Nicolin Chen wrote: > > On Thu, Jul 25, 2019 at 01:06:42PM -0300, Ezequiel Garcia wrote: > > > I can't find a way to forward-redirect from Gmail, so I'm Ccing Dafna > > > who found a regression ca

[PATCH 2/2] dma-contiguous: page-align the size in dma_free_contiguous()

2019-07-25 Thread Nicolin Chen
According to the original dma_direct_alloc_pages() code: { unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT; if (!dma_release_from_contiguous(dev, page, count)) __free_pages(page, get_order(size)); } The count parameter for dma_release_from_contiguous() was page

[PATCH 0/2] dma-contiguous: two bug fixes for dma_{alloc, free}_contiguous()

2019-07-25 Thread Nicolin Chen
There are two obvious bugs in these two functions. So having two patches to fix them. Nicolin Chen (2): dma-contiguous: do not overwrite align in dma_alloc_contiguous() dma-contiguous: page-align the size in dma_free_contiguous() kernel/dma/contiguous.c | 12 +++- 1 file changed, 7 i

[PATCH 1/2] dma-contiguous: do not overwrite align in dma_alloc_contiguous()

2019-07-25 Thread Nicolin Chen
The dma_alloc_contiguous() limits align at CONFIG_CMA_ALIGNMENT for cma_alloc() however it does not restore it for the fallback routine. This will result in a size mismatch between the allocation and free when running in the fallback routines, if the align is larger than CONFIG_CMA_ALIGNMENT. This

Possible bug in intel_iommu_iova_to_phys() in drivers/iommu/intel-iommu.c

2019-07-25 Thread Yonghyun Hwang via iommu
Hello, It seems that intel_iommu_iova_to_phys() doesn't return a correct physical address for a given iova. This is the latest kernel code for the function. static phys_addr_t intel_iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova) {

Re: cma_remap when using dma_alloc_attr :- DMA_ATTR_NO_KERNEL_MAPPING

2019-07-25 Thread Pankaj Suryawanshi
On Tue, Jul 16, 2019 at 5:40 PM Christoph Hellwig wrote: > > On Tue, Jul 16, 2019 at 01:02:19PM +0100, Robin Murphy wrote: > >> Lets say 4k video allocation required 300MB cma memory but not required > >> virtual mapping for all the 300MB, its require only 20MB virtually mapped > >> at some specif

Re: [PATCH] iommu/dma: Fix calculation overflow in __finalise_sg()

2019-07-25 Thread Nicolin Chen
Sorry to ping this but it's been a while. Robin, did you get a chance to resend your version? Thanks Nicolin On Tue, Jul 02, 2019 at 02:04:01PM -0700, Nicolin Chen wrote: > On Tue, Jul 02, 2019 at 11:40:02AM +0100, Robin Murphy wrote: > > On reflection, I don't really think that size_t fits here

Re: [PATCH v3 1/2] dma-contiguous: Abstract dma_{alloc,free}_contiguous()

2019-07-25 Thread Dafna Hirschfeld
On Thu, 2019-07-25 at 09:50 -0700, Nicolin Chen wrote: > On Thu, Jul 25, 2019 at 01:06:42PM -0300, Ezequiel Garcia wrote: > > I can't find a way to forward-redirect from Gmail, so I'm Ccing Dafna > > who found a regression caused by this commit. Dafna, can you give all > > the details, including th

Re: [PATCH v3 1/2] dma-contiguous: Abstract dma_{alloc,free}_contiguous()

2019-07-25 Thread Nicolin Chen
On Thu, Jul 25, 2019 at 01:06:42PM -0300, Ezequiel Garcia wrote: > I can't find a way to forward-redirect from Gmail, so I'm Ccing Dafna > who found a regression caused by this commit. Dafna, can you give all > the details, including the log and how you are reproducing it? I saw the conversation t

Re: [PATCH 2/2] virtio/virtio_ring: Fix the dma_max_mapping_size call

2019-07-25 Thread Auger Eric
Hi Christoph, Michael, On 7/25/19 3:04 PM, Christoph Hellwig wrote: > On Thu, Jul 25, 2019 at 01:53:49PM +0200, Auger Eric wrote: >> I am confused: if vring_use_dma_api() returns false if the dma_mask is >> unset (ie. vring_use_dma_api() returns false), the virtio-blk-pci device >> will not be abl

Re: [PATCH v3 1/2] dma-contiguous: Abstract dma_{alloc,free}_contiguous()

2019-07-25 Thread Ezequiel Garcia
I can't find a way to forward-redirect from Gmail, so I'm Ccing Dafna who found a regression caused by this commit. Dafna, can you give all the details, including the log and how you are reproducing it? On Fri, 24 May 2019 at 01:08, Nicolin Chen wrote: > > Both dma_alloc_from_contiguous() and dm

Re: [PATCH 2/2] virtio/virtio_ring: Fix the dma_max_mapping_size call

2019-07-25 Thread Christoph Hellwig
On Thu, Jul 25, 2019 at 01:53:49PM +0200, Auger Eric wrote: > I am confused: if vring_use_dma_api() returns false if the dma_mask is > unset (ie. vring_use_dma_api() returns false), the virtio-blk-pci device > will not be able to get translated addresses and won't work properly. > > The patch abov

Re: [PATCH v5 09/10] iommu/vt-d: Add trace events for device dma map/unmap

2019-07-25 Thread Steven Rostedt
On Thu, 25 Jul 2019 11:17:16 +0800 Lu Baolu wrote: > This adds trace support for the Intel IOMMU driver. It > also declares some events which could be used to trace > the events when an IOVA is being mapped or unmapped in > a domain. > > Cc: Ashok Raj > Cc: Jacob Pan > Cc: Kevin Tian > Signed

Re: [PATCH 2/2] virtio/virtio_ring: Fix the dma_max_mapping_size call

2019-07-25 Thread Auger Eric
Hi, On 7/23/19 5:38 PM, Christoph Hellwig wrote: > On Mon, Jul 22, 2019 at 04:36:09PM +0100, Robin Murphy wrote: >>> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c >>> index c8be1c4f5b55..37c143971211 100644 >>> --- a/drivers/virtio/virtio_ring.c >>> +++ b/drivers/virtio/

Re: [PATCH v5 06/10] swiotlb: Zero out bounce buffer for untrusted device

2019-07-25 Thread Christoph Hellwig
> index 43c88626a1f3..edc84a00b9f9 100644 > --- a/kernel/dma/swiotlb.c > +++ b/kernel/dma/swiotlb.c > @@ -35,6 +35,7 @@ > #include > #include > #include > +#include > #ifdef CONFIG_DEBUG_FS > #include > #endif > @@ -562,6 +563,11 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev

Re: [PATCH v5 05/10] swiotlb: Split size parameter to map/unmap APIs

2019-07-25 Thread Christoph Hellwig
On Thu, Jul 25, 2019 at 11:17:12AM +0800, Lu Baolu wrote: > This splits the size parameter to swiotlb_tbl_map_single() and > swiotlb_tbl_unmap_single() into an alloc_size and a mapping_size > parameter, where the latter one is rounded up to the iommu page > size. > > Suggested-by: Christoph Hellwi

Re: [PATCH v5 02/10] iommu/vt-d: Use per-device dma_ops

2019-07-25 Thread Christoph Hellwig
On Thu, Jul 25, 2019 at 03:18:03PM +0800, Lu Baolu wrote: >> Don't we need to keep this bit so that we still allow the IOMMU >> to act if the device has a too small DMA mask to address all memory in >> the system, even if if it should otherwise be identity mapped? >> > > This checking happens only

Re: [RFC PATCH v2 18/19] iommu/arm-smmu-v3: Reduce contention during command-queue insertion

2019-07-25 Thread John Garry
Hi Will, + old = cmpxchg_relaxed(&cmdq->q.llq.val, llq.val, head.val); I added some basic debug to the stress test on your branch, and this cmpxchg was failing ~10 times on average on my D06. So we're not using the spinlock now, but this cmpxchg may lack fairness. It definitel

Re: [RFC,v3 8/9] media: platform: Add Mediatek ISP P1 SCP communication

2019-07-25 Thread Tomasz Figa
Hi Jungo, On Sun, Jul 21, 2019 at 11:18 AM Jungo Lin wrote: [snip] > > > + wake_up_interruptible(&isp_ctx->composer_tx_thread.wq); > > > + isp_ctx->composer_tx_thread.thread = NULL; > > > + } > > > + > > > + if (isp_ctx->composer_deinit_thread.thread) { > > > + w

Re: [RFC PATCH v2 00/19] Try to reduce lock contention on the SMMUv3 command queue

2019-07-25 Thread John Garry
On 24/07/2019 15:48, Will Deacon wrote: On Wed, Jul 24, 2019 at 03:25:07PM +0100, John Garry wrote: On 24/07/2019 13:20, Will Deacon wrote: On Wed, Jul 24, 2019 at 10:58:26AM +0100, John Garry wrote: On 11/07/2019 18:19, Will Deacon wrote: This is a significant rework of the RFC I previously

Re: [RFC,v3 7/9] media: platform: Add Mediatek ISP P1 device driver

2019-07-25 Thread Tomasz Figa
.Hi Jungo, On Sat, Jul 20, 2019 at 6:58 PM Jungo Lin wrote: > > Hi, Tomasz: > > On Wed, 2019-07-10 at 18:56 +0900, Tomasz Figa wrote: > > Hi Jungo, > > > > On Tue, Jun 11, 2019 at 11:53:42AM +0800, Jungo Lin wrote: > > > This patch adds the Mediatek ISP P1 HW control device driver. > > > It handl

Re: [RFC PATCH v2 04/19] iommu: Introduce struct iommu_iotlb_gather for batching TLB flushes

2019-07-25 Thread Joerg Roedel
Hi Will, On Wed, Jul 24, 2019 at 08:41:30AM +0100, Will Deacon wrote: > There aren't tonnes of (direct) users of the iommu-api, and the additional > complexity introduced by the 'struct iotlb_gather' only applies to users of > iommu_unmap_fast(), which I think is a reasonable trade-off in return f

Re: [PATCH] media: staging: tegra-vde: Fix build error

2019-07-25 Thread Dmitry Osipenko
25.07.2019 5:41, YueHaibing пишет: > If IOMMU_SUPPORT is not set, and COMPILE_TEST is y, > IOMMU_IOVA may be set to m. So building will fails: > > drivers/staging/media/tegra-vde/iommu.o: In function `tegra_vde_iommu_map': > iommu.c:(.text+0x41): undefined reference to `alloc_iova' > iommu.c:(.tex

Re: [PATCH v5 02/10] iommu/vt-d: Use per-device dma_ops

2019-07-25 Thread Lu Baolu
Hi Christoph, On 7/25/19 1:44 PM, Christoph Hellwig wrote: /* Check if the dev needs to go through non-identity map and unmap process.*/ static bool iommu_need_mapping(struct device *dev) { - int ret; - if (iommu_dummy(dev)) return false; - ret = identity_m