Skip to contentSkip to conversation

drm: renesas: rz-du: mipi_dsi: Fix return path on error

PATCH Superseded Chris Brandt 3 participants 3 messages Apr 22 – Apr 24

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm: renesas: rz-du: mipi_dsi: Fix return path on error

In case of error, we should unwind correctly.
Switching to using dmam_ instead of dma_ and moving the code earlier fixes the issue.

Fixes 6f392f371650 ("drm: renesas: rz-du: Implement MIPI DSI host transfers")

---
V1->V2:
- Need to take into account mipi_dsi_host_register was already called (Geert)
- Switch to using dmam_alloc_coherent to automate unwinding (Chris)
- Added Acked-by (Hugo)

---
 drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c +5 -7
index 29f2b7d24fe5..b908e702b607 100644
@@ -1442,6 +1442,11 @@ static int rzg2l_mipi_dsi_probe(struct platform_device *pdev)
 		return dev_err_probe(dsi->dev, PTR_ERR(dsi->prstc),
 				     "failed to get prst\n");
 
+	dsi->dcs_buf_virt = dmam_alloc_coherent(dsi->dev, RZG2L_DCS_BUF_SIZE,
+						&dsi->dcs_buf_phys, GFP_KERNEL);
+	if (!dsi->dcs_buf_virt)
+		return -ENOMEM;
+
 	platform_set_drvdata(pdev, dsi);
 
 	pm_runtime_enable(dsi->dev);
@@ -1474,11 +1479,6 @@ static int rzg2l_mipi_dsi_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto err_pm_disable;
 
-	dsi->dcs_buf_virt = dma_alloc_coherent(dsi->host.dev, RZG2L_DCS_BUF_SIZE,
-					       &dsi->dcs_buf_phys, GFP_KERNEL);
-	if (!dsi->dcs_buf_virt)
-		return -ENOMEM;
-
 	return 0;
 
 err_phy:
@@ -1493,8 +1493,6 @@ static void rzg2l_mipi_dsi_remove(struct platform_device *pdev)
 {
 	struct rzg2l_mipi_dsi *dsi = platform_get_drvdata(pdev);
 
-	dma_free_coherent(dsi->host.dev, RZG2L_DCS_BUF_SIZE, dsi->dcs_buf_virt,
-			  dsi->dcs_buf_phys);
 	mipi_dsi_host_unregister(&dsi->host);
 	pm_runtime_disable(&pdev->dev);
 }

--
2.52.0

#1 lore raw

Hi Chris,

Quoted 9 lines · On Wed, 22 Apr 2026 10:51:46 -0400 Chris Brandt <[email protected]>…

In case of error, we should unwind correctly.
Switching to using dmam_ instead of dma_ and moving the code earlier fixes the issue.

Fixes 6f392f371650 ("drm: renesas: rz-du: Implement MIPI DSI host transfers")
Quoted 5 lines

---
V1->V2:
- Need to take into account mipi_dsi_host_register was already called (Geert)
- Switch to using dmam_alloc_coherent to automate unwinding (Chris)
- Added Acked-by (Hugo)

You should not add "Acked-by" tags if you make modifications _after_ someone has given its Ack (unless it is just a minor cosmetic or coding style change)...

In other words, my ack was for V1, not V2 which is quite different from V1 :)

Don't resend a V3 just for that, I will have a look later at V2...

Quoted 45 lines
---
 drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c +5 -8
index 29f2b7d24fe5..b908e702b607 100644
@@ -1442,6 +1442,11 @@ static int rzg2l_mipi_dsi_probe(struct platform_device *pdev)
 		return dev_err_probe(dsi->dev, PTR_ERR(dsi->prstc),
 				     "failed to get prst\n");
 
+	dsi->dcs_buf_virt = dmam_alloc_coherent(dsi->dev, RZG2L_DCS_BUF_SIZE,
+						&dsi->dcs_buf_phys, GFP_KERNEL);
+	if (!dsi->dcs_buf_virt)
+		return -ENOMEM;
+
 	platform_set_drvdata(pdev, dsi);
 
 	pm_runtime_enable(dsi->dev);
@@ -1474,11 +1479,6 @@ static int rzg2l_mipi_dsi_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto err_pm_disable;
 
-	dsi->dcs_buf_virt = dma_alloc_coherent(dsi->host.dev, RZG2L_DCS_BUF_SIZE,
-					       &dsi->dcs_buf_phys, GFP_KERNEL);
-	if (!dsi->dcs_buf_virt)
-		return -ENOMEM;
-
 	return 0;
 
 err_phy:
@@ -1493,8 +1493,6 @@ static void rzg2l_mipi_dsi_remove(struct platform_device *pdev)
 {
 	struct rzg2l_mipi_dsi *dsi = platform_get_drvdata(pdev);
 
-	dma_free_coherent(dsi->host.dev, RZG2L_DCS_BUF_SIZE, dsi->dcs_buf_virt,
-			  dsi->dcs_buf_phys);
 	mipi_dsi_host_unregister(&dsi->host);
 	pm_runtime_disable(&pdev->dev);
 }
--

2.52.0

Signature · 1 line
Hugo Villeneuve
maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to Chris Brandt

Hi Chris,

Thanks for the patch.

Quoted 5 lines

-----Original Message-----
From: Chris Brandt <[email protected]>
Sent: 22 April 2026 15:52
Subject: [PATCH v2] drm: renesas: rz-du: mipi_dsi: Fix return path on error

Quoted 7 lines

In case of error, we should unwind correctly.
Switching to using dmam_ instead of dma_ and moving the code earlier fixes the issue.

Fixes 6f392f371650 ("drm: renesas: rz-du: Implement MIPI DSI host transfers")

Cheers,
Biju

Quoted 49 lines

---
V1->V2:
- Need to take into account mipi_dsi_host_register was already called (Geert)
- Switch to using dmam_alloc_coherent to automate unwinding (Chris)
- Added Acked-by (Hugo)

---
 drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/renesas/rz- renamed from drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c +0 -0

du/rzg2l_mipi_dsi.c
index 29f2b7d24fe5..b908e702b607 100644

drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c +5 -8
@@ -1442,6 +1442,11 @@ static int rzg2l_mipi_dsi_probe(struct platform_device *pdev)
 		return dev_err_probe(dsi->dev, PTR_ERR(dsi->prstc),
 				     "failed to get prst\n");
 
+	dsi->dcs_buf_virt = dmam_alloc_coherent(dsi->dev, RZG2L_DCS_BUF_SIZE,
+						&dsi->dcs_buf_phys, GFP_KERNEL);
+	if (!dsi->dcs_buf_virt)
+		return -ENOMEM;
+
 	platform_set_drvdata(pdev, dsi);
 
 	pm_runtime_enable(dsi->dev);
@@ -1474,11 +1479,6 @@ static int rzg2l_mipi_dsi_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto err_pm_disable;
 
-	dsi->dcs_buf_virt = dma_alloc_coherent(dsi->host.dev, RZG2L_DCS_BUF_SIZE,
-					       &dsi->dcs_buf_phys, GFP_KERNEL);
-	if (!dsi->dcs_buf_virt)
-		return -ENOMEM;
-
 	return 0;
 
 err_phy:
@@ -1493,8 +1493,6 @@ static void rzg2l_mipi_dsi_remove(struct platform_device *pdev)  {
 	struct rzg2l_mipi_dsi *dsi = platform_get_drvdata(pdev);
 
-	dma_free_coherent(dsi->host.dev, RZG2L_DCS_BUF_SIZE, dsi->dcs_buf_virt,
-			  dsi->dcs_buf_phys);
 	mipi_dsi_host_unregister(&dsi->host);
 	pm_runtime_disable(&pdev->dev);
 }
--

2.52.0