Skip to content

Commit 533e346

Browse files
testacegiChun-Kuang Hu
authored andcommitted
drm/mediatek: ovl_adaptor: balance component registrations
The OVL adaptor registers both an aggregate driver for its child devices and a component for the main DRM aggregate. Probe currently ignores an error from registering the child aggregate and leaves that aggregate registered if registering the DRM component fails. The remove callback also leaves the DRM component registered. These imbalances can leave component framework entries referring to a device whose probe failed or whose driver has been detached. The aggregate unbind callback also fails to undo component_bind_all(), leaving its child components marked as bound when the aggregate is removed. Check the aggregate registration result, unwind it when the component registration fails, and unregister the component before the aggregate on remove. Keep runtime PM enabled until both framework registrations have been removed, and unbind all child components from the aggregate unbind callback. Fixes: 453c336 ("drm/mediatek: Add ovl_adaptor support for MT8195") Cc: stable@vger.kernel.org # 6.4+ Co-developed-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Myeonghun Pak <mhun512@gmail.com> Reviewed-by: CK Hu <ck.hu@mediatek.com> Link: https://patchwork.kernel.org/project/linux-mediatek/patch/20260721152242.47138-1-mhun512@gmail.com/ Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
1 parent 3e191ed commit 533e346

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,7 @@ static void mtk_disp_ovl_adaptor_master_unbind(struct device *dev)
625625
struct mtk_disp_ovl_adaptor *priv = dev_get_drvdata(dev);
626626

627627
priv->children_bound = false;
628+
component_unbind_all(dev, priv->mmsys_dev);
628629
}
629630

630631
static const struct component_master_ops mtk_disp_ovl_adaptor_master_ops = {
@@ -651,12 +652,15 @@ static int mtk_disp_ovl_adaptor_probe(struct platform_device *pdev)
651652

652653
priv->mmsys_dev = pdev->dev.platform_data;
653654

654-
component_master_add_with_match(dev, &mtk_disp_ovl_adaptor_master_ops, match);
655+
ret = component_master_add_with_match(dev, &mtk_disp_ovl_adaptor_master_ops, match);
656+
if (ret)
657+
return dev_err_probe(dev, ret, "Failed to add component master\n");
655658

656659
pm_runtime_enable(dev);
657660

658661
ret = component_add(dev, &mtk_disp_ovl_adaptor_comp_ops);
659662
if (ret != 0) {
663+
component_master_del(dev, &mtk_disp_ovl_adaptor_master_ops);
660664
pm_runtime_disable(dev);
661665
return dev_err_probe(dev, ret, "Failed to add component\n");
662666
}
@@ -666,6 +670,7 @@ static int mtk_disp_ovl_adaptor_probe(struct platform_device *pdev)
666670

667671
static void mtk_disp_ovl_adaptor_remove(struct platform_device *pdev)
668672
{
673+
component_del(&pdev->dev, &mtk_disp_ovl_adaptor_comp_ops);
669674
component_master_del(&pdev->dev, &mtk_disp_ovl_adaptor_master_ops);
670675
pm_runtime_disable(&pdev->dev);
671676
}

0 commit comments

Comments
 (0)