Re: [PATCH v2 12/13] iommu/rockchip: Add runtime PM support

2018-01-16 Thread JeffyChen
Hi Tomasz, On 01/17/2018 03:38 PM, Tomasz Figa wrote: >>Don't we need to check here (and in _shutdown() too) if we have a >>domain attached? > >hmmm, right, the startup might been called by resume, so should check >iommu->domain here. > >but the shutdown would be called at the end of detach or

Re: [PATCH v2 11/13] iommu/rockchip: Use OF_IOMMU to attach devices automatically

2018-01-16 Thread JeffyChen
On 01/17/2018 03:30 PM, Tomasz Figa wrote: >but it's possible the probe failed after calling iommu_device_set_fwnode, so >i'll try to add some checks here, and maybe adjust probe() to prevent it >too. I think iommu_device_set_fwnode() is not enough for of_iommu_xlate() to find the IOMMU. The

Re: [PATCH v2 01/13] iommu/rockchip: Request irqs in rk_iommu_probe()

2018-01-16 Thread JeffyChen
Hi Tomasz, On 01/17/2018 03:16 PM, Tomasz Figa wrote: >> >>This lacks consistency. of_irq_count() is used for counting, but >>platform_get_irq() is used for getting. Either platform_ or of_ API >>should be used for both and I'd lean for platform_, since it's more >>general. > >hmmm, right, i

Re: [PATCH v2 12/13] iommu/rockchip: Add runtime PM support

2018-01-16 Thread JeffyChen
Hi Tomasz, Thanks for your reply. On 01/17/2018 02:20 PM, Tomasz Figa wrote: On Tue, Jan 16, 2018 at 10:25 PM, Jeffy Chen wrote: When the power domain is powered off, the IOMMU cannot be accessed and register programming must be deferred until the power domain

Re: [PATCH v2 11/13] iommu/rockchip: Use OF_IOMMU to attach devices automatically

2018-01-16 Thread JeffyChen
Hi Tomasz, Thanks for your reply. On 01/17/2018 01:44 PM, Tomasz Figa wrote: On Tue, Jan 16, 2018 at 10:25 PM, Jeffy Chen wrote: Converts the rockchip-iommu driver to use the OF_IOMMU infrastructure, which allows attaching master devices to their IOMMUs

Re: [PATCH v2 02/13] iommu/rockchip: Suppress unbinding

2018-01-16 Thread JeffyChen
Hi Tomasz, On 01/17/2018 01:32 PM, Tomasz Figa wrote: On Wed, Jan 17, 2018 at 1:23 PM, Tomasz Figa wrote: On Tue, Jan 16, 2018 at 10:25 PM, Jeffy Chen wrote: It's not safe to unbind rockchip IOMMU driver. Might be good to explain why it is

Re: [PATCH v2 05/13] iommu/rockchip: Fix error handling in init

2018-01-16 Thread JeffyChen
Hi Tomasz, On 01/17/2018 01:26 PM, Tomasz Figa wrote: On Tue, Jan 16, 2018 at 10:25 PM, Jeffy Chen wrote: It's hard to undo bus_set_iommu() in the error path, so move it to the end of rk_iommu_probe(). Does this work fine now? I remember we used to need this

Re: [PATCH v2 01/13] iommu/rockchip: Request irqs in rk_iommu_probe()

2018-01-16 Thread JeffyChen
Hi Tomasz, Thanks for your reply. On 01/17/2018 12:21 PM, Tomasz Figa wrote: Hi Jeffy, Thanks for the patch. Please see my comments inline. On Tue, Jan 16, 2018 at 10:25 PM, Jeffy Chen wrote: Please add patch description. ok, will do. Suggested-by: Robin

Re: [PATCH v2 12/13] iommu/rockchip: Add runtime PM support

2018-01-16 Thread Tomasz Figa
On Tue, Jan 16, 2018 at 10:25 PM, Jeffy Chen wrote: > When the power domain is powered off, the IOMMU cannot be accessed and > register programming must be deferred until the power domain becomes > enabled. > > Add runtime PM support, and use runtime PM device link from

Re: [PATCH v2 11/13] iommu/rockchip: Use OF_IOMMU to attach devices automatically

2018-01-16 Thread Tomasz Figa
On Tue, Jan 16, 2018 at 10:25 PM, Jeffy Chen wrote: > Converts the rockchip-iommu driver to use the OF_IOMMU infrastructure, > which allows attaching master devices to their IOMMUs automatically > according to DT properties. > > Signed-off-by: Jeffy Chen

Re: [PATCH v2 10/13] iommu/rockchip: Use IOMMU device for dma mapping operations

2018-01-16 Thread Tomasz Figa
On Tue, Jan 16, 2018 at 10:25 PM, Jeffy Chen wrote: > Use the first registered IOMMU device for dma mapping operations, and > drop the domain platform device. > > This is similar to exynos iommu driver. > > Signed-off-by: Jeffy Chen > --- > >

Re: [PATCH v2 02/13] iommu/rockchip: Suppress unbinding

2018-01-16 Thread Tomasz Figa
On Wed, Jan 17, 2018 at 1:23 PM, Tomasz Figa wrote: > On Tue, Jan 16, 2018 at 10:25 PM, Jeffy Chen > wrote: >> It's not safe to unbind rockchip IOMMU driver. > > Might be good to explain why it is not safe and actually add that it > does not make

Re: [PATCH v2 05/13] iommu/rockchip: Fix error handling in init

2018-01-16 Thread Tomasz Figa
On Tue, Jan 16, 2018 at 10:25 PM, Jeffy Chen wrote: > It's hard to undo bus_set_iommu() in the error path, so move it to the > end of rk_iommu_probe(). Does this work fine now? I remember we used to need this called in an early initcall for all the ARM/ARM64 DMA stuff

Re: [PATCH v2 04/13] iommu/rockchip: Fix error handling in probe

2018-01-16 Thread Tomasz Figa
On Tue, Jan 16, 2018 at 10:25 PM, Jeffy Chen wrote: > Add missing iommu_device_sysfs_remove in error path. > > Also adjust sequence of deinit functions in the remove. > > Signed-off-by: Jeffy Chen > --- > > Changes in v2: None > >

Re: [PATCH v2 02/13] iommu/rockchip: Suppress unbinding

2018-01-16 Thread Tomasz Figa
On Tue, Jan 16, 2018 at 10:25 PM, Jeffy Chen wrote: > It's not safe to unbind rockchip IOMMU driver. Might be good to explain why it is not safe and actually add that it does not make any sense for such low level devices. Best regards, Tomasz

Re: [PATCH v2 01/13] iommu/rockchip: Request irqs in rk_iommu_probe()

2018-01-16 Thread Tomasz Figa
Hi Jeffy, Thanks for the patch. Please see my comments inline. On Tue, Jan 16, 2018 at 10:25 PM, Jeffy Chen wrote: Please add patch description. > Suggested-by: Robin Murphy > Signed-off-by: Jeffy Chen > --- [snip]

Re: [RFC PATCH v2 2/5] iommu/virtio-iommu: Add probe request

2018-01-16 Thread Auger Eric
Hi Jean-Philippe, On 17/11/17 19:52, Jean-Philippe Brucker wrote: > When the device offers the probe feature, send a probe request for each > device managed by the IOMMU. Extract RESV_MEM information. When we > encounter a MSI doorbell region, set it up as a IOMMU_RESV_MSI region. > This will

Re: [RFC PATCH v2 3/5] iommu/virtio-iommu: Add event queue

2018-01-16 Thread Jean-Philippe Brucker
On 16/01/18 10:10, Auger Eric wrote: > Hi, > > On 17/11/17 19:52, Jean-Philippe Brucker wrote: >> The event queue offers a way for the device to report access faults from >> devices. > end points? Yes [...] >> +static void viommu_event_handler(struct virtqueue *vq) >> +{ >> +int ret; >> +

Re: [RFC PATCH v2 2/5] iommu/virtio-iommu: Add probe request

2018-01-16 Thread Jean-Philippe Brucker
On 16/01/18 09:25, Auger Eric wrote: [...] >> +static int viommu_add_resv_mem(struct viommu_endpoint *vdev, >> + struct virtio_iommu_probe_resv_mem *mem, >> + size_t len) >> +{ >> +struct iommu_resv_region *region = NULL; >> +unsigned

Re: [RFC PATCH v2 1/5] iommu: Add virtio-iommu driver

2018-01-16 Thread Jean-Philippe Brucker
On 15/01/18 15:12, Auger Eric wrote: [...] >> +/* >> + * viommu_get_req_size - compute request size >> + * >> + * A virtio-iommu request is split into one device-read-only part (top) and >> one >> + * device-write-only part (bottom). Given a request, return the sizes of >> the two >> + * parts

[PATCH v2 12/13] iommu/rockchip: Add runtime PM support

2018-01-16 Thread Jeffy Chen
When the power domain is powered off, the IOMMU cannot be accessed and register programming must be deferred until the power domain becomes enabled. Add runtime PM support, and use runtime PM device link from IOMMU to master to startup and shutdown IOMMU. Signed-off-by: Jeffy Chen

[PATCH v2 13/13] iommu/rockchip: Support sharing IOMMU between masters

2018-01-16 Thread Jeffy Chen
There would be some masters sharing the same IOMMU device. Put them in the same iommu group and share the same iommu domain. Signed-off-by: Jeffy Chen --- Changes in v2: None drivers/iommu/rockchip-iommu.c | 39 +++ 1 file

[PATCH v2 08/13] iommu/rockchip: Control clocks needed to access the IOMMU

2018-01-16 Thread Jeffy Chen
From: Tomasz Figa Current code relies on master driver enabling necessary clocks before IOMMU is accessed, however there are cases when the IOMMU should be accessed while the master is not running yet, for example allocating V4L2 videobuf2 buffers, which is done by the VB2

[PATCH v2 11/13] iommu/rockchip: Use OF_IOMMU to attach devices automatically

2018-01-16 Thread Jeffy Chen
Converts the rockchip-iommu driver to use the OF_IOMMU infrastructure, which allows attaching master devices to their IOMMUs automatically according to DT properties. Signed-off-by: Jeffy Chen --- Changes in v2: None drivers/iommu/rockchip-iommu.c | 116

[PATCH v2 10/13] iommu/rockchip: Use IOMMU device for dma mapping operations

2018-01-16 Thread Jeffy Chen
Use the first registered IOMMU device for dma mapping operations, and drop the domain platform device. This is similar to exynos iommu driver. Signed-off-by: Jeffy Chen --- Changes in v2: None drivers/iommu/rockchip-iommu.c | 91

[PATCH v2 09/13] iommu/rockchip: Use iommu_group_get_for_dev() for add_device

2018-01-16 Thread Jeffy Chen
IOMMU drivers are supposed to call this function instead of manually creating a group in their .add_device callback. This behavior is not strictly required by ARM DMA mapping implementation, but ARM64 already relies on it. This patch fixes the rockchip-iommu driver to comply with this requirement.

[PATCH v2 05/13] iommu/rockchip: Fix error handling in init

2018-01-16 Thread Jeffy Chen
It's hard to undo bus_set_iommu() in the error path, so move it to the end of rk_iommu_probe(). Signed-off-by: Jeffy Chen --- Changes in v2: Move bus_set_iommu() to rk_iommu_probe(). drivers/iommu/rockchip-iommu.c | 20 +++- 1 file changed, 7

[PATCH v2 07/13] iommu/rockchip: Fix TLB flush of secondary IOMMUs

2018-01-16 Thread Jeffy Chen
From: Tomasz Figa Due to the bug in current code, only first IOMMU has the TLB lines flushed in rk_iommu_zap_lines. This patch fixes the inner loop to execute for all IOMMUs and properly flush the TLB. Signed-off-by: Tomasz Figa Signed-off-by: Jeffy Chen

[PATCH v2 01/13] iommu/rockchip: Request irqs in rk_iommu_probe()

2018-01-16 Thread Jeffy Chen
Suggested-by: Robin Murphy Signed-off-by: Jeffy Chen --- Changes in v2: None drivers/iommu/rockchip-iommu.c | 38 +++--- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git

[PATCH v2 04/13] iommu/rockchip: Fix error handling in probe

2018-01-16 Thread Jeffy Chen
Add missing iommu_device_sysfs_remove in error path. Also adjust sequence of deinit functions in the remove. Signed-off-by: Jeffy Chen --- Changes in v2: None drivers/iommu/rockchip-iommu.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff

[PATCH v2 02/13] iommu/rockchip: Suppress unbinding

2018-01-16 Thread Jeffy Chen
It's not safe to unbind rockchip IOMMU driver. Signed-off-by: Jeffy Chen --- Changes in v2: None drivers/iommu/rockchip-iommu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index

[PATCH v2 03/13] iommu/rockchip: Fix error handling in attach

2018-01-16 Thread Jeffy Chen
From: Tomasz Figa Currently if the driver encounters an error while attaching device, it will leave the IOMMU in an inconsistent state. Even though it shouldn't really happen in reality, let's just add proper error path to keep things consistent. Signed-off-by: Tomasz Figa

Re: [RFC PATCH v2 2/5] iommu/virtio-iommu: Add probe request

2018-01-16 Thread Auger Eric
Hi Jean-Philippe, On 17/11/17 19:52, Jean-Philippe Brucker wrote: > When the device offers the probe feature, send a probe request for each > device managed by the IOMMU. Extract RESV_MEM information. When we > encounter a MSI doorbell region, set it up as a IOMMU_RESV_MSI region. > This will

Re: consolidate swiotlb dma_map implementations

2018-01-16 Thread Christian König
Am 16.01.2018 um 09:28 schrieb Christoph Hellwig: On Tue, Jan 16, 2018 at 09:22:52AM +0100, Christian König wrote: Hi Konrad, can you send the first patch to Linus for inclusion in 4.15 if you haven't already done so? It's in the 4.16 queue with a cc to stable. I guess we're ok with a

Re: consolidate swiotlb dma_map implementations

2018-01-16 Thread Christoph Hellwig
On Tue, Jan 16, 2018 at 09:22:52AM +0100, Christian König wrote: > Hi Konrad, > > can you send the first patch to Linus for inclusion in 4.15 if you haven't > already done so? It's in the 4.16 queue with a cc to stable. I guess we're ok with a duplicate commit if we have to.

Re: consolidate swiotlb dma_map implementations

2018-01-16 Thread Christian König
Hi Konrad, can you send the first patch to Linus for inclusion in 4.15 if you haven't already done so? I'm still getting reports from people complaining about the error message. Thanks, Christian. Am 16.01.2018 um 08:53 schrieb Christoph Hellwig: I've pulled this into the dma-mapping