All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] some fixes for sifive_ccache
@ 2022-10-18  2:31 Yang Yingliang
  2022-10-18  2:31 ` [PATCH v2 1/3] soc: sifive: ccache: fix missing iounmap() in error path in sifive_ccache_init() Yang Yingliang
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Yang Yingliang @ 2022-10-18  2:31 UTC (permalink / raw)
  To: linux-riscv; +Cc: yash.shah, palmer, paul.walmsley, conor, yangyingliang

Add missing iounmap()/free_irq()/of_node_put() in sifive_ccache_init().

v1 -> v2:
  - Add review tag from Conor Dooley in patch #1 and #2.
  - Add patch #3 to fix missing of_node_put().

Yang Yingliang (3):
  soc: sifive: ccache: fix missing iounmap() in error path in
    sifive_ccache_init()
  soc: sifive: ccache: fix missing free_irq() in error path in
    sifive_ccache_init()
  soc: sifive: ccache: fix missing of_node_put() in sifive_ccache_init()

 drivers/soc/sifive/sifive_ccache.c | 33 ++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

-- 
2.25.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/3] soc: sifive: ccache: fix missing iounmap() in error path in sifive_ccache_init()
  2022-10-18  2:31 [PATCH v2 0/3] some fixes for sifive_ccache Yang Yingliang
@ 2022-10-18  2:31 ` Yang Yingliang
  2022-10-18  2:31 ` [PATCH v2 2/3] soc: sifive: ccache: fix missing free_irq() " Yang Yingliang
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Yang Yingliang @ 2022-10-18  2:31 UTC (permalink / raw)
  To: linux-riscv; +Cc: yash.shah, palmer, paul.walmsley, conor, yangyingliang

Add missing iounmap() before return error from sifive_ccache_init().

Fixes: a967a289f169 ("RISC-V: sifive_l2_cache: Add L2 cache controller driver for SiFive SoCs")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
---
 drivers/soc/sifive/sifive_ccache.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/soc/sifive/sifive_ccache.c b/drivers/soc/sifive/sifive_ccache.c
index 1c171150e878..25019c16d8ae 100644
--- a/drivers/soc/sifive/sifive_ccache.c
+++ b/drivers/soc/sifive/sifive_ccache.c
@@ -222,13 +222,16 @@ static int __init sifive_ccache_init(void)
 	if (!ccache_base)
 		return -ENOMEM;
 
-	if (of_property_read_u32(np, "cache-level", &level))
-		return -ENOENT;
+	if (of_property_read_u32(np, "cache-level", &level)) {
+		rc = -ENOENT;
+		goto err_unmap;
+	}
 
 	intr_num = of_property_count_u32_elems(np, "interrupts");
 	if (!intr_num) {
 		pr_err("No interrupts property\n");
-		return -ENODEV;
+		rc = -ENODEV;
+		goto err_unmap;
 	}
 
 	for (i = 0; i < intr_num; i++) {
@@ -237,7 +240,7 @@ static int __init sifive_ccache_init(void)
 				 NULL);
 		if (rc) {
 			pr_err("Could not request IRQ %d\n", g_irq[i]);
-			return rc;
+			goto err_unmap;
 		}
 	}
 
@@ -250,6 +253,10 @@ static int __init sifive_ccache_init(void)
 	setup_sifive_debug();
 #endif
 	return 0;
+
+err_unmap:
+	iounmap(ccache_base);
+	return rc;
 }
 
 device_initcall(sifive_ccache_init);
-- 
2.25.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/3] soc: sifive: ccache: fix missing free_irq() in error path in sifive_ccache_init()
  2022-10-18  2:31 [PATCH v2 0/3] some fixes for sifive_ccache Yang Yingliang
  2022-10-18  2:31 ` [PATCH v2 1/3] soc: sifive: ccache: fix missing iounmap() in error path in sifive_ccache_init() Yang Yingliang
@ 2022-10-18  2:31 ` Yang Yingliang
  2022-10-18  2:31 ` [PATCH v2 3/3] soc: sifive: ccache: fix missing of_node_put() " Yang Yingliang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Yang Yingliang @ 2022-10-18  2:31 UTC (permalink / raw)
  To: linux-riscv; +Cc: yash.shah, palmer, paul.walmsley, conor, yangyingliang

Add missing free_irq() before return error from sifive_ccache_init().

Fixes: a967a289f169 ("RISC-V: sifive_l2_cache: Add L2 cache controller driver for SiFive SoCs")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
---
 drivers/soc/sifive/sifive_ccache.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/sifive/sifive_ccache.c b/drivers/soc/sifive/sifive_ccache.c
index 25019c16d8ae..98269d056728 100644
--- a/drivers/soc/sifive/sifive_ccache.c
+++ b/drivers/soc/sifive/sifive_ccache.c
@@ -240,7 +240,7 @@ static int __init sifive_ccache_init(void)
 				 NULL);
 		if (rc) {
 			pr_err("Could not request IRQ %d\n", g_irq[i]);
-			goto err_unmap;
+			goto err_free_irq;
 		}
 	}
 
@@ -254,6 +254,9 @@ static int __init sifive_ccache_init(void)
 #endif
 	return 0;
 
+err_free_irq:
+	while (--i >= 0)
+		free_irq(g_irq[i], NULL);
 err_unmap:
 	iounmap(ccache_base);
 	return rc;
-- 
2.25.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 3/3] soc: sifive: ccache: fix missing of_node_put() in sifive_ccache_init()
  2022-10-18  2:31 [PATCH v2 0/3] some fixes for sifive_ccache Yang Yingliang
  2022-10-18  2:31 ` [PATCH v2 1/3] soc: sifive: ccache: fix missing iounmap() in error path in sifive_ccache_init() Yang Yingliang
  2022-10-18  2:31 ` [PATCH v2 2/3] soc: sifive: ccache: fix missing free_irq() " Yang Yingliang
@ 2022-10-18  2:31 ` Yang Yingliang
  2022-10-18  7:40   ` Conor Dooley
  2022-10-18  7:35 ` [PATCH v2 0/3] some fixes for sifive_ccache Ben Dooks
  2022-11-16 18:33 ` Conor Dooley
  4 siblings, 1 reply; 7+ messages in thread
From: Yang Yingliang @ 2022-10-18  2:31 UTC (permalink / raw)
  To: linux-riscv; +Cc: yash.shah, palmer, paul.walmsley, conor, yangyingliang

The device_node pointer returned by of_find_matching_node() with
refcount incremented, when finish using it, the refcount need be
decreased.

Fixes: a967a289f169 ("RISC-V: sifive_l2_cache: Add L2 cache controller driver for SiFive SoCs")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/soc/sifive/sifive_ccache.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/soc/sifive/sifive_ccache.c b/drivers/soc/sifive/sifive_ccache.c
index 98269d056728..3684f5b40a80 100644
--- a/drivers/soc/sifive/sifive_ccache.c
+++ b/drivers/soc/sifive/sifive_ccache.c
@@ -215,12 +215,16 @@ static int __init sifive_ccache_init(void)
 	if (!np)
 		return -ENODEV;
 
-	if (of_address_to_resource(np, 0, &res))
-		return -ENODEV;
+	if (of_address_to_resource(np, 0, &res)) {
+		rc = -ENODEV;
+		goto err_node_put;
+	}
 
 	ccache_base = ioremap(res.start, resource_size(&res));
-	if (!ccache_base)
-		return -ENOMEM;
+	if (!ccache_base) {
+		rc = -ENOMEM;
+		goto err_node_put;
+	}
 
 	if (of_property_read_u32(np, "cache-level", &level)) {
 		rc = -ENOENT;
@@ -243,6 +247,7 @@ static int __init sifive_ccache_init(void)
 			goto err_free_irq;
 		}
 	}
+	of_node_put(np);
 
 	ccache_config_read();
 
@@ -259,6 +264,8 @@ static int __init sifive_ccache_init(void)
 		free_irq(g_irq[i], NULL);
 err_unmap:
 	iounmap(ccache_base);
+err_node_put:
+	of_node_put(np);
 	return rc;
 }
 
-- 
2.25.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/3] some fixes for sifive_ccache
  2022-10-18  2:31 [PATCH v2 0/3] some fixes for sifive_ccache Yang Yingliang
                   ` (2 preceding siblings ...)
  2022-10-18  2:31 ` [PATCH v2 3/3] soc: sifive: ccache: fix missing of_node_put() " Yang Yingliang
@ 2022-10-18  7:35 ` Ben Dooks
  2022-11-16 18:33 ` Conor Dooley
  4 siblings, 0 replies; 7+ messages in thread
From: Ben Dooks @ 2022-10-18  7:35 UTC (permalink / raw)
  To: Yang Yingliang, linux-riscv; +Cc: yash.shah, palmer, paul.walmsley, conor

On 18/10/2022 03:31, Yang Yingliang wrote:
> Add missing iounmap()/free_irq()/of_node_put() in sifive_ccache_init().
> 
> v1 -> v2:
>    - Add review tag from Conor Dooley in patch #1 and #2.
>    - Add patch #3 to fix missing of_node_put().
> 
> Yang Yingliang (3):
>    soc: sifive: ccache: fix missing iounmap() in error path in
>      sifive_ccache_init()
>    soc: sifive: ccache: fix missing free_irq() in error path in
>      sifive_ccache_init()
>    soc: sifive: ccache: fix missing of_node_put() in sifive_ccache_init()
> 
>   drivers/soc/sifive/sifive_ccache.c | 33 ++++++++++++++++++++++--------
>   1 file changed, 25 insertions(+), 8 deletions(-)

i might get some time to test these, initial review looks fine.


-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 3/3] soc: sifive: ccache: fix missing of_node_put() in sifive_ccache_init()
  2022-10-18  2:31 ` [PATCH v2 3/3] soc: sifive: ccache: fix missing of_node_put() " Yang Yingliang
@ 2022-10-18  7:40   ` Conor Dooley
  0 siblings, 0 replies; 7+ messages in thread
From: Conor Dooley @ 2022-10-18  7:40 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: linux-riscv, yash.shah, palmer, paul.walmsley, conor

On Tue, Oct 18, 2022 at 10:31:49AM +0800, Yang Yingliang wrote:
> The device_node pointer returned by of_find_matching_node() with
> refcount incremented, when finish using it, the refcount need be
> decreased.

Cool, patch looks about as I'd expect. Thanks!
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>

> 
> Fixes: a967a289f169 ("RISC-V: sifive_l2_cache: Add L2 cache controller driver for SiFive SoCs")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  drivers/soc/sifive/sifive_ccache.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/soc/sifive/sifive_ccache.c b/drivers/soc/sifive/sifive_ccache.c
> index 98269d056728..3684f5b40a80 100644
> --- a/drivers/soc/sifive/sifive_ccache.c
> +++ b/drivers/soc/sifive/sifive_ccache.c
> @@ -215,12 +215,16 @@ static int __init sifive_ccache_init(void)
>  	if (!np)
>  		return -ENODEV;
>  
> -	if (of_address_to_resource(np, 0, &res))
> -		return -ENODEV;
> +	if (of_address_to_resource(np, 0, &res)) {
> +		rc = -ENODEV;
> +		goto err_node_put;
> +	}
>  
>  	ccache_base = ioremap(res.start, resource_size(&res));
> -	if (!ccache_base)
> -		return -ENOMEM;
> +	if (!ccache_base) {
> +		rc = -ENOMEM;
> +		goto err_node_put;
> +	}
>  
>  	if (of_property_read_u32(np, "cache-level", &level)) {
>  		rc = -ENOENT;
> @@ -243,6 +247,7 @@ static int __init sifive_ccache_init(void)
>  			goto err_free_irq;
>  		}
>  	}
> +	of_node_put(np);
>  
>  	ccache_config_read();
>  
> @@ -259,6 +264,8 @@ static int __init sifive_ccache_init(void)
>  		free_irq(g_irq[i], NULL);
>  err_unmap:
>  	iounmap(ccache_base);
> +err_node_put:
> +	of_node_put(np);
>  	return rc;
>  }
>  
> -- 
> 2.25.1
> 
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/3] some fixes for sifive_ccache
  2022-10-18  2:31 [PATCH v2 0/3] some fixes for sifive_ccache Yang Yingliang
                   ` (3 preceding siblings ...)
  2022-10-18  7:35 ` [PATCH v2 0/3] some fixes for sifive_ccache Ben Dooks
@ 2022-11-16 18:33 ` Conor Dooley
  4 siblings, 0 replies; 7+ messages in thread
From: Conor Dooley @ 2022-11-16 18:33 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: linux-riscv, yash.shah, palmer, paul.walmsley

Hey,

On Tue, Oct 18, 2022 at 10:31:46AM +0800, Yang Yingliang wrote:
> Add missing iounmap()/free_irq()/of_node_put() in sifive_ccache_init().

I've picked the series up for v6.2, should be here:
https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/log/?h=riscv-soc-for-next

We've been sorting out re-routing stuff like this soc driver via the soc
tree rather than via the RISC-V and it took a bit of time so apologies
for the delay.

Thanks,
Conor.

> 
> v1 -> v2:
>   - Add review tag from Conor Dooley in patch #1 and #2.
>   - Add patch #3 to fix missing of_node_put().
> 
> Yang Yingliang (3):
>   soc: sifive: ccache: fix missing iounmap() in error path in
>     sifive_ccache_init()
>   soc: sifive: ccache: fix missing free_irq() in error path in
>     sifive_ccache_init()
>   soc: sifive: ccache: fix missing of_node_put() in sifive_ccache_init()
> 
>  drivers/soc/sifive/sifive_ccache.c | 33 ++++++++++++++++++++++--------
>  1 file changed, 25 insertions(+), 8 deletions(-)
> 
> -- 
> 2.25.1
> 
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-11-16 18:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-18  2:31 [PATCH v2 0/3] some fixes for sifive_ccache Yang Yingliang
2022-10-18  2:31 ` [PATCH v2 1/3] soc: sifive: ccache: fix missing iounmap() in error path in sifive_ccache_init() Yang Yingliang
2022-10-18  2:31 ` [PATCH v2 2/3] soc: sifive: ccache: fix missing free_irq() " Yang Yingliang
2022-10-18  2:31 ` [PATCH v2 3/3] soc: sifive: ccache: fix missing of_node_put() " Yang Yingliang
2022-10-18  7:40   ` Conor Dooley
2022-10-18  7:35 ` [PATCH v2 0/3] some fixes for sifive_ccache Ben Dooks
2022-11-16 18:33 ` Conor Dooley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.