Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp181399pxj; Fri, 28 May 2021 01:06:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjYtYTAZDXHuM09dFftXt2tlC+ey+vN6uoBKt9tQEaN/SCXNG7sL3itZjgbjeEzvnj61fY X-Received: by 2002:a17:907:10c7:: with SMTP id rv7mr7843364ejb.125.1622189213713; Fri, 28 May 2021 01:06:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622189213; cv=none; d=google.com; s=arc-20160816; b=LFdsGPqHXTsRHlCXEQLNbYOJzXrxa5ZTO4SQC54EW6IFwMCSFO86g1fKvAtwJK1zZD m/knI7ahYN+UvIsGDkvptY/TNCe2Lxp4rlKQ2W5zG12/iCPIDgTgKt9rlphpEVvVx+WO yd09R5Q1+4aTHPpFo9iOtQ9Q5grpRl6JFKTNyPhJYkEFSyQLPkSyivcxdkTtbrwNz+t9 raWSoJPLRoQQ0/aoOE0q2SCOlnh0ePFdWXWOb++o445KGz+wSMtC1YsogSNvZU9Bl2A0 0/z7QzGPUTKcKb8uzsxZ0AV9U3sAMNi0tiAfZerwkB9L9Vj1GDUTXafhzJ0LlAWVrx8e 24cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=dKw/3puYbjMGb5FGOG+6h+7xc8UGjhWBbSRNreyNYLU=; b=xWt9UtKL1j2V2/X1H9S8drHUZBEpGplRG0GUY8ZcznIVLJJpq1FJSfpPSIEi8g3MJm Hp82kqXWqJQYtthxa1byZHdj6XUDRqH3dXSfjjeIkVQN0e07pw2uUSxvojwx5J/aUZ35 jIkQPvEK94dlpy7my9H1lGfB6H2RVXNExMF79xeyouUQsoRnGMIUpLjDHWcfBOGK9Wd/ zDQZFZ/BsrvYcpU1oy7pNM8RUKWRC8Gop2sWHuPA+5+D0F9g1pyQhlF+c2h8KpLdKctQ uSl6QkPVXBsP2P3ZDswK4FRWggd05MlZwLeMQ+i8NWuGXe8OHM4wljTwWvi7y5yOme3G BDzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=bRpTZaP7; 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=foss.st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id di24si4120090edb.224.2021.05.28.01.06.29; Fri, 28 May 2021 01:06:53 -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=@foss.st.com header.s=selector1 header.b=bRpTZaP7; 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=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235793AbhE1IFV (ORCPT + 99 others); Fri, 28 May 2021 04:05:21 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:30500 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235665AbhE1IFS (ORCPT ); Fri, 28 May 2021 04:05:18 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14S82IlX002830; Fri, 28 May 2021 10:03:41 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=selector1; bh=dKw/3puYbjMGb5FGOG+6h+7xc8UGjhWBbSRNreyNYLU=; b=bRpTZaP7jf8JntQCTtDec8iwe9dmkLlJk9COfudvI/dpvf2tWocz9atRy6ngIWni1r1s WSBcluXberbohH5zwlCGWXV1Zei/YVcDEhPvDapEVc3f3UrLL+oY5294n75BPzdkcSl9 v4dSWUfSWcyoxyBKMzAN/jydG7LdHtR7WWn4IDDezEm+Uqc39obdX/3nAQZBwsy5VUZz C++hesdooYKb1TQtY37Ly4M7h1XnLbXrQc8nwwFyrCnND/+TzAL5facd6W5n93/iFRbd 06z4o0cuvg5kEqV0Esys9ZNuUTyNZhe6nA0VOsuJ405eKAppIN3CaosI+tg4Mv+LLCeT xA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 38t7k3ek3a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 May 2021 10:03:41 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9BC1B10002A; Fri, 28 May 2021 10:03:40 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 88E1D21B51E; Fri, 28 May 2021 10:03:40 +0200 (CEST) Received: from lmecxl0889.lme.st.com (10.75.127.46) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 28 May 2021 10:03:39 +0200 Subject: Re: [PATCH] remoteproc: stm32: fix mbox_send_message call To: Bjorn Andersson CC: Ohad Ben-Cohen , Mathieu Poirier , , , References: <20210420091922.29429-1-arnaud.pouliquen@foss.st.com> From: Arnaud POULIQUEN Message-ID: Date: Fri, 28 May 2021 10:03:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG3NODE3.st.com (10.75.127.9) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-05-28_04:2021-05-27,2021-05-28 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 >>