Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1535470ybt; Thu, 9 Jul 2020 09:15:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFSXSZ4ewJGbAI5wCFBPUTXCvxfcrag1FdtVR7clC6ZMb6/KRJrv6nX3EVctf2yHikO65c X-Received: by 2002:a05:6402:1803:: with SMTP id g3mr69604017edy.377.1594311313815; Thu, 09 Jul 2020 09:15:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594311313; cv=none; d=google.com; s=arc-20160816; b=xaekyxjGVZIyryOXJ8JdawcEhnQD3/1gruBjqYqB1PiXTBtfLGfXjxx+fsAh+lEIZB uj0UqwBQrZylhclSt0WJ3pi+BEqJGI6Nr9QaUVjj8ioDybB1+BT2hE0XZnErMs2tgjNi +GjJ9H42VUf9AlAfqZH0X/Xp3WWS/9ieRlUeH9MBIRy4m3DKSp9Qrxuzus47tju4uzxw +/vV9+PB4mQcxtOBw6ooI1yy1sgJCtJBO7xgyQWwRYUpfoFtylGZKsqGzNxkguSSWfUa B2Sc18FEpytqbfscAOX7JddHg2AjL6f/Vs8iKc8BqjRFt1yxQHQApO/WfU6goEt0Ldpw 9uGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=0xSGilh0ludhB1OFskA9wbIbxe83I0mwt+UNuHXHO00=; b=E/LyJol/w0o11ON4v5+iHYRc0n7OccOsEwydH9Timx1UqOZarnWsF7ZDNhjTsuLDFw uq3NM0UTIFQExK9f6dZWlIzPEQ8paytar2oPPXs5GwX4WHXd+0XJSTLFMIQhO6nOvEzI +LJa1WIIMob26bvBMcbeBtynLSfuzGSy0ubUJv8lulLXc3b/G3yNAFBcPREBfWjJHMYc 7jVVRSyoEYzlETRQ9BmPzpgPOTNaMDgK2f7orzeIcLlGNC8JcYmM7fRh3/GdzkgcFnKi 94Xo8sIQrkJ12oH4I55ZAMnf0foGxFGPcqaKCyJXzMbmf20Ge7/RIFuhp1CV/RNN6JTh 4+7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=SvDoD9IT; 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=st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sd17si2342542ejb.306.2020.07.09.09.14.50; Thu, 09 Jul 2020 09:15:13 -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=@st.com header.s=STMicroelectronics header.b=SvDoD9IT; 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=st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727949AbgGIQOH (ORCPT + 99 others); Thu, 9 Jul 2020 12:14:07 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:9032 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726339AbgGIQOG (ORCPT ); Thu, 9 Jul 2020 12:14:06 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 069G4Qqt005774; Thu, 9 Jul 2020 18:14:02 +0200 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=0xSGilh0ludhB1OFskA9wbIbxe83I0mwt+UNuHXHO00=; b=SvDoD9ITrIN3zZ9X8LVOpreeTFPreuxGxy2czt+r/VRRl3Buz313opOpxMDEj5ZToxA6 N78OysxGqRJTt5z3GAecT2ulNC8bUhZYKTMpSpu2d3H2rqPAoU3CDjxZ4SktP+KlBAyo 318p1g5Hk719gLU6MZEvv4zNhlHwDWiiszBpkBNWRQW6AJxD9yl/APGua8reAjCkTY0P I5U9ShytQsJLJsO+cKB+bFsVLxYI/fsYK0h8ZUuuHT83QFGCJba6+Jn+St2ruZQOw3IJ EeBBQabvul5CHKbizEplcv/sDvvgg/MUwwIV2MWqQBIxX3MsDr9kUozJToiLcot0oQPS EA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 325k405ubb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 09 Jul 2020 18:14:02 +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 53AB5100039; Thu, 9 Jul 2020 18:14:01 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 44B802CA1C6; Thu, 9 Jul 2020 18:14:01 +0200 (CEST) Received: from lmecxl0889.tpe.st.com (10.75.127.49) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 9 Jul 2020 18:14:00 +0200 Subject: Re: [PATCH v5 06/11] remoteproc: stm32: Properly set co-processor state when attaching To: Mathieu Poirier , "ohad@wizery.com" , "bjorn.andersson@linaro.org" , Loic PALLARDY , "mcoquelin.stm32@gmail.com" , Alexandre TORGUE CC: "linux-remoteproc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-stm32@st-md-mailman.stormreply.com" References: <20200707213112.928383-1-mathieu.poirier@linaro.org> <20200707213112.928383-7-mathieu.poirier@linaro.org> From: Arnaud POULIQUEN Message-ID: <12c083ce-1a49-e17c-8048-eb1b3f314836@st.com> Date: Thu, 9 Jul 2020 18:13:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200707213112.928383-7-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: SFHDAG8NODE3.st.com (10.75.127.24) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-09_08:2020-07-09,2020-07-09 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mathieu, On 7/7/20 11:31 PM, Mathieu Poirier wrote: > Introduce the required mechanic to set the state of the M4 in order > to properly deal with scenarios where the co-processor has been > started by another entity. > > Mainly based on the work published by Arnaud Pouliquen [1]. > > [1]. https://patchwork.kernel.org/project/linux-remoteproc/list/?series=239877 > > Signed-off-by: Mathieu Poirier > Reviewed-by: Bjorn Andersson > --- > drivers/remoteproc/stm32_rproc.c | 32 ++++++++++++++++++++++++++++++++ > 1 file changed, 32 insertions(+) > > diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c > index 961a53f67ec5..cbeb5ceb15c5 100644 > --- a/drivers/remoteproc/stm32_rproc.c > +++ b/drivers/remoteproc/stm32_rproc.c > @@ -39,6 +39,13 @@ > #define STM32_MBX_VQ1_ID 1 > #define STM32_MBX_SHUTDOWN "shutdown" > > +#define M4_STATE_OFF 0 > +#define M4_STATE_INI 1 > +#define M4_STATE_CRUN 2 > +#define M4_STATE_CSTOP 3 > +#define M4_STATE_STANDBY 4 > +#define M4_STATE_CRASH 5 > + > struct stm32_syscon { > struct regmap *map; > u32 reg; > @@ -636,12 +643,30 @@ static int stm32_rproc_parse_dt(struct platform_device *pdev, > return 0; > } > > +static int stm32_rproc_get_m4_status(struct stm32_rproc *ddata, > + unsigned int *state) > +{ > + /* See stm32_rproc_parse_dt() */ > + if (!ddata->m4_state.map) { > + /* > + * We couldn't get the coprocessor's state, assume > + * it is not running. > + */ > + state = M4_STATE_OFF; > + return 0; > + } > + > + return regmap_read(ddata->m4_state.map, ddata->m4_state.reg, state); > +} > + > + nitpicking: multiple blank lines here > static int stm32_rproc_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > struct stm32_rproc *ddata; > struct device_node *np = dev->of_node; > struct rproc *rproc; > + unsigned int state; > int ret; > > ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32)); > @@ -664,6 +689,13 @@ static int stm32_rproc_probe(struct platform_device *pdev) > if (ret) > goto free_rproc; > > + ret = stm32_rproc_get_m4_status(ddata, &state); > + if (ret) > + goto free_rproc; > + > + if (state == M4_STATE_CRUN) > + rproc->state = RPROC_DETACHED; > + > rproc->has_iommu = false; > ddata->workqueue = create_workqueue(dev_name(dev)); > if (!ddata->workqueue) { >