Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1707160imm; Thu, 27 Sep 2018 00:55:58 -0700 (PDT) X-Google-Smtp-Source: ACcGV60i3MI1RRUfkS5Kahe6buPkMRpLPYZ3uPyYNnYHDWoD6ArIoXBwng8vy8fKfMDxwbJR8RKW X-Received: by 2002:a63:4907:: with SMTP id w7-v6mr8941519pga.123.1538034958649; Thu, 27 Sep 2018 00:55:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538034958; cv=none; d=google.com; s=arc-20160816; b=nfApTRR2LDBvxMC/nNTZu6GpCQMWG8Lu+1EU01qLqD7FOMEHvMjLk1XCkc7MO8by/H cXjZhs5/SUOgbCtyBt320fEqUCBk9lc4oHofNlNxF72l35DKgIYIdkL82n8eUHMQutBc xJnaAJHT2i3iHJoEZHgdpgFJfVlX41TtFWBTV91yEE6YvBys4rH7AqvMf+MvCw03H+HP TXiAb1jGVlXtuTOmi/f+q9XJykI6XjxYvVGHLqEdmAHhvR093OoJinNmyibuSTZKmKIh JL22bjRjZfHcaJ+ggltwIT4ZfA6ny2gRulcFH+JxqjuTaJFPieIK/XBRnQq/LSbfiTTg XM1Q== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature; bh=GPpYznAj87DPVzlW6kNndkK3D9Uz+Fy28fCyfcBw0VM=; b=Nnf56mTREUSLO4YFJIHPrIly+O4+E+RxCnZedjfj+wg2iXH3p1hQjWp9rsSD2P6X0O Ovp2woaqRWTZlomipCtjCP3F0yn8rQ5NTEF9WawKKXeTooZ9mxAoTvf0++HzGjC1KvIP UkE1EFNKcxr3lcFb16psPxSWgJsdJe0v8STS/f5WxuzQnsNL3ldp0RCTsTVNnOFalDZ1 hGOttXBo4lVwjQW3qaCkW3ocnC7l1Ztb9rRHDgpHeuw0PA4UnUYBdcxtF7Db3h+3eD+s DJuy6ASl1NnkncEZqYjhR60BiKjsAd3FbwXmpmXIRR1N3rNbTikWCWUNQm3nzp6Dxi6+ Rg3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=n3Xc2tN7; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m7-v6si1302621pls.194.2018.09.27.00.55.43; Thu, 27 Sep 2018 00:55:58 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=n3Xc2tN7; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727131AbeI0OMC (ORCPT + 99 others); Thu, 27 Sep 2018 10:12:02 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:38485 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726708AbeI0OMC (ORCPT ); Thu, 27 Sep 2018 10:12:02 -0400 Received: by mail-ed1-f67.google.com with SMTP id x8-v6so4186780eds.5; Thu, 27 Sep 2018 00:55:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=GPpYznAj87DPVzlW6kNndkK3D9Uz+Fy28fCyfcBw0VM=; b=n3Xc2tN7Lx0dERyjHNQ1nesr467135Mb4UuUvTnL2ay+ZUEW+TnTsYrh3fkXJQqz/3 t05enBTldqSGGftj55nZNg4TjAQRi8eKZMYtQKSaMcb77fTTnZGO5YJqCwLzeJDr9sD+ ZWkVuRWCZt33I3+jWdCULu3KJECPhQpOWDBLTg50vxa/C3TPMAdAHeAHJ5MEiDtXuetC 4o0eazNIlVR2EHr9JmJhlWRPlGGGYCgXuMuEt9jnA368smFGDuqCg5w6VyzX3cR0LsIy rNJTcJ9DbOmGPofV0ulVHsTpxE2+XqhXW+a3Gb+p6cjU/k/QsJCCUazyjN7DclRJW0rX aqTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=GPpYznAj87DPVzlW6kNndkK3D9Uz+Fy28fCyfcBw0VM=; b=BSHFR97c5CWDyl8YEtfLiwtTlLkVsaan5kHjwaoC9N3K8mFyxL+z9Sj5nZafLRRSvg 5VYjNZ5CxHCh21hUsTCZuStVx7/EJTu53TiAmbc5Fg0XtD2G3AybllVGc6pCxeFj038Z x4fDp+LHxkWDQhrMgicaPmc0uvplOgUBmHEaVQkGNgodkEBKLvOV758u5tB+qXnJCX17 xLBz578IY3gQMye5uzgMwPCf5CCbKhgFNu+bVBrF+P2yTwIlCIwtXtfeF31KiprPh/uJ tmPMgswJLUJDJfCtW/aRk8W7hHWD6uJdmIqJ3tny7I9E6EPudjXOfkfKUvPiyLGpG6rM RJ7Q== X-Gm-Message-State: ABuFfojEGN5VyumnasO977G/eMaotomRXu2R4T10DoJOCvOEc+NdsCWw m6nKzq5faP7jZq5iPTFK2ig= X-Received: by 2002:a50:9ac5:: with SMTP id p63-v6mr17097101edb.112.1538034902840; Thu, 27 Sep 2018 00:55:02 -0700 (PDT) Received: from ziggy.stardust ([93.176.144.101]) by smtp.gmail.com with ESMTPSA id j14-v6sm847911edq.25.2018.09.27.00.55.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 00:55:01 -0700 (PDT) Subject: Re: [PATCH v23 4/4] soc: mediatek: Add Mediatek CMDQ helper To: houlong wei Cc: Jassi Brar , Rob Herring , 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 , =?UTF-8?B?Q0sgSHUgKOiDoeS/iuWFiSk=?= , =?UTF-8?B?QmliYnkgSHNpZWggKOisnea/n+mBoCk=?= , =?UTF-8?B?WVQgU2hlbiAo5rKI5bKz6ZyGKQ==?= , =?UTF-8?B?RGFveXVhbiBIdWFuZyAo6buD6YGT5Y6fKQ==?= , =?UTF-8?B?SmlhZ3VhbmcgWmhhbmcgKOW8oOWKoOW5vyk=?= , =?UTF-8?B?RGVubmlzLVlDIEhzaWVoICjorJ3lroflk7Ip?= , =?UTF-8?B?TW9uaWNhIFdhbmcgKOeOi+Wtn+Wptyk=?= , =?UTF-8?B?SHMgTGlhbyAo5buW5a6P56WlKQ==?= , =?UTF-8?B?R2lubnkgQ2hlbiAo6Zmz5rK75YKRKQ==?= , =?UTF-8?B?RW56aHUgV2FuZyAo546L5oGp5p+xKQ==?= References: <1532482002-11164-1-git-send-email-houlong.wei@mediatek.com> <1532482002-11164-5-git-send-email-houlong.wei@mediatek.com> <1534297570.21668.3.camel@mhfsdcap03> From: Matthias Brugger Openpgp: preference=signencrypt Autocrypt: addr=matthias.bgg@gmail.com; prefer-encrypt=mutual; keydata= xsFNBFP1zgUBEAC21D6hk7//0kOmsUrE3eZ55kjc9DmFPKIz6l4NggqwQjBNRHIMh04BbCMY fL3eT7ZsYV5nur7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BvIEBiVvPxy AtL+L+Lh1Sni7w3HBk1EJvUAEQEAAcLBXwQYAQIACQUCU/YJEgIbDAAKCRDZFAuyVhMC8Qnd EACuN16mvivnWwLDdypvco5PF8w9yrfZDKW4ggf9TFVB9skzMNCuQc+tc+QM+ni2c4kKIdz2 jmcg6QytgqVum6V1OsNmpjADaQkVp5jL0tmg6/KA9Tvr07Kuv+Uo4tSrS/4djDjJnXHEp/tB +Fw7CArNtUtLlc8SuADCmMD+kBOVWktZyzkBkDfBXlTWl46T/8291lEspDWe5YW1ZAH/HdCR 1rQNZWjNCpB2Cic58CYMD1rSonCnbfUeyZYNNhNHZosl4dl7f+am87Q2x3pK0DLSoJRxWb7v ZB0uo9CzCSm3I++aYozF25xQoT+7zCx2cQi33jwvnJAK1o4VlNx36RfrxzBqc1uZGzJBCQu4 8UjmUSsTwWC3HpE/D9sM+xACs803lFUIZC5H62G059cCPAXKgsFpNMKmBAWweBkVJAisoQeX 50OP+/11ArV0cv+fOTfJj0/KwFXJaaYh3LUQNILLBNxkSrhCLl8dUg53IbHx4NfIAgqxLWGf XM8DY1aFdU79pac005PuhxCWkKTJz3gCmznnoat4GCnL5gy/m0Qk45l4PFqwWXVLo9AQg2Kp 3mlIFZ6fsEKIAN5hxlbNvNb9V2Zo5bFZjPWPFTxOteM0omUAS+QopwU0yPLLGJVf2iCmItHc UXI+r2JwH1CJjrHWeQEI2ucSKsNa8FllDmG/fQ== Message-ID: <23d76d03-c0e9-cd83-f9a8-f5efa0c72938@gmail.com> Date: Thu, 27 Sep 2018 09:55:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <1534297570.21668.3.camel@mhfsdcap03> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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