Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3824683ybl; Tue, 20 Aug 2019 02:52:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9D16mYYnAeYseckO+eIDji1q1vW4OQPr2qgs6fyhrWVGNjewROE5P2IkX325lT/zWpwrj X-Received: by 2002:a17:902:b28:: with SMTP id 37mr27278059plq.2.1566294745862; Tue, 20 Aug 2019 02:52:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566294745; cv=none; d=google.com; s=arc-20160816; b=m5AWVwMVxg36Ncv9ajJW9YlYFhWKcyIhYBU4VFbTh85UvYyqQTWTL6IZYvT+UcPb/1 8XHE0qbaDifHJcqvvqdy3uuGVsvJKygbWM8QbZrMHywj1VNogZkxN8hrMKm4J8GLLrCX JC5pynnrnEPdB6Ery3M63rbMaDl+Zxf50yhv9ZDeWk/fqJIdkA9K8S8EqL0loDu6XfeA x3Vp10ePqgpyWVJeYS5rNYHiRgADTQNB4YFGMdIB45jgiNHTG9z3Hr7bOAvDF4/HUEzy ucr96E+jsXIBYtgr8Sir6hFvYL0aAQITJ+zeb/SdqABL26JmyEOQff9tkUH/R4Re93lj uzVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=3G65+rcWgv4LJlh4Ie7nYVx4DA7yo1K1LfeitjsDHNg=; b=VqzSyP5mgIYiPOTm9YhG6un43noJS99Z3k+/PaGOK5yhxi5CkL2k1rQSqwTiNG/Dn2 F9FPvPWKE8lAr07VuKDrXB6c20T6SmCM3UzAeKTRFpm/u5WhJQm+DmwygcQNAk/mqait fSyKLtFCy0hdUMgmVebRJzzP+dAX34sMTsVHKSaKpF7YvryUDx3C4q/BwjNht03u1inV erTmbkTPVQI0vtVMa+QZ35tHdpUwzHQUiaJr/2shRarQEyCoq/Z+eKltTGU58laVnWSZ yD9ObXYERTPRSK24HnNrSERAeG7qGgB4/qe7ldXqarsD3VI8/c+BzwQ0RivBKwcAmZrR AorQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d35si11964572pla.174.2019.08.20.02.52.11; Tue, 20 Aug 2019 02:52:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729895AbfHTJu6 (ORCPT + 99 others); Tue, 20 Aug 2019 05:50:58 -0400 Received: from mailgw02.mediatek.com ([1.203.163.81]:22109 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728842AbfHTJu5 (ORCPT ); Tue, 20 Aug 2019 05:50:57 -0400 X-UUID: 0d111ed75cf6450da6462f8b5b67472c-20190820 X-UUID: 0d111ed75cf6450da6462f8b5b67472c-20190820 Received: from mtkcas36.mediatek.inc [(172.27.4.253)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 466551399; Tue, 20 Aug 2019 17:50:41 +0800 Received: from MTKCAS36.mediatek.inc (172.27.4.186) by MTKMBS31N2.mediatek.inc (172.27.4.87) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 20 Aug 2019 17:50:38 +0800 Received: from [10.17.3.153] (172.27.4.253) by MTKCAS36.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 20 Aug 2019 17:50:37 +0800 Message-ID: <1566294639.24117.20.camel@mhfsdcap03> Subject: Re: [RESEND, PATCH v13 10/12] soc: mediatek: cmdq: add polling function From: houlong wei To: Bibby Hsieh CC: Jassi Brar , Matthias Brugger , Rob Herring , CK Hu =?UTF-8?Q?=28=E8=83=A1=E4=BF=8A=E5=85=89=29?= , "Daniel Kurtz" , Sascha Hauer , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-mediatek@lists.infradead.org" , srv_heupstream , Sascha Hauer , Philipp Zabel , "Nicolas Boichat" , YT Shen =?UTF-8?Q?=28=E6=B2=88=E5=B2=B3=E9=9C=86=29?= , Daoyuan Huang =?UTF-8?Q?=28=E9=BB=83=E9=81=93=E5=8E=9F=29?= , Jiaguang Zhang =?UTF-8?Q?=28=E5=BC=A0=E5=8A=A0=E5=B9=BF=29?= , Dennis-YC Hsieh =?UTF-8?Q?=28=E8=AC=9D=E5=AE=87=E5=93=B2=29?= , Ginny Chen =?UTF-8?Q?=28=E9=99=B3=E6=B2=BB=E5=82=91=29?= , Date: Tue, 20 Aug 2019 17:50:39 +0800 In-Reply-To: <20190820084932.22282-11-bibby.hsieh@mediatek.com> References: <20190820084932.22282-1-bibby.hsieh@mediatek.com> <20190820084932.22282-11-bibby.hsieh@mediatek.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-SNTS-SMTP: AD847517EDF494422E6C49834592B2BA7A3D1534F5AC2FD5ACD6AD8A255DC0552000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2019-08-20 at 16:49 +0800, Bibby Hsieh wrote: > add polling function in cmdq helper functions > > Signed-off-by: Bibby Hsieh > Reviewed-by: CK Hu > --- > drivers/soc/mediatek/mtk-cmdq-helper.c | 28 ++++++++++++++++++++++++ > include/linux/mailbox/mtk-cmdq-mailbox.h | 1 + > include/linux/soc/mediatek/mtk-cmdq.h | 15 +++++++++++++ > 3 files changed, 44 insertions(+) > > diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c > index e3d5b0be8e79..c53f8476c68d 100644 > --- a/drivers/soc/mediatek/mtk-cmdq-helper.c > +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c > @@ -221,6 +221,34 @@ int cmdq_pkt_clear_event(struct cmdq_pkt *pkt, u16 event) > } > EXPORT_SYMBOL(cmdq_pkt_clear_event); > > +int cmdq_pkt_poll(struct cmdq_pkt *pkt, u8 subsys, > + u16 offset, u32 value, u32 mask) > +{ > + struct cmdq_instruction *inst; > + > + if (mask != 0xffffffff) { > + inst = cmdq_pkt_append_command(pkt); > + if (!inst) > + return -ENOMEM; > + > + inst->op = CMDQ_CODE_MASK; > + inst->value = ~mask; > + offset = offset | 0x1; > + } > + > + inst = cmdq_pkt_append_command(pkt); > + if (!inst) > + return -ENOMEM; > + > + inst->op = CMDQ_CODE_POLL; > + inst->value = value; > + inst->offset = offset; > + inst->subsys = subsys; > + > + return 0; > +} > +EXPORT_SYMBOL(cmdq_pkt_poll); > + > static int cmdq_pkt_finalize(struct cmdq_pkt *pkt) > { > struct cmdq_instruction *inst; > diff --git a/include/linux/mailbox/mtk-cmdq-mailbox.h b/include/linux/mailbox/mtk-cmdq-mailbox.h > index c8adedefaf42..9e3502945bc1 100644 > --- a/include/linux/mailbox/mtk-cmdq-mailbox.h > +++ b/include/linux/mailbox/mtk-cmdq-mailbox.h > @@ -46,6 +46,7 @@ > enum cmdq_code { > CMDQ_CODE_MASK = 0x02, > CMDQ_CODE_WRITE = 0x04, > + CMDQ_CODE_POLL = 0x08, > CMDQ_CODE_JUMP = 0x10, > CMDQ_CODE_WFE = 0x20, > CMDQ_CODE_EOC = 0x40, > diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/mediatek/mtk-cmdq.h > index 9618debb9ceb..a345870a6d10 100644 > --- a/include/linux/soc/mediatek/mtk-cmdq.h > +++ b/include/linux/soc/mediatek/mtk-cmdq.h > @@ -99,6 +99,21 @@ int cmdq_pkt_wfe(struct cmdq_pkt *pkt, u16 event); > */ > int cmdq_pkt_clear_event(struct cmdq_pkt *pkt, u16 event); > > +/** > + * cmdq_pkt_poll() - Append polling command to the CMDQ packet, ask GCE to > + * execute an instruction that wait for a specified hardware > + * register to check for the value. All GCE hardware > + * threads will be blocked by this instruction. > + * @pkt: the CMDQ packet > + * @subsys: the CMDQ sub system code > + * @offset: register offset from CMDQ sub system > + * @value: the specified target register value > + * @mask: the specified target register mask > + * > + * Return: 0 for success; else the error code is returned > + */ > +int cmdq_pkt_poll(struct cmdq_pkt *pkt, u8 subsys, > + u16 offset, u32 value, u32 mask); > /** > * cmdq_pkt_flush_async() - trigger CMDQ to asynchronously execute the CMDQ > * packet and call back at the end of done packet Reviewed-by: Houlong Wei