Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1845972imm; Thu, 27 Sep 2018 03:32:32 -0700 (PDT) X-Google-Smtp-Source: ACcGV632UqishE1vOCCVot9IVkiR/ppGMttJ4APqdWDF7wJyDi6vhMjJpc1h2CMjwmxqOaHB8QVs X-Received: by 2002:a63:d946:: with SMTP id e6-v6mr335957pgj.24.1538044352398; Thu, 27 Sep 2018 03:32:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538044352; cv=none; d=google.com; s=arc-20160816; b=pU01mvUtEbDSiChDDnjTKeHwdhq3xk/ePkQVrZM7jSq9R6qTVljhArkODdaqoYGIMl zRlMbih4I3nzb1OWHqwelsT7eSOh2+jtlshZNVCOROp6xe6NeX0iJmVUk4kGtLzVY21z 7c17o43fXHIRPDvqDFgRu0YpNrSlt5fC8C0NEWqd/DXrYLJwDR9DP083t0pTRVnGcFPa d2u0o1VaxEaoMggYpPTIGuudgC5g6L0lNYmSuFzS6kHJpiJedApF+ziambvOVoXHUlHr VOqLk1DBX7/R9QtaTWSzPsN1UbR00DtIAZP8PlL1DNCialpa2m3UmdCFNxrXahgHOcrd z8JQ== 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=wOMbWmPVjb+duM4IObJRsrSyhft3JxTWaf5iYhCdTy4=; b=ka2YctONxpNNApKEbOjZR0QphFTOCnBAYHdl720NLRmC4UzUP+46wIiQIu5aiwB6gR Lh359KQHozexcxtsQ2gIq0Ihdu11CTlDU7KsP7s+ec7H9JGl5XIrDdCjHEEiUQ2cEqod r9/ZeVWHs9IiIVNcqbqcQPA46xxZh/8G25ildtGBEdSF872NfSPlcSb7sEbMeyguTQUi kmv5/02oubzVZiSS7rXRCdER3yAAhaQstvSkEW/S5xbPFJUX3MxAWoGdpAt3bxDnV79V 1kUBCMi1K/y0CK9bggXxas+UOq9oEIXLwtUYnZ/Y+mYAg7W/5bCrKUMVCyDsjANuzrxp Vi0Q== 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 y20-v6si1680313plr.110.2018.09.27.03.32.17; Thu, 27 Sep 2018 03:32:32 -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 S1727363AbeI0Qs3 (ORCPT + 99 others); Thu, 27 Sep 2018 12:48:29 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:59909 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726959AbeI0Qs1 (ORCPT ); Thu, 27 Sep 2018 12:48:27 -0400 X-UUID: 6e25e46227994875a424110e5e14f151-20180927 Received: from mtkcas34.mediatek.inc [(172.27.4.250)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 838928504; Thu, 27 Sep 2018 18:30:48 +0800 Received: from MTKCAS32.mediatek.inc (172.27.4.184) by MTKMBS31N1.mediatek.inc (172.27.4.69) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 27 Sep 2018 18:30:47 +0800 Received: from [10.17.3.153] (10.17.3.153) by MTKCAS32.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Thu, 27 Sep 2018 18:30:46 +0800 Message-ID: <1538044246.17514.51.camel@mhfsdcap03> Subject: Re: [PATCH v23 4/4] 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: Thu, 27 Sep 2018 18:30:46 +0800 In-Reply-To: <3773f620-e135-578d-5307-08483436f4c2@gmail.com> References: <1532482002-11164-1-git-send-email-houlong.wei@mediatek.com> <1532482002-11164-5-git-send-email-houlong.wei@mediatek.com> <1538013431.17514.31.camel@mhfsdcap03> <3773f620-e135-578d-5307-08483436f4c2@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 Thu, 2018-09-27 at 15:50 +0800, Matthias Brugger wrote: > > On 27/09/2018 03:57, 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; > >> > >> Why do we update the cmd_buf_size here? > > > > Because in developing phase of consumer driver, the consumer has to know > > the real command buffer size after adding command failure. Then the > > consumer will increase the size and run the cmdq flow (cmdq_pkt_create, > > cmdq_pkt_write/wfe...) again. Finally, the consumer get the real size > > and fix it. > > > > But the consumer should know the size it needs for it's buffer and if not it > should be able to decide on it's own how much space it needs. If he get's a > -ENOMEM he implicitly knows that he has to increase the buf_size. Now the size > depends on how many command he has pending and wasn't able to write to the cmdq_pkt. > > Regards, > Matthias The consumer doesn't know how to calculate the command buffer size that he needs. When the consumer driver is developing, he could ignore the return value of cmdq_pkt_write and other command appending functions. He can print the pkt->cmdq_buf_size after cmdq_pkt_flush() or cmdq_pkt_flush_async() failure. Now he can get the buffer size he needs. I copy your another comment here, so I can reply in one mail. >>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. Thanks, I will move WARN_ON() into cmdq_pkt_append_command() before returning -ENOMEM. After your confirmation of the comments above, I will re-send a new patch.