Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C002DC433F5 for ; Thu, 25 Nov 2021 08:25:47 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 1AE2C1828; Thu, 25 Nov 2021 09:24:55 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1AE2C1828 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637828745; bh=QwPZq/jl5XuE9VBWfjOrXWTriG7Q8YL7m/hdAlaferw=; h=Subject:From:To:Date:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=k+YG8xOXpFzoeiDcSro1SEXQC9EGjuBB6cDv/bUXRhY7w1q9+fTEh9pWt5bS9aPbF 1dkfmzxp7cRY93oIruYtWDXCqq6GjM2+WbdlpejdgC3GHAgUr0vvIEH2b4W76fMwE4 gMsmKdE1wpH5EkQF1euMXOJn3naYOretZpcOrwBo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 60DFEF804AB; Thu, 25 Nov 2021 09:24:54 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 25BC4F8049E; Thu, 25 Nov 2021 09:24:47 +0100 (CET) Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4395FF80087; Thu, 25 Nov 2021 09:24:39 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4395FF80087 X-UUID: ce4a736e9ec949118e53bf084a580923-20211125 X-UUID: ce4a736e9ec949118e53bf084a580923-20211125 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1816071343; Thu, 25 Nov 2021 16:24:34 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Thu, 25 Nov 2021 16:24:32 +0800 Received: from mtksdccf07 (172.21.84.99) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 25 Nov 2021 16:24:32 +0800 Message-ID: Subject: Re: [PATCH v3 2/3] mailbox: mediatek: add support for adsp mailbox controller From: allen-kh.cheng To: Tzung-Bi Shih Date: Thu, 25 Nov 2021 16:24:32 +0800 References: <20211124084514.28002-1-allen-kh.cheng@mediatek.com> <20211124084514.28002-3-allen-kh.cheng@mediatek.com> In-Reply-To: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-MTK: N Cc: "devicetree@vger.kernel.org" , Linux-ALSA , Kai Vehmanen , "cujomalainey@google.com" , Daniel Baluta , Mark Brown , Jassi Brar , Liam Girdwood , "linux-kernel@vger.kernel.org" , Project_Global_Chrome_Upstream_Group , Rob Herring , "linux-mediatek@lists.infradead.org" , Ranjani Sridharan , Matthias Brugger , Takashi Iwai , Pierre-Louis Bossart , "linux-arm-kernel@lists.infradead.org" , "sound-open-firmware@alsa-project.org" X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Thu, 2021-11-25 at 14:23 +0800, Tzung-Bi Shih wrote: > > On Thu, Nov 25, 2021 at 09:51:27AM +0800, allen-kh.cheng wrote: > > > > On Wed, 2021-11-24 at 18:25 +0800, Tzung-Bi Shih wrote: > > > > > > > > On Wed, Nov 24, 2021 at 04:45:13PM +0800, allen- > > > > kh.cheng wrote: > > > > > > > > > > > > +static int mtk_adsp_mbox_send_data(struct > > > > > > mbox_chan *chan, > > > > > > > > > > > > > > > > > > > > void > > > > > > > > > > > > *data) > > > > > > > > > > > > +{ > > > > > > > > > > > > + struct adsp_mbox_ch_info *ch_info = chan- > > > > > > >con_priv; > > > > > > > > > > > > + void __iomem *reg = ch_info->va_reg; > > > > > > > > > > > > + > > > > > > > > > > > > + spin_lock(&ch_info->lock); > > > > > > > > > > > > + writel(ch_info->ipc_op_val, reg + > > > > > > MTK_ADSP_MBOX_IN_CMD); > > > > > > > > > > > > + spin_unlock(&ch_info->lock); > > > > > > > > > > > > > > > > > > > > Why does it need the lock? > > > > > > > > > > > > > > > > Is the write to MTK_ADSP_MBOX_IN_CMD a synchronous > > > > operation? > > > > > > > > - If yes, I failed to understand why does it need the > > > > > > > > lock. Every > > > > > > > > calls to mtk_adsp_mbox_send_data() should wait for the > > > > data > > > > > > > > > > > > > > > transfer > > > > > > > > completion. > > > > > > > > - If no, I also failed to understand > > > > > > > > > > > > > > > why. mtk_adsp_mbox_send_data() > > > > > > > > has no way to be aware of the transfer > > > > completion. Would > > > > > > > > expect a > > > > > > > > loop for checking the completion for the case. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > In ADSP MBOX IPC flow, > > > > > > > > Host would call mbox send data when the shared data transfer > > > > completed. > > > > > > > > (mtk_adsp_mbox_send_data will notice client using > > > > MTK_ADSP_MBOX_IN_CMD) > > > > > > > > It’s more like a signal. > > > > > > > > In general case, > > > > > > > > There may be some hosts use the same mbox channel. > > > > > > > > I think it’s better using lock to protect access to > > > > MTK_ADSP_MBOX_IN_CMD registers > > > > > I still failed to understand. What if 2 hosts notify the same > client > > by writing MTK_ADSP_MBOX_IN_CMD at the same time? Hi Tzung-Bi, After I think carefully. There is no need to add lock in mtk_adsp_mbox_send_data. In our dsp ipc design, we only have one host(ap) and one client(dsp). If sof ip message transfer is complete, host will use mbox notice dsp message arrived. (MTK_ADSP_MBOX_IN_CMD is signal to trigger mbox irq) I will remove this in next version.