Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp270207pxb; Sat, 10 Apr 2021 02:14:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiB0tpNYgRwW/fAK5Q/aIUPT76IYAse1G4rE5MzLkSEbyPXkra9vAbMYlqPXDfxnLYUSUz X-Received: by 2002:a62:1c86:0:b029:205:5428:41eb with SMTP id c128-20020a621c860000b0290205542841ebmr16159463pfc.33.1618046074631; Sat, 10 Apr 2021 02:14:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618046074; cv=none; d=google.com; s=arc-20160816; b=J8dqo+V3jqCUR5IvdPEBAVDsnJoEuezs7qIL8/XbwhTb5s+V+hk5k5pZFsPPRRYXaH +c/zcJ9yivnZ0qGQ96NqU8+FPvkm0LliCH3Ooomdu6rbHV6Y+0p8hfbkPnGORKya4sfY E6HIpj8wDwhLMdk+Nefjjxj7t8Uei8M3RZB6+py+/UGaCjk9Pdk7mTxrUlhNLd78uiLx CP3kgPwBjGWijXWiecM4oJGV2KPAQsNosrQNn26xpZnWdyv8y2d69lfCZIYHnSYsbW3v BAKk8Bas1n7gM8DZ84bReTWWHg+Aacwa4l5U6IpFA0VYx9p6r3Z/cdHhNKdJXsQgNz9R KKJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=eDNAbdUkuTX4WKJux0pkfq+zLpj4KESp6gUVm8nFzJw=; b=xUg12cDMDRb1tiZuwYO9qyIGOR+L3LTSSchuuzpd8UUhqdeMc61f0x0fvBFo9Z151g tqGr6UvxngqCeeJikkBV0nkAWmh0s3ZmrO5W0TGOGmX9ZF1t8kMm8E9mJ2jKWUdoiYOK i0qi10HgHN0zGlLE87EjqqjuBOcs0onxp4YXmiSbP6OUTAPXXg+4VV6orMnB3BUXfcof 8iJRkTxlex60pf82gAQCkSMdJwIpEsrbEEpe0JTsoV12Jw3Rw9e3xLCS+L/Lq7lVWPgd CLcWiC093lxMtahbgHrFga00TXio15XW/4gEcXHHOuGGHy+oKKk8EWTxgiOjJ7SUEyJV Zzdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id u38si5712062pga.491.2021.04.10.02.14.20; Sat, 10 Apr 2021 02:14:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S234592AbhDJJNv (ORCPT + 99 others); Sat, 10 Apr 2021 05:13:51 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:34488 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S234386AbhDJJNu (ORCPT ); Sat, 10 Apr 2021 05:13:50 -0400 X-UUID: 7bfa4f1ce0fb4620826386e85f8ce8d0-20210410 X-UUID: 7bfa4f1ce0fb4620826386e85f8ce8d0-20210410 Received: from mtkmrs01.mediatek.inc [(172.21.131.159)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1256648205; Sat, 10 Apr 2021 17:13:33 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 10 Apr 2021 17:13:31 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 10 Apr 2021 17:13:30 +0800 From: Yong Wu To: Matthias Brugger , Joerg Roedel , Rob Herring , Krzysztof Kozlowski CC: Evan Green , Robin Murphy , Tomasz Figa , Will Deacon , , , , , , , , , Nicolas Boichat , Matthias Kaehlcke , , , , , , , Yongqiang Niu , CK Hu Subject: [PATCH v5 10/16] drm/mediatek: Add pm runtime support for ovl and rdma Date: Sat, 10 Apr 2021 17:11:22 +0800 Message-ID: <20210410091128.31823-11-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210410091128.31823-1-yong.wu@mediatek.com> References: <20210410091128.31823-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 whose nodes has "iommus" property, then display could help pm_runtime_get for smi via ovl or rdma device. This is a preparing patch that smi cleaning up "mediatek,larb". CC: CK Hu Signed-off-by: Yongqiang Niu Signed-off-by: Yong Wu (Yong: Use pm_runtime_resume_and_get instead of pm_runtime_get_sync) Acked-by: Chun-Kuang Hu --- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 9 ++++++++- drivers/gpu/drm/mediatek/mtk_disp_rdma.c | 9 ++++++++- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 12 +++++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c index 961f87f8d4d1..ee464ccd8a9c 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "mtk_disp_drv.h" @@ -415,15 +416,21 @@ 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) + if (ret) { + pm_runtime_disable(dev); dev_err(dev, "Failed to add component: %d\n", ret); + } return ret; } static int mtk_disp_ovl_remove(struct platform_device *pdev) { + 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 728aaadfea8c..9565f3de773e 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 #include "mtk_disp_drv.h" @@ -329,9 +330,13 @@ 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) + if (ret) { + pm_runtime_disable(dev); dev_err(dev, "Failed to add component: %d\n", ret); + } return ret; } @@ -340,6 +345,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 69d23ce56d2c..971ef58ac1dc 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -550,9 +550,15 @@ static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc, return; } + ret = pm_runtime_resume_and_get(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) { mtk_smi_larb_put(comp->larb_dev); + pm_runtime_put(comp->dev); return; } @@ -565,7 +571,7 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc, { struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; - int i; + int i, ret; DRM_DEBUG_DRIVER("%s %d\n", __func__, crtc->base.id); if (!mtk_crtc->enabled) @@ -589,6 +595,10 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc, drm_crtc_vblank_off(crtc); mtk_crtc_ddp_hw_fini(mtk_crtc); mtk_smi_larb_put(comp->larb_dev); + ret = pm_runtime_put(comp->dev); + if (ret < 0) + DRM_DEV_ERROR(comp->dev, "Failed to disable power domain: %d\n", + ret); mtk_crtc->enabled = false; } -- 2.18.0