Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1072303pxu; Wed, 2 Dec 2020 10:17:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfagkVT9XVnvFtbMIzDD9ZQIu1H/OYPVrFGlOraisdO3PL+KmfKm0RWxyj8a9HyBuX0KHR X-Received: by 2002:a50:8a02:: with SMTP id i2mr1260206edi.222.1606933029898; Wed, 02 Dec 2020 10:17:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606933029; cv=none; d=google.com; s=arc-20160816; b=fue1y4fGkLKFzEMVSWEUkvDkwlHzmiJeRWue4k7WcxlE2JawtmVGxuZkJ/qtCsizdg YRuOy3WctdKO85DWaOWSi/QMUuvmpj6pc3MBOUHBqNCMGwJhbe2+XANYeAjHQ3JAxYNz z+AagciV6MU2o01rqy/UINkQyFVp2mANTGedVrOXHPz4DwGJIFsxDWgRDVsRCiFO76T2 MMyTHPpiAL/vLl0AWoNRwyosBwWdQ2H9x+EL9MzlCfNXiGn3TT2Cr8oL9PVS+qRDjtNb wFT5i9n9ioAi35NaZuwH6p3ZA2mhPjLZ4BiZBLtn9HR0oYwUbsIjCH7F6k7gD9UKeIoQ prRw== 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=+ehhIvZT3gHwM+iFz5dh1rgFUsswUN3WcEf/7+x1Dz8=; b=uezs/nIroMhE3dSqbDZyAg3wtEGT42eRbLYlljB7D3sVY+jzXkQTvuj2NmbvT4+XA5 bw7dkEb8JAMaazbPLKtK10UtWiqfmrBaXpvB7YRswbx/gfwDK3H5RJdzRrKBM/m0UK1p 3evBHvRtuqlcmxZBuLwuZuL9t1k/RaD6t56OTuoxWr+LgL7Mis5G0REZDADcBFicmB1M +8i/H7EJ/9+Lr0pGyMPGEn7OPWRoIrYfbx7P9dhs97+f9EveQi26uRzC8vzS8awOswcj OIynrY/+hxTGNC4S3vs7Hk6twcgBjrgxhxJKyTspgoXmGTcC0tDG9ywyxNpPCav3mkOH q7kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b="IjRgF/+o"; 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=REJECT sp=REJECT dis=NONE) header.from=st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr10si465752ejc.306.2020.12.02.10.16.45; Wed, 02 Dec 2020 10:17:09 -0800 (PST) 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=@st.com header.s=STMicroelectronics header.b="IjRgF/+o"; 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=REJECT sp=REJECT dis=NONE) header.from=st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389377AbgLBSPA (ORCPT + 99 others); Wed, 2 Dec 2020 13:15:00 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:7126 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728928AbgLBSO7 (ORCPT ); Wed, 2 Dec 2020 13:14:59 -0500 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 0B2I6tYT028933; Wed, 2 Dec 2020 19:14:13 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=STMicroelectronics; bh=+ehhIvZT3gHwM+iFz5dh1rgFUsswUN3WcEf/7+x1Dz8=; b=IjRgF/+o6j8F1XYDHMSWcFchK4Y7SSq88RjQRY1DY1q6fYCoS2MCdlqo9zGAgkZ85PKf Bd2s7DUoUoNVuCFTflR+8BTbPRLY38qEdWC+iU6RIJruLu0OpVFtnNWwZTZ38DwDn5GT sEB/EvxlgZldRRsZ3GjGPNBWWCXlnweS0d1htQI/YGXqsjWv3bA1jPiYF1lWg7hTk+kK 5ZBagCg9lO1CmQeokV8pvBlLzW7zfIxH9yaQmub9KhgEd1vH7H5H1I5KXwwWgttU7ybj /AwQx/2+vmvHnpv3Sb3Iir4299RB8dWrrgviMIePshiAwWziJNJIm5RTMhRfccDojKoM hA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 355w3cd362-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Dec 2020 19:14:13 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E3CE610002A; Wed, 2 Dec 2020 19:14:12 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id D149B23FCD6; Wed, 2 Dec 2020 19:14:12 +0100 (CET) Received: from lmecxl0889.lme.st.com (10.75.127.49) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 2 Dec 2020 19:14:12 +0100 Subject: Re: [PATCH v3 11/15] remoteproc: Add return value to function rproc_shutdown() To: Mathieu Poirier , "ohad@wizery.com" , "bjorn.andersson@linaro.org" , "robh+dt@kernel.org" CC: "linux-remoteproc@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20201126210642.897302-1-mathieu.poirier@linaro.org> <20201126210642.897302-12-mathieu.poirier@linaro.org> From: Arnaud POULIQUEN Message-ID: <7aeadffa-f024-7bdc-2bdf-a09210c7a393@st.com> Date: Wed, 2 Dec 2020 19:14:10 +0100 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: <20201126210642.897302-12-mathieu.poirier@linaro.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312,18.0.737 definitions=2020-12-02_10:2020-11-30,2020-12-02 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/26/20 10:06 PM, Mathieu Poirier wrote: > Add a return value to function rproc_shutdown() in order to > properly deal with error conditions that may occur. > > Signed-off-by: Mathieu Poirier > Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen Thanks, Arnaud > --- > drivers/remoteproc/remoteproc_core.c | 19 ++++++++++++++----- > include/linux/remoteproc.h | 2 +- > 2 files changed, 15 insertions(+), 6 deletions(-) > > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c > index b54f60cc3cbd..51275107eb1f 100644 > --- a/drivers/remoteproc/remoteproc_core.c > +++ b/drivers/remoteproc/remoteproc_core.c > @@ -1869,7 +1869,7 @@ EXPORT_SYMBOL(rproc_boot); > * returns, and users can still use it with a subsequent rproc_boot(), if > * needed. > */ > -void rproc_shutdown(struct rproc *rproc) > +int rproc_shutdown(struct rproc *rproc) > { > struct device *dev = &rproc->dev; > int ret; > @@ -1877,15 +1877,19 @@ void rproc_shutdown(struct rproc *rproc) > ret = mutex_lock_interruptible(&rproc->lock); > if (ret) { > dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, ret); > - return; > + return ret; > } > > - if (rproc->state != RPROC_RUNNING) > + if (rproc->state != RPROC_RUNNING) { > + ret = -EPERM; > goto out; > + } > > /* if the remote proc is still needed, bail out */ > - if (!atomic_dec_and_test(&rproc->power)) > + if (!atomic_dec_and_test(&rproc->power)) { > + ret = -EBUSY; > goto out; > + } > > ret = rproc_stop(rproc, false); > if (ret) { > @@ -1897,7 +1901,11 @@ void rproc_shutdown(struct rproc *rproc) > rproc_resource_cleanup(rproc); > > /* release HW resources if needed */ > - rproc_unprepare_device(rproc); > + ret = rproc_unprepare_device(rproc); > + if (ret) { > + atomic_inc(&rproc->power); > + goto out; > + } > > rproc_disable_iommu(rproc); > > @@ -1907,6 +1915,7 @@ void rproc_shutdown(struct rproc *rproc) > rproc->table_ptr = NULL; > out: > mutex_unlock(&rproc->lock); > + return ret; > } > EXPORT_SYMBOL(rproc_shutdown); > > diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h > index 329c1c071dcf..02312096d59f 100644 > --- a/include/linux/remoteproc.h > +++ b/include/linux/remoteproc.h > @@ -655,7 +655,7 @@ rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, size_t len, > u32 da, const char *name, ...); > > int rproc_boot(struct rproc *rproc); > -void rproc_shutdown(struct rproc *rproc); > +int rproc_shutdown(struct rproc *rproc); > int rproc_detach(struct rproc *rproc); > int rproc_set_firmware(struct rproc *rproc, const char *fw_name); > void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type); >