From patchwork Wed Feb 14 17:21:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 201072 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1377023dyb; Wed, 14 Feb 2024 09:31:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVR2CDpv00lnYCa2Tdy31tpgvK/1rA4xnRyRdWsadxaPxN0csEUjuM2STVs1N/Td1rdV2TloAQpl/R/eG+3xIqw6aDZlA== X-Google-Smtp-Source: AGHT+IELEE8hJwJSl/yIolvB/Wl88dfmGO5gEMPPRX4llUfFWrhD+BrRgODzDAszkbt+JjKVKuYi X-Received: by 2002:a05:6a00:3d54:b0:6e0:f3f4:8da2 with SMTP id lp20-20020a056a003d5400b006e0f3f48da2mr3551520pfb.2.1707931874397; Wed, 14 Feb 2024 09:31:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707931874; cv=pass; d=google.com; s=arc-20160816; b=FZmAlxOAYBNxMj4mY0/KTJnbyDl0BGbUqOffxiOv1iYahbBx4hVNE0VoYwQBra30Nz auOe2MRgL/eP6CtPy8Jgw3BLlALNHCfHKxe7VNmsvNcPkyWcrsD8zfy0UDD9YvKARyx0 Ot1e1EfojsaftGY1VsIgt3egQE5htUNa6cQ8Z+LmQlUnl0NyprR7fgxfg9gZguGujj50 lHXX0qSgHGCEATo4SsUloOqHol85rT+KoXre5AOHo8KXq5Nu5QKf6u4QBqjcXg5WDbWo uzMWeL/k6IVBRb8L6SwdF2IA4dJWNJP9pGS/vPScV8lWdPHXnoKY+ovLGFwL1h29TA38 K4WA== 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=zgREzdhY3dfyw5CqKC1QMhxIqf0N7qEmUTEATB1Ym2k=; b=r+rrXecz7hYrMIfp+SWsXDKk6Z9p5d7XS4LAPgv6TRXbyTfeaUeA2dqOARdWF5ZpLE by+qu2mQH4Ey+u9h/u81kKVsG5DNcmFQtSrDbZFxJsu109HHETLZEu3kwG+5Tc021LXF +66nwXoNvpSlhI9NiY23a4WmThrQmeFJqQTGg2RGpS5I6w2tWgHO7CVzuKvBziMTiXiw miSj2LgcTZHRdWO0cOLsFAWbNoUmpLWoymXpkmNuXZ5GJf605Y5sPa5ECkU5Tb2tqlN+ L2gqhGiVmXe+dRwmW9qeWIJtVMaepkT7+Osb8yaq8buBitgIBIo7bYZbH/UG1ACD08pN Bzcw==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65668-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com X-Forwarded-Encrypted: i=2; AJvYcCUfHNvUbsTZhHxj36yLj2hwCBGDiuw7pauFaLoLa6M6y0eCawCQWZhteWyqOoxzSmmDoIpNoeq2CMJ2dus5BaLXbW7oQA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i123-20020a62c181000000b006e07c7c4eadsi8762051pfg.129.2024.02.14.09.31.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 09:31:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65668-ouuuleilei=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=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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65668-ouuuleilei=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 25ACF285F3E for ; Wed, 14 Feb 2024 17:28:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D7F9E12BF3D; Wed, 14 Feb 2024 17:23: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="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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790896373443879727 X-GMAIL-MSGID: 1790896373443879727 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)