Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp337521lqg; Fri, 1 Mar 2024 06:44:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVh7Mi80PSYo7rv9E5s2YeLBCnZQNVsNFCgQpaY7fUNTCVyoVBqyV9O0zK1IyDv1pBXHL8/TW9WL0HyceME+GaKBdupj9Qc5qwoxEVXPw== X-Google-Smtp-Source: AGHT+IGcwysyKg+nbfSil26V8+F58yBqCpSjgg3lvMdN/5VLhXObJA5L7S3No6w1VL+ady+LDlmc X-Received: by 2002:ae9:f118:0:b0:788:ec0:26f6 with SMTP id k24-20020ae9f118000000b007880ec026f6mr820507qkg.8.1709304299525; Fri, 01 Mar 2024 06:44:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709304299; cv=pass; d=google.com; s=arc-20160816; b=kyZhmUERQfAJvUzxtfKLbSYtL8oHgB5rT6Big262n/kl84oMu2godu77DmE9zSMa4P QvxgLOX00uN+gC2PGwUGsUmDrVCjA+LulHVoatz5O6Z1ERKkyiO9NDlbGPINyVqKlpCx aMFQDtarPMIiE9iyqSCjW/EdnHKS3nNRGVi3Ed2Eu5+PDy8aCCHNFK4pf9oBvtGUVuAM OBZG9v9bg2Ar/11oyK1ENbt+2+tCaMbcfKj2cgRXT6WasE/cK6peOCvx+3BIkV90OiNM o+sKq7clVCKwoTxPUSzt5XFx5h57AJKsnCouZRfbqsHqxN8GZSe3anN3PO3c6NIfVgFz Cllw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oTUfVJxuZrvqX09d0OmYEW32i4hjXrbksVX4sghk4+0=; fh=/ugC6UPXmWUlk9++6CULpLk86ijV12MoDCJJaRsql5M=; b=TqVTSJ1bchM3YUnmxta9m6sF4gzpTvegZU5XWerfjUKYp+bsu4z13u9iLpYfL2haZa LM5IqfcR/KnKQ/ehGXb2t12mbZd+i+ErUiWmhXjIf8fsDYBzy6wR8rql5+rOWlWXvAvZ F/ZbSpWy6zt/xbr1fHhOW6y/2+9w3jepO4KcGObEViYo3DeRDCYPuz8LHzFyC6bCrDYz jPNGUofaYBftKsxjqjyRN5ZcRShgAgCkLO/BpwIoA4MxQJxk6MAlZeSHq99LAcKMnqKN vjhwN2lT1DZHanz4t9Ervmbq80nHhwQcDoD5Jyt/AZpJw6WkH2rU3YfYS61qTUHGyZ+1 u0ow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=DUVqWY0x; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-88577-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88577-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id l19-20020a37f513000000b00787bc601c72si3625584qkk.165.2024.03.01.06.44.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 06:44:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88577-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=DUVqWY0x; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-88577-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88577-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 25BE01C228C8 for ; Fri, 1 Mar 2024 14:44:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 71D786FBB8; Fri, 1 Mar 2024 14:44:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="DUVqWY0x" 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 CD1763AC0C for ; Fri, 1 Mar 2024 14:44:13 +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=1709304255; cv=none; b=HCnqeMWYLtGLRzq25zep1shHNAABDUTpPYW9/G9GtTqF9J1G4pL1JsxusbV+j1WKQSERdlwDcFyjPwmuIipndf4LtjVdMOY+Tm6H+HDPvWONs27DEyNOBHr5SGkTgARkc4pwhU7fscwDS+nfrx7W8D+yNafpYlrSw3Is8aZOQtI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709304255; c=relaxed/simple; bh=nEBISZhRLnmZQR1GppQaZadHgVStFIak6rMZ86tO/Gc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UpqQBZpLh+7+oXSTGCNv11CuSM7FL7JVRf6u4RNTAGJu+760dY4JjUVqFbfzS926ye51cgaBJzRGN0Hrhv1KCTWW/lwE2TCyPG3BsKvXOlaRCZ0WHfh/3zMeSmjRJAyxkEmaH3Js8A3E1iYgRfQOXBYclma7cm0WHVcFG/C+0Nw= 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=DUVqWY0x; 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 X-UUID: 2795cee0d7da11ee935d6952f98a51a9-20240301 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=oTUfVJxuZrvqX09d0OmYEW32i4hjXrbksVX4sghk4+0=; b=DUVqWY0xfQM3U/Lc9kZVGgIjr6AmlXxLN1MznG5LeScY7l7x9H6AiiXgGmrFWn7FKpGNc/d7BEAPph6Xn+e9E8dnQKrBWAiExsRVnQLlc9Le1tpTqeobujiRLUWjnDr3CNsVWGXEQvtJGf2dJQ73YGP5lLnBrodZEoi549MWlYI=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:49fbbb22-8d38-4923-8944-c6ae1f536402,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:3044e88f-e2c0-40b0-a8fe-7c7e47299109,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: 2795cee0d7da11ee935d6952f98a51a9-20240301 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 1447994538; Fri, 01 Mar 2024 22:44:06 +0800 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; Fri, 1 Mar 2024 22:44:05 +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; Fri, 1 Mar 2024 22:44:05 +0800 From: Jason-JH.Lin To: Jassi Brar , Chun-Kuang Hu , Matthias Brugger CC: AngeloGioacchino Del Regno , Jason-ch Chen , "Jason-JH . Lin" , Singo Chang , Nancy Lin , Shawn Sung , , , , Subject: [RESEND, PATCH 4/5] soc: mediatek: mtk-cmdq: Add cmdq_pkt_acquire_event() function Date: Fri, 1 Mar 2024 22:44:02 +0800 Message-ID: <20240301144403.2977-5-jason-jh.lin@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20240301144403.2977-1-jason-jh.lin@mediatek.com> References: <20240301144403.2977-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-Type: text/plain X-MTK: N Add cmdq_pkt_acquire_event() function to support CMDQ user making an instruction for acquiring event. CMDQ users can use cmdq_pkt_acquire_event() and cmdq_pkt_clear_event() to acquire GCE event and release GCE event and achieve the MUTEX_LOCK protection between GCE threads. Signed-off-by: Jason-JH.Lin --- drivers/soc/mediatek/mtk-cmdq-helper.c | 15 +++++++++++++++ include/linux/soc/mediatek/mtk-cmdq.h | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c index 2e9fc9bb1183..0183b40a0eff 100644 --- a/drivers/soc/mediatek/mtk-cmdq-helper.c +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c @@ -342,6 +342,21 @@ int cmdq_pkt_wfe(struct cmdq_pkt *pkt, u16 event, bool clear) } EXPORT_SYMBOL(cmdq_pkt_wfe); +int cmdq_pkt_acquire_event(struct cmdq_pkt *pkt, u16 event) +{ + struct cmdq_instruction inst = {}; + + if (event >= CMDQ_MAX_EVENT) + return -EINVAL; + + inst.op = CMDQ_CODE_WFE; + inst.value = CMDQ_WFE_UPDATE | CMDQ_WFE_UPDATE_VALUE | CMDQ_WFE_WAIT; + inst.event = event; + + return cmdq_pkt_append_command(pkt, inst); +} +EXPORT_SYMBOL(cmdq_pkt_acquire_event); + int cmdq_pkt_clear_event(struct cmdq_pkt *pkt, u16 event) { struct cmdq_instruction inst = { {0} }; diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/mediatek/mtk-cmdq.h index 2fe9be240fbc..de93c0a8e8a9 100644 --- a/include/linux/soc/mediatek/mtk-cmdq.h +++ b/include/linux/soc/mediatek/mtk-cmdq.h @@ -202,6 +202,15 @@ int cmdq_pkt_mem_move(struct cmdq_pkt *pkt, dma_addr_t src_addr, dma_addr_t dst_ */ int cmdq_pkt_wfe(struct cmdq_pkt *pkt, u16 event, bool clear); +/** + * cmdq_pkt_acquire_event() - append acquire event command to the CMDQ packet + * @pkt: the CMDQ packet + * @event: the desired event to be acquired + * + * Return: 0 for success; else the error code is returned + */ +int cmdq_pkt_acquire_event(struct cmdq_pkt *pkt, u16 event); + /** * cmdq_pkt_clear_event() - append clear event command to the CMDQ packet * @pkt: the CMDQ packet -- 2.18.0