Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3072604imm; Sun, 7 Oct 2018 19:29:46 -0700 (PDT) X-Google-Smtp-Source: ACcGV63uidp/IK851+2BHZd+rY4GRTLPRM4MW0gtve+zhTb5Vybsmtj8SR0H977pDRIj6agxRvKm X-Received: by 2002:a63:e216:: with SMTP id q22-v6mr19008750pgh.206.1538965786474; Sun, 07 Oct 2018 19:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538965786; cv=none; d=google.com; s=arc-20160816; b=ypEGh7Qgl+VXOqTip1ceSI0g+h53Q9cBP4ZROMvorjdexY1ijxYsXOQ1IurClmr57L EswXlWgIIBLg25ojPsn1skfg7hlXfJv17TM1A+Pt2UzXMal+NMaSkIH5F0qjUPb39AZX dgxvtjUb2E9xJzCYOU4Y1p50u6VNSu4J84iqMJbvQFPbtY0s9nS+QcSX2RV6IjmIjR5i ThObis2nGoAxo6Yh+xHMQvXCxklwkpMdk2nN3LmbF/vYiJanwYQKXU9rcVeWhRxZX6pb 7mFrh/zlJ2IC+EWS9ZLsI3QzI/34DI9xQby9gpUSog+fTeSQZaioF7qVR304dFj17rZ3 jkUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id; bh=JNTKCCJBFrklNb0tgdYd4L+kml29TXXaaDM8K+zu3nI=; b=1JlN1HcljtgsZIEwAOQWBTX6RCFDtKhfeZSflAn1Ne7Lof41pfnlYiY9Ld9C5TJlN/ 0SN9kF98N7MogVtzXVYrluulVyPoH3iFIEVk1AHcPZfQtujtXoNEGWyfht9z4o6jeJ+4 B4w4MfFdo6T7EVBKvTafZWcm21tWfbUyuWgLJGruFHW4cVFHW+JxRqZ0ISCT5O8lcbGE 6/xn3pbZ/zmT9nJ9dsmv7h8Qa+BBNcRaV8tViYH0tLkoAkJkKs0bjIVA7Sff5+PQ/XL7 Posqh7deyYC1Benlbg2gfDMG/3U3KOH88Y6fW3V8e4gBnp6KiBdq+aDPE9VlV4CObB8C RNjA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h25-v6si16916565pgn.567.2018.10.07.19.29.31; Sun, 07 Oct 2018 19:29:46 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726548AbeJHJif (ORCPT + 99 others); Mon, 8 Oct 2018 05:38:35 -0400 Received: from mailgw02.mediatek.com ([1.203.163.81]:51979 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725760AbeJHJif (ORCPT ); Mon, 8 Oct 2018 05:38:35 -0400 X-UUID: 763574578d224a5fb2f1997172f0b3f9-20181008 X-UUID: 763574578d224a5fb2f1997172f0b3f9-20181008 Received: from mtkcas36.mediatek.inc [(172.27.4.250)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 1584730236; Mon, 08 Oct 2018 10:29:09 +0800 Received: from MTKCAS36.mediatek.inc (172.27.4.186) by MTKMBS31DR.mediatek.inc (172.27.6.102) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 8 Oct 2018 10:29:07 +0800 Received: from [10.17.3.153] (10.17.3.153) by MTKCAS36.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 8 Oct 2018 10:29:06 +0800 Message-ID: <1538965746.4271.20.camel@mhfsdcap03> Subject: Re: [PATCH v25 2/2] soc: mediatek: Add Mediatek CMDQ helper From: houlong wei To: Matthias Brugger 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" , CK Hu =?UTF-8?Q?=28=E8=83=A1=E4=BF=8A=E5=85=89=29?= , "Bibby Hsieh =?UTF-8?Q?=28=E8=AC=9D=E6=BF=9F=E9=81=A0=29?=" , 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?= , Monica Wang =?UTF-8?Q?=28=E7=8E=8B=E5=AD=9F=E5=A9=B7=29?= , Hs Liao =?UTF-8?Q?=28=E5=BB=96=E5=AE=8F=E7=A5=A5=29?= , Ginny Chen =?UTF-8?Q?=28=E9=99=B3=E6=B2=BB=E5=82=91=29?= , Enzhu Wang =?UTF-8?Q?=28=E7=8E=8B=E6=81=A9=E6=9F=B1=29?= , Date: Mon, 8 Oct 2018 10:29:06 +0800 In-Reply-To: <7040427b-f580-ec33-8afa-35dcf5735abb@gmail.com> References: <1538212903-14331-1-git-send-email-houlong.wei@mediatek.com> <1538212903-14331-3-git-send-email-houlong.wei@mediatek.com> <7040427b-f580-ec33-8afa-35dcf5735abb@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2018-09-29 at 20:50 +0800, Matthias Brugger wrote: > > On 29/09/2018 11:21, 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; > > Can you plesae provide some example code of a driver that will use this API, I > still don't understand why you need to update the cmd_buf_size here. In our previous design, when appending a new command to buffer and the buffer gets overflow, we will re-allocate a larger buffer to use. CK.Hu had concern about the performance of buffer re-allocation. Please refer: http://lists.infradead.org/pipermail/linux-mediatek/2018-June/013797.html One of his suggestions is that the consumer dynamically allocates buffer with a initial size. Because the consumer doesn't know how to calculate the buffer size. So we increase cmdq_buf_size here, that will help the consumer get the buffer size in developing phase. In release driver code, consumer passes a constant value to function call cmdq_pkt_create(client, cmdq_buffer_size), cmdq_buffer_size is the specified command queue buffer size. > > > + WARN_ON(1); > > can we add some debug information: > WARN_ON(1, "%s: buffer size too small for the amount of commands", __func__); > > Would it make sense to use WARN_ONCE()? > Yes, I will add debug information and use WARN_ONCE(). > > + 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; > > +} > > Thanks, > Matthias