Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp543677rdb; Mon, 15 Jan 2024 05:55:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4nXqhUxHTRW8Wz+wyrEDl9L0ekmr1ESzlnIhUc837CyII4CbMztk73864xd04akR260eJ X-Received: by 2002:a17:902:ebce:b0:1d5:71c5:4d58 with SMTP id p14-20020a170902ebce00b001d571c54d58mr8395933plg.47.1705326901075; Mon, 15 Jan 2024 05:55:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705326901; cv=none; d=google.com; s=arc-20160816; b=s1qrzPKIFbo9HDy+INIlODQQzqoLwLbjmuhoIjaHX1zQ4RFcV1RpnEFKT8LgcJ4Zj4 GSNoYRCvghAKITjYrRnp8cB4Fa6ERBOe70PDCGSqNdOCF8wlU8qpPRqUUV/3zYBS/A2Y Fi6R+bxJl7cNakbF2m7+6q+PTVAhkqn5XTk9jowoybcQPliqCVCxY3LB4ZrKrQammMbv KI63bDiPsAJr7HjsQig/IRTroBtvxDpO55FkKMmyHObmR7neCjVB46BLTZ2xDb51exr6 Q1GPCQd/Ee71PhiIRuzoRXyXLN+6VSTEwS5fxgKIs3TAS+KI1HNjW1EzWVpgTnkfmpt5 +4Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JgTqkog598RbC204zCHUiytINQsebXi6rfWzdONWWfk=; fh=v3NBvV5+vj//chOYHzS5ZDleqozbh7nyGvHDjEWDUSE=; b=usPwGVBOKc95rvYGLx7+wejn7QRO+0NokUyXwrc1d7cEqIzCR+pbqGKUF90pqtejQa 1pbidE9loR+Hjp3CKfqbeWIdOMUVFAyGJ6537Nykn6TczRxjwyMprLdO++fQ6EuSJb+6 NvwkcSkOPIpA/eX5ixIVj+jkVn7DEv/11Wl6/pXYB/5APo5Tzn7NeNyHP588Ny48LChe pcptHIiab0sv63xh3eoVjsq1IIETPys7yhllQ660jE/0H4z8FB2gYt6WRVrvGct9HmGg MnYGxWMAWxi7UqeIvBk4lci6ujn/DG0ScP+c3MiAuVW8cpKwbMMvziB47z0x7MkVzJ/U 8HbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=D9FrRzYm; spf=pass (google.com: domain of linux-kernel+bounces-26059-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26059-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b4-20020a170902d50400b001d36a6c7de2si9911645plg.351.2024.01.15.05.55.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 05:55:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26059-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=D9FrRzYm; spf=pass (google.com: domain of linux-kernel+bounces-26059-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26059-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B3E27282714 for ; Mon, 15 Jan 2024 13:55:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 96D1E17747; Mon, 15 Jan 2024 13:54:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b="D9FrRzYm" 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 D4DCC1754F; Mon, 15 Jan 2024 13:54:19 +0000 (UTC) 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 Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40FD9OnB009290; Mon, 15 Jan 2024 14:54:02 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= selector1; bh=JgTqkog598RbC204zCHUiytINQsebXi6rfWzdONWWfk=; b=D9 FrRzYm0JDUdFDfvftiNJO8KroHy7qrDoBca/+lhkZQYV/aCzOkZUk6iDM5KiTPrY KHBUgNTw7zE02ms0shdVytXy8mHfz37hpqI5OMsXkvBn0WXGuJdqPfYfgjP+fEuZ 7apOftYeq7pCRBhkoMU1d+V8Bdlp/1eX9gCk3IRGFbk0e5o5RMOGkX5ut0x1sPPh i7+BbPUwwsyT3vKWer5FPXoOPGXi9vDul0xrnY+gVIPxzsKmOeqSgknsTE0scpjW 8OvBEJFN4AJmGnJ3WC+AQ8KfTWrxjFKknpnZTgVqVH2feTU5hGZHmnkbyC0C+f8M RymqkLaH2HbSoI0qxqFA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3vkmfy8xer-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Jan 2024 14:54:02 +0100 (CET) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E7680100057; Mon, 15 Jan 2024 14:54:01 +0100 (CET) Received: from Webmail-eu.st.com (shfdag1node2.st.com [10.75.129.70]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id DC90228EF7F; Mon, 15 Jan 2024 14:54:01 +0100 (CET) Received: from localhost (10.201.20.75) by SHFDAG1NODE2.st.com (10.75.129.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 15 Jan 2024 14:53:58 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier , Jens Wiklander , Rob Herring , Krzysztof Kozlowski , Conor Dooley CC: , , , , , , Arnaud Pouliquen Subject: [PATCH 3/4] remoteproc: stm32: create sub-functions to request shutdown and release Date: Mon, 15 Jan 2024 14:52:48 +0100 Message-ID: <20240115135249.296822-4-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240115135249.296822-1-arnaud.pouliquen@foss.st.com> References: <20240115135249.296822-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: 8bit Content-Type: text/plain X-ClientProxiedBy: EQNCAS1NODE3.st.com (10.75.129.80) To SHFDAG1NODE2.st.com (10.75.129.70) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-05_08,2024-01-05_01,2023-05-22_02 To prepare for the support of TEE remoteproc, create sub-functions that can be used in both cases, with and without TEE support. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/stm32_rproc.c | 84 +++++++++++++++++++------------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index 4f469f0bcf8b..fcc0001e2657 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -209,6 +209,54 @@ static int stm32_rproc_mbox_idx(struct rproc *rproc, const unsigned char *name) return -EINVAL; } +static void stm32_rproc_request_shutdown(struct rproc *rproc) +{ + struct stm32_rproc *ddata = rproc->priv; + int err, dummy_data, idx; + + /* Request shutdown of the remote processor */ + if (rproc->state != RPROC_OFFLINE && rproc->state != RPROC_CRASHED) { + idx = stm32_rproc_mbox_idx(rproc, STM32_MBX_SHUTDOWN); + if (idx >= 0 && ddata->mb[idx].chan) { + /* A dummy data is sent to allow to block on transmit. */ + err = mbox_send_message(ddata->mb[idx].chan, + &dummy_data); + 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 = rproc->priv; + unsigned int err = 0; + + /* To allow platform Standby power mode, set remote proc Deep Sleep. */ + if (ddata->pdds.map) { + err = 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 = 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 err; +} + static int stm32_rproc_prepare(struct rproc *rproc) { struct device *dev = rproc->dev.parent; @@ -519,17 +567,9 @@ static int stm32_rproc_detach(struct rproc *rproc) static int stm32_rproc_stop(struct rproc *rproc) { struct stm32_rproc *ddata = rproc->priv; - int err, idx; + int err; - /* request shutdown of the remote processor */ - if (rproc->state != RPROC_OFFLINE && rproc->state != RPROC_CRASHED) { - idx = stm32_rproc_mbox_idx(rproc, STM32_MBX_SHUTDOWN); - if (idx >= 0 && ddata->mb[idx].chan) { - err = 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); err = stm32_rproc_set_hold_boot(rproc, true); if (err) @@ -541,29 +581,7 @@ static int stm32_rproc_stop(struct rproc *rproc) return err; } - /* to allow platform Standby power mode, set remote proc Deep Sleep */ - if (ddata->pdds.map) { - err = 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 = 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); } static void stm32_rproc_kick(struct rproc *rproc, int vqid) -- 2.25.1