From patchwork Wed Apr 3 10:25:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?U2hhd24gU3VuZyAo5a6L5a2d6KyZKQ==?= X-Patchwork-Id: 13615724 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D9ACFCD1294 for ; Wed, 3 Apr 2024 10:27:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UBLSGA9hcSEY+1hQ6m8B00KdRZPmb4u/o+gv9nu2JIg=; b=YNWbSxC027/5Nq qXaSA5Dlh3qTS6jHNcdK4KTp5gke2RdAbEgiM3A0Jr4Jl8NBrz43JT0qyjpwSC/OLakmsr/tC/uUw S3/S9+godX28ha02lTRcZG0HPt4LkordDf8A7ITZMKbX9474HbW73/+DHjwDodi3+dsUb52wJVXO6 HKpw3jzPSUYuUGwiCtzMwfwXJOdX3dr9kO68IAuYc7QavGHTop+5NhPYsEYbl/3ZjMOgexXokNA28 B46hxA1v0vqUrjsCEiEszZ1AWjFodzFaV9AAZDq/PCmNVIRu0BUHH9QR5Yu/XyJTILeKLEyt5K+qy S8zZ7jyitJv7+07Qoqow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rrxpe-0000000FUL9-0WqQ; Wed, 03 Apr 2024 10:27:02 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rrxpT-0000000FUDk-0KQH; Wed, 03 Apr 2024 10:26:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=CaEo9t4w8Wnx0t6QxvMtg/WxTOIvZPRuUESUXWMpGKI=; b=FxwY//ELutImIyq9vPoIUwhjVv H0NQX+R7Peai8lOyE/GNdOdqcg9JoxZoetn5gaYoCisyQ2bOj2zgliWbs8T+B5RAKfRiRI4bax5vp lzxDrV9OTsEfQHa0Vf+L6TNyC069BEEaQ4B5FIwwH2sABGJ7qgPbqCKMfEG1EAyMgMjwng/VZGZsX F9p2LPYS9M5tmkiomo99zydrXjTtK8b/jvEBuFHece444w+w5qYe2PINkAK86XF1FZY0eYaesPWmK A6WgAtppAYXcUxlWF0fxEvtKoYMOh2v1ixyuiIY/BwyDa/kOgPaTZJ74ZE8InWaBWLnjbohUvtBlT bvVv6zZQ==; Received: from mailgw01.mediatek.com ([216.200.240.184]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rrxpP-00000004A5D-1T9f; Wed, 03 Apr 2024 10:26:49 +0000 X-UUID: a78607eef1a411eeac1957ae9f99f617-20240403 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=CaEo9t4w8Wnx0t6QxvMtg/WxTOIvZPRuUESUXWMpGKI=; b=rs/wCJGT1WUWkU3j2imEh8539mP+2+pMW+xN+hIqOPax1o7RcQc7l1ErPwEb6wHMqyJ67N1udkT5dmLVTrj+nZiL8b3mpSEr3Ln4CXBV6P/H1bqPRoVgAWsObHQGJxRuT93wZktSJr3y8VatkvLSR3Csh9KB4Jsg1Fr+e2Zr5No=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:b287247c-3565-474c-b98b-e28de4c60eed,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:6f543d0,CLOUDID:4dfdc585-8d4f-477b-89d2-1e3bdbef96d1,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL: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 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: a78607eef1a411eeac1957ae9f99f617-20240403 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1574377062; Wed, 03 Apr 2024 03:26:38 -0700 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 3 Apr 2024 18:26:04 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Wed, 3 Apr 2024 18:26:04 +0800 From: Shawn Sung To: CK Hu , Jassi Brar , AngeloGioacchino Del Regno CC: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , Hsiao Chien Sung , "Jason-JH . Lin" , Houlong Wei , , , , Subject: [PATCH v5 06/10] soc: mediatek: cmdq: Add cmdq_pkt_finalize_loop for looping cmd with irq Date: Wed, 3 Apr 2024 18:25:58 +0800 Message-ID: <20240403102602.32155-7-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20240403102602.32155-1-shawn.sung@mediatek.com> References: <20240403102602.32155-1-shawn.sung@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240403_112647_787183_C00AA0CA X-CRM114-Status: GOOD ( 13.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: "Jason-JH.Lin" Add cmdq_pkt_finalize_loop to CMDQ driver. cmdq_pkt_finalize_loop appends end of command(EOC) instruction and jump to start of command buffer instruction to make the command buffer loopable. Signed-off-by: Jason-JH.Lin Signed-off-by: Hsiao Chien Sung --- drivers/soc/mediatek/mtk-cmdq-helper.c | 23 +++++++++++++++++++++++ include/linux/soc/mediatek/mtk-cmdq.h | 8 ++++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c index 42a0194198d5b..3e5a9c4592fd0 100644 --- a/drivers/soc/mediatek/mtk-cmdq-helper.c +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c @@ -568,6 +568,29 @@ int cmdq_pkt_finalize(struct cmdq_pkt *pkt) } EXPORT_SYMBOL(cmdq_pkt_finalize); +int cmdq_pkt_finalize_loop(struct cmdq_pkt *pkt) +{ + struct cmdq_instruction inst = { {0} }; + int err; + + /* insert EOC and generate IRQ for each command iteration */ + inst.op = CMDQ_CODE_EOC; + inst.value = CMDQ_EOC_IRQ_EN; + err = cmdq_pkt_append_command(pkt, inst); + if (err < 0) + return err; + + /* JUMP to start of pkt */ + err = cmdq_pkt_jump(pkt, pkt->pa_base); + if (err < 0) + return err; + + pkt->loop = true; + + return err; +} +EXPORT_SYMBOL(cmdq_pkt_finalize_loop); + int cmdq_pkt_flush_async(struct cmdq_pkt *pkt) { int err; diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/mediatek/mtk-cmdq.h index 7bd77d40a5720..f986117d930c0 100644 --- a/include/linux/soc/mediatek/mtk-cmdq.h +++ b/include/linux/soc/mediatek/mtk-cmdq.h @@ -371,6 +371,14 @@ int cmdq_pkt_jump(struct cmdq_pkt *pkt, dma_addr_t addr); */ int cmdq_pkt_finalize(struct cmdq_pkt *pkt); +/** + * cmdq_pkt_finalize_loop() - Append EOC and jump to start command. + * @pkt: the CMDQ packet + * + * Return: 0 for success; else the error code is returned + */ +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