From: CK Hu <ck.hu@mediatek.com>
To: Yong Wu <yong.wu@mediatek.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>,
Joerg Roedel <joro@8bytes.org>, Rob Herring <robh+dt@kernel.org>,
<youlin.pei@mediatek.com>, <devicetree@vger.kernel.org>,
Nicolas Boichat <drinkcat@chromium.org>, <cui.zhang@mediatek.com>,
<srv_heupstream@mediatek.com>, <chao.hao@mediatek.com>,
Will Deacon <will.deacon@arm.com>, <linux-kernel@vger.kernel.org>,
Evan Green <evgreen@chromium.org>, Tomasz Figa <tfiga@google.com>,
<iommu@lists.linux-foundation.org>,
Matthias Kaehlcke <mka@chromium.org>,
<linux-mediatek@lists.infradead.org>,
Yongqiang Niu <yongqiang.niu@mediatek.com>,
<ming-fan.chen@mediatek.com>, <anan.sun@mediatek.com>,
Robin Murphy <robin.murphy@arm.com>,
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v3 12/14] drm/mediatek: Add pm runtime support for ovl and rdma
Date: Mon, 16 Sep 2019 15:55:40 +0800 [thread overview]
Message-ID: <1568620540.7280.1.camel@mtksdaap41> (raw)
In-Reply-To: <1567503456-24725-13-git-send-email-yong.wu@mediatek.com>
Hi, Yong:
On Tue, 2019-09-03 at 17:37 +0800, Yong Wu wrote:
> From: Yongqiang Niu <yongqiang.niu@mediatek.com>
>
> 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 <yongqiang.niu@mediatek.com>
> Signed-off-by: Yong Wu <yong.wu@mediatek.com>
> ---
> 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 <linux/of_device.h>
> #include <linux/of_irq.h>
> #include <linux/platform_device.h>
> +#include <linux/pm_runtime.h>
>
> #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 <linux/of_device.h>
> #include <linux/of_irq.h>
> #include <linux/platform_device.h>
> +#include <linux/pm_runtime.h>
>
> #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;
> };
next prev parent reply other threads:[~2019-09-16 7:55 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-03 9:37 [PATCH v3 00/14] Clean up "mediatek,larb" after adding device_link Yong Wu
2019-09-03 9:37 ` [PATCH v3 01/14] dt-binding: mediatek: Get rid of mediatek,larb for multimedia HW Yong Wu
2019-09-03 9:37 ` [PATCH v3 02/14] iommu/mediatek: Add probe_defer for smi-larb Yong Wu
2019-09-03 9:37 ` [PATCH v3 03/14] iommu/mediatek: Add device_link between the consumer and the larb devices Yong Wu
2020-03-05 5:14 ` Nicolas Boichat
2020-03-06 6:59 ` Yong Wu
2019-09-03 9:37 ` [PATCH v3 04/14] memory: mtk-smi: Add device-link between smi-larb and smi-common Yong Wu
2019-09-03 9:37 ` [PATCH v3 05/14] media: mtk-jpeg: Get rid of mtk_smi_larb_get/put Yong Wu
2019-09-03 9:37 ` [PATCH v3 06/14] media: mtk-mdp: " Yong Wu
2019-09-03 9:37 ` [PATCH v3 07/14] media: mtk-vcodec: " Yong Wu
2019-09-03 9:37 ` [PATCH v3 08/14] drm/mediatek: " Yong Wu
2019-09-03 9:37 ` [PATCH v3 09/14] memory: mtk-smi: " Yong Wu
2019-09-03 9:37 ` [PATCH v3 10/14] iommu/mediatek: Use builtin_platform_driver Yong Wu
2019-09-03 9:37 ` [PATCH v3 11/14] memory: mtk-smi: Use device_is_bound to check if smi-common is ready Yong Wu
2019-09-03 9:37 ` [PATCH v3 12/14] drm/mediatek: Add pm runtime support for ovl and rdma Yong Wu
2019-09-16 7:55 ` CK Hu [this message]
2019-09-03 9:37 ` [PATCH v3 13/14] arm: dts: mediatek: Get rid of mediatek,larb for MM nodes Yong Wu
2019-09-03 9:37 ` [PATCH v3 14/14] arm64: " Yong Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1568620540.7280.1.camel@mtksdaap41 \
--to=ck.hu@mediatek.com \
--cc=anan.sun@mediatek.com \
--cc=chao.hao@mediatek.com \
--cc=cui.zhang@mediatek.com \
--cc=devicetree@vger.kernel.org \
--cc=drinkcat@chromium.org \
--cc=evgreen@chromium.org \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=ming-fan.chen@mediatek.com \
--cc=mka@chromium.org \
--cc=robh+dt@kernel.org \
--cc=robin.murphy@arm.com \
--cc=srv_heupstream@mediatek.com \
--cc=tfiga@google.com \
--cc=will.deacon@arm.com \
--cc=yong.wu@mediatek.com \
--cc=yongqiang.niu@mediatek.com \
--cc=youlin.pei@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).