lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <23d76d03-c0e9-cd83-f9a8-f5efa0c72938@gmail.com>
Date:   Thu, 27 Sep 2018 09:55:00 +0200
From:   Matthias Brugger <matthias.bgg@...il.com>
To:     houlong wei <houlong.wei@...iatek.com>
Cc:     Jassi Brar <jassisinghbrar@...il.com>,
        Rob Herring <robh+dt@...nel.org>,
        Daniel Kurtz <djkurtz@...omium.org>,
        Sascha Hauer <s.hauer@...gutronix.de>,
        "devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-arm-kernel@...ts.infradead.org" 
        <linux-arm-kernel@...ts.infradead.org>,
        "linux-mediatek@...ts.infradead.org" 
        <linux-mediatek@...ts.infradead.org>,
        srv_heupstream <srv_heupstream@...iatek.com>,
        Sascha Hauer <kernel@...gutronix.de>,
        Philipp Zabel <p.zabel@...gutronix.de>,
        Nicolas Boichat <drinkcat@...omium.org>,
        CK Hu (胡俊光) <ck.hu@...iatek.com>,
        Bibby Hsieh (謝濟遠) 
        <Bibby.Hsieh@...iatek.com>,
        YT Shen (沈岳霆) <Yt.Shen@...iatek.com>,
        Daoyuan Huang (黃道原) 
        <Daoyuan.Huang@...iatek.com>,
        Jiaguang Zhang (张加广) 
        <Jiaguang.Zhang@...iatek.com>,
        Dennis-YC Hsieh (謝宇哲) 
        <Dennis-YC.Hsieh@...iatek.com>,
        Monica Wang (王孟婷) 
        <monica.wang@...iatek.com>,
        Hs Liao (廖宏祥) <Hs.Liao@...iatek.com>,
        Ginny Chen (陳治傑) 
        <ginny.chen@...iatek.com>,
        Enzhu Wang (王恩柱) 
        <enzhu.wang@...iatek.com>
Subject: Re: [PATCH v23 4/4] soc: mediatek: Add Mediatek CMDQ helper



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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ