Skip to contentSkip to conversation

some fixes for sifive_ccache

PATCH In review Yang Yingliang 4 participants 7 messages Oct 18, 2022 – Nov 16, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover some fixes for sifive_ccache

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(-)
Signature · 7 lines
2.25.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#1 lore raw

PATCH v2 1/3 soc: sifive: ccache: fix missing iounmap() in error path in sifive_ccache_init()

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")
---
 drivers/soc/sifive/sifive_ccache.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/soc/sifive/sifive_ccache.c +11 -4
index 1c171150e878..25019c16d8ae 100644
@@ -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);
Signature · 7 lines
2.25.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#2 lore raw

PATCH v2 2/3 soc: sifive: ccache: fix missing free_irq() in error path in sifive_ccache_init()

In reply to Yang Yingliang

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")
---
 drivers/soc/sifive/sifive_ccache.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/soc/sifive/sifive_ccache.c +4 -1
index 25019c16d8ae..98269d056728 100644
@@ -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;
Signature · 7 lines
2.25.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#3 lore raw

PATCH v2 3/3 soc: sifive: ccache: fix missing of_node_put() in sifive_ccache_init()

In reply to Yang Yingliang

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")
---
 drivers/soc/sifive/sifive_ccache.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/soc/sifive/sifive_ccache.c +11 -4
index 98269d056728..3684f5b40a80 100644
@@ -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;
 }
 
Signature · 7 lines
2.25.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Reviewed-by on v2 3/3
#4 lore raw

Re: [PATCH v2 3/3] soc: sifive: ccache: fix missing of_node_put() in sifive_ccache_init()

Quoted 3 lines · Yang Yingliang

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!

Quoted 57 lines
Fixes a967a289f169 ("RISC-V: sifive_l2_cache: Add L2 cache controller driver for SiFive SoCs")
---
 drivers/soc/sifive/sifive_ccache.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/soc/sifive/sifive_ccache.c +11 -4
index 98269d056728..3684f5b40a80 100644
@@ -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;
 }
 
Signature · 7 lines
2.25.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#5 lore raw
In reply to Yang Yingliang
Quoted 13 lines · Yang Yingliang

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()

Quoted 2 lines
  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.

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

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


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#6 lore raw
In reply to Yang Yingliang

Hey,

Quoted 1 line · Yang Yingliang

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.

Quoted 12 lines

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()

Quoted 11 lines
 drivers/soc/sifive/sifive_ccache.c | 33 ++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)
Signature · 7 lines
2.25.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv