Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1693328 > unrolled thread

[PATCH 1/2] iommu/rockchip: add multi irqs support

Started bySimon Xue <xxm@rock-chips.com>
First post2017-07-21 03:40 +0200
Last post2017-07-21 04:10 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/2] iommu/rockchip: add multi irqs support Simon Xue <xxm@rock-chips.com> - 2017-07-21 03:40 +0200
    [PATCH 2/2] iommu/rockchip: ignore isp mmu reset operation Simon Xue <xxm@rock-chips.com> - 2017-07-21 03:40 +0200
      Re: [PATCH 2/2] iommu/rockchip: ignore isp mmu reset operation Shawn Lin <shawn.lin@rock-chips.com> - 2017-07-21 04:00 +0200
    Re: [PATCH 1/2] iommu/rockchip: add multi irqs support Shawn Lin <shawn.lin@rock-chips.com> - 2017-07-21 04:10 +0200

#1693328 — [PATCH 1/2] iommu/rockchip: add multi irqs support

FromSimon Xue <xxm@rock-chips.com>
Date2017-07-21 03:40 +0200
Subject[PATCH 1/2] iommu/rockchip: add multi irqs support
Message-ID<u5v58-6JE-7@gated-at.bofh.it>
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>
---
 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..b38283e 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_kzalloc(dev, sizeof(*iommu->irq) * iommu->num_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

[toc] | [next] | [standalone]


#1693329 — [PATCH 2/2] iommu/rockchip: ignore isp mmu reset operation

FromSimon Xue <xxm@rock-chips.com>
Date2017-07-21 03:40 +0200
Subject[PATCH 2/2] iommu/rockchip: ignore isp mmu reset operation
Message-ID<u5v58-6JE-5@gated-at.bofh.it>
In reply to#1693328
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>
---
 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 b38283e..47c00b9 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

[toc] | [prev] | [next] | [standalone]


#1693332 — Re: [PATCH 2/2] iommu/rockchip: ignore isp mmu reset operation

FromShawn Lin <shawn.lin@rock-chips.com>
Date2017-07-21 04:00 +0200
SubjectRe: [PATCH 2/2] iommu/rockchip: ignore isp mmu reset operation
Message-ID<u5vou-6RY-5@gated-at.bofh.it>
In reply to#1693329
Hi Simon,

On 2017/7/21 9:35, Simon Xue wrote:
> 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>
> ---
>   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 b38283e..47c00b9 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");
> +

Please update Documentation/devicetree/bindings/iommu/rockchip,iommu.txt
as well. And please use '-' instead of '_' for DT property.


>   	err = iommu_device_sysfs_add(&iommu->iommu, dev, NULL, dev_name(dev));
>   	if (err)
>   		return err;
> 

[toc] | [prev] | [next] | [standalone]


#1693333

FromShawn Lin <shawn.lin@rock-chips.com>
Date2017-07-21 04:10 +0200
Message-ID<u5vy9-7aa-1@gated-at.bofh.it>
In reply to#1693328
Hi Simon,

On 2017/7/21 9:35, Simon Xue wrote:
> 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>
> ---
>   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..b38283e 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_kzalloc(dev, sizeof(*iommu->irq) * iommu->num_irq,
> +				  GFP_KERNEL);

Prefer to used devm_kcalloc for array allocation,see
Documentation/process/coding-style.rst +831

> +	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));
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web