From nobody Thu Nov 14 05:44:17 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93831EE4993 for ; Wed, 23 Aug 2023 15:14:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236889AbjHWPOH (ORCPT ); Wed, 23 Aug 2023 11:14:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236686AbjHWPOE (ORCPT ); Wed, 23 Aug 2023 11:14:04 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CDB6CEF for ; Wed, 23 Aug 2023 08:14:01 -0700 (PDT) X-UUID: ac79c70a41c711ee9cb5633481061a41-20230823 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=GQhZU5jltz/YkgRBmJidnMnzG4E1Okj2IfoRrJzjcxQ=; b=riTo1pdHGek2OX/FHiSz3CKLg6Hth1N7k+NK7WMVmepkhuoVXN6oZBcEQCdjH0BVmv1uVjdKnX7BvD0QQ+PhmdHrDOsMwtMIIraJC3AlMusCQ4102CRh9fyKti/mI8jUIePmA2kROa0/fHts5zkpWPLWWz9S9YSASgqd79nzpV4=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.31,REQID:01873391-89e3-4c2d-be9f-b4c9be16e194,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:95 X-CID-INFO: VERSION:1.1.31,REQID:01873391-89e3-4c2d-be9f-b4c9be16e194,IP:0,URL :0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTION :quarantine,TS:95 X-CID-META: VersionHash:0ad78a4,CLOUDID:8e04ab1f-33fd-4aaa-bb43-d3fd68d9d5ae,B ulkID:230823231355RRXIN3SB,BulkQuantity:0,Recheck:0,SF:38|29|28|17|19|48,T C:nil,Content:0,EDM:-3,IP:nil,URL:0,File: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 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_SDM,TF_CID_SPAM_ASC,TF_CID_SPAM_FAS, TF_CID_SPAM_FSD X-UUID: ac79c70a41c711ee9cb5633481061a41-20230823 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 426391261; Wed, 23 Aug 2023 23:13:54 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS14N1.mediatek.inc (172.21.101.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 23 Aug 2023 23:13:52 +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; Wed, 23 Aug 2023 23:13:52 +0800 From: Hsiao Chien Sung To: Chun-Kuang Hu , Philipp Zabel , David Airlie , Daniel Vetter , Matthias Brugger , AngeloGioacchino Del Regno , Jassi Brar CC: , , , , Singo Chang , Nancy Lin , Jason-JH Lin , Hsiao Chien Sung Subject: [PATCH 03/15] soc: mediatek: Support GCE thread loop Date: Wed, 23 Aug 2023 23:13:20 +0800 Message-ID: <20230823151332.28811-4-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230823151332.28811-1-shawn.sung@mediatek.com> References: <20230823151332.28811-1-shawn.sung@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a new API to create GCE thread loop by appending a command at the end of CMDQ packet to jump to the head of it. Signed-off-by: Hsiao Chien Sung --- drivers/soc/mediatek/mtk-cmdq-helper.c | 30 ++++++++++++++++++++++++++ include/linux/soc/mediatek/mtk-cmdq.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/= mtk-cmdq-helper.c index c1837a468267..7d503d491c0d 100644 --- a/drivers/soc/mediatek/mtk-cmdq-helper.c +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c @@ -430,6 +430,9 @@ int cmdq_pkt_flush_async(struct cmdq_pkt *pkt) int err; struct cmdq_client *client =3D (struct cmdq_client *)pkt->cl; =20 + dma_sync_single_for_device(client->chan->mbox->dev, pkt->pa_base, + pkt->cmd_buf_size, DMA_TO_DEVICE); + err =3D mbox_send_message(client->chan, pkt); if (err < 0) return err; @@ -440,4 +443,31 @@ int cmdq_pkt_flush_async(struct cmdq_pkt *pkt) } EXPORT_SYMBOL(cmdq_pkt_flush_async); =20 +int cmdq_pkt_finalize_loop(struct cmdq_pkt *pkt) +{ + struct cmdq_instruction inst =3D { {0} }; + int err; + u8 shift_pa =3D 0; + + shift_pa =3D cmdq_get_shift_pa(((struct cmdq_client *)pkt->cl)->chan); + + /* insert EOC and generate IRQ for command iteration */ + inst.op =3D CMDQ_CODE_EOC; + inst.value =3D CMDQ_EOC_IRQ_EN; + err =3D cmdq_pkt_append_command(pkt, inst); + if (err < 0) + return err; + + /* jump to head of the packet */ + inst.op =3D CMDQ_CODE_JUMP; + inst.offset =3D CMDQ_JUMP_RELATIVE; + inst.value =3D pkt->pa_base >> shift_pa; + err =3D cmdq_pkt_append_command(pkt, inst); + + pkt->loop =3D true; + + return err; +} +EXPORT_SYMBOL(cmdq_pkt_finalize_loop); + MODULE_LICENSE("GPL v2"); diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/medi= atek/mtk-cmdq.h index 3eb95ef34c6c..4c30f891d924 100644 --- a/include/linux/soc/mediatek/mtk-cmdq.h +++ b/include/linux/soc/mediatek/mtk-cmdq.h @@ -273,6 +273,8 @@ int cmdq_pkt_jump(struct cmdq_pkt *pkt, dma_addr_t addr= ); */ int cmdq_pkt_finalize(struct cmdq_pkt *pkt); =20 +int cmdq_pkt_finalize_loop(struct cmdq_pkt *pkt); + /** * cmdq_pkt_flush_async() - trigger CMDQ to asynchronously execute the CMDQ * packet and call back at the end of done packet --=20 2.18.0