Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp212316rdb; Fri, 6 Oct 2023 00:40:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEnP38mC5C5OWFSNTUI8OxoL0inh/oKhafLQMGG+ROhJTGmCFKV+n2VC0ph44lTYjONb39H X-Received: by 2002:a05:6358:4327:b0:13a:1e90:4813 with SMTP id r39-20020a056358432700b0013a1e904813mr8508018rwc.29.1696578051677; Fri, 06 Oct 2023 00:40:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696578051; cv=none; d=google.com; s=arc-20160816; b=BdSjQF1wqfihUCgHFgivnaNUU/wq6YN1SCPPuuhp6Ad4Ev2Zm+pyThLik3OOfkXGlb 3CGNDI8sjC0BHOGE4h9XfaUTukpLfxaHHA3z6o0a5U1vjDH5FeeerE1hZy0+tc8i1fiQ j0HlJGZ0CdzSFVrl66+DMpxLR2pfC3XHxXM3rKGyOIPmENd2jcEwNtBhK/RQhrmzsarU AzNvEHmd0Ql5I0UZZrcXiAlZNKoLYrfVet0mobIYDQngnIPoeSaT+zU+6C248yuoVcUY bnGW4X2siQ7e94alwgiJsRpI7Ra0M+P3U7Jh/HdzG3+9FvWlhO5Ga2hjCDJKUHEJv3Bh N71Q== 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:dkim-signature; bh=NBROvn7reN2AdeOdoiUJaEiRlJ43UR/SH09KqXbEQlQ=; fh=kY3/KDC2qEzU7tuRfKV0Ke/m2LpBFtrYwW4wOL/Oepc=; b=pVTgkvtYFZnxXf8Yu/hj7wLmdSS8pOkIE1MLKXRTW3qb0/AfvwqVKnYgMxypaUg3Nv XuQqBPUGLObjQNK8lyyqESeh7Y2XSMoakJw89IBQjGlSg1Eaj+oBgCOBsCx2m2xVx7Uc NoiXj44C3oo1dXs3FR7fbAZKj4HdducPDXgRPBCy3EYJ14YKTu1cdXalzKbjEU9lwis/ 2FNg2DqUjgBSkS4+1I265CBHbNRtHQISqK4JfTeJxh+B4RW1g/CJBPSxLvghl98+A2e8 SiB+W4Bzu35q2EAPc6+WUZtTHTaQEvXj0jqZTg2ovPRO8PYWKC9wgA52K3LxFcogIbiy nceg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=Fo37CJg3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id f20-20020a637554000000b005898e5f41f9si632766pgn.40.2023.10.06.00.40.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 00:40:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=Fo37CJg3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 9BFC881D68F3; Fri, 6 Oct 2023 00:40:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231134AbjJFHkJ (ORCPT + 99 others); Fri, 6 Oct 2023 03:40:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230447AbjJFHjB (ORCPT ); Fri, 6 Oct 2023 03:39:01 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEC0E106; Fri, 6 Oct 2023 00:38:50 -0700 (PDT) X-UUID: 60223510641b11eea33bb35ae8d461a2-20231006 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=NBROvn7reN2AdeOdoiUJaEiRlJ43UR/SH09KqXbEQlQ=; b=Fo37CJg3VFuwurz45gYTKsDQ3PPHeEbwTX5+kVpy2mePGIVFyZgbLAPA0QF58SjNnECu9xlY1itpaoQTDEht1y39pgcn4FX+gocjQ9vMt25C4v+AWlK+yjQRmL7vWenl3cGUDgaO1UEfvyBSoPrzVkxeOeoxuMm2BudfPbwONYs=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.32,REQID:929bb158-e6ff-4313-84be-0d3af94b5a87,IP:0,U RL:0,TC:0,Content:-25,EDM:25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:5f78ec9,CLOUDID:b8db82f0-9a6e-4c39-b73e-f2bc08ca3dc5,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:5,IP:nil,UR L:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,D KR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 60223510641b11eea33bb35ae8d461a2-20231006 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 760231053; Fri, 06 Oct 2023 15:38:43 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 6 Oct 2023 15:38:42 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 6 Oct 2023 15:38:42 +0800 From: Hsiao Chien Sung To: AngeloGioacchino Del Regno , "CK Hu" , Krzysztof Kozlowski , Matthias Brugger , Rob Herring CC: Conor Dooley , Philipp Zabel , David Airlie , Daniel Vetter , Chun-Kuang Hu , "Mauro Carvalho Chehab" , , , , , , Singo Chang , "Nancy . Lin" , "Jason-JH . Lin" , "Hsiao Chien Sung" Subject: [PATCH v7 22/23] drm/mediatek: Power on devices in OVL adaptor when atomic enable Date: Fri, 6 Oct 2023 15:38:30 +0800 Message-ID: <20231006073831.10402-23-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20231006073831.10402-1-shawn.sung@mediatek.com> References: <20231006073831.10402-1-shawn.sung@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--7.232500-8.000000 X-TMASE-MatchedRID: VNPsBabfPUTcOmQcPTi0T2095hplj6TXreJWlnSW7AxUvGw7a0fFC6iz 2yX3N56R8nkUz/YHQPwtHWp5Fn7onzzr4TJKjukKXP5rFAucBUHfOHKWwT12zNiCsYPC4Ul2Zvo +mFW19mBjVrjGHPfv8bikr1TvSs3rfpMzRCm11qOwr5ZZVOw5dW7VDoOMIlRgJLfQYoCQHFZVrD 1vLzV5H8uV9ObvGZuCgDLqnrRlXrZ8nn9tnqel2LI7zVffJqTzIcToYFzziozVGNOnovHchtiQw df+PwcHG0AHL7kw20dobA+IiRtG137cGd19dSFd X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--7.232500-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: F769F3DAA5F011F11AC8A52717BE2D962DBFB2D98D1C1EE22229C68A1BC6CCF92000:8 X-MTK: N X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 06 Oct 2023 00:40:46 -0700 (PDT) Different from OVL, OVL adaptor is a pseudo device so we didn't define it in the device tree, consequently, pm_runtime_resume_and_get() called by .atomic_enable() powers on no device in OVL adaptor and leads to power outage in the corresponding IOMMU. To resolve the issue, we implement a function to power on the RDMAs in OVL adaptor, and the system will make sure the IOMMU is powered on as well because of the device link (iommus) in the RDMA nodes in DTS. Fixes: 5db12f5d843b ("media: drm/mediatek: Add pm runtime support for ovl and rdma") Signed-off-by: Hsiao Chien Sung --- drivers/gpu/drm/mediatek/mtk_disp_drv.h | 1 + .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 49 +++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 9 ++++ drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 1 + drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 9 ++++ 5 files changed, 69 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_drv.h b/drivers/gpu/drm/mediatek/mtk_disp_drv.h index 45b30a2fe11a..971d64261fb9 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_drv.h +++ b/drivers/gpu/drm/mediatek/mtk_disp_drv.h @@ -107,6 +107,7 @@ void mtk_ovl_adaptor_connect(struct device *dev, struct device *mmsys_dev, unsigned int next); void mtk_ovl_adaptor_disconnect(struct device *dev, struct device *mmsys_dev, unsigned int next); +int mtk_ovl_adaptor_power_on(struct device *dev); int mtk_ovl_adaptor_clk_enable(struct device *dev); void mtk_ovl_adaptor_clk_disable(struct device *dev); void mtk_ovl_adaptor_config(struct device *dev, unsigned int w, diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c index c326a658dc63..ae3b6ba655b1 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c @@ -242,6 +242,55 @@ void mtk_ovl_adaptor_stop(struct device *dev) } } +/** + * mtk_ovl_adaptor_power_on - Power on devices in OVL adaptor + * @dev: device to be powered on + * + * Different from OVL, OVL adaptor is a pseudo device so + * we didn't define it in the device tree, pm_runtime_resume_and_get() + * called by .atomic_enable() power on no device in OVL adaptor, + * we have to implement a function to do the job instead. + * + * returns: + * zero on success, errno on failure. + */ +int mtk_ovl_adaptor_power_on(struct device *dev) +{ + int i, ret; + struct device *comp; + struct mtk_disp_ovl_adaptor *ovl_adaptor = dev_get_drvdata(dev); + + for (i = 0; i < OVL_ADAPTOR_ID_MAX; i++) { + comp = ovl_adaptor->ovl_adaptor_comp[i]; + + if (!comp) + continue; + + if (comp_matches[i].type != OVL_ADAPTOR_TYPE_MDP_RDMA) + continue; + + ret = pm_runtime_resume_and_get(comp); + if (ret < 0) { + dev_err(dev, "Failed to power on comp(%u): %d\n", i, ret); + goto error; + } + } + return 0; +error: + while (--i >= 0) { + comp = ovl_adaptor->ovl_adaptor_comp[i]; + + if (!comp) + continue; + + if (comp_matches[i].type != OVL_ADAPTOR_TYPE_MDP_RDMA) + continue; + + pm_runtime_put(comp); + } + return ret; +} + int mtk_ovl_adaptor_clk_enable(struct device *dev) { int i; diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index b6fa4ad2f94d..5bd62027190b 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -364,6 +364,15 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc) return ret; } + for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { + ret = mtk_ddp_comp_power_on(mtk_crtc->ddp_comp[i]); + if (ret) { + DRM_ERROR("Failed to power on %s: %d\n", + dev_name(mtk_crtc->ddp_comp[i]->dev), ret); + return ret; + } + } + ret = mtk_mutex_prepare(mtk_crtc->mutex); if (ret < 0) { DRM_ERROR("Failed to enable mutex clock: %d\n", ret); diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c index 771f4e173353..e39860f2be78 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c @@ -394,6 +394,7 @@ static const struct mtk_ddp_comp_funcs ddp_ufoe = { }; static const struct mtk_ddp_comp_funcs ddp_ovl_adaptor = { + .power_on = mtk_ovl_adaptor_power_on, .clk_enable = mtk_ovl_adaptor_clk_enable, .clk_disable = mtk_ovl_adaptor_clk_disable, .config = mtk_ovl_adaptor_config, diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h index febcaeef16a1..4fef283f17d2 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h @@ -46,6 +46,7 @@ enum mtk_ddp_comp_type { struct mtk_ddp_comp; struct cmdq_pkt; struct mtk_ddp_comp_funcs { + int (*power_on)(struct device *dev); int (*clk_enable)(struct device *dev); void (*clk_disable)(struct device *dev); void (*config)(struct device *dev, unsigned int w, @@ -89,6 +90,14 @@ struct mtk_ddp_comp { const struct mtk_ddp_comp_funcs *funcs; }; +static inline int mtk_ddp_comp_power_on(struct mtk_ddp_comp *comp) +{ + if (comp->funcs && comp->funcs->power_on) + return comp->funcs->power_on(comp->dev); + + return 0; +} + static inline int mtk_ddp_comp_clk_enable(struct mtk_ddp_comp *comp) { if (comp->funcs && comp->funcs->clk_enable) -- 2.18.0