From: Matthias Brugger <matthias.bgg@gmail.com>
To: houlong wei <houlong.wei@mediatek.com>
Cc: "Jassi Brar" <jassisinghbrar@gmail.com>,
"Rob Herring" <robh+dt@kernel.org>,
"Daniel Kurtz" <djkurtz@chromium.org>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
srv_heupstream <srv_heupstream@mediatek.com>,
"Sascha Hauer" <kernel@pengutronix.de>,
"Philipp Zabel" <p.zabel@pengutronix.de>,
"Nicolas Boichat" <drinkcat@chromium.org>,
"CK Hu (胡俊光)" <ck.hu@mediatek.com>,
"Bibby Hsieh (謝濟遠)" <Bibby.Hsieh@mediatek.com>
Subject: Re: [PATCH v23 4/4] soc: mediatek: Add Mediatek CMDQ helper
Date: Thu, 27 Sep 2018 09:55:00 +0200 [thread overview]
Message-ID: <23d76d03-c0e9-cd83-f9a8-f5efa0c72938@gmail.com> (raw)
In-Reply-To: <1534297570.21668.3.camel@mhfsdcap03>
On 15/08/2018 03:46, houlong wei wrote:
[...]
>> +
>> +static int cmdq_pkt_append_command(struct cmdq_pkt *pkt, enum cmdq_code code,
>> + u32 arg_a, u32 arg_b)
>> +{
>> + u64 *cmd_ptr;
>> +
>> + if (unlikely(pkt->cmd_buf_size + CMDQ_INST_SIZE > pkt->buf_size)) {
>> + pkt->cmd_buf_size += CMDQ_INST_SIZE;
>> + return -ENOMEM;
>> + }
>> + cmd_ptr = pkt->va_base + pkt->cmd_buf_size;
>> + (*cmd_ptr) = (u64)((code << CMDQ_OP_CODE_SHIFT) | arg_a) << 32 | arg_b;
>> + pkt->cmd_buf_size += CMDQ_INST_SIZE;
>> +
>> + return 0;
>> +}
>> +
>> +int cmdq_pkt_write(struct cmdq_pkt *pkt, u32 value, u32 subsys, u32 offset)
>> +{
>> + u32 arg_a = (offset & CMDQ_ARG_A_WRITE_MASK) |
>> + (subsys << CMDQ_SUBSYS_SHIFT);
>> +
>> + return cmdq_pkt_append_command(pkt, CMDQ_CODE_WRITE, arg_a, value);
>> +}
>> +EXPORT_SYMBOL(cmdq_pkt_write);
>> +
>> +int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u32 value,
>> + u32 subsys, u32 offset, u32 mask)
>> +{
>> + u32 offset_mask = offset;
>> + int err;
>> +
>> + if (mask != 0xffffffff) {
>> + err = cmdq_pkt_append_command(pkt, CMDQ_CODE_MASK, 0, ~mask);
>> + WARN_ON(err < 0);
If we want to write out a warning to the kernel log, then we should but that in
the if (unlikely(pkt->cmd_buf_size + CMDQ_INST_SIZE > pkt->buf_size)) from
cmdq_pkt_append_command to make it consistent between cmdq_pkt_write,
cmdq_pkt_write_mask and cmdq_pkt_finalize
Sorry, just saw this right now.
>> + offset_mask |= CMDQ_WRITE_ENABLE_MASK;
>> + }
>> +
>> + return cmdq_pkt_write(pkt, value, subsys, offset_mask);
>> +}
>> +EXPORT_SYMBOL(cmdq_pkt_write_mask);
>> +
>> +int cmdq_pkt_wfe(struct cmdq_pkt *pkt, u32 event)
>> +{
>> + u32 arg_b;
>> +
>> + if (event >= CMDQ_MAX_EVENT)
>> + return -EINVAL;
>> +
>> + /*
>> + * WFE arg_b
>> + * bit 0-11: wait value
>> + * bit 15: 1 - wait, 0 - no wait
>> + * bit 16-27: update value
>> + * bit 31: 1 - update, 0 - no update
>> + */
>> + arg_b = CMDQ_WFE_UPDATE | CMDQ_WFE_WAIT | CMDQ_WFE_WAIT_VALUE;
>> +
>> + return cmdq_pkt_append_command(pkt, CMDQ_CODE_WFE, event, arg_b);
>> +}
>> +EXPORT_SYMBOL(cmdq_pkt_wfe);
>> +
>> +int cmdq_pkt_clear_event(struct cmdq_pkt *pkt, u32 event)
>> +{
>> + if (event >= CMDQ_MAX_EVENT)
>> + return -EINVAL;
>> +
>> + return cmdq_pkt_append_command(pkt, CMDQ_CODE_WFE, event,
>> + CMDQ_WFE_UPDATE);
>> +}
>> +EXPORT_SYMBOL(cmdq_pkt_clear_event);
>> +
>> +static int cmdq_pkt_finalize(struct cmdq_pkt *pkt)
>> +{
>> + int err;
>> +
>> + /* insert EOC and generate IRQ for each command iteration */
>> + err = cmdq_pkt_append_command(pkt, CMDQ_CODE_EOC, 0, CMDQ_EOC_IRQ_EN);
>> + WARN_ON(err < 0);
Should move into cmdq_pkt_append_command
>> +
>> + /* JUMP to end */
>> + err = cmdq_pkt_append_command(pkt, CMDQ_CODE_JUMP, 0, CMDQ_JUMP_PASS);
>> + WARN_ON(err < 0);
same here.
>> +
>> + return err;
>> +}
>> +
[...]
Regards,
Matthias
next prev parent reply other threads:[~2018-09-27 7:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-25 1:26 [PATCH v23 0/4] MediaTek MT8173 CMDQ support Houlong Wei
2018-07-25 1:26 ` [PATCH v23 1/4] dt-bindings: soc: Add documentation for the MediaTek GCE unit Houlong Wei
2018-07-25 14:47 ` Rob Herring
2018-07-25 1:26 ` [PATCH v23 2/4] mailbox: mediatek: Add Mediatek CMDQ driver Houlong Wei
2018-07-27 5:39 ` CK Hu
2018-07-25 1:26 ` [PATCH v23 3/4] arm64: dts: mt8173: Add GCE node Houlong Wei
2018-08-15 1:48 ` houlong wei
2018-09-09 6:57 ` houlong wei
2018-07-25 1:26 ` [PATCH v23 4/4] soc: mediatek: Add Mediatek CMDQ helper Houlong Wei
2018-08-15 1:46 ` houlong wei
2018-09-09 6:54 ` houlong wei
2018-09-27 7:55 ` Matthias Brugger [this message]
2018-09-26 15:53 ` Matthias Brugger
2018-09-27 1:57 ` houlong wei
2018-09-27 7:50 ` Matthias Brugger
2018-09-27 10:30 ` houlong wei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=23d76d03-c0e9-cd83-f9a8-f5efa0c72938@gmail.com \
--to=matthias.bgg@gmail.com \
--cc=Bibby.Hsieh@mediatek.com \
--cc=ck.hu@mediatek.com \
--cc=devicetree@vger.kernel.org \
--cc=djkurtz@chromium.org \
--cc=drinkcat@chromium.org \
--cc=houlong.wei@mediatek.com \
--cc=jassisinghbrar@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=p.zabel@pengutronix.de \
--cc=robh+dt@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=srv_heupstream@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).