drm/sti: remove bridge when sti_hda component_add fails
Subsystems (8)
PATCH v3 1/3 drm/sti: remove bridge when sti_hda component_add fails
Use devm_drm_bridge_add() so the bridge is released if probe fails after registration, and drop the manual drm_bridge_remove() in remove().
Check the return value of devm_drm_bridge_add().
---
v3: add Fixes and Cc tags
v2: devm_drm_bridge_add instead of drm_bridge_add + goto remove_bridge
--- drivers/gpu/drm/sti/sti_hda.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/sti/sti_hda.c +4 -4
@@ -741,6 +741,7 @@ static int sti_hda_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct sti_hda *hda;struct resource *res; +int ret;DRM_INFO ("%s\n" , __func__);
@@ -779,7 +780,9 @@ static int sti_hda_probe(struct platform_device *pdev)return PTR_ERR (hda->clk_hddac); } -drm_bridge_add (&hda->bridge); + ret =devm_drm_bridge_add (dev, &hda->bridge); +if (ret) +return ret;platform_set_drvdata (pdev, hda);
@@ -788,10 +791,7 @@ static int sti_hda_probe(struct platform_device *pdev)static void sti_hda_remove (struct platform_device *pdev) { -struct sti_hda *hda =platform_get_drvdata (pdev); -component_del (&pdev->dev, &sti_hda_ops); -drm_bridge_remove (&hda->bridge); }static const struct of_device_id hda_of_match[] = {
Signature · 1 line
2.43.0
PATCH v3 2/3 drm/exynos: remove bridge when component_add fails
Use devm_drm_bridge_add() so the bridge is released if probe fails after registration, and drop the manual drm_bridge_remove() in remove().
Check the return value of devm_drm_bridge_add().
---
v3: add Fixes and Cc tags
v2: devm_drm_bridge_add instead of drm_bridge_add + goto remove_bridge
--- drivers/gpu/drm/exynos/exynos_drm_mic.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_mic.c +3 -5
@@ -423,7 +423,9 @@ static int exynos_mic_probe(struct platform_device *pdev) mic->bridge.of_node = dev->of_node; -drm_bridge_add (&mic->bridge); + ret =devm_drm_bridge_add (dev, &mic->bridge); +if (ret) + goto err;pm_runtime_enable (dev);
@@ -443,12 +445,8 @@ static int exynos_mic_probe(struct platform_device *pdev)static void exynos_mic_remove (struct platform_device *pdev) { -struct exynos_mic *mic =platform_get_drvdata (pdev); -component_del (&pdev->dev, &exynos_mic_component_ops);pm_runtime_disable (&pdev->dev); - -drm_bridge_remove (&mic->bridge); }static const struct of_device_id exynos_mic_of_match[] = {
Signature · 1 line
2.43.0
Re: [PATCH v3 2/3] drm/exynos: remove bridge when component_add fails
Quoted 8 lines · Osama Abdelkader
Use
devm_drm_bridge_add()so the bridge is released if probe fails after registration, and drop the manualdrm_bridge_remove()inremove().Check the return value of
devm_drm_bridge_add().Signed-off-by Osama Abdelkader <[email protected]>Fixes 576d72fbfb45 ("drm/exynos: mic: add a bridge at probe")
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Re: [PATCH v3 2/3] drm/exynos: remove bridge when component_add fails
In reply to Osama AbdelkaderQuoted 5 lines · Osama Abdelkader
Use
devm_drm_bridge_add()so the bridge is released if probe fails after registration, and drop the manualdrm_bridge_remove()inremove().Check the return value of
devm_drm_bridge_add().
Quoted 7 lines
Signed-off-by Osama Abdelkader <[email protected]>Fixes 576d72fbfb45 ("drm/exynos: mic: add a bridge at probe")---
v3: add Fixes and Cc tags
v2:devm_drm_bridge_addinstead ofdrm_bridge_add+ gotoremove_bridge
---
Hi,
Best regards,
Raphaël
PATCH v3 3/3 drm/bridge: megachips: remove bridge when irq request fails
In reply to Osama AbdelkaderIf devm_request_threaded_irq() fails after drm_bridge_add(), remove the bridge before returning.
Keep drm_bridge_add() rather than devm_drm_bridge_add(): registration is tied to the STDP4028 device while ge_b850v3_register() may complete from either I2C probe; devm would not unwind the bridge if the other client's probe fails.
---
v3: add Fixes and Cc tags
v2: IRQ failure path only (explicit drm_bridge_remove)
--- .../drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c +10 -6
@@ -251,7 +251,6 @@ static void ge_b850v3_lvds_remove(void) goto out;drm_bridge_remove (&ge_b850v3_lvds_ptr->bridge); - ge_b850v3_lvds_ptr =NULL ; out:mutex_unlock (&ge_b850v3_lvds_dev_mutex);
@@ -261,6 +260,7 @@ static int ge_b850v3_register(void) {struct i2c_client *stdp4028_i2c = ge_b850v3_lvds_ptr->stdp4028_i2c;struct device *dev = &stdp4028_i2c->dev; +int ret;/* drm bridge initialization */ ge_b850v3_lvds_ptr->bridge.ops = DRM_BRIDGE_OP_DETECT |
@@ -277,11 +277,15 @@ static int ge_b850v3_register(void)if (!stdp4028_i2c->irq)return 0 ; -return devm_request_threaded_irq (&stdp4028_i2c->dev, - stdp4028_i2c->irq,NULL , - ge_b850v3_lvds_irq_handler, -IRQF_TRIGGER_HIGH |IRQF_ONESHOT , -"ge-b850v3-lvds-dp" , ge_b850v3_lvds_ptr); + ret =devm_request_threaded_irq (&stdp4028_i2c->dev, + stdp4028_i2c->irq,NULL , + ge_b850v3_lvds_irq_handler, +IRQF_TRIGGER_HIGH |IRQF_ONESHOT , +"ge-b850v3-lvds-dp" , ge_b850v3_lvds_ptr); +if (ret) +drm_bridge_remove (&ge_b850v3_lvds_ptr->bridge); + +return ret; }static int stdp4028_ge_b850v3_fw_probe (struct i2c_client *stdp4028_i2c)
Signature · 1 line
2.43.0
Luca Ceresoli
reviewerRe: [PATCH v3 3/3] drm/bridge: megachips: remove bridge when irq request fails
Quoted 10 lines · Osama Abdelkader
If
devm_request_threaded_irq()fails afterdrm_bridge_add(), remove the bridge before returning.Keep
drm_bridge_add()rather thandevm_drm_bridge_add(): registration is tied to the STDP4028 device whilege_b850v3_register()may complete from either I2C probe; devm would not unwind the bridge if the other client's probe fails.Signed-off-by Osama Abdelkader <[email protected]>Fixes a68ee76f4a28 ("drm/bridge: megachips-stdpxxxx-ge-b850v3-fw: Fix bridge initialization")
That commit only moved the bug to a slightly different location. The bug was present even before, since commit fcfa0ddc18ed ("drm/bridge: Drivers for megachips-stdpxxxx-ge-b850v3-fw (LVDS-DP++)"), so you should update your Fixes line to point to it.
Quoted 34 lines
---
v3: add Fixes and Cc tags
v2: IRQ failure path only (explicitdrm_bridge_remove)--- .../drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c +1
-3@@ -251,7 +251,6 @@ static void ge_b850v3_lvds_remove(void) goto out;drm_bridge_remove (&ge_b850v3_lvds_ptr->bridge); - ge_b850v3_lvds_ptr =NULL ; out:mutex_unlock (&ge_b850v3_lvds_dev_mutex);@@ -261,6 +260,7 @@ static int ge_b850v3_register(void) {struct i2c_client *stdp4028_i2c = ge_b850v3_lvds_ptr->stdp4028_i2c;struct device *dev = &stdp4028_i2c->dev; +int ret;/* drm bridge initialization */ ge_b850v3_lvds_ptr->bridge.ops = DRM_BRIDGE_OP_DETECT |@@ -277,11 +277,15 @@ static int ge_b850v3_register(void)if (!stdp4028_i2c->irq)return 0 ; - return devm_request_threaded_irq(&stdp4028_i2c->dev, - stdp4028_i2c->irq, NULL,
drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c static int ge_b850v3_register(void) · line 286
Quoted 10 lines
drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c +7
-3- ge_b850v3_lvds_irq_handler, -IRQF_TRIGGER_HIGH |IRQF_ONESHOT , - "ge-b850v3-lvds-dp", ge_b850v3_lvds_ptr); + ret =devm_request_threaded_irq (&stdp4028_i2c->dev, + stdp4028_i2c->irq,NULL , + ge_b850v3_lvds_irq_handler, +IRQF_TRIGGER_HIGH |IRQF_ONESHOT , +"ge-b850v3-lvds-dp" , ge_b850v3_lvds_ptr); +if (ret) +drm_bridge_remove (&ge_b850v3_lvds_ptr->bridge);
Why not just using devm_drm_bridge_add() and keep everything else clean, as you did in other patches in the series?
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Re: [PATCH v3 3/3] drm/bridge: megachips: remove bridge when irq request fails
Hello Luca,
Quoted 9 lines · Luca Ceresoli
Quoted 8 lines · Osama Abdelkader
If
devm_request_threaded_irq()fails afterdrm_bridge_add(), remove the bridge before returning.Keep
drm_bridge_add()rather thandevm_drm_bridge_add(): registration is tied to the STDP4028 device whilege_b850v3_register()may complete from either I2C probe; devm would not unwind the bridge if the other client's probe fails.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Osama Abdelkader <[email protected]>Fixes a68ee76f4a28 ("drm/bridge: megachips-stdpxxxx-ge-b850v3-fw: Fix bridge initialization")That commit only moved the bug to a slightly different location. The bug was present even before, since commit
fcfa0ddc18ed("drm/bridge: Drivers for megachips-stdpxxxx-ge-b850v3-fw (LVDS-DP++)"), so you should update your Fixes line to point to it.
Updated in v4, thanks.
Quoted 34 lines
Quoted 34 lines
---
v3: add Fixes and Cc tags
v2: IRQ failure path only (explicitdrm_bridge_remove)--- .../drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c +1
-1@@ -251,7 +251,6 @@ static void ge_b850v3_lvds_remove(void) goto out;drm_bridge_remove (&ge_b850v3_lvds_ptr->bridge); - ge_b850v3_lvds_ptr =NULL ; out:mutex_unlock (&ge_b850v3_lvds_dev_mutex);@@ -261,6 +260,7 @@ static int ge_b850v3_register(void) {struct i2c_client *stdp4028_i2c = ge_b850v3_lvds_ptr->stdp4028_i2c;struct device *dev = &stdp4028_i2c->dev; +int ret;/* drm bridge initialization */ ge_b850v3_lvds_ptr->bridge.ops = DRM_BRIDGE_OP_DETECT |@@ -277,11 +277,15 @@ static int ge_b850v3_register(void)if (!stdp4028_i2c->irq)return 0 ;
Quoted 15 lines
drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c static int ge_b850v3_register(void) · line 286
Quoted 12 lines
drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c +7
-5-return devm_request_threaded_irq (&stdp4028_i2c->dev, - stdp4028_i2c->irq,NULL , - ge_b850v3_lvds_irq_handler, -IRQF_TRIGGER_HIGH |IRQF_ONESHOT , -"ge-b850v3-lvds-dp" , ge_b850v3_lvds_ptr); + ret =devm_request_threaded_irq (&stdp4028_i2c->dev, + stdp4028_i2c->irq,NULL , + ge_b850v3_lvds_irq_handler, +IRQF_TRIGGER_HIGH |IRQF_ONESHOT , +"ge-b850v3-lvds-dp" , ge_b850v3_lvds_ptr); +if (ret) +drm_bridge_remove (&ge_b850v3_lvds_ptr->bridge);Why not just using
devm_drm_bridge_add()and keep everything else clean, as you did in other patches in the series?
Because registration is tied to the STDP4028 device while ge_b850v3_register() may complete from either I2C probe; so devm would not unwind the bridge if the other client's probe fails.
Quoted 7 lines
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Quoted 8 lines · Osama Abdelkader
Use
devm_drm_bridge_add()so the bridge is released if probe fails after registration, and drop the manualdrm_bridge_remove()inremove().Check the return value of
devm_drm_bridge_add().Signed-off-by Osama Abdelkader <[email protected]>Fixes d28726efc637 ("drm/sti: hda: add bridge before attaching")
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Quoted 9 lines · Osama Abdelkader
Use
devm_drm_bridge_add()so the bridge is released if probe fails after registration, and drop the manualdrm_bridge_remove()inremove().Check the return value of
devm_drm_bridge_add().Signed-off-by Osama Abdelkader <[email protected]>Fixes d28726efc637 ("drm/sti: hda: add bridge before attaching")---
Hi Osama,
Thanks,
Best regards,
Raphaël
Raphael Gallais-Pou
AppliedQuoted 6 lines · Osama Abdelkader
Use
devm_drm_bridge_add()so the bridge is released if probe fails after registration, and drop the manualdrm_bridge_remove()inremove().Check the return value of
devm_drm_bridge_add().
Applied, thanks!
[1/3] drm/sti: remove bridge when sti_hda component_add fails
commit: 84ae1840260fece9b6b70d3872b79384bbe5a90b
Best regards,
Signature · 1 line
Raphael Gallais-Pou <[email protected]>
Re: (subset) [PATCH v3 1/3] drm/sti: remove bridge when sti_hda component_add fails
In reply to Osama AbdelkaderQuoted 4 lines · Osama Abdelkader
Use
devm_drm_bridge_add()so the bridge is released if probe fails after registration, and drop the manualdrm_bridge_remove()inremove().Check the return value of
devm_drm_bridge_add().
Applied, thanks!
[2/3] drm/exynos: remove bridge when component_add fails
commit: 26f6654a9a60eb4d241f42a0ec85412e8821480b
Best regards,
Signature · 1 line
Luca Ceresoli <[email protected]>