* [PATCH 1/6] drm/tegra: dsi: Fix some error handling paths in tegra_dsi_probe()
2023-09-02 15:22 [PATCH 0/6] drm/tegra: Fix some error handling paths Christophe JAILLET
@ 2023-09-02 15:22 ` Christophe JAILLET
2023-09-02 15:22 ` [PATCH 2/6] drm/tegra: dsi: Fix missing pm_runtime_disable() in the error handling path of tegra_dsi_probe() Christophe JAILLET
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Christophe JAILLET @ 2023-09-02 15:22 UTC (permalink / raw)
To: thierry.reding, mperttunen, airlied, daniel, jonathanh, digetx
Cc: dri-devel, linux-tegra, linux-kernel, kernel-janitors,
Christophe JAILLET
If an error occurs after calling tegra_output_probe(),
tegra_output_remove() should be called as already done in the remove
function.
Fixes: dec727399a4b ("drm/tegra: Add DSI support")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/gpu/drm/tegra/dsi.c | 54 ++++++++++++++++++++++++-------------
1 file changed, 35 insertions(+), 19 deletions(-)
diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c
index a9870c828374..70a77c75bfe1 100644
--- a/drivers/gpu/drm/tegra/dsi.c
+++ b/drivers/gpu/drm/tegra/dsi.c
@@ -1593,44 +1593,58 @@ static int tegra_dsi_probe(struct platform_device *pdev)
if (!pdev->dev.pm_domain) {
dsi->rst = devm_reset_control_get(&pdev->dev, "dsi");
- if (IS_ERR(dsi->rst))
- return PTR_ERR(dsi->rst);
+ if (IS_ERR(dsi->rst)) {
+ err = PTR_ERR(dsi->rst);
+ goto tegra_remove;
+ }
}
dsi->clk = devm_clk_get(&pdev->dev, NULL);
- if (IS_ERR(dsi->clk))
- return dev_err_probe(&pdev->dev, PTR_ERR(dsi->clk),
- "cannot get DSI clock\n");
+ if (IS_ERR(dsi->clk)) {
+ err = dev_err_probe(&pdev->dev, PTR_ERR(dsi->clk),
+ "cannot get DSI clock\n");
+ goto tegra_remove;
+ }
dsi->clk_lp = devm_clk_get(&pdev->dev, "lp");
- if (IS_ERR(dsi->clk_lp))
- return dev_err_probe(&pdev->dev, PTR_ERR(dsi->clk_lp),
- "cannot get low-power clock\n");
+ if (IS_ERR(dsi->clk_lp)) {
+ err = dev_err_probe(&pdev->dev, PTR_ERR(dsi->clk_lp),
+ "cannot get low-power clock\n");
+ goto tegra_remove;
+ }
dsi->clk_parent = devm_clk_get(&pdev->dev, "parent");
- if (IS_ERR(dsi->clk_parent))
- return dev_err_probe(&pdev->dev, PTR_ERR(dsi->clk_parent),
- "cannot get parent clock\n");
+ if (IS_ERR(dsi->clk_parent)) {
+ err = dev_err_probe(&pdev->dev, PTR_ERR(dsi->clk_parent),
+ "cannot get parent clock\n");
+ goto tegra_remove;
+ }
dsi->vdd = devm_regulator_get(&pdev->dev, "avdd-dsi-csi");
- if (IS_ERR(dsi->vdd))
- return dev_err_probe(&pdev->dev, PTR_ERR(dsi->vdd),
- "cannot get VDD supply\n");
+ if (IS_ERR(dsi->vdd)) {
+ err = dev_err_probe(&pdev->dev, PTR_ERR(dsi->vdd),
+ "cannot get VDD supply\n");
+ goto tegra_remove;
+ }
err = tegra_dsi_setup_clocks(dsi);
if (err < 0) {
dev_err(&pdev->dev, "cannot setup clocks\n");
- return err;
+ goto tegra_remove;
}
regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
dsi->regs = devm_ioremap_resource(&pdev->dev, regs);
- if (IS_ERR(dsi->regs))
- return PTR_ERR(dsi->regs);
+ if (IS_ERR(dsi->regs)) {
+ err = PTR_ERR(dsi->regs);
+ goto tegra_remove;
+ }
dsi->mipi = tegra_mipi_request(&pdev->dev, pdev->dev.of_node);
- if (IS_ERR(dsi->mipi))
- return PTR_ERR(dsi->mipi);
+ if (IS_ERR(dsi->mipi)) {
+ err = PTR_ERR(dsi->mipi);
+ goto tegra_remove;
+ }
dsi->host.ops = &tegra_dsi_host_ops;
dsi->host.dev = &pdev->dev;
@@ -1661,6 +1675,8 @@ static int tegra_dsi_probe(struct platform_device *pdev)
mipi_dsi_host_unregister(&dsi->host);
mipi_free:
tegra_mipi_free(dsi->mipi);
+tegra_remove:
+ tegra_output_remove(&dsi->output);
return err;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 2/6] drm/tegra: dsi: Fix missing pm_runtime_disable() in the error handling path of tegra_dsi_probe()
2023-09-02 15:22 [PATCH 0/6] drm/tegra: Fix some error handling paths Christophe JAILLET
2023-09-02 15:22 ` [PATCH 1/6] drm/tegra: dsi: Fix some error handling paths in tegra_dsi_probe() Christophe JAILLET
@ 2023-09-02 15:22 ` Christophe JAILLET
2023-09-02 15:22 ` [PATCH 3/6] drm/tegra: hdmi: Fix some error handling paths in tegra_hdmi_probe() Christophe JAILLET
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Christophe JAILLET @ 2023-09-02 15:22 UTC (permalink / raw)
To: thierry.reding, mperttunen, airlied, daniel, jonathanh, digetx
Cc: dri-devel, linux-tegra, linux-kernel, kernel-janitors,
Christophe JAILLET
If an error occurs after calling pm_runtime_enable(), pm_runtime_disable()
should be called as already done in the remove function.
Fixes: ef8187d75265 ("drm/tegra: dsi: Implement runtime PM")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/gpu/drm/tegra/dsi.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c
index 70a77c75bfe1..0cf379e20d89 100644
--- a/drivers/gpu/drm/tegra/dsi.c
+++ b/drivers/gpu/drm/tegra/dsi.c
@@ -1672,6 +1672,7 @@ static int tegra_dsi_probe(struct platform_device *pdev)
return 0;
unregister:
+ pm_runtime_disable(&pdev->dev);
mipi_dsi_host_unregister(&dsi->host);
mipi_free:
tegra_mipi_free(dsi->mipi);
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 3/6] drm/tegra: hdmi: Fix some error handling paths in tegra_hdmi_probe()
2023-09-02 15:22 [PATCH 0/6] drm/tegra: Fix some error handling paths Christophe JAILLET
2023-09-02 15:22 ` [PATCH 1/6] drm/tegra: dsi: Fix some error handling paths in tegra_dsi_probe() Christophe JAILLET
2023-09-02 15:22 ` [PATCH 2/6] drm/tegra: dsi: Fix missing pm_runtime_disable() in the error handling path of tegra_dsi_probe() Christophe JAILLET
@ 2023-09-02 15:22 ` Christophe JAILLET
2023-09-02 15:22 ` [PATCH 4/6] drm/tegra: rgb: Fix some error handling paths in tegra_dc_rgb_probe() Christophe JAILLET
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Christophe JAILLET @ 2023-09-02 15:22 UTC (permalink / raw)
To: thierry.reding, mperttunen, airlied, daniel, jonathanh, digetx
Cc: dri-devel, linux-tegra, linux-kernel, kernel-janitors,
Christophe JAILLET
If an error occurs after calling tegra_output_probe(),
tegra_output_remove() should be called as already done in the remove
function.
Fixes: 59d29c0ec93f ("drm/tegra: Allocate resources at probe time")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/gpu/drm/tegra/hdmi.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c
index 80c760986d9e..c73e7fb1877e 100644
--- a/drivers/gpu/drm/tegra/hdmi.c
+++ b/drivers/gpu/drm/tegra/hdmi.c
@@ -1854,12 +1854,14 @@ static int tegra_hdmi_probe(struct platform_device *pdev)
return err;
hdmi->regs = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(hdmi->regs))
- return PTR_ERR(hdmi->regs);
+ if (IS_ERR(hdmi->regs)) {
+ err = PTR_ERR(hdmi->regs);
+ goto tegra_remove;
+ }
err = platform_get_irq(pdev, 0);
if (err < 0)
- return err;
+ goto tegra_remove;
hdmi->irq = err;
@@ -1868,18 +1870,18 @@ static int tegra_hdmi_probe(struct platform_device *pdev)
if (err < 0) {
dev_err(&pdev->dev, "failed to request IRQ#%u: %d\n",
hdmi->irq, err);
- return err;
+ goto tegra_remove;
}
platform_set_drvdata(pdev, hdmi);
err = devm_pm_runtime_enable(&pdev->dev);
if (err)
- return err;
+ goto tegra_remove;
err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev);
if (err)
- return err;
+ goto tegra_remove;
INIT_LIST_HEAD(&hdmi->client.list);
hdmi->client.ops = &hdmi_client_ops;
@@ -1889,10 +1891,14 @@ static int tegra_hdmi_probe(struct platform_device *pdev)
if (err < 0) {
dev_err(&pdev->dev, "failed to register host1x client: %d\n",
err);
- return err;
+ goto tegra_remove;
}
return 0;
+
+tegra_remove:
+ tegra_output_remove(&hdmi->output);
+ return err;
}
static void tegra_hdmi_remove(struct platform_device *pdev)
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 4/6] drm/tegra: rgb: Fix some error handling paths in tegra_dc_rgb_probe()
2023-09-02 15:22 [PATCH 0/6] drm/tegra: Fix some error handling paths Christophe JAILLET
` (2 preceding siblings ...)
2023-09-02 15:22 ` [PATCH 3/6] drm/tegra: hdmi: Fix some error handling paths in tegra_hdmi_probe() Christophe JAILLET
@ 2023-09-02 15:22 ` Christophe JAILLET
2023-09-02 15:22 ` [PATCH 5/6] drm/tegra: rgb: Fix missing clk_put() in the error handling paths of tegra_dc_rgb_probe() Christophe JAILLET
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Christophe JAILLET @ 2023-09-02 15:22 UTC (permalink / raw)
To: thierry.reding, mperttunen, airlied, daniel, jonathanh, digetx
Cc: dri-devel, linux-tegra, linux-kernel, kernel-janitors,
Christophe JAILLET
If an error occurs after calling tegra_output_probe(),
tegra_output_remove() should be called as already done in the remove
function.
Fixes: 59d29c0ec93f ("drm/tegra: Allocate resources at probe time")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/gpu/drm/tegra/rgb.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
index 79566c9ea8ff..26d4d87b83de 100644
--- a/drivers/gpu/drm/tegra/rgb.c
+++ b/drivers/gpu/drm/tegra/rgb.c
@@ -215,26 +215,28 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc)
rgb->clk = devm_clk_get(dc->dev, NULL);
if (IS_ERR(rgb->clk)) {
dev_err(dc->dev, "failed to get clock\n");
- return PTR_ERR(rgb->clk);
+ err = PTR_ERR(rgb->clk);
+ goto tegra_remove;
}
rgb->clk_parent = devm_clk_get(dc->dev, "parent");
if (IS_ERR(rgb->clk_parent)) {
dev_err(dc->dev, "failed to get parent clock\n");
- return PTR_ERR(rgb->clk_parent);
+ err = PTR_ERR(rgb->clk_parent);
+ goto tegra_remove;
}
err = clk_set_parent(rgb->clk, rgb->clk_parent);
if (err < 0) {
dev_err(dc->dev, "failed to set parent clock: %d\n", err);
- return err;
+ goto tegra_remove;
}
rgb->pll_d_out0 = clk_get_sys(NULL, "pll_d_out0");
if (IS_ERR(rgb->pll_d_out0)) {
err = PTR_ERR(rgb->pll_d_out0);
dev_err(dc->dev, "failed to get pll_d_out0: %d\n", err);
- return err;
+ goto tegra_remove;
}
if (dc->soc->has_pll_d2_out0) {
@@ -242,13 +244,17 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc)
if (IS_ERR(rgb->pll_d2_out0)) {
err = PTR_ERR(rgb->pll_d2_out0);
dev_err(dc->dev, "failed to get pll_d2_out0: %d\n", err);
- return err;
+ goto tegra_remove;
}
}
dc->rgb = &rgb->output;
return 0;
+
+tegra_remove:
+ tegra_output_remove(&rgb->output);
+ return err;
}
void tegra_dc_rgb_remove(struct tegra_dc *dc)
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 5/6] drm/tegra: rgb: Fix missing clk_put() in the error handling paths of tegra_dc_rgb_probe()
2023-09-02 15:22 [PATCH 0/6] drm/tegra: Fix some error handling paths Christophe JAILLET
` (3 preceding siblings ...)
2023-09-02 15:22 ` [PATCH 4/6] drm/tegra: rgb: Fix some error handling paths in tegra_dc_rgb_probe() Christophe JAILLET
@ 2023-09-02 15:22 ` Christophe JAILLET
2023-09-02 15:22 ` [PATCH 6/6] drm/tegra: output: Fix missing i2c_put_adapter() in the error handling paths of tegra_output_probe() Christophe JAILLET
2023-12-14 17:40 ` [PATCH 0/6] drm/tegra: Fix some error handling paths Thierry Reding
6 siblings, 0 replies; 8+ messages in thread
From: Christophe JAILLET @ 2023-09-02 15:22 UTC (permalink / raw)
To: thierry.reding, mperttunen, airlied, daniel, jonathanh, digetx
Cc: dri-devel, linux-tegra, linux-kernel, kernel-janitors,
Christophe JAILLET
If clk_get_sys(..., "pll_d2_out0") fails, the clk_get_sys() call must be
undone.
Add the missing clk_put and a new 'put_pll_d_out0' label in the error
handling path, and use it.
Fixes: 0c921b6d4ba0 ("drm/tegra: dc: rgb: Allow changing PLLD rate on Tegra30+")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/gpu/drm/tegra/rgb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
index 26d4d87b83de..e277826ab494 100644
--- a/drivers/gpu/drm/tegra/rgb.c
+++ b/drivers/gpu/drm/tegra/rgb.c
@@ -244,7 +244,7 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc)
if (IS_ERR(rgb->pll_d2_out0)) {
err = PTR_ERR(rgb->pll_d2_out0);
dev_err(dc->dev, "failed to get pll_d2_out0: %d\n", err);
- goto tegra_remove;
+ goto put_pll_d_out0;
}
}
@@ -252,6 +252,8 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc)
return 0;
+put_pll_d_out0:
+ clk_put(rgb->pll_d_out0);
tegra_remove:
tegra_output_remove(&rgb->output);
return err;
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 6/6] drm/tegra: output: Fix missing i2c_put_adapter() in the error handling paths of tegra_output_probe()
2023-09-02 15:22 [PATCH 0/6] drm/tegra: Fix some error handling paths Christophe JAILLET
` (4 preceding siblings ...)
2023-09-02 15:22 ` [PATCH 5/6] drm/tegra: rgb: Fix missing clk_put() in the error handling paths of tegra_dc_rgb_probe() Christophe JAILLET
@ 2023-09-02 15:22 ` Christophe JAILLET
2023-12-14 17:40 ` [PATCH 0/6] drm/tegra: Fix some error handling paths Thierry Reding
6 siblings, 0 replies; 8+ messages in thread
From: Christophe JAILLET @ 2023-09-02 15:22 UTC (permalink / raw)
To: thierry.reding, mperttunen, airlied, daniel, jonathanh, digetx
Cc: dri-devel, linux-tegra, linux-kernel, kernel-janitors,
Christophe JAILLET
If an error occurs after a successful of_get_i2c_adapter_by_node() call, it
should be undone by a corresponding i2c_put_adapter().
Add the missing i2c_put_adapter() call.
Fixes: 9be7d864cf07 ("drm/tegra: Implement panel support")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/gpu/drm/tegra/output.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c
index dc2dcb5ca1c8..d7d2389ac2f5 100644
--- a/drivers/gpu/drm/tegra/output.c
+++ b/drivers/gpu/drm/tegra/output.c
@@ -142,8 +142,10 @@ int tegra_output_probe(struct tegra_output *output)
GPIOD_IN,
"HDMI hotplug detect");
if (IS_ERR(output->hpd_gpio)) {
- if (PTR_ERR(output->hpd_gpio) != -ENOENT)
- return PTR_ERR(output->hpd_gpio);
+ if (PTR_ERR(output->hpd_gpio) != -ENOENT) {
+ err = PTR_ERR(output->hpd_gpio);
+ goto put_i2c;
+ }
output->hpd_gpio = NULL;
}
@@ -152,7 +154,7 @@ int tegra_output_probe(struct tegra_output *output)
err = gpiod_to_irq(output->hpd_gpio);
if (err < 0) {
dev_err(output->dev, "gpiod_to_irq(): %d\n", err);
- return err;
+ goto put_i2c;
}
output->hpd_irq = err;
@@ -165,7 +167,7 @@ int tegra_output_probe(struct tegra_output *output)
if (err < 0) {
dev_err(output->dev, "failed to request IRQ#%u: %d\n",
output->hpd_irq, err);
- return err;
+ goto put_i2c;
}
output->connector.polled = DRM_CONNECTOR_POLL_HPD;
@@ -179,6 +181,12 @@ int tegra_output_probe(struct tegra_output *output)
}
return 0;
+
+put_i2c:
+ if (output->ddc)
+ i2c_put_adapter(output->ddc);
+
+ return err;
}
void tegra_output_remove(struct tegra_output *output)
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 0/6] drm/tegra: Fix some error handling paths
2023-09-02 15:22 [PATCH 0/6] drm/tegra: Fix some error handling paths Christophe JAILLET
` (5 preceding siblings ...)
2023-09-02 15:22 ` [PATCH 6/6] drm/tegra: output: Fix missing i2c_put_adapter() in the error handling paths of tegra_output_probe() Christophe JAILLET
@ 2023-12-14 17:40 ` Thierry Reding
6 siblings, 0 replies; 8+ messages in thread
From: Thierry Reding @ 2023-12-14 17:40 UTC (permalink / raw)
To: Christophe JAILLET
Cc: mperttunen, airlied, daniel, jonathanh, digetx, dri-devel,
linux-tegra, linux-kernel, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1468 bytes --]
On Sat, Sep 02, 2023 at 05:22:07PM +0200, Christophe JAILLET wrote:
> Most of the patches are retated to tegra_output_probe() and missing
> tegra_output_remove(). Others are things spotted while writting the serie.
>
>
> Patches 1, 3, 4 are verbose, but some functions called in the probe can
> return -EPROBE_DEFER, so it is nice to correctly release resources.
>
> Maybe moving the tegra_output_probe() call would minimize the changes, but I'm
> always reluctant to move code, because of possible side-effects.
>
>
> Christophe JAILLET (6):
> drm/tegra: dsi: Fix some error handling paths in tegra_dsi_probe()
> drm/tegra: dsi: Fix missing pm_runtime_disable() in the error handling
> path of tegra_dsi_probe()
> drm/tegra: dsi: Fix some error handling paths in tegra_hdmi_probe()
> drm/tegra: rgb: Fix some error handling paths in tegra_dc_rgb_probe()
> drm/tegra: rgb: Fix missing clk_put() in the error handling paths of
> tegra_dc_rgb_probe()
> drm/tegra: output: Fix missing i2c_put_adapter() in the error handling
> paths of tegra_output_probe()
>
> drivers/gpu/drm/tegra/dsi.c | 55 ++++++++++++++++++++++------------
> drivers/gpu/drm/tegra/hdmi.c | 20 ++++++++-----
> drivers/gpu/drm/tegra/output.c | 16 +++++++---
> drivers/gpu/drm/tegra/rgb.c | 18 +++++++----
> 4 files changed, 74 insertions(+), 35 deletions(-)
Sorry, this fell through the cracks. Applied now, thanks.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread