Skip to contentSkip to conversation

soc: mediatek: mtk-svs: Enable the IRQ later

PATCH In review Ricardo Ribalda 3 participants 4 messages Dec 20, 2022 – Jan 30, 2023 Arm MediaTek

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 soc: mediatek: mtk-svs: Enable the IRQ later

If the system does not come from reset (like when is booted via kexec()), the peripheral might triger an IRQ before the data structures are initialised.

Fixes:

[    0.227710] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000f08
[    0.227913] Call trace:
[    0.227918]  svs_isr+0x8c/0x538

---
To: Matthias Brugger <[email protected]>
To: Roger Lu <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
Changes in v2:
- Enable the irq before svs_start, to avoid MT8192 not starting.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 drivers/soc/mediatek/mtk-svs.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/soc/mediatek/mtk-svs.c +8 -8
index 0469c9dfeb04..75b2f534aa9d 100644
@@ -2385,14 +2385,6 @@ static int svs_probe(struct platform_device *pdev)
 		goto svs_probe_free_resource;
 	}
 
-	ret = devm_request_threaded_irq(svsp->dev, svsp_irq, NULL, svs_isr,
-					IRQF_ONESHOT, svsp->name, svsp);
-	if (ret) {
-		dev_err(svsp->dev, "register irq(%d) failed: %d\n",
-			svsp_irq, ret);
-		goto svs_probe_free_resource;
-	}
-
 	svsp->main_clk = devm_clk_get(svsp->dev, "main");
 	if (IS_ERR(svsp->main_clk)) {
 		dev_err(svsp->dev, "failed to get clock: %ld\n",
@@ -2414,6 +2406,14 @@ static int svs_probe(struct platform_device *pdev)
 		goto svs_probe_clk_disable;
 	}
 
+	ret = devm_request_threaded_irq(svsp->dev, svsp_irq, NULL, svs_isr,
+					IRQF_ONESHOT, svsp->name, svsp);
+	if (ret) {
+		dev_err(svsp->dev, "register irq(%d) failed: %d\n",
+			svsp_irq, ret);
+		goto svs_probe_iounmap;
+	}
+
 	ret = svs_start(svsp);
 	if (ret) {
 		dev_err(svsp->dev, "svs start fail: %d\n", ret);

---
base-commit: 4312098baf37ee17a8350725e6e0d0e8590252d4
change-id: 20221127-mtk-svs-add137fbf187

Best regards,

Signature · 1 line
Ricardo Ribalda <[email protected]>
maintainer
#1 lore raw
Quoted 11 lines · Ricardo Ribalda

If the system does not come from reset (like when is booted via kexec()), the peripheral might triger an IRQ before the data structures are initialised.

Fixes:

[    0.227710] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000f08
[    0.227913] Call trace:
[    0.227918]  svs_isr+0x8c/0x538

Thanks Ricardo. Roger I'll wait for a Tested-by tag from you to make sure this time everything is fine.

Regards,
Matthias

Quoted 54 lines

---
To: Matthias Brugger <[email protected]>
To: Roger Lu <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
Changes in v2:
- Enable the irq before svs_start, to avoid MT8192 not starting.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
  drivers/soc/mediatek/mtk-svs.c | 16 ++++++++--------
  1 file changed, 8 insertions(+), 8 deletions(-)
drivers/soc/mediatek/mtk-svs.c +8 -9
index 0469c9dfeb04..75b2f534aa9d 100644
@@ -2385,14 +2385,6 @@ static int svs_probe(struct platform_device *pdev)
  		goto svs_probe_free_resource;
  	}
 
-	ret = devm_request_threaded_irq(svsp->dev, svsp_irq, NULL, svs_isr,
-					IRQF_ONESHOT, svsp->name, svsp);
-	if (ret) {
-		dev_err(svsp->dev, "register irq(%d) failed: %d\n",
-			svsp_irq, ret);
-		goto svs_probe_free_resource;
-	}
-
  	svsp->main_clk = devm_clk_get(svsp->dev, "main");
  	if (IS_ERR(svsp->main_clk)) {
  		dev_err(svsp->dev, "failed to get clock: %ld\n",
@@ -2414,6 +2406,14 @@ static int svs_probe(struct platform_device *pdev)
  		goto svs_probe_clk_disable;
  	}
 
+	ret = devm_request_threaded_irq(svsp->dev, svsp_irq, NULL, svs_isr,
+					IRQF_ONESHOT, svsp->name, svsp);
+	if (ret) {
+		dev_err(svsp->dev, "register irq(%d) failed: %d\n",
+			svsp_irq, ret);
+		goto svs_probe_iounmap;
+	}
+
  	ret = svs_start(svsp);
  	if (ret) {
  		dev_err(svsp->dev, "svs start fail: %d\n", ret);
 
---

base-commit: 4312098baf37ee17a8350725e6e0d0e8590252d4
change-id: 20221127-mtk-svs-add137fbf187

Best regards,

maintainer
#2 lore raw
Quoted 9 lines · Matthias Brugger
Quoted 6 lines · Ricardo Ribalda

If the system does not come from reset (like when is booted via kexec()), the peripheral might triger an IRQ before the data structures are initialised.

Fixes:

Quoted 8 lines
Quoted 5 lines

[    0.227710] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000f08 [    0.227913] Call trace:
[    0.227918]  svs_isr+0x8c/0x538

Thanks Ricardo. Roger I'll wait for a Tested-by tag from you to make sure this time everything is fine.

Given the chinese new year holidays I don't expect a Tested-by tag from Roger in time. So I just took this one without it.

Thanks!
Matthias

#3 lore raw

Hi Matthias Sir,

Excuse me for missing this thread. Add Tested-by tag.

Quoted 19 lines · Matthias Brugger
Quoted 17 lines · Matthias Brugger
Quoted 13 lines · Ricardo Ribalda

If the system does not come from reset (like when is booted via kexec()), the peripheral might triger an IRQ before the data structures are initialised.

Fixes:

[    0.227710] Unable to handle kernel NULL pointer dereference at
virtual 
address 0000000000000f08
[    0.227913] Call trace:
[    0.227918]  svs_isr+0x8c/0x538
Quoted 8 lines
Quoted 4 lines

Thanks Ricardo. Roger I'll wait for a Tested-by tag from you to make sure this
time everything is fine.

Given the chinese new year holidays I don't expect a Tested-by tag from Roger in
time. So I just took this one without it.

Quoted 3 lines

Thanks!
Matthias