Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2929215lqo; Tue, 21 May 2024 01:13:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVIYPN7hypLy3eevGEThbBGzd6qQCbPZYGNrGvPU1CNmxz1TVAC/B4NhjaxnC4bTGPsJEBHQ0TjOd04XL4q3XXOZQVh7SZHaSCVsG5Ucg== X-Google-Smtp-Source: AGHT+IEXlqhem5OKEY6/p8t+RRBPTP4V8+vyrKZL6y+z+g8dZuerwaDFbmyI4o2Uuy/GNRqBYFQv X-Received: by 2002:a05:6870:5713:b0:244:c8a1:8086 with SMTP id 586e51a60fabf-244c8a1c7efmr29184750fac.24.1716279213938; Tue, 21 May 2024 01:13:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716279213; cv=pass; d=google.com; s=arc-20160816; b=x94DTSnYGbX+ZPOsGffY1zMwSAJU8nqbAsNb9l6y20Do+i/iDojY6bNPhOC/yw72UD ylFYlFmKr06sG7+VDpcJVxvLHHqe2aapIUi6ggtFcjD3zgWyrR1CVbLfik4I5GGFWEGz aPFoDQEfWFMVNgn9Trp6NR8y8+ew/RC8el4rk+ZUKnR6+1son6o64+u4gZwDDq9ujN7z p65unPZptThoewiYhtq0pRyOJ2Ue67jiNWGc5R+vlcr8GJJWA7KSaBfIlY8iiKXUTrj1 CMQRepgp7/LdTre5DjicHsYBPZB113wRxLXH+RzmxB5mftN5fbFAk9MBoDTaE7cXxHtx 8vrA== 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=luA+ZUFTcJknApwisPNPdZman1Wn25gDMX3CVQ3XRQs=; fh=BmUATlDGZqfVcf9e+weO/u7Pa1hPMaSww1TRE+r23OE=; b=ncuDB12tB+jVG1JAJuVqPnFk3ZtdNmX/qxZnOTGHdhbUsbUt/23f+csQJEgYSZhFGm drFhVwXK6LyPbzGI8S+RUeMmYfvvCrLA8Lj7Z/nFbo+OFkZq7SskNGi8s1e7WBTX4aZX xZm5cdKZUHqqQ/89SXB88M7437MZlr3bPCCZ2WSMhToXtedcMsFqNweN+ihzh1Bm44fW LyxLiPTy8kcfJ4+VDGTohveW4LF7/sow9IlXPC4ogr8T5G1UBM9XaJ7LSSZ/1NQ5xV/B G15ImWIVOt4xdXMtI/iKnGn+T9LoRl3YOe81+HC2IqeFMj6kHgr3OHpifCOEOVMVgWys ltIQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=jNguU73i; 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-184626-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184626-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f4d2b419d9si23627460b3a.331.2024.05.21.01.13.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 01:13:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184626-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=jNguU73i; 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-184626-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184626-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 AEFEF282A07 for ; Tue, 21 May 2024 08:12:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ADE186BFB0; Tue, 21 May 2024 08:11:06 +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="jNguU73i" 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 98A0254777; Tue, 21 May 2024 08:11:00 +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=1716279063; cv=none; b=naIDnR2gVE9fT2BPMbUXFmBvLtvt3th/xccZufqNiHl6akAmVYtCYU2eHzi5aek0mz2Wft8mVj5ETRgs0ylXGx/hiWhbBTjwj3/2jkAI6haKoLRx1WCgTcmu6BGQ6bAmhjJmccMfZPmYiCUhX6jSEVqDL1tZMrHnjYPUJ2EeKw8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716279063; c=relaxed/simple; bh=W9OC2fUk3FD1xhnbtvYwKD+7Xd1c9IdLOs7cBPZSL7o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=E9B8KnVKxusAweOMXhTYqcd7+2bXTIr8MiqNXzEwkF5jOnmiHb8bef10IDQAvPD19OPWIOS0//7De2qhtVXqeWCYNlBEnPXZh51c4i6Qpl5EJgktyJkTGRMX0A6bAtQbeIV5SFGk9BGRUdWfg6rbn8XeuMXRsTrC6QiSIeCL04Q= 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=jNguU73i; 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 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44L2t8qW030566; Tue, 21 May 2024 10:10:46 +0200 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=luA+ZUFTcJknApwisPNPdZman1Wn25gDMX3CVQ3XRQs=; b=jN guU73iiJsePF8/meNXmocQ6wDBeYwBXkUltIWK/FRDu1mPhmauEJPWwLk/6DUD83 cWdj01cz9/RSAUUSDM+cJv28helRGSJ3CNp37joFeq6iQtOFe8pMxBInMS+j/hPz VtYcxivSxua7vniy0NONCue3VmOXiRrfc1ZSoJ3IQH6hYFYi++xmq1H17oXD7pbP NnwQ3jv+XVMlznePqwGlH18Onyzm8oAiW9QQN1A/FcxvlJkStQOV3aQPeUyA0NDe 4A9ELrFkTmAkd6FsNMOVNHCttKAPjxayquZi2htB/SERYiMMoOlwFeVW4XBdrEbE MrasaJIELFNd2VXpen3A== 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 3y6n33ag80-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 May 2024 10:10:45 +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 E9BBB40050; Tue, 21 May 2024 10:10:41 +0200 (CEST) Received: from Webmail-eu.st.com (eqndag1node6.st.com [10.75.129.135]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id B11202122FA; Tue, 21 May 2024 10:10:15 +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.35; Tue, 21 May 2024 10:10:15 +0200 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.35; Tue, 21 May 2024 10:10:15 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier CC: , , , Subject: [PATCH v5 6/7] remoteproc: stm32: Create sub-functions to request shutdown and release Date: Tue, 21 May 2024 10:10:00 +0200 Message-ID: <20240521081001.2989417-7-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240521081001.2989417-1-arnaud.pouliquen@foss.st.com> References: <20240521081001.2989417-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.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-21_04,2024-05-21_01,2024-05-17_01 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 | 84 +++++++++++++++++++------------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index 88623df7d0c3..8cd838df4e92 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 0; +} + 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