Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp630117ybz; Wed, 29 Apr 2020 06:41:04 -0700 (PDT) X-Google-Smtp-Source: APiQypIWoP4OveZjAJYZHzoevLvw+PrO+JVvREJechRcX05+HbOk5D7UVpDm+q7Q5y6DI/oVJzz/ X-Received: by 2002:aa7:dd84:: with SMTP id g4mr2553574edv.257.1588167663856; Wed, 29 Apr 2020 06:41:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588167663; cv=none; d=google.com; s=arc-20160816; b=Sn+yNy8CzswJV5Qol7afS7vPeqysbs0Jr5yQ5u5hYxfK1A2buvslqe9aRW535fthbT pa/irz5p8j9x3+975DyeQpkh25ii/a+Yq4xMeIH8KVnx4LfTyTXboorGZdb6DloKspLJ LYAGzFRtvb4mtGxo0EiBn3ngzjj4SDWNEyxdu7sYR8b9PkcsqEA7qB5DfOz2j2IijGVA tUXy3xNT5u2oPi2biHnfpzHiVbYn3P9a2ICtBXpTQnm1CwijzoN3o6ZFKTzAerDpV8bT OlCGq5YVxWLFhq8FnueCxN7OHbAOl39f/81KarPMFOZR0rFZM342KHB8m1kPdbCc8elg zknQ== 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=1c+9ulLdfVEh/Q0upa3QLpGbsPOwrW8hiYWHA/MwWE4=; b=cEU6ORG1gKUys3X23b4byuG49LmxImaxV8hF6neBMZahmyq32Ov9rizn2MwdD1a9KY DxuomVS9LkJR90FQIpG+DdNRvasSYy/2AuDMi/Zm66PE12aYiixkaPqdaqeLfiyd9IyH 64Mc5iaGBuV4fCGzLdRsRS2dMs+asudub3yVBMbCsyQhUzIQzEsdQCMV6hozeGsEsQlo 4aM4cncEalnR4E3EO4CxKmN8gmgcvDKCZPyC9pUzv0Lid/Q5GlsGOeO/Wej//gOE5U86 uM+/EwYYeOKJWeA2jvbPH02kBut2PwMfMqExsHk0ynIpV/S9WkvgpwP8dW9aakddjST1 eHEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=iJSd+3uG; 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 m7si692137edg.244.2020.04.29.06.40.40; Wed, 29 Apr 2020 06:41:03 -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=iJSd+3uG; 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 S1728222AbgD2Nig (ORCPT + 99 others); Wed, 29 Apr 2020 09:38:36 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:19406 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728207AbgD2Nif (ORCPT ); Wed, 29 Apr 2020 09:38:35 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03TDWLDs030996; Wed, 29 Apr 2020 15:38:27 +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=1c+9ulLdfVEh/Q0upa3QLpGbsPOwrW8hiYWHA/MwWE4=; b=iJSd+3uG+4/NHLyHFb2RXlYu3GhLhCZHEg/KdVHdD/FqwZAPhG1Dsl+eUZrT5mpqqzCx TIjrIpmqeUSNdPckLB0hc09qRC6XTxj7K3t9XfFW6RWaifvUvGPG/XGljC1UPdB0ZmJi 6at3nAUeyruV0/WpnGzPywOuTMA4c2BvtZPKnx+pZNBptJMiWuCxQc68IB5YMBYC7UFu QN6C+uan5fNPn4evmaiGrq2jtKc3+3/PqXw4iwW/u/bMByp8aN+kYxHegLxC4E62H/CS nMRm6pB7mh6AY/X4h8Qo5WPJEpc8HITkNOrNFk/Sqi9owbjdfjrjIwQxCBTne5BbEC8l gA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30n4j62sya-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Apr 2020 15:38:27 +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 08472100034; Wed, 29 Apr 2020 15:38:27 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id EB7C221F699; Wed, 29 Apr 2020 15:38:26 +0200 (CEST) Received: from lmecxl0889.tpe.st.com (10.75.127.47) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 29 Apr 2020 15:38:26 +0200 Subject: Re: [PATCH v2 06/12] remoteproc: stm32: Get coprocessor state To: Mathieu Poirier , , , , CC: , , , , References: <20200424202505.29562-1-mathieu.poirier@linaro.org> <20200424202505.29562-7-mathieu.poirier@linaro.org> From: Arnaud POULIQUEN Message-ID: Date: Wed, 29 Apr 2020 15:38:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200424202505.29562-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.47] X-ClientProxiedBy: SFHDAG1NODE3.st.com (10.75.127.3) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-29_05:2020-04-29,2020-04-29 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/24/20 10:24 PM, Mathieu Poirier wrote: > Introduce the required mechanic to get the state of the M4 when the > remoteproc core is initialising. > > 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: Loic Pallardy > --- > drivers/remoteproc/stm32_rproc.c | 29 +++++++++++++++++++++++++++++ > 1 file changed, 29 insertions(+) > > diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c > index a285f338bed8..89fbd2ffac93 100644 > --- a/drivers/remoteproc/stm32_rproc.c > +++ b/drivers/remoteproc/stm32_rproc.c > @@ -38,6 +38,15 @@ > #define STM32_MBX_VQ1_ID 1 > #define STM32_MBX_SHUTDOWN "shutdown" > > +#define RSC_TBL_SIZE (1024) > + > +#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; > @@ -635,12 +644,23 @@ 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) > + return -EINVAL; > + > + return regmap_read(ddata->m4_state.map, ddata->m4_state.reg, state); > +} i would manage here the default state depending on the error types 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); > + > 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; > bool auto_boot = false; > int ret; > > @@ -664,6 +684,15 @@ static int stm32_rproc_probe(struct platform_device *pdev) > if (ret) > goto free_rproc; > > + ret = stm32_rproc_get_m4_status(ddata, &state); > + if (ret) { > + /* > + * We couldn't get the coprocessor's state, assume > + * it is not running. > + */ > + state = M4_STATE_OFF; So here just handle the error; Regards Arnaud > + } > + > rproc->auto_boot = auto_boot; > rproc->has_iommu = false; > ddata->workqueue = create_workqueue(dev_name(dev)); >