mirror of
git://git.openwrt.org/openwrt/openwrt.git
synced 2024-12-23 07:03:44 +00:00
146 lines
4.2 KiB
Diff
146 lines
4.2 KiB
Diff
|
From 51f5523151d8de2b1476482e575bb5989e55ba16 Mon Sep 17 00:00:00 2001
|
||
|
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||
|
Date: Tue, 6 Jul 2021 18:53:28 +0100
|
||
|
Subject: [PATCH] drm/vc4: Release workaround buffer and DMA in error
|
||
|
paths and unbind
|
||
|
|
||
|
On Pi0-3 the driver allocates a buffer and requests a DMA channel
|
||
|
because the ARM can't write to DSI1's registers directly.
|
||
|
However unbind and the error paths in bind don't release the buffer or
|
||
|
the DMA channel.
|
||
|
|
||
|
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||
|
---
|
||
|
drivers/gpu/drm/vc4/vc4_dsi.c | 51 ++++++++++++++++++++++++++---------
|
||
|
1 file changed, 39 insertions(+), 12 deletions(-)
|
||
|
|
||
|
--- a/drivers/gpu/drm/vc4/vc4_dsi.c
|
||
|
+++ b/drivers/gpu/drm/vc4/vc4_dsi.c
|
||
|
@@ -1612,7 +1612,7 @@ static int vc4_dsi_bind(struct device *d
|
||
|
if (ret != -EPROBE_DEFER)
|
||
|
DRM_ERROR("Failed to get DMA channel: %d\n",
|
||
|
ret);
|
||
|
- return ret;
|
||
|
+ goto err_free_dma_mem;
|
||
|
}
|
||
|
|
||
|
/* Get the physical address of the device's registers. The
|
||
|
@@ -1641,7 +1641,7 @@ static int vc4_dsi_bind(struct device *d
|
||
|
if (ret) {
|
||
|
if (ret != -EPROBE_DEFER)
|
||
|
dev_err(dev, "Failed to get interrupt: %d\n", ret);
|
||
|
- return ret;
|
||
|
+ goto err_free_dma;
|
||
|
}
|
||
|
|
||
|
dsi->escape_clock = devm_clk_get(dev, "escape");
|
||
|
@@ -1649,7 +1649,7 @@ static int vc4_dsi_bind(struct device *d
|
||
|
ret = PTR_ERR(dsi->escape_clock);
|
||
|
if (ret != -EPROBE_DEFER)
|
||
|
dev_err(dev, "Failed to get escape clock: %d\n", ret);
|
||
|
- return ret;
|
||
|
+ goto err_free_dma;
|
||
|
}
|
||
|
|
||
|
dsi->pll_phy_clock = devm_clk_get(dev, "phy");
|
||
|
@@ -1657,7 +1657,7 @@ static int vc4_dsi_bind(struct device *d
|
||
|
ret = PTR_ERR(dsi->pll_phy_clock);
|
||
|
if (ret != -EPROBE_DEFER)
|
||
|
dev_err(dev, "Failed to get phy clock: %d\n", ret);
|
||
|
- return ret;
|
||
|
+ goto err_free_dma;
|
||
|
}
|
||
|
|
||
|
dsi->pixel_clock = devm_clk_get(dev, "pixel");
|
||
|
@@ -1665,7 +1665,7 @@ static int vc4_dsi_bind(struct device *d
|
||
|
ret = PTR_ERR(dsi->pixel_clock);
|
||
|
if (ret != -EPROBE_DEFER)
|
||
|
dev_err(dev, "Failed to get pixel clock: %d\n", ret);
|
||
|
- return ret;
|
||
|
+ goto err_free_dma;
|
||
|
}
|
||
|
|
||
|
ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0,
|
||
|
@@ -1680,33 +1680,37 @@ static int vc4_dsi_bind(struct device *d
|
||
|
if (ret == -ENODEV)
|
||
|
return 0;
|
||
|
|
||
|
- return ret;
|
||
|
+ goto err_free_dma;
|
||
|
}
|
||
|
|
||
|
if (panel) {
|
||
|
dsi->bridge = devm_drm_panel_bridge_add_typed(dev, panel,
|
||
|
DRM_MODE_CONNECTOR_DSI);
|
||
|
- if (IS_ERR(dsi->bridge))
|
||
|
- return PTR_ERR(dsi->bridge);
|
||
|
+ if (IS_ERR(dsi->bridge)) {
|
||
|
+ ret = PTR_ERR(dsi->bridge);
|
||
|
+ goto err_free_dma;
|
||
|
+ }
|
||
|
}
|
||
|
|
||
|
/* The esc clock rate is supposed to always be 100Mhz. */
|
||
|
ret = clk_set_rate(dsi->escape_clock, 100 * 1000000);
|
||
|
if (ret) {
|
||
|
dev_err(dev, "Failed to set esc clock: %d\n", ret);
|
||
|
- return ret;
|
||
|
+ goto err_free_dma;
|
||
|
}
|
||
|
|
||
|
ret = vc4_dsi_init_phy_clocks(dsi);
|
||
|
if (ret)
|
||
|
- return ret;
|
||
|
+ goto err_free_dma;
|
||
|
|
||
|
drm_simple_encoder_init(drm, dsi->encoder, DRM_MODE_ENCODER_DSI);
|
||
|
drm_encoder_helper_add(dsi->encoder, &vc4_dsi_encoder_helper_funcs);
|
||
|
|
||
|
ret = drm_bridge_attach(dsi->encoder, dsi->bridge, NULL, 0);
|
||
|
- if (ret)
|
||
|
- return ret;
|
||
|
+ if (ret) {
|
||
|
+ dev_err(dev, "bridge attach failed: %d\n", ret);
|
||
|
+ goto err_free_dma;
|
||
|
+ }
|
||
|
/* Disable the atomic helper calls into the bridge. We
|
||
|
* manually call the bridge pre_enable / enable / etc. calls
|
||
|
* from our driver, since we need to sequence them within the
|
||
|
@@ -1719,6 +1723,19 @@ static int vc4_dsi_bind(struct device *d
|
||
|
pm_runtime_enable(dev);
|
||
|
|
||
|
return 0;
|
||
|
+
|
||
|
+err_free_dma:
|
||
|
+ if (dsi->reg_dma_chan) {
|
||
|
+ dma_release_channel(dsi->reg_dma_chan);
|
||
|
+ dsi->reg_dma_chan = NULL;
|
||
|
+ }
|
||
|
+err_free_dma_mem:
|
||
|
+ if (dsi->reg_dma_mem) {
|
||
|
+ dma_free_coherent(dev, 4, dsi->reg_dma_mem, dsi->reg_dma_paddr);
|
||
|
+ dsi->reg_dma_mem = NULL;
|
||
|
+ }
|
||
|
+
|
||
|
+ return ret;
|
||
|
}
|
||
|
|
||
|
static void vc4_dsi_unbind(struct device *dev, struct device *master,
|
||
|
@@ -1735,6 +1752,16 @@ static void vc4_dsi_unbind(struct device
|
||
|
*/
|
||
|
list_splice_init(&dsi->bridge_chain, &dsi->encoder->bridge_chain);
|
||
|
drm_encoder_cleanup(dsi->encoder);
|
||
|
+
|
||
|
+ if (dsi->reg_dma_chan) {
|
||
|
+ dma_release_channel(dsi->reg_dma_chan);
|
||
|
+ dsi->reg_dma_chan = NULL;
|
||
|
+ }
|
||
|
+
|
||
|
+ if (dsi->reg_dma_mem) {
|
||
|
+ dma_free_coherent(dev, 4, dsi->reg_dma_mem, dsi->reg_dma_paddr);
|
||
|
+ dsi->reg_dma_mem = NULL;
|
||
|
+ }
|
||
|
}
|
||
|
|
||
|
static const struct component_ops vc4_dsi_ops = {
|