From nobody Mon Nov 25 17:57:38 2024 Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56D067E792; Fri, 25 Oct 2024 21:03:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.132.182.106 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729890207; cv=none; b=EJzqpqNIj4oNlHz5U4g/rKTQV9nmmHeTJMaDoUCjMnUbwfxLaxam1lWW84mr5CTDPmmS5RHWiOpZEcKCuwyUvkDv09hDi+L6uTFa0iVVtZnwauj7e+xsQgexD/dkpUyt8GPIu5B/XKUfKRzuronJUdOEGyeWjwor9URcR5PRVC4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729890207; c=relaxed/simple; bh=jh3Bn2BjYhL3fMoBgibBoHC5d7By4ErkEAJruMg+Qco=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ak4lhUc37ukECMg0zvk4/VGxBEYGhIZy/7f2YjuFOt+1F422/i1lv5yrTIi1YKp0vxTl5asUGBj+u+/HicLWPU4hE9Yr3g6/NZ8ScCAg48jmP254XRkEQgMB+2bJobjiSu5S9gb+P4ubpqiCqCjiQGNC2ECJyapynRGGfONYpRE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com; spf=pass smtp.mailfrom=foss.st.com; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b=zC+4inlr; arc=none smtp.client-ip=185.132.182.106 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=foss.st.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b="zC+4inlr" Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49PKYfjW006899; Fri, 25 Oct 2024 23:03:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=selector1; bh= H/QGMmQQvSdjTzGfb0ViGoe+R9DpAr0GnLMuS6bq550=; b=zC+4inlrM5HfkC2r TlC64uKipIUWWch7Y+xZePJrE7LCdcwrldjZ15x6A2w/EcfiVNdSFgg6Dz+tKlMU wdIAf6YQyNhOBcwLLKlm8XlSneeUB1s3zRyaKDJ1czumrqvWRwQggnW5K7ukCikV vTPH3y5bdXZzyQ5Q3aItAEJcIjI3uDVSE64XiKWWmvKmEH9xxWPaAKkmrLAvgxX+ yssqblNojOgFDTeQXZvracsxJpsoQfxhP+n/IFci24N2fGdkL8zmh73MiKHrbNYK AqvfGuKfSSQIw0crv0blMcTUMOfgX/Sl/oxH9MEQieaJOxbQqaeVLZOidQJ5asrU uttpDw== Received: from beta.dmz-ap.st.com (beta.dmz-ap.st.com [138.198.100.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 42em4cquku-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Oct 2024 23:03:05 +0200 (MEST) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 17DA040044; Fri, 25 Oct 2024 23:01:40 +0200 (CEST) Received: from Webmail-eu.st.com (eqndag1node6.st.com [10.75.129.135]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 37EAA231948; Fri, 25 Oct 2024 22:59:40 +0200 (CEST) Received: from SAFDAG1NODE1.st.com (10.75.90.17) by EQNDAG1NODE6.st.com (10.75.129.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37; Fri, 25 Oct 2024 22:59:40 +0200 Received: from localhost (10.252.3.121) by SAFDAG1NODE1.st.com (10.75.90.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37; Fri, 25 Oct 2024 22:59:39 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier , Jens Wiklander , "Rob Herring" , Krzysztof Kozlowski , Conor Dooley CC: , , , , , , Arnaud Pouliquen Subject: [PATCH v12 6/7] remoteproc: stm32: Create sub-functions to request shutdown and release Date: Fri, 25 Oct 2024 22:59:23 +0200 Message-ID: <20241025205924.2087768-7-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241025205924.2087768-1-arnaud.pouliquen@foss.st.com> References: <20241025205924.2087768-1-arnaud.pouliquen@foss.st.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SAFCAS1NODE2.st.com (10.75.90.13) To SAFDAG1NODE1.st.com (10.75.90.17) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 Content-Type: text/plain; charset="utf-8" To prepare for the support of TEE remoteproc, create sub-functions that can be used in both cases, with and without remoteproc TEE support. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/stm32_rproc.c | 82 +++++++++++++++++++------------- 1 file changed, 49 insertions(+), 33 deletions(-) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rp= roc.c index 8c7f7950b80e..288bd70c7861 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -209,6 +209,52 @@ static int stm32_rproc_mbox_idx(struct rproc *rproc, c= onst unsigned char *name) return -EINVAL; } =20 +static void stm32_rproc_request_shutdown(struct rproc *rproc) +{ + struct stm32_rproc *ddata =3D rproc->priv; + int err, idx; + + /* Request shutdown of the remote processor */ + if (rproc->state !=3D RPROC_OFFLINE && rproc->state !=3D RPROC_CRASHED) { + idx =3D stm32_rproc_mbox_idx(rproc, STM32_MBX_SHUTDOWN); + if (idx >=3D 0 && ddata->mb[idx].chan) { + err =3D mbox_send_message(ddata->mb[idx].chan, "detach"); + if (err < 0) + dev_warn(&rproc->dev, "warning: remote FW shutdown without ack\n"); + } + } +} + +static int stm32_rproc_release(struct rproc *rproc) +{ + struct stm32_rproc *ddata =3D rproc->priv; + unsigned int err =3D 0; + + /* To allow platform Standby power mode, set remote proc Deep Sleep */ + if (ddata->pdds.map) { + err =3D regmap_update_bits(ddata->pdds.map, ddata->pdds.reg, + ddata->pdds.mask, 1); + if (err) { + dev_err(&rproc->dev, "failed to set pdds\n"); + return err; + } + } + + /* Update coprocessor state to OFF if available */ + if (ddata->m4_state.map) { + err =3D regmap_update_bits(ddata->m4_state.map, + ddata->m4_state.reg, + ddata->m4_state.mask, + M4_STATE_OFF); + if (err) { + dev_err(&rproc->dev, "failed to set copro state\n"); + return err; + } + } + + return 0; +} + static int stm32_rproc_prepare(struct rproc *rproc) { struct device *dev =3D rproc->dev.parent; @@ -519,17 +565,9 @@ static int stm32_rproc_detach(struct rproc *rproc) static int stm32_rproc_stop(struct rproc *rproc) { struct stm32_rproc *ddata =3D rproc->priv; - int err, idx; + int err; =20 - /* request shutdown of the remote processor */ - if (rproc->state !=3D RPROC_OFFLINE && rproc->state !=3D RPROC_CRASHED) { - idx =3D stm32_rproc_mbox_idx(rproc, STM32_MBX_SHUTDOWN); - if (idx >=3D 0 && ddata->mb[idx].chan) { - err =3D mbox_send_message(ddata->mb[idx].chan, "detach"); - if (err < 0) - dev_warn(&rproc->dev, "warning: remote FW shutdown without ack\n"); - } - } + stm32_rproc_request_shutdown(rproc); =20 err =3D stm32_rproc_set_hold_boot(rproc, true); if (err) @@ -541,29 +579,7 @@ static int stm32_rproc_stop(struct rproc *rproc) return err; } =20 - /* to allow platform Standby power mode, set remote proc Deep Sleep */ - if (ddata->pdds.map) { - err =3D regmap_update_bits(ddata->pdds.map, ddata->pdds.reg, - ddata->pdds.mask, 1); - if (err) { - dev_err(&rproc->dev, "failed to set pdds\n"); - return err; - } - } - - /* update coprocessor state to OFF if available */ - if (ddata->m4_state.map) { - err =3D regmap_update_bits(ddata->m4_state.map, - ddata->m4_state.reg, - ddata->m4_state.mask, - M4_STATE_OFF); - if (err) { - dev_err(&rproc->dev, "failed to set copro state\n"); - return err; - } - } - - return 0; + return stm32_rproc_release(rproc); } =20 static void stm32_rproc_kick(struct rproc *rproc, int vqid) --=20 2.25.1