* [PATCH V2 1/3] Docs: dt: rockchip: add rk-iommu,disable-reset-quirk property @ 2017-07-21 6:27 Simon Xue 2017-07-21 6:27 ` [PATCH V2 2/3] iommu/rockchip: add multi irqs support Simon Xue ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Simon Xue @ 2017-07-21 6:27 UTC (permalink / raw) To: Joerg Roedel, Heiko Stuebner; +Cc: linux-rockchip, iommu, linux-kernel, Simon From: Simon <xxm@rock-chips.com> Add rk-iommu,disable-reset-quirk property to ignore the isp mmu reset operation Signed-off-by: Simon <xxm@rock-chips.com> --- changes since V1: - new added file Documentation/devicetree/bindings/iommu/rockchip,iommu.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/iommu/rockchip,iommu.txt b/Documentation/devicetree/bindings/iommu/rockchip,iommu.txt index 9a55ac3..aa2136c 100644 --- a/Documentation/devicetree/bindings/iommu/rockchip,iommu.txt +++ b/Documentation/devicetree/bindings/iommu/rockchip,iommu.txt @@ -15,6 +15,11 @@ Required properties: to associate with its master device. See: Documentation/devicetree/bindings/iommu/iommu.txt +Optional properties: +- rk-iommu,disable-reset-quirk : This ignore the isp mmu reset operation. + It can't get the expected result when isp mmu + reset, but the reset function work normally + Example: vopl_mmu: iommu@ff940300 { -- 1.9.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH V2 2/3] iommu/rockchip: add multi irqs support 2017-07-21 6:27 [PATCH V2 1/3] Docs: dt: rockchip: add rk-iommu,disable-reset-quirk property Simon Xue @ 2017-07-21 6:27 ` Simon Xue 2017-07-21 7:07 ` Heiko Stuebner 2017-07-21 6:27 ` [PATCH V2 3/3] iommu/rockchip: ignore isp mmu reset operation Simon Xue 2017-07-21 6:57 ` [PATCH V2 1/3] Docs: dt: rockchip: add rk-iommu,disable-reset-quirk property Heiko Stuebner 2 siblings, 1 reply; 7+ messages in thread From: Simon Xue @ 2017-07-21 6:27 UTC (permalink / raw) To: Joerg Roedel, Heiko Stuebner; +Cc: linux-rockchip, iommu, linux-kernel, Simon From: Simon <xxm@rock-chips.com> RK3368 vpu mmu have two irqs, this patch support multi irqs Signed-off-by: Simon <xxm@rock-chips.com> --- changes since V1: - use devm_kcalloc instead of devm_kzalloc when alloc irq array drivers/iommu/rockchip-iommu.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 4ba48a2..3c462c0 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -90,7 +90,8 @@ struct rk_iommu { struct device *dev; void __iomem **bases; int num_mmu; - int irq; + int *irq; + int num_irq; struct iommu_device iommu; struct list_head node; /* entry in rk_iommu_domain.iommus */ struct iommu_domain *domain; /* domain to which iommu is attached */ @@ -825,10 +826,12 @@ static int rk_iommu_attach_device(struct iommu_domain *domain, iommu->domain = domain; - ret = devm_request_irq(iommu->dev, iommu->irq, rk_iommu_irq, - IRQF_SHARED, dev_name(dev), iommu); - if (ret) - return ret; + for (i = 0; i < iommu->num_irq; i++) { + ret = devm_request_irq(iommu->dev, iommu->irq[i], rk_iommu_irq, + IRQF_SHARED, dev_name(dev), iommu); + if (ret) + return ret; + } for (i = 0; i < iommu->num_mmu; i++) { rk_iommu_write(iommu->bases[i], RK_MMU_DTE_ADDR, @@ -878,7 +881,8 @@ static void rk_iommu_detach_device(struct iommu_domain *domain, } rk_iommu_disable_stall(iommu); - devm_free_irq(iommu->dev, iommu->irq, iommu); + for (i = 0; i < iommu->num_irq; i++) + devm_free_irq(iommu->dev, iommu->irq[i], iommu); iommu->domain = NULL; @@ -1157,10 +1161,20 @@ static int rk_iommu_probe(struct platform_device *pdev) if (iommu->num_mmu == 0) return PTR_ERR(iommu->bases[0]); - iommu->irq = platform_get_irq(pdev, 0); - if (iommu->irq < 0) { - dev_err(dev, "Failed to get IRQ, %d\n", iommu->irq); - return -ENXIO; + while (platform_get_irq(pdev, iommu->num_irq) >= 0) + iommu->num_irq++; + + iommu->irq = devm_kcalloc(dev, iommu->num_irq, sizeof(*iommu->irq), + GFP_KERNEL); + if (!iommu->irq) + return -ENOMEM; + + for (i = 0; i < iommu->num_irq; i++) { + iommu->irq[i] = platform_get_irq(pdev, i); + if (iommu->irq[i] < 0) { + dev_err(dev, "Failed to get IRQ, %d\n", iommu->irq[i]); + return -ENXIO; + } } err = iommu_device_sysfs_add(&iommu->iommu, dev, NULL, dev_name(dev)); -- 1.9.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH V2 2/3] iommu/rockchip: add multi irqs support 2017-07-21 6:27 ` [PATCH V2 2/3] iommu/rockchip: add multi irqs support Simon Xue @ 2017-07-21 7:07 ` Heiko Stuebner 2017-07-21 7:54 ` xxm 0 siblings, 1 reply; 7+ messages in thread From: Heiko Stuebner @ 2017-07-21 7:07 UTC (permalink / raw) To: Simon Xue; +Cc: Joerg Roedel, linux-rockchip, iommu, linux-kernel Am Freitag, 21. Juli 2017, 14:27:09 CEST schrieb Simon Xue: > From: Simon <xxm@rock-chips.com> > > RK3368 vpu mmu have two irqs, this patch support multi irqs > > Signed-off-by: Simon <xxm@rock-chips.com> > --- > changes since V1: > - use devm_kcalloc instead of devm_kzalloc when alloc irq array > > drivers/iommu/rockchip-iommu.c | 34 ++++++++++++++++++++++++---------- > 1 file changed, 24 insertions(+), 10 deletions(-) > > diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c > index 4ba48a2..3c462c0 100644 > --- a/drivers/iommu/rockchip-iommu.c > +++ b/drivers/iommu/rockchip-iommu.c > @@ -90,7 +90,8 @@ struct rk_iommu { > struct device *dev; > void __iomem **bases; > int num_mmu; > - int irq; > + int *irq; > + int num_irq; > struct iommu_device iommu; > struct list_head node; /* entry in rk_iommu_domain.iommus */ > struct iommu_domain *domain; /* domain to which iommu is attached */ > @@ -825,10 +826,12 @@ static int rk_iommu_attach_device(struct iommu_domain *domain, > > iommu->domain = domain; > > - ret = devm_request_irq(iommu->dev, iommu->irq, rk_iommu_irq, > - IRQF_SHARED, dev_name(dev), iommu); > - if (ret) > - return ret; > + for (i = 0; i < iommu->num_irq; i++) { > + ret = devm_request_irq(iommu->dev, iommu->irq[i], rk_iommu_irq, > + IRQF_SHARED, dev_name(dev), iommu); > + if (ret) > + return ret; > + } > > for (i = 0; i < iommu->num_mmu; i++) { > rk_iommu_write(iommu->bases[i], RK_MMU_DTE_ADDR, > @@ -878,7 +881,8 @@ static void rk_iommu_detach_device(struct iommu_domain *domain, > } > rk_iommu_disable_stall(iommu); > > - devm_free_irq(iommu->dev, iommu->irq, iommu); > + for (i = 0; i < iommu->num_irq; i++) > + devm_free_irq(iommu->dev, iommu->irq[i], iommu); > > iommu->domain = NULL; > > @@ -1157,10 +1161,20 @@ static int rk_iommu_probe(struct platform_device *pdev) > if (iommu->num_mmu == 0) > return PTR_ERR(iommu->bases[0]); > > - iommu->irq = platform_get_irq(pdev, 0); > - if (iommu->irq < 0) { > - dev_err(dev, "Failed to get IRQ, %d\n", iommu->irq); > - return -ENXIO; > + while (platform_get_irq(pdev, iommu->num_irq) >= 0) > + iommu->num_irq++; Hmm, this could also result in a iommu having 0 irqs if wrongly configured and probe would still suceed. This sounds somehow wrong to me. But I'm not sure if there is precedent on how to handle a variable number of interrupts correctly somewhere. Heiko > + > + iommu->irq = devm_kcalloc(dev, iommu->num_irq, sizeof(*iommu->irq), > + GFP_KERNEL); > + if (!iommu->irq) > + return -ENOMEM; > + > + for (i = 0; i < iommu->num_irq; i++) { > + iommu->irq[i] = platform_get_irq(pdev, i); > + if (iommu->irq[i] < 0) { > + dev_err(dev, "Failed to get IRQ, %d\n", iommu->irq[i]); > + return -ENXIO; > + } > } > > err = iommu_device_sysfs_add(&iommu->iommu, dev, NULL, dev_name(dev)); > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V2 2/3] iommu/rockchip: add multi irqs support 2017-07-21 7:07 ` Heiko Stuebner @ 2017-07-21 7:54 ` xxm 2017-07-21 18:37 ` Heiko Stuebner 0 siblings, 1 reply; 7+ messages in thread From: xxm @ 2017-07-21 7:54 UTC (permalink / raw) To: Heiko Stuebner; +Cc: Joerg Roedel, linux-rockchip, iommu, linux-kernel Hi Heiko, On 07/21/2017 03:07 PM, Heiko Stuebner wrote: > Am Freitag, 21. Juli 2017, 14:27:09 CEST schrieb Simon Xue: >> From: Simon <xxm@rock-chips.com> >> >> RK3368 vpu mmu have two irqs, this patch support multi irqs >> >> Signed-off-by: Simon <xxm@rock-chips.com> >> --- >> changes since V1: >> - use devm_kcalloc instead of devm_kzalloc when alloc irq array >> >> drivers/iommu/rockchip-iommu.c | 34 ++++++++++++++++++++++++---------- >> 1 file changed, 24 insertions(+), 10 deletions(-) >> >> diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c >> index 4ba48a2..3c462c0 100644 >> --- a/drivers/iommu/rockchip-iommu.c >> +++ b/drivers/iommu/rockchip-iommu.c >> @@ -90,7 +90,8 @@ struct rk_iommu { >> struct device *dev; >> void __iomem **bases; >> int num_mmu; >> - int irq; >> + int *irq; >> + int num_irq; >> struct iommu_device iommu; >> struct list_head node; /* entry in rk_iommu_domain.iommus */ >> struct iommu_domain *domain; /* domain to which iommu is attached */ >> @@ -825,10 +826,12 @@ static int rk_iommu_attach_device(struct iommu_domain *domain, >> >> iommu->domain = domain; >> >> - ret = devm_request_irq(iommu->dev, iommu->irq, rk_iommu_irq, >> - IRQF_SHARED, dev_name(dev), iommu); >> - if (ret) >> - return ret; >> + for (i = 0; i < iommu->num_irq; i++) { >> + ret = devm_request_irq(iommu->dev, iommu->irq[i], rk_iommu_irq, >> + IRQF_SHARED, dev_name(dev), iommu); >> + if (ret) >> + return ret; >> + } >> >> for (i = 0; i < iommu->num_mmu; i++) { >> rk_iommu_write(iommu->bases[i], RK_MMU_DTE_ADDR, >> @@ -878,7 +881,8 @@ static void rk_iommu_detach_device(struct iommu_domain *domain, >> } >> rk_iommu_disable_stall(iommu); >> >> - devm_free_irq(iommu->dev, iommu->irq, iommu); >> + for (i = 0; i < iommu->num_irq; i++) >> + devm_free_irq(iommu->dev, iommu->irq[i], iommu); >> >> iommu->domain = NULL; >> >> @@ -1157,10 +1161,20 @@ static int rk_iommu_probe(struct platform_device *pdev) >> if (iommu->num_mmu == 0) >> return PTR_ERR(iommu->bases[0]); >> >> - iommu->irq = platform_get_irq(pdev, 0); >> - if (iommu->irq < 0) { >> - dev_err(dev, "Failed to get IRQ, %d\n", iommu->irq); >> - return -ENXIO; >> + while (platform_get_irq(pdev, iommu->num_irq) >= 0) >> + iommu->num_irq++; > Hmm, this could also result in a iommu having 0 irqs if wrongly > configured and probe would still suceed. This sounds somehow > wrong to me. > > But I'm not sure if there is precedent on how to handle a variable > number of interrupts correctly somewhere. How about add a judgement for iommu->num_irq ? like this: if (!iommu->num_irq) return -ENOXIO; > > Heiko > >> + >> + iommu->irq = devm_kcalloc(dev, iommu->num_irq, sizeof(*iommu->irq), >> + GFP_KERNEL); >> + if (!iommu->irq) >> + return -ENOMEM; >> + >> + for (i = 0; i < iommu->num_irq; i++) { >> + iommu->irq[i] = platform_get_irq(pdev, i); >> + if (iommu->irq[i] < 0) { >> + dev_err(dev, "Failed to get IRQ, %d\n", iommu->irq[i]); >> + return -ENXIO; >> + } >> } >> >> err = iommu_device_sysfs_add(&iommu->iommu, dev, NULL, dev_name(dev)); >> > > > > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V2 2/3] iommu/rockchip: add multi irqs support 2017-07-21 7:54 ` xxm @ 2017-07-21 18:37 ` Heiko Stuebner 0 siblings, 0 replies; 7+ messages in thread From: Heiko Stuebner @ 2017-07-21 18:37 UTC (permalink / raw) To: xxm; +Cc: Joerg Roedel, linux-rockchip, iommu, linux-kernel Am Freitag, 21. Juli 2017, 15:54:40 CEST schrieb xxm: > Hi Heiko, > > > On 07/21/2017 03:07 PM, Heiko Stuebner wrote: > > Am Freitag, 21. Juli 2017, 14:27:09 CEST schrieb Simon Xue: > >> From: Simon <xxm@rock-chips.com> > >> > >> RK3368 vpu mmu have two irqs, this patch support multi irqs > >> > >> Signed-off-by: Simon <xxm@rock-chips.com> > >> --- > >> changes since V1: > >> - use devm_kcalloc instead of devm_kzalloc when alloc irq array > >> > >> drivers/iommu/rockchip-iommu.c | 34 ++++++++++++++++++++++++---------- > >> 1 file changed, 24 insertions(+), 10 deletions(-) > >> > >> diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c > >> index 4ba48a2..3c462c0 100644 > >> --- a/drivers/iommu/rockchip-iommu.c > >> +++ b/drivers/iommu/rockchip-iommu.c > >> @@ -90,7 +90,8 @@ struct rk_iommu { > >> struct device *dev; > >> void __iomem **bases; > >> int num_mmu; > >> - int irq; > >> + int *irq; > >> + int num_irq; > >> struct iommu_device iommu; > >> struct list_head node; /* entry in rk_iommu_domain.iommus */ > >> struct iommu_domain *domain; /* domain to which iommu is attached */ > >> @@ -825,10 +826,12 @@ static int rk_iommu_attach_device(struct iommu_domain *domain, > >> > >> iommu->domain = domain; > >> > >> - ret = devm_request_irq(iommu->dev, iommu->irq, rk_iommu_irq, > >> - IRQF_SHARED, dev_name(dev), iommu); > >> - if (ret) > >> - return ret; > >> + for (i = 0; i < iommu->num_irq; i++) { > >> + ret = devm_request_irq(iommu->dev, iommu->irq[i], rk_iommu_irq, > >> + IRQF_SHARED, dev_name(dev), iommu); > >> + if (ret) > >> + return ret; > >> + } > >> > >> for (i = 0; i < iommu->num_mmu; i++) { > >> rk_iommu_write(iommu->bases[i], RK_MMU_DTE_ADDR, > >> @@ -878,7 +881,8 @@ static void rk_iommu_detach_device(struct iommu_domain *domain, > >> } > >> rk_iommu_disable_stall(iommu); > >> > >> - devm_free_irq(iommu->dev, iommu->irq, iommu); > >> + for (i = 0; i < iommu->num_irq; i++) > >> + devm_free_irq(iommu->dev, iommu->irq[i], iommu); > >> > >> iommu->domain = NULL; > >> > >> @@ -1157,10 +1161,20 @@ static int rk_iommu_probe(struct platform_device *pdev) > >> if (iommu->num_mmu == 0) > >> return PTR_ERR(iommu->bases[0]); > >> > >> - iommu->irq = platform_get_irq(pdev, 0); > >> - if (iommu->irq < 0) { > >> - dev_err(dev, "Failed to get IRQ, %d\n", iommu->irq); > >> - return -ENXIO; > >> + while (platform_get_irq(pdev, iommu->num_irq) >= 0) > >> + iommu->num_irq++; > > Hmm, this could also result in a iommu having 0 irqs if wrongly > > configured and probe would still suceed. This sounds somehow > > wrong to me. > > > > But I'm not sure if there is precedent on how to handle a variable > > number of interrupts correctly somewhere. > > How about add a judgement for iommu->num_irq ? like this: > if (!iommu->num_irq) > return -ENOXIO; platform devices already have a function that gets you the number of irqs. Re-using that is way better than open-coding it, so iommu->num_irq = platform_irq_count(pdev); if (iommu->num_irq < 0) return iommu->num_irq; if (iommu->num_irq == 0) return -ENXIO; Heiko ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH V2 3/3] iommu/rockchip: ignore isp mmu reset operation 2017-07-21 6:27 [PATCH V2 1/3] Docs: dt: rockchip: add rk-iommu,disable-reset-quirk property Simon Xue 2017-07-21 6:27 ` [PATCH V2 2/3] iommu/rockchip: add multi irqs support Simon Xue @ 2017-07-21 6:27 ` Simon Xue 2017-07-21 6:57 ` [PATCH V2 1/3] Docs: dt: rockchip: add rk-iommu,disable-reset-quirk property Heiko Stuebner 2 siblings, 0 replies; 7+ messages in thread From: Simon Xue @ 2017-07-21 6:27 UTC (permalink / raw) To: Joerg Roedel, Heiko Stuebner; +Cc: linux-rockchip, iommu, linux-kernel, Simon From: Simon <xxm@rock-chips.com> ISP mmu can't support reset operation, it won't get the expected result when reset, but rest functions work normally. Add this patch as a WA for this issue. Signed-off-by: Simon <xxm@rock-chips.com> --- changes since V1: - use '-' instead of '_' for DT property. drivers/iommu/rockchip-iommu.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 3c462c0..3c6dc81 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -92,6 +92,7 @@ struct rk_iommu { int num_mmu; int *irq; int num_irq; + bool reset_disabled; struct iommu_device iommu; struct list_head node; /* entry in rk_iommu_domain.iommus */ struct iommu_domain *domain; /* domain to which iommu is attached */ @@ -415,6 +416,9 @@ static int rk_iommu_force_reset(struct rk_iommu *iommu) int ret, i; u32 dte_addr; + if (iommu->reset_disabled) + return 0; + /* * Check if register DTE_ADDR is working by writing DTE_ADDR_DUMMY * and verifying that upper 5 nybbles are read back. @@ -1177,6 +1181,9 @@ static int rk_iommu_probe(struct platform_device *pdev) } } + iommu->reset_disabled = device_property_read_bool(dev, + "rk-iommu,disable-reset-quirk"); + err = iommu_device_sysfs_add(&iommu->iommu, dev, NULL, dev_name(dev)); if (err) return err; -- 1.9.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH V2 1/3] Docs: dt: rockchip: add rk-iommu,disable-reset-quirk property 2017-07-21 6:27 [PATCH V2 1/3] Docs: dt: rockchip: add rk-iommu,disable-reset-quirk property Simon Xue 2017-07-21 6:27 ` [PATCH V2 2/3] iommu/rockchip: add multi irqs support Simon Xue 2017-07-21 6:27 ` [PATCH V2 3/3] iommu/rockchip: ignore isp mmu reset operation Simon Xue @ 2017-07-21 6:57 ` Heiko Stuebner 2 siblings, 0 replies; 7+ messages in thread From: Heiko Stuebner @ 2017-07-21 6:57 UTC (permalink / raw) To: Simon Xue; +Cc: Joerg Roedel, linux-rockchip, iommu, linux-kernel Hi Simon, Am Freitag, 21. Juli 2017, 14:27:08 CEST schrieb Simon Xue: > From: Simon <xxm@rock-chips.com> > > Add rk-iommu,disable-reset-quirk property to ignore the isp mmu > reset operation > > Signed-off-by: Simon <xxm@rock-chips.com> please use your full name in From and Signed-off. Also, you need to include devicetree-people and mailinglists (as scripts/get_maintainer.pl will show you) when sending dt-binding changes. > --- > changes since V1: > - new added file > > Documentation/devicetree/bindings/iommu/rockchip,iommu.txt | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/Documentation/devicetree/bindings/iommu/rockchip,iommu.txt b/Documentation/devicetree/bindings/iommu/rockchip,iommu.txt > index 9a55ac3..aa2136c 100644 > --- a/Documentation/devicetree/bindings/iommu/rockchip,iommu.txt > +++ b/Documentation/devicetree/bindings/iommu/rockchip,iommu.txt > @@ -15,6 +15,11 @@ Required properties: > to associate with its master device. See: > Documentation/devicetree/bindings/iommu/iommu.txt > > +Optional properties: > +- rk-iommu,disable-reset-quirk : This ignore the isp mmu reset operation. Prefix should be "rockchip," not "rk-iommu,". Also, this quirk could be renamed to something like: rockchip,disable-mmu-reset: Don't use the mmu reset operation. Some mmu instances may produce unexpected results when the reset operation is used. But that is more a Heiko > + It can't get the expected result when isp mmu > + reset, but the reset function work normally > + > Example: > > vopl_mmu: iommu@ff940300 { > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-07-21 18:37 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-07-21 6:27 [PATCH V2 1/3] Docs: dt: rockchip: add rk-iommu,disable-reset-quirk property Simon Xue 2017-07-21 6:27 ` [PATCH V2 2/3] iommu/rockchip: add multi irqs support Simon Xue 2017-07-21 7:07 ` Heiko Stuebner 2017-07-21 7:54 ` xxm 2017-07-21 18:37 ` Heiko Stuebner 2017-07-21 6:27 ` [PATCH V2 3/3] iommu/rockchip: ignore isp mmu reset operation Simon Xue 2017-07-21 6:57 ` [PATCH V2 1/3] Docs: dt: rockchip: add rk-iommu,disable-reset-quirk property Heiko Stuebner
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).