From nobody Fri Oct 3 14:29:31 2025 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2648E28032D; Fri, 29 Aug 2025 09:17:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756459059; cv=none; b=osSF0r64B+TGGceyC/XZ0L0EJdUDZ2rUWJImbFpD5vkMNxrhTlYtPYUJ6QmzRCq+x0CCtOvBcfNREmsZFd/R5ijQBDvS1L/v/HWay3kQ6wfYmvguwPuPmaCZfrhVDlveF0W+fjyKakXMGwRhiZKO7Knytg2AjeXYCAAuKIPxfN8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756459059; c=relaxed/simple; bh=MFLjBZaIkGb9HOlD/v4VJZhdZ4rVdRLJNZK1tDmXpXU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FnlWr5RC7NZlK8HFA2ZT7foKvzm8eBXA4iYkcCeVJRCsKHEAJyvCnK2PTVeph6LDhNj0QiMFDHZmTD04JytwLpeTtD8JWV3axaDN/nLRguMW9pt5VEaoXpsCGPlLZQLHSOltfIq9OFZ9Z0JMqnpac6E8gvXz5rAhnxwbEnovX00= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=Fte1++nL; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="Fte1++nL" X-UUID: fcc0392a84b811f0bd5779446731db89-20250829 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=OpvKQ5RZmE4EfaTAo3mt11IS3VqOx6Zab6zSWyDeGd8=; b=Fte1++nL/Z4b5qTQNBqCSaIJV/hZ4+KJ5UQcDRJk8IBug5EATyUamXcBtHy1UaVdMtHSth7lQ0HIX0deMmRfB3TMHTV5ROTgnGanYt5Wr0kLoBUZZCwRX2X6f+H+52MlkHGJOUPCHvMyXdUNHh1nfLzV422WEh60PL4Vjt7AoYM=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.3,REQID:17191d81-2939-465f-af3a-390ffdeae228,IP:0,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION:r elease,TS:0 X-CID-META: VersionHash:f1326cf,CLOUDID:f23dc2a8-24df-464e-9c88-e53ab7cf7153,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:-5,Content:0|15|50,EDM: -3,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0, AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: fcc0392a84b811f0bd5779446731db89-20250829 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1610497612; Fri, 29 Aug 2025 17:17:29 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS14N2.mediatek.inc (172.21.101.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.39; Fri, 29 Aug 2025 17:17:28 +0800 Received: from mtksitap99.mediatek.inc (10.233.130.16) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1258.39 via Frontend Transport; Fri, 29 Aug 2025 17:17:28 +0800 From: Jason-JH Lin To: Chun-Kuang Hu , AngeloGioacchino Del Regno , Jassi Brar , Mauro Carvalho Chehab CC: Philipp Zabel , David Airlie , Simona Vetter , Jason-JH Lin , Nancy Lin , Singo Chang , Paul-PL Chen , Yongqiang Niu , Zhenxing Qin , Xiandong Wang , Sirius Wang , Xavier Chang , Jarried Lin , Fei Shao , Chen-yu Tsai , , , , , , Subject: [PATCH v2 1/3] mailbox: mtk-cmdq: Remove pm_runtime APIs from cmdq_mbox_send_data() Date: Fri, 29 Aug 2025 17:15:58 +0800 Message-ID: <20250829091727.3745415-2-jason-jh.lin@mediatek.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250829091727.3745415-1-jason-jh.lin@mediatek.com> References: <20250829091727.3745415-1-jason-jh.lin@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Content-Type: text/plain; charset="utf-8" pm_runtime_get_sync() and pm_runtime_put_autosuspend() were previously called in cmdq_mbox_send_data(), which is under a spinlock in msg_submit() (mailbox.c). This caused lockdep warnings such as "sleeping function called from invalid context" when running with lockdebug enabled. The BUG report: BUG: sleeping function called from invalid context at drivers/base/power/= runtime.c:1164 in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 3616, name: kwor= ker/u17:3 preempt_count: 1, expected: 0 RCU nest depth: 0, expected: 0 INFO: lockdep is turned off. irq event stamp: 0 CPU: 1 PID: 3616 Comm: kworker/u17:3 Not tainted 6.1.87-lockdep-14133-g= 26e933aca785 #1 Hardware name: Google Ciri sku0/unprovisioned board (DT) Workqueue: imgsys_runner imgsys_runner_func Call trace: dump_backtrace+0x100/0x120 show_stack+0x20/0x2c dump_stack_lvl+0x84/0xb4 dump_stack+0x18/0x48 __might_resched+0x354/0x4c0 __might_sleep+0x98/0xe4 __pm_runtime_resume+0x70/0x124 cmdq_mbox_send_data+0xe4/0xb1c msg_submit+0x194/0x2dc mbox_send_message+0x190/0x330 imgsys_cmdq_sendtask+0x1618/0x2224 imgsys_runner_func+0xac/0x11c process_one_work+0x638/0xf84 worker_thread+0x808/0xcd0 kthread+0x24c/0x324 ret_from_fork+0x10/0x20 Additionally, pm_runtime_put_autosuspend() should be invoked from the GCE IRQ handler to ensure the hardware has actually completed its work. To resolve these issues, remove the pm_runtime calls from cmdq_mbox_send_data() and delegate power management responsibilities to the client driver. Fixes: 8afe816b0c99 ("mailbox: mtk-cmdq-mailbox: Implement Runtime PM with = autosuspend") Signed-off-by: Jason-JH Lin Reviewed-by: AngeloGioacchino Del Regno --- drivers/mailbox/mtk-cmdq-mailbox.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-= mailbox.c index 532929916e99..654a60f63756 100644 --- a/drivers/mailbox/mtk-cmdq-mailbox.c +++ b/drivers/mailbox/mtk-cmdq-mailbox.c @@ -379,20 +379,13 @@ static int cmdq_mbox_send_data(struct mbox_chan *chan= , void *data) struct cmdq *cmdq =3D dev_get_drvdata(chan->mbox->dev); struct cmdq_task *task; unsigned long curr_pa, end_pa; - int ret; =20 /* Client should not flush new tasks if suspended. */ WARN_ON(cmdq->suspended); =20 - ret =3D pm_runtime_get_sync(cmdq->mbox.dev); - if (ret < 0) - return ret; - task =3D kzalloc(sizeof(*task), GFP_ATOMIC); - if (!task) { - pm_runtime_put_autosuspend(cmdq->mbox.dev); + if (!task) return -ENOMEM; - } =20 task->cmdq =3D cmdq; INIT_LIST_HEAD(&task->list_entry); @@ -439,9 +432,6 @@ static int cmdq_mbox_send_data(struct mbox_chan *chan, = void *data) } list_move_tail(&task->list_entry, &thread->task_busy_list); =20 - pm_runtime_mark_last_busy(cmdq->mbox.dev); - pm_runtime_put_autosuspend(cmdq->mbox.dev); - return 0; } =20 --=20 2.43.0 From nobody Fri Oct 3 14:29:31 2025 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33F812F0680; Fri, 29 Aug 2025 09:17:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756459060; cv=none; b=DlfdjZ8p9wWdsNZ3xNcJXdjaUNwW2GaC62amVFS083JxkGhVA/gwrO5rmbCf1RroJgWIjYE0C6rAWllyBeHheZrt36p83Aof8g+XXwHPBHdgtUQF4EGEe1a921s75RqVKs+x6cjhBn5+9fJ2nhT3XqKbe2YclQGs0sQzaW5S3/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756459060; c=relaxed/simple; bh=QwLc9VF5JieXCNfOisZ3GBSrXR0Pw0Pg+/cLb+FUYzs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l3kE8qQzjnUneuWDh8JMOnlrU+5QnAFAXo5uv2WoCcfRd/p/apYI4OfZZl+tEtb+kwokxkYl0iWFeU7/Yq/h4C7u04DT8k4yCq0kdcpWiC9uxEXbiuMqi6eIAbSGrHC5QVCCBiM8hVIW7Q8Cg9K6EGVjOumZURHafoLzIF5KY3A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=C9EZxGZT; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="C9EZxGZT" X-UUID: fc9c060e84b811f0bd5779446731db89-20250829 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=gR2Eo+J2cJi0h9wrzKWKG6q+OkJdztAxAqpHMtTyJqw=; b=C9EZxGZT9Rngx+WYblmG7jHb43MuksXtzPMurGT6EmQg3MmbG1ybl40ik/2VTyaDbAdEcxk6Yeg61hjolmyqH95ifdFZVFYrD0mjc9WjQ62sb+x8xPoof9rbESvsKNDeA1F74u7qlwMqPg6li88RRGMTV96prshASj5Hb2ji/P0=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.3,REQID:584547db-8b40-43ee-aad0-dc1464491cee,IP:0,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION:r elease,TS:0 X-CID-META: VersionHash:f1326cf,CLOUDID:743f3a84-5317-4626-9d82-238d715c253f,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:-5,Content:0|15|50,EDM: -3,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0, AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: fc9c060e84b811f0bd5779446731db89-20250829 Received: from mtkmbs09n1.mediatek.inc [(172.21.101.35)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 614642119; Fri, 29 Aug 2025 17:17:29 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS09N1.mediatek.inc (172.21.101.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.39; Fri, 29 Aug 2025 17:17:28 +0800 Received: from mtksitap99.mediatek.inc (10.233.130.16) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1258.39 via Frontend Transport; Fri, 29 Aug 2025 17:17:28 +0800 From: Jason-JH Lin To: Chun-Kuang Hu , AngeloGioacchino Del Regno , Jassi Brar , Mauro Carvalho Chehab CC: Philipp Zabel , David Airlie , Simona Vetter , Jason-JH Lin , Nancy Lin , Singo Chang , Paul-PL Chen , Yongqiang Niu , Zhenxing Qin , Xiandong Wang , Sirius Wang , Xavier Chang , Jarried Lin , Fei Shao , Chen-yu Tsai , , , , , , Subject: [PATCH v2 2/3] drm/mediatek: Add pm_runtime support for GCE power control Date: Fri, 29 Aug 2025 17:15:59 +0800 Message-ID: <20250829091727.3745415-3-jason-jh.lin@mediatek.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250829091727.3745415-1-jason-jh.lin@mediatek.com> References: <20250829091727.3745415-1-jason-jh.lin@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Content-Type: text/plain; charset="utf-8" Call pm_runtime_resume_and_get() before accessing GCE hardware in mbox_send_message(), and invoke pm_runtime_put_autosuspend() in the cmdq callback to release the PM reference and start autosuspend for GCE. This ensures correct power management for the GCE device. Fixes: 8afe816b0c99 ("mailbox: mtk-cmdq-mailbox: Implement Runtime PM with = autosuspend") Signed-off-by: Jason-JH Lin Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: CK Hu --- drivers/gpu/drm/mediatek/mtk_crtc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_crtc.c b/drivers/gpu/drm/mediatek= /mtk_crtc.c index bc7527542fdc..c4c6d0249df5 100644 --- a/drivers/gpu/drm/mediatek/mtk_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_crtc.c @@ -283,6 +283,10 @@ static void ddp_cmdq_cb(struct mbox_client *cl, void *= mssg) unsigned int i; unsigned long flags; =20 + /* release GCE HW usage and start autosuspend */ + pm_runtime_mark_last_busy(cmdq_cl->chan->mbox->dev); + pm_runtime_put_autosuspend(cmdq_cl->chan->mbox->dev); + if (data->sta < 0) return; =20 @@ -618,6 +622,9 @@ static void mtk_crtc_update_config(struct mtk_crtc *mtk= _crtc, bool needs_vblank) mtk_crtc->config_updating =3D false; spin_unlock_irqrestore(&mtk_crtc->config_lock, flags); =20 + if (pm_runtime_resume_and_get(mtk_crtc->cmdq_client.chan->mbox->dev) < 0) + goto update_config_out; + mbox_send_message(mtk_crtc->cmdq_client.chan, cmdq_handle); mbox_client_txdone(mtk_crtc->cmdq_client.chan, 0); goto update_config_out; --=20 2.43.0 From nobody Fri Oct 3 14:29:31 2025 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 044AC304973; Fri, 29 Aug 2025 09:17:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756459063; cv=none; b=d2IL2CpukAOuy7Ljf8gIgplnKzjt7ncegV6bJh2fUolYuPy+T1qHus3C10X5p9cs/QpTVx6yAPwFeJpDrceIm5IjlHX/AVnFRqab9qWWvCK57MfBblPZRh0KOdkU5H6YTV08zJsodxQdo5hHInFnU81aKBVx0uL06lQTYKKDxcM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756459063; c=relaxed/simple; bh=c/tJtF9fMiC/gfsIIeJBBc0fi/SYftvTh80Mcl8YuRU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=G6obC1u0Dzusm4PEo+A7hXZuVDcnga1d3QgBTnkuQKbJudoD1etcp3olr/nIa09Xe2lbPNG+R/OW5pbwLVKBcUwBLqGBkVRJXUPB5WO0Oz9OygFmfmm5oV5cPTeawr6rF5KVmihmKOKebjTa9HGv84wDXhHsedHNMzwZXbXmtL4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=fFa2JM+k; arc=none smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="fFa2JM+k" X-UUID: fce927e084b811f0b33aeb1e7f16c2b6-20250829 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=gJ0fGW8LBFDyCYyGl0z+4IhGB806t2gObXrk4IGCHXQ=; b=fFa2JM+kuvyWdCo8RZn/Zalnc6hhneVr5jLDpVU16RFt3M44Og6hXWBU9s2VMsBBuF9chpgCWhf5FZMnkGAHlu1fHFn/3qVENoKEx86Zi5L2Y2NgRUWgk56oH3v+dtOqMfsZDjvBdcMb3Plh4YraYDGjEAx5J9evsh2iZjxPbfw=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.3,REQID:73de13f5-ff43-498b-88b7-0867abf6a52a,IP:0,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION:r elease,TS:0 X-CID-META: VersionHash:f1326cf,CLOUDID:8e37fe6b-8443-424b-b119-dc42e68239b0,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:-5,Content:0|15|50,EDM: -3,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0, AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: fce927e084b811f0b33aeb1e7f16c2b6-20250829 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1471814497; Fri, 29 Aug 2025 17:17:30 +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.1258.39; Fri, 29 Aug 2025 17:17:28 +0800 Received: from mtksitap99.mediatek.inc (10.233.130.16) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1258.39 via Frontend Transport; Fri, 29 Aug 2025 17:17:28 +0800 From: Jason-JH Lin To: Chun-Kuang Hu , AngeloGioacchino Del Regno , Jassi Brar , Mauro Carvalho Chehab CC: Philipp Zabel , David Airlie , Simona Vetter , Jason-JH Lin , Nancy Lin , Singo Chang , Paul-PL Chen , Yongqiang Niu , Zhenxing Qin , Xiandong Wang , Sirius Wang , Xavier Chang , "Jarried Lin" , Fei Shao , Chen-yu Tsai , , , , , , Subject: [PATCH v2 3/3] media: platform: mtk-mdp3: Add pm_runtime support for GCE power control Date: Fri, 29 Aug 2025 17:16:00 +0800 Message-ID: <20250829091727.3745415-4-jason-jh.lin@mediatek.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250829091727.3745415-1-jason-jh.lin@mediatek.com> References: <20250829091727.3745415-1-jason-jh.lin@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Content-Type: text/plain; charset="utf-8" Call pm_runtime_resume_and_get() before accessing GCE hardware in mbox_send_message(), and invoke pm_runtime_put_autosuspend() in the cmdq callback to release the PM reference and start autosuspend for GCE. This ensures correct power management for the GCE device. Fixes: 8afe816b0c99 ("mailbox: mtk-cmdq-mailbox: Implement Runtime PM with = autosuspend") Signed-off-by: Jason-JH Lin Reviewed-by: AngeloGioacchino Del Regno --- drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c b/drivers= /media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c index e5ccf673e152..bb7a895318af 100644 --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c @@ -6,6 +6,7 @@ =20 #include #include +#include #include "mtk-mdp3-cfg.h" #include "mtk-mdp3-cmdq.h" #include "mtk-mdp3-comp.h" @@ -521,6 +522,9 @@ static void mdp_handle_cmdq_callback(struct mbox_client= *cl, void *mssg) mdp =3D cmd->mdp; dev =3D &mdp->pdev->dev; =20 + pm_runtime_mark_last_busy(mdp->cmdq_clt[cmd->pp_idx]->chan->mbox->dev); + pm_runtime_put_autosuspend(mdp->cmdq_clt[cmd->pp_idx]->chan->mbox->dev); + INIT_WORK(&cmd->auto_release_work, mdp_auto_release_work); if (!queue_work(mdp->clock_wq, &cmd->auto_release_work)) { struct mtk_mutex *mutex; @@ -702,6 +706,13 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq= _param *param) cmd[i]->pkt.pa_base, cmd[i]->pkt.cmd_buf_size, DMA_TO_DEVICE); =20 + ret =3D pm_runtime_resume_and_get(mdp->cmdq_clt[i]->chan->mbox->dev); + if (ret < 0) { + dev_err(dev, "pm_runtime_resume_and_get fail: %d!\n", ret); + i =3D pp_used; + goto err_clock_off; + } + ret =3D mbox_send_message(mdp->cmdq_clt[i]->chan, &cmd[i]->pkt); if (ret < 0) { dev_err(dev, "mbox send message fail %d!\n", ret); --=20 2.43.0