Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp3044908lqo; Tue, 21 May 2024 05:29:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX8y7OURyvXSV0CFeY194GjgjcsK7oMbfqVePyP8+dGC0gb/nYQrRqJ2F7X64CPJPEq1w+ORGFETdN8B6s3m0aMq8RK3XATyiGBomrbAA== X-Google-Smtp-Source: AGHT+IFcjd5UwNF04s5iFqnygn3yVqCtr1piliz4i5LHDlo1FisQ7SkvHLhCUC9wc3VwByrNbK8X X-Received: by 2002:a17:902:f64c:b0:1f2:fe60:2d80 with SMTP id d9443c01a7336-1f2fe602f64mr67436885ad.6.1716294572674; Tue, 21 May 2024 05:29:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716294572; cv=pass; d=google.com; s=arc-20160816; b=LnNAysZsGSQyUKKgnnBmooCVQtStfRIL1H/qu6LZi1LubMwAL3Ee5LsVOzMBavn6SB t8r7W0Qh/ZxS5iPbDrWHHATLCILKl3qaYSe0vZWga3v3lEHaNAJ/Ig5fejZ7s3NmTTnL xGt4lqe4fa/6LBbALo+4sTmZ0fcY3Y/UnmweS8m5v3w5P9f7/rX3+dukJ9jzU7fDVcEk ZisiQHifrGRkaoAEARGYoyp0C6Fib+bYrnCptWnclU/aDMzbqIh/p3AezhZ9gH0BXckS z0jF5EpFiX728g4T42aAip0FSMo+gnM/fsHnDwXOVbevfPaHtMCH6+eH07W3S+SDrAz+ 2eFQ== 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=WsAawMTax3oHIlOFWQKZnqllSyCUDt+4e8kM5A/lBqE=; fh=hTJigRCoV4/ES7XxqKE71DbJJyraFtTSDFtlGOKfKPo=; b=PnyezMsZAkY9iyjhzSmkN6toGSENBVvEbhWsq2ufwTkjZKuuVxWVAbc6dvQLA+EyPA g139Hqmj3CjsdXdZFW2di+rs1G5Id5AhCpd5cJmCsHHvkeQd8aOsG8Z1BzR3aF4gZdJp YocturTW3P6oE+w663xy86XphSEcvZ/j1Thb3q0AVPCmFEZLLrXgD1bSYJzzd20+DCcj MXsWqeNnrcYD0GWBVNcb2Hv8l8ra6xDMDOePJMszZe+GaAck02NqFgIncWZ0FMd+fhGK j7WVpiwPbhnB87+ETjs+oK+ZEvPw+sbC1XOWvPMGpbXXzHevXl9E2b1D7uTOSClK4mEP uSJg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=KEvoIRVc; 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-184944-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184944-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 sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f08ea06c1esi3686005ad.212.2024.05.21.05.29.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 05:29:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184944-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=KEvoIRVc; 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-184944-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184944-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id CF9A7B217E9 for ; Tue, 21 May 2024 12:29:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D62277F32; Tue, 21 May 2024 12:29:05 +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="KEvoIRVc" 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 65AF0762FF; Tue, 21 May 2024 12:29:02 +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=1716294544; cv=none; b=OvuAPbs2bHLPMqjPngiJoYXzjORwDoef84HYtDLA36VldbLvJevw9t6U4lhAYAK5lRBR3qXQxoMattsf3u+8sdsG9oJa5vYSHyN5NKTjmgp1JUEGzA0P0mQdA9KddBILvzJ/CepcM2T++zH35TKbkSs5Sz0tEt2RQGlRCbP7Oxc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716294544; c=relaxed/simple; bh=bLYKYpw0Io3gEogXgy0VDE4XhpywXwGCkssIfUsXU7U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jZqOOiaF3/x45TiaBR6EIXr/xLsVO61y4qEyoBsOpCs+lWOSCz5TPPx3tZlJIJRfy3taZScDJk6CBwueEx6E3iDsyY6Gprrxq+tM/byZen5iZE8xrxGw2+uiTa3/vIOfsU9ylez5vlqISD9c/7IsNGzkAD30arLJ+DzbeLgrzXg= 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=KEvoIRVc; 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 44LBSA3G018788; Tue, 21 May 2024 14:28:43 +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=WsAawMTax3oHIlOFWQKZnqllSyCUDt+4e8kM5A/lBqE=; b=KE voIRVc6II8ylRGWXoTMUo4n6LJN3JtoCdC6L9LVc10vWeQ7/bTfoSeSuhu+CcZtK urHqpiR8P45bn8MstoQTXmGUHsjfZ8kcR0csEKpivzWTu1JyQH6jAgTceaYem4s0 wpan1S5hEwhTQIcPjprNWMnrO+XUkTePosdGS1W7hXiHRgO/jYLT8NWL94IkGHj/ bhm7nGzl3GyX7ouejRajiicJ58sZkK9cOYm/9oAC1CHXM9EVka5eziqq1OwgzRj6 MFumgGWIz3u5KhlG7S9YUGldOWkGV5vSXXJvZKRGgCeogJWlXxmLrYJpxXLN20eJ kY7NCXZKP5RM3FPIRPkQ== 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 3y6n33bsfu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 May 2024 14:28:43 +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 083FB4004B; Tue, 21 May 2024 14:28:39 +0200 (CEST) Received: from Webmail-eu.st.com (eqndag1node4.st.com [10.75.129.133]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id D6F0A21A200; Tue, 21 May 2024 14:27:49 +0200 (CEST) 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.35; Tue, 21 May 2024 14:27:49 +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 14:27:49 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier , Jens Wiklander , "Rob Herring" , Krzysztof Kozlowski , Conor Dooley CC: , , , , , , Arnaud Pouliquen Subject: [RESEND PATCH v5 5/7] remoteproc: core: support of the tee interface Date: Tue, 21 May 2024 14:24:56 +0200 Message-ID: <20240521122458.3517054-6-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240521122458.3517054-1-arnaud.pouliquen@foss.st.com> References: <20240521122458.3517054-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_08,2024-05-21_01,2024-05-17_01 1) on start: - Using the TEE loader, the resource table is loaded by an external entity. In such case the resource table address is not find from the firmware but provided by the TEE remoteproc framework. Use the rproc_get_loaded_rsc_table instead of rproc_find_loaded_rsc_table - test that rproc->cached_table is not null before performing the memcpy 2)on stop The use of the cached_table seems mandatory: - during recovery sequence to have a snapshot of the resource table resources used, - on stop to allow for the deinitialization of resources after the the remote processor has been shutdown. However if the TEE interface is being used, we first need to unmap the table_ptr before setting it to rproc->cached_table. The update of rproc->table_ptr to rproc->cached_table is performed in tee_remoteproc. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 31 +++++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 42bca01f3bde..3a642151c983 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1267,6 +1267,7 @@ EXPORT_SYMBOL(rproc_resource_cleanup); static int rproc_set_rsc_table_on_start(struct rproc *rproc, const struct firmware *fw) { struct resource_table *loaded_table; + struct device *dev = &rproc->dev; /* * The starting device has been given the rproc->cached_table as the @@ -1276,12 +1277,21 @@ static int rproc_set_rsc_table_on_start(struct rproc *rproc, const struct firmwa * this information to device memory. We also update the table_ptr so * that any subsequent changes will be applied to the loaded version. */ - loaded_table = rproc_find_loaded_rsc_table(rproc, fw); - if (loaded_table) { - memcpy(loaded_table, rproc->cached_table, rproc->table_sz); - rproc->table_ptr = loaded_table; + if (rproc->tee_interface) { + loaded_table = rproc_get_loaded_rsc_table(rproc, &rproc->table_sz); + if (IS_ERR(loaded_table)) { + dev_err(dev, "can't get resource table\n"); + return PTR_ERR(loaded_table); + } + } else { + loaded_table = rproc_find_loaded_rsc_table(rproc, fw); } + if (loaded_table && rproc->cached_table) + memcpy(loaded_table, rproc->cached_table, rproc->table_sz); + + rproc->table_ptr = loaded_table; + return 0; } @@ -1318,11 +1328,16 @@ static int rproc_reset_rsc_table_on_stop(struct rproc *rproc) kfree(rproc->clean_table); out: - /* - * Use a copy of the resource table for the remainder of the - * shutdown process. + /* If the remoteproc_tee interface is used, then we have first to unmap the resource table + * before updating the proc->table_ptr reference. */ - rproc->table_ptr = rproc->cached_table; + if (!rproc->tee_interface) { + /* + * Use a copy of the resource table for the remainder of the + * shutdown process. + */ + rproc->table_ptr = rproc->cached_table; + } return 0; } -- 2.25.1