Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp726015rdh; Wed, 14 Feb 2024 09:28:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVdG1A8ZFqionedJ81FzrVucRq/cm7xgCfWZ61cGUmHQcpGc4EFz0FhIgHxiGli/ohyeSENYJoyxNpnEtP0pFD9kTOSfcVsAL3mHH7FCw== X-Google-Smtp-Source: AGHT+IE1MPNklW4HK/QKs/IHld8qhKFh5ocMvVoiERdU+KTAEqWDcxLPLyE4At6eao3UhZtNXtfp X-Received: by 2002:aa7:c509:0:b0:562:b77:c77c with SMTP id o9-20020aa7c509000000b005620b77c77cmr2582770edq.2.1707931701398; Wed, 14 Feb 2024 09:28:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707931701; cv=pass; d=google.com; s=arc-20160816; b=gBFIR3+WPIhKaSkJJJO+CtrFLfNfJ2adjIQ+3OEhCaniiSfLT/tOodzNCpXJhDjwbo Fs2fczWYZvhXUR5co7c6zX0w/vfr3x6eKqScTJjTF1roHRPsCawiRjdJULzRZscRDVGn mbVKS2cVrl0Qf1ZDjn1hbnQ8Ppp8qyBGq7EtSj3Wk5zSA8sYxlLIbcdD+tS9S7BUTHtS N5ahSUCt9wZjLf9IHxPoHUrTW0ovnlTBCafnPrA7LK7oTCXW1IRRfLkhQHGL1CYD4SF6 qKXVhy0RHHdSEIVyc3bXGa9Er0d5L15MsB70b9zOwCtZDyddQ5VO7ItOzd+++qVJHz6G 9I/w== ARC-Message-Signature: i=2; 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=pn3TNm+cEefz6g+WBTkhM7AAcLnjIIwl9IpP46YUMbs=; b=DaI9tqfZRo5V9RYSXKoA1SOf+MDViYJ58BDAsVHGwNiWkwyj8sVyTVUkDEqdkvIT6L Han+4VLsgPEzOIdwPg/jfQ11H48DL+y2H5euE4dDM2yhNe6vsIkMWsAK6Zifs8VG8vqX I1xtiheO2BZswEe2iO8hls0m6jtXzVta8PcsSUXVYXJxOKdvixDsKhPKokp16Eqbw1nl ll8UuacXQBKJWPICbCzOrsok+p07xARUUW9K6nEw4ymIQnzvpZjtkyoB1bZa/7nWaCaL XV4BzctaUzJVZWvVLSQCEpl2fS6azqlFYQSDPUGZWLGjAiRnmlAowUTQN9ekZ6epIMs7 xONw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=tZdSiDjZ; arc=pass (i=1 spf=pass spfdomain=foss.st.com dkim=pass dkdomain=foss.st.com dmarc=pass fromdomain=foss.st.com); spf=pass (google.com: domain of linux-kernel+bounces-65668-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65668-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com X-Forwarded-Encrypted: i=2; AJvYcCU5xhy+E+iPbmok7HMAYieiqEfZ9FHBI9bCLDcSIQnZltOz1D1jkF1uVvOA6OynwIzhyPR2F4cuYA03oEjKmfsQkEg3XxnqmtUtBThvyQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id cx11-20020a05640222ab00b005639e5eb4a8si50166edb.477.2024.02.14.09.28.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 09:28:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65668-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=tZdSiDjZ; arc=pass (i=1 spf=pass spfdomain=foss.st.com dkim=pass dkdomain=foss.st.com dmarc=pass fromdomain=foss.st.com); spf=pass (google.com: domain of linux-kernel+bounces-65668-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65668-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0188D1F23F55 for ; Wed, 14 Feb 2024 17:28:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CA00112BEA3; Wed, 14 Feb 2024 17:23:04 +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="tZdSiDjZ" 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 3A9D81272DB; Wed, 14 Feb 2024 17:23:01 +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=1707931383; cv=none; b=Hr91YQS+5OAhUuksXYTJ5eqN9z1NZI73gpCgXqGGdOjjn0SBzp/S8r9Weo1M8XoqVF9hlLH1dWwjl0Zn2JYRZiGU+vcPiyR7hmEEby7mJR+MCZpkjCFiaojH5HBM6ePjmpk7C6Hz87hiV1PqjD6dfhmpotmG0C+DdKN1AhPuSI4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707931383; c=relaxed/simple; bh=xbP+qBkAgbP8SmfFKf4c6P+KDk0bMEaf2tvnAZRQWuk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TD7ob+ecVb1gQX5rUZK6Fh5HKCwTJ93yXsjFfeUU8HVEKz6rg8Jc1KFtTx5gH4cRif2jWeNUJBojf7sVPT1KCH4ulZpS4SZEelg/olJvy3xJiOxDZZ6RLzAlPb9gCq8nZSGvaoiKe1Sri5tXhS5mweVuqgT9wKtvFTkOF9VSYOE= 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=tZdSiDjZ; 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 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 41EFqjp8028749; Wed, 14 Feb 2024 18:22:48 +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=tZ dSiDjZ7KVmoK+EEauKGw5tpdse5RCi8Sx7TDQij9IeP/V1EUVw7LC/81trxXV2J9 W2k8xXHV7jz6m83jx6FAomeYhWA2Iy4hmIvwKy65W6BZxoPKXLxY2SwomndSL+nK /+LtBt+lsNqjniTfyYxwQ+o5lNwObikHhqOQDfHxVvvHNHzDVhWev2OzshA7zHez Lw6qjxOtPGvWQQuyByKQEaZ/cUwAseJSDzCi/QCtfVX88UdLfeufB3JBmayN8TbA 4lS22dOsqzZ01y43RspufH0gdZuWfrtpt+FJTFRVVYAPDoMRFOtG/ExNWoQ64+9C QRBtNO0coltrq79RWtnQ== 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 3w62jsgb7f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Feb 2024 18:22:48 +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 91A4F4002D; Wed, 14 Feb 2024 18:22:44 +0100 (CET) Received: from Webmail-eu.st.com (eqndag1node4.st.com [10.75.129.133]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 3B53D2CA54F; Wed, 14 Feb 2024 18:21:36 +0100 (CET) Received: from SAFDAG1NODE1.st.com (10.75.90.17) by EQNDAG1NODE4.st.com (10.75.129.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 14 Feb 2024 18:21:36 +0100 Received: from localhost (10.201.20.75) 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.27; Wed, 14 Feb 2024 18:21:35 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier , Jens Wiklander , "Rob Herring" , Krzysztof Kozlowski , Conor Dooley CC: , , , , , , Arnaud Pouliquen Subject: [PATCH v3 6/7] remoteproc: stm32: Create sub-functions to request shutdown and release Date: Wed, 14 Feb 2024 18:21:26 +0100 Message-ID: <20240214172127.1022199-7-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240214172127.1022199-1-arnaud.pouliquen@foss.st.com> References: <20240214172127.1022199-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: 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.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-14_10,2024-02-14_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