Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4170022ybe; Mon, 16 Sep 2019 07:49:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeABeA+fxGrzGdFg5mqZVc2vYiTbEwsmoRbr5YtGlYszOPEp/GmoajbQM4K0S48QDBQhDB X-Received: by 2002:a50:c3c7:: with SMTP id i7mr7176788edf.138.1568645365218; Mon, 16 Sep 2019 07:49:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568645365; cv=none; d=google.com; s=arc-20160816; b=qC9kkQJFIVdLC3e6tolGn4Qqdyqy1/2tsOo76rurFzDThkm7m6lULaWLEuLdQ7UbnJ PizgNzz4nvrXH6TbKJ9bML90e3/RXOQrF+j0/svo60kWSoUj+vMCNyqT2j8zGnsp6c5O MG7e3qoxwr1vYN2NwQqUyxg1x7QWYvkUa5j39Bemgpp72X6XaHLHl1Khlo9bTEWybmJU vmbvuyp0Vq4sPT1Es2AKxhxKMmeH4kV67ydeqCgHqhozQod+GvHoz1q1tbn/Vv2WdlP6 FSUbgGRguKXE+vj0ltyGOvPY7fVZN6AEA8FF65OuH2nv2k83xZQYTVZKdWLF/aPteM6M clig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=+m0mr80I/sQQ0FJdUVOJFQ9BWzVGPSUsa7bUn6T9dT4=; b=bAdx/ZLDHq0nNJN8vq3+GmeS+i3LI0p3No/8wk66DmtNNj4IH5N3WmGygmT6dYmeuU jv7kTJKDKkrK9JkWVYtJEs0KO0k6ya7CWO9uXkNrlKUMXlzjwF3tOvPQW0E6TL+cIEJ1 9R8zhsgPF5mFFtDYeUoN48WGME7f5eg2vtha2Z1WNFjCw1ktUK+I2wSKdotJRniDIt1O rFMxOB/92TQQ5qzvfGuBg0/UzLAmuOx8+Rf4oZUisCwdyD7XRYZKfslQYYs1G89hZhFZ HU3sKht2COnDFMRfCf5R8KJnuBJ2avLXlbwte7N4zMY74x+dek5OfbbUR6lt1gv0qdDz mupg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y44si23533662edb.251.2019.09.16.07.49.00; Mon, 16 Sep 2019 07:49:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730419AbfIPHzr (ORCPT + 99 others); Mon, 16 Sep 2019 03:55:47 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:16670 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726074AbfIPHzq (ORCPT ); Mon, 16 Sep 2019 03:55:46 -0400 X-UUID: cdd2059cd0e84fb58249955718d5a645-20190916 X-UUID: cdd2059cd0e84fb58249955718d5a645-20190916 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1205137553; Mon, 16 Sep 2019 15:55:42 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 16 Sep 2019 15:55:40 +0800 Received: from [172.21.77.4] (172.21.77.4) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 16 Sep 2019 15:55:40 +0800 Message-ID: <1568620540.7280.1.camel@mtksdaap41> Subject: Re: [PATCH v3 12/14] drm/mediatek: Add pm runtime support for ovl and rdma From: CK Hu To: Yong Wu CC: Matthias Brugger , Joerg Roedel , Rob Herring , , , Nicolas Boichat , , , , Will Deacon , , Evan Green , Tomasz Figa , , Matthias Kaehlcke , , Yongqiang Niu , , , Robin Murphy , Date: Mon, 16 Sep 2019 15:55:40 +0800 In-Reply-To: <1567503456-24725-13-git-send-email-yong.wu@mediatek.com> References: <1567503456-24725-1-git-send-email-yong.wu@mediatek.com> <1567503456-24725-13-git-send-email-yong.wu@mediatek.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Yong: On Tue, 2019-09-03 at 17:37 +0800, Yong Wu wrote: > From: Yongqiang Niu > > Display use the dispsys device to call pm_rumtime_get_sync before. > This patch add pm_runtime_xx with ovl and rdma device which has linked > with larb0, then it will enable the correpsonding larb0 clock > automatically by the device link. This patch should be applied before "drm/mediatek: Get rid of mtk_smi_larb_get/put". If before that patch, this patch is a preparation of that patch. If after that patch, this patch is a bug fix of that patch. Why let bug happen? > > Signed-off-by: Yongqiang Niu > Signed-off-by: Yong Wu > --- > drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 5 +++++ > drivers/gpu/drm/mediatek/mtk_disp_rdma.c | 5 +++++ > drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 18 ++++++++++++++++-- > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 9 +++++++++ > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 1 + > 5 files changed, 36 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c > index c4f07c2..51958cf 100644 > --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c > +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c > @@ -9,6 +9,7 @@ > #include > #include > #include > +#include > > #include "mtk_drm_crtc.h" > #include "mtk_drm_ddp_comp.h" > @@ -300,6 +301,8 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev) > return ret; > } > > + pm_runtime_enable(dev); > + > ret = component_add(dev, &mtk_disp_ovl_component_ops); > if (ret) > dev_err(dev, "Failed to add component: %d\n", ret); This error should do some error handling to undo pm_runtime_enable(). > @@ -311,6 +314,8 @@ static int mtk_disp_ovl_remove(struct platform_device *pdev) > { > component_del(&pdev->dev, &mtk_disp_ovl_component_ops); > > + pm_runtime_disable(&pdev->dev); > + > return 0; > } > > diff --git a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c > index 9a6f0a2..15e5c3a 100644 > --- a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c > +++ b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c > @@ -9,6 +9,7 @@ > #include > #include > #include > +#include > > #include "mtk_drm_crtc.h" > #include "mtk_drm_ddp_comp.h" > @@ -306,6 +307,8 @@ static int mtk_disp_rdma_probe(struct platform_device *pdev) > > platform_set_drvdata(pdev, priv); > > + pm_runtime_enable(dev); > + > ret = component_add(dev, &mtk_disp_rdma_component_ops); > if (ret) > dev_err(dev, "Failed to add component: %d\n", ret); Ditto. > @@ -317,6 +320,8 @@ static int mtk_disp_rdma_remove(struct platform_device *pdev) > { > component_del(&pdev->dev, &mtk_disp_rdma_component_ops); > > + pm_runtime_disable(&pdev->dev); > + > return 0; > } > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > index c1e891e..daf002e 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > @@ -358,13 +358,21 @@ static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc, > struct drm_crtc_state *old_state) > { > struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); > + struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; > int ret; > > DRM_DEBUG_DRIVER("%s %d\n", __func__, crtc->base.id); > > + ret = pm_runtime_get_sync(comp->dev); > + if (ret < 0) > + DRM_DEV_ERROR(comp->dev, "Failed to enable power domain: %d\n", > + ret); > + > ret = mtk_crtc_ddp_hw_init(mtk_crtc); > - if (ret) > + if (ret) { > + pm_runtime_put(comp->dev); > return; > + } > > drm_crtc_vblank_on(crtc); > mtk_crtc->enabled = true; > @@ -374,7 +382,8 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc, > struct drm_crtc_state *old_state) > { > struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); > - int i; > + struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; > + int i, ret; > > DRM_DEBUG_DRIVER("%s %d\n", __func__, crtc->base.id); > if (!mtk_crtc->enabled) > @@ -398,6 +407,11 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc, > mtk_crtc_ddp_hw_fini(mtk_crtc); > > mtk_crtc->enabled = false; > + > + ret = pm_runtime_put(comp->dev); > + if (ret < 0) > + DRM_DEV_ERROR(comp->dev, "Failed to disable power domain: %d\n", > + ret); > } > > static void mtk_drm_crtc_atomic_begin(struct drm_crtc *crtc, > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c > index 7dc8496..c45e1f0 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c > @@ -256,6 +256,8 @@ int mtk_ddp_comp_init(struct device *dev, struct device_node *node, > struct mtk_ddp_comp *comp, enum mtk_ddp_comp_id comp_id, > const struct mtk_ddp_comp_funcs *funcs) > { > + struct platform_device *comp_pdev; > + > if (comp_id < 0 || comp_id >= DDP_COMPONENT_ID_MAX) > return -EINVAL; > > @@ -282,6 +284,13 @@ int mtk_ddp_comp_init(struct device *dev, struct device_node *node, > if (IS_ERR(comp->clk)) > return PTR_ERR(comp->clk); > > + comp_pdev = of_find_device_by_node(node); > + if (!comp_pdev) { > + dev_err(dev, "Waiting for device %s\n", node->full_name); > + return -EPROBE_DEFER; > + } > + comp->dev = &comp_pdev->dev; This should be comp->dev = dev; Regards, CK > + > return 0; > } > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h > index 108de60..d1838a8 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h > +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h > @@ -83,6 +83,7 @@ struct mtk_ddp_comp { > struct clk *clk; > void __iomem *regs; > int irq; > + struct device *dev; > enum mtk_ddp_comp_id id; > const struct mtk_ddp_comp_funcs *funcs; > };