Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5915913pxj; Wed, 23 Jun 2021 11:46:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/+OnCpCCkyixiK3EXECmRR/mtATLgwpayAo7UI3SnW+g1wmkWH6NVr92x/SNdJ6PfW9gn X-Received: by 2002:a92:7f04:: with SMTP id a4mr628762ild.156.1624473984960; Wed, 23 Jun 2021 11:46:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624473984; cv=none; d=google.com; s=arc-20160816; b=lMrKBm37MmBmG14h5MK9luQHNYtk9r9CTvCosrJPSm4RYHLm4zv3uc5Cl1NtdF+gPe DJs9EpQmEhYyo/R+O4aZcDWgg2mBFR59PFefBUm+AUbOSkqyXa5ZS5R/fvUuZyDjPxZo esBLytf7Nor7WHgZYOzFzmG4G4+nrPD4+jOJkE3mrG964lAL12N2w7hHuK9QDIxVFu6L umcjz8iMUZmvKaBHeHE8Tf6kPcM59PQlyDnMe2haBJDnsmY3XRZQAHdv2k8JuQQPiDKU 5x84EcFyksF40V4vUM4W4MU+WKaFP+wRlWZQiV7N1bO1LAbjazTxiY361axC3Kcx3RN4 X72g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=25Xb4P9ONl4NzuOE9BknQdHYzn3+WMCAH5CmkrDBv8c=; b=jxkWG7ifxPi1GfnwQb10i6YdF/Mt2SG5QVi/wpMw2zIINTYJXM+ykUslxP0yuiHtPc cGIHMMAs/0z/JClOOUMtwLukaV6ThPRJKMKgyzHA6VUiLLEFd7GJtcWbKQXpZKATO3Oj fhz5QHmq22CYR6AB6zX39mWm1jk9wPgRjyCH3vK5f5ydi9YziCowwJEt3ue62h29WOic DT9Tf2B53zri1RYP4lSTgBcQfqZFxSiwvCa+zpU0mBX33VkewJ6DzO9ArbSQ+DIgWiyI aMzdFo+xjhtd/huuf63dFlimcW8cJur1YrLkmjDQPdWyMCHQfIdUX/TpltD23cBjfGpI UcrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="nspS8/ZD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r13si374926ill.4.2021.06.23.11.46.12; Wed, 23 Jun 2021 11:46:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="nspS8/ZD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229994AbhFWSrg (ORCPT + 99 others); Wed, 23 Jun 2021 14:47:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230006AbhFWSrf (ORCPT ); Wed, 23 Jun 2021 14:47:35 -0400 Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4921CC061756 for ; Wed, 23 Jun 2021 11:45:16 -0700 (PDT) Received: by mail-oi1-x22b.google.com with SMTP id s23so4397423oiw.9 for ; Wed, 23 Jun 2021 11:45:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=25Xb4P9ONl4NzuOE9BknQdHYzn3+WMCAH5CmkrDBv8c=; b=nspS8/ZDtdjWSrZvTFB2KZLPbZsxOpGn627p0IOIQNtGCxXkG50wmJ3EULXwPEIzFc mFdNRIrWbhiKHovPgDEdXLAr4/LKlZrtEj0mG+mWTH7HAZVsGxzgLo/SvuiWx1YN5uQH aPp5GXJr56C6TvZxA1xLowlM7TFEbWyxx8CLOW+CXNluKaOmP2FRhXJEMj0X8KLOh1Ui MsKz/Vetz0ClkYt29qCLhtoLf99QlgzJhLcn8Vmi9c49a11Y/dwJfh8HxOyp05b+a5vW hGNXGX8JGfINtmrC+9Icqbz8f9OfASh8MHhBaRFS32+sFwgYXyE2LfNCQGdyyl2yzRAI spQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=25Xb4P9ONl4NzuOE9BknQdHYzn3+WMCAH5CmkrDBv8c=; b=eXw4tOzEVClKDEnARTP3nZUuitgvObKJ9Ii7bab3lysJQfFCESk334hVYTSj3BiiwK 8E9K3JcWK+aSE1Z7Jkco1msnQOcESWrb8pqHdVMMXGd5i5zSZAfAD4aBXe9IEj1GIxwt Qzg4aVLGX3jr3SagoQYmvkuI+AcZHTMnlr8wEt/HhlrV8t/9w0aN1lnGTp1i88bHxJwB 4K6d3bJD4hvjHMsyRLBLsponRxuwhI+GyxbdKLQhnQLTfHK9HBSabyaVcqbsUELlRFIg bafMavn35CXKwIKcTemArPmm94h/i9DnpJquy3C2pimxKGUsh40mOWIIUyoYqsBoAPH1 FkRw== X-Gm-Message-State: AOAM530WSCygAcrLrQdQrYe8mBGUjUqSgfRIG+3gSU9oIIz/S9tH9ZYo m2bWbxtt1qQktmLGPozo8E2yZQ== X-Received: by 2002:aca:3285:: with SMTP id y127mr973809oiy.115.1624473915614; Wed, 23 Jun 2021 11:45:15 -0700 (PDT) Received: from builder.lan (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id v42sm147961ott.70.2021.06.23.11.45.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 11:45:14 -0700 (PDT) Date: Wed, 23 Jun 2021 13:45:13 -0500 From: Bjorn Andersson To: Arnaud POULIQUEN Cc: Ohad Ben-Cohen , Mathieu Poirier , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Subject: Re: [PATCH] remoteproc: stm32: fix mbox_send_message call Message-ID: References: <20210420091922.29429-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 22 Jun 02:56 CDT 2021, Arnaud POULIQUEN wrote: > Hello Bjorn > > On 5/28/21 10:03 AM, Arnaud POULIQUEN wrote: > > Hello Bjorn, > > > > On 5/28/21 5:26 AM, Bjorn Andersson wrote: > >> On Tue 20 Apr 04:19 CDT 2021, Arnaud Pouliquen wrote: > >> > >>> mbox_send_message is called by passing a local dummy message or > >>> a function parameter. As the message is queued, it is dereferenced. > >>> This works because the message field is not used by the stm32 ipcc > >>> driver, but it is not clean. > >>> > >>> Fix by passing a constant string in all cases. > >>> > >>> The associated comments are removed because rproc should not have to > >>> deal with the behavior of the mailbox frame. > >>> > >> > >> Didn't we conclude that the mailbox driver doesn't actually dereference > >> the pointer being passed? > > > > Right it can store the reference to queue the sent. > > > >> > >> If so I would prefer that you just pass NULL, so that if you in the > >> future need to pass some actual data it will be easy to distinguish the > >> old and new case. > > > > I can not use NULL pointer in stm32_rproc_attach and stm32_rproc_detach case. > > The reason is that the tx_done callback is not called if the message is NULL. > > (https://elixir.bootlin.com/linux/latest/source/drivers/mailbox/mailbox.c#L106) > > > > I could use NULL pointer in stm32_rproc_kick, but I would prefer to use the same way > > of calling mbox_send_message for all use cases and not take into account the > > mailbox internal behavior. > > Do you still have any concern about this patch? > I think my concern is now directed at the mailbox api. I think the change is reasonable given that. Thanks for the explanation. I'm picking up the patch. Regards, Bjorn > Thanks, > Arnaud > > > > > Thanks, > > Arnaud > > > > > >> > >> Regards, > >> Bjorn > >> > >>> Reported-by: Bjorn Andersson > >>> Signed-off-by: Arnaud Pouliquen > >>> --- > >>> drivers/remoteproc/stm32_rproc.c | 14 +++++--------- > >>> 1 file changed, 5 insertions(+), 9 deletions(-) > >>> > >>> diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c > >>> index 7353f9e7e7af..0e8203a432ab 100644 > >>> --- a/drivers/remoteproc/stm32_rproc.c > >>> +++ b/drivers/remoteproc/stm32_rproc.c > >>> @@ -474,14 +474,12 @@ static int stm32_rproc_attach(struct rproc *rproc) > >>> static int stm32_rproc_detach(struct rproc *rproc) > >>> { > >>> struct stm32_rproc *ddata = rproc->priv; > >>> - int err, dummy_data, idx; > >>> + int err, idx; > >>> > >>> /* Inform the remote processor of the detach */ > >>> idx = stm32_rproc_mbox_idx(rproc, STM32_MBX_DETACH); > >>> if (idx >= 0 && ddata->mb[idx].chan) { > >>> - /* A dummy data is sent to allow to block on transmit */ > >>> - err = mbox_send_message(ddata->mb[idx].chan, > >>> - &dummy_data); > >>> + err = mbox_send_message(ddata->mb[idx].chan, "stop"); > >>> if (err < 0) > >>> dev_warn(&rproc->dev, "warning: remote FW detach without ack\n"); > >>> } > >>> @@ -493,15 +491,13 @@ static int stm32_rproc_detach(struct rproc *rproc) > >>> static int stm32_rproc_stop(struct rproc *rproc) > >>> { > >>> struct stm32_rproc *ddata = rproc->priv; > >>> - int err, dummy_data, idx; > >>> + int err, idx; > >>> > >>> /* request shutdown of the remote processor */ > >>> if (rproc->state != RPROC_OFFLINE) { > >>> idx = stm32_rproc_mbox_idx(rproc, STM32_MBX_SHUTDOWN); > >>> if (idx >= 0 && ddata->mb[idx].chan) { > >>> - /* a dummy data is sent to allow to block on transmit */ > >>> - err = mbox_send_message(ddata->mb[idx].chan, > >>> - &dummy_data); > >>> + err = mbox_send_message(ddata->mb[idx].chan, "detach"); > >>> if (err < 0) > >>> dev_warn(&rproc->dev, "warning: remote FW shutdown without ack\n"); > >>> } > >>> @@ -556,7 +552,7 @@ static void stm32_rproc_kick(struct rproc *rproc, int vqid) > >>> continue; > >>> if (!ddata->mb[i].chan) > >>> return; > >>> - err = mbox_send_message(ddata->mb[i].chan, (void *)(long)vqid); > >>> + err = mbox_send_message(ddata->mb[i].chan, "kick"); > >>> if (err < 0) > >>> dev_err(&rproc->dev, "%s: failed (%s, err:%d)\n", > >>> __func__, ddata->mb[i].name, err); > >>> -- > >>> 2.17.1 > >>>