From nobody Wed Nov 27 16:37:14 2024 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) (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 2A3D11B6CF0; Tue, 26 Nov 2024 09:13:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.207.212.93 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732612428; cv=none; b=FC0/dVDS9tf+RlTl37ebQ7J6S/ZZ0m86raCYZMMiXMzDiY7zwGxAX3NKVumT6pVviCnsJ5uV+PUjycgk4s1PK7HLrT+GVgHxnXKN+viT/GlN534114mW5349CyM5OWUineE+hNfGP5JPzzwk+TqExme5i92GiA74AXD767f5l68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732612428; c=relaxed/simple; bh=PGMZdK5awwVDRLUhZUEkP/i8jR95TALsyjUYmkCVA9o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=K8CN0OYc8MPLwbURvrtQa0OrOYYjaSvPy3HvnJfUxow59yMuH9v9GZ0xaNKZM6q7cLi1MwCnufqMm0+JdyTdSxQX11yYs4aMqQ2ukS4W+87Lu2rl1IQmAFrcoj/Jnxq53UwBTTxuMfjcKtnFkLzrFO494BsNQN7r6yvSN2T4fnA= 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=Pn26EfkB; arc=none smtp.client-ip=91.207.212.93 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="Pn26EfkB" Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AQ3Lbj1030017; Tue, 26 Nov 2024 10:13:27 +0100 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= fhFYWPWRu1fKy+2nIifEQQLFbsyaAYIzY0cZaLes9RI=; b=Pn26EfkBMS8iV4gv LPqmYHWjofpk1Hs8vf+Iyg/e3Wj8TztL0PviT7QyxCO3RX3IKu5DBsH/XF1I5lrT GKqkUhOaOl8/6POLubt+93jyRiLCt3i3hV7unHyEwA1qDFQQmhKyCo3A528k76wf +HZUNTGdflqZrg92Ad7/s6FWMXoGXmExRh3nQMR2640v03hB3u6hobQKrFIMW9sA TLk1YRCHm164xw1pOjPnui3nwMaNmRR+eSFLoKjeV19oKZllLCJ9SEIAK6q9erWL nt82jESecY/3iw9lLjb6TuoAENZB+Lb7Zg2qkGfsju3HlVQ4DVPm5MaL/cPgCAvG KqL3iQ== 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 433529425r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Nov 2024 10:13:26 +0100 (CET) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 9B58840075; Tue, 26 Nov 2024 10:12:33 +0100 (CET) Received: from Webmail-eu.st.com (eqndag1node6.st.com [10.75.129.135]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 9729926B654; Tue, 26 Nov 2024 10:11:17 +0100 (CET) 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; Tue, 26 Nov 2024 10:11:17 +0100 Received: from localhost (10.48.86.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; Tue, 26 Nov 2024 10:11:17 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier , Maxime Coquelin , Alexandre Torgue CC: Arnaud Pouliquen , , , , Subject: [PATCH v14 7/8] remoteproc: stm32: Create sub-functions to request shutdown and release Date: Tue, 26 Nov 2024 10:10:38 +0100 Message-ID: <20241126091042.918144-8-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241126091042.918144-1-arnaud.pouliquen@foss.st.com> References: <20241126091042.918144-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: SAFCAS1NODE1.st.com (10.75.90.11) 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 7e8ffd9fcc57..1586978c5757 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