Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp248345lqb; Tue, 28 May 2024 14:30:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU6nwtkctNb+YE9qOJwPEw2qJbJX2J8mL2WEPgxuYqeZJSanAMZXO1K2dy+ZKKsihtw0m0H2N1azqQU1ZXPYQaDyLmRA5BaGf9o/DSPLw== X-Google-Smtp-Source: AGHT+IGfe/k8kLSwYzxXB7oR+2wgDdlQmskQU77FPbgs+hlVyfClHt4G2D5npx4B5QlPcylw6ovi X-Received: by 2002:a2e:a265:0:b0:2e6:f4c1:31e5 with SMTP id 38308e7fff4ca-2e95b209930mr86840351fa.23.1716931851557; Tue, 28 May 2024 14:30:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716931851; cv=pass; d=google.com; s=arc-20160816; b=Fe5iY9IXyyHN5gA0O7CLRrRWposIDrPkMo9O4XY9Zien3bV7hJfZ5A6k/Dll5OdQKE kzztfCXaP5hVrYSsP62WRTRea9vuMLB/y1JivpUu5xsWqkzQAIDuLUKrZCwFCcvFfjcw 9E00mbIjUaTOSvUfwmmkoD5wN5bkloX4tdIpXLxIrkCPK+m4YmqKPRnQQQzGzyF3cQPd i5m8Mt81VlMrRATlMp3GLt9kY2K7tZfUcmTVxB6mHeKOMMV/dTqkf0OtmvE8M18Zm0NF sIVzG/XWr0r2GaoQRk4PtSNRWRmZGQiOjVluioQI3R5nX7DsBW6QgJE2J0kHMaRSJh0I 2iBQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=J/886KhgNlZLfUXdG7YdFOApfJCvvDP8iK4brhkLxPE=; fh=niVCQQWCpIAGdK5StsVK4fU7TgQ8U4k0kcdz6sUGBLo=; b=Z4lXae8+A/HJF+c1KYvnxexNBQ2mfOqmxU3EXsgI0huxVKEatqUdGRhh9QOAzmgHh6 EIh1Pb5ow+qNAgKg7Hx6c/jKQdVKCgE04Fv+1iomA+jtwiPGRUJE++3bBvIlTtfEGVEZ JBA9Ctc9ys8bBrvFrvVPGZ+jEv8FIitAewuPpCijwzcpnmni9FjffOWB0yRTrvWwrgdq iLjdfQh/AOklXYNMh90s6y2O4SKtcFLC6VMPfbhkLKHzDOn/+W4IX9rVbuShJQKRGOIS 86B6sKgMsJSaCeRYHW8FdG6Sd5DPtV0yG4R5K2FYhSraILVpiUrOR+Q2/OOs16dn8ubd CoDA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wc594tiK; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-193115-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193115-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-578632d091fsi4803617a12.530.2024.05.28.14.30.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 14:30:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193115-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=@linaro.org header.s=google header.b=wc594tiK; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-193115-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193115-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 227811F24E41 for ; Tue, 28 May 2024 21:30:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C15C717B4E0; Tue, 28 May 2024 21:30:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="wc594tiK" Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B305199B8 for ; Tue, 28 May 2024 21:30:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716931843; cv=none; b=b+C8TK5FzWGKobE7rE628uxQ2Uenq+MLhU2iIWO6x9ehVdSTLNwsCemYecTE1/uXBFi547if4JyGSVb3QpOp5Gq1/EgHuU4VhpHkNddtfWBnIh6UdwmSzee1lPvknTKAsE/uGSb1ArtjvAfgL+iwgpiIDvvD1/otYdSQZCaon0o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716931843; c=relaxed/simple; bh=5rJ6C2fvM31iHiu5ju1m5SG2s+zChPz9rDT003tlYZg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=K7JOJsh1GUf13kigYljjT+c+mkSEdTWHNgOSrsrxexQrKemETK4HVq+1akK3TL1HLAE5mAvruxk+qbMwiZZo5/frIMGEeNTj9etAeQsQFqmfhYVw3kL5WHAVk3997aEGHqIW4pdFWHwbPZc5lojKNtIuVBl6VdE3wmmATyQcju8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=wc594tiK; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1f44b59f8daso10385945ad.2 for ; Tue, 28 May 2024 14:30:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716931841; x=1717536641; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=J/886KhgNlZLfUXdG7YdFOApfJCvvDP8iK4brhkLxPE=; b=wc594tiKNC7VBSM9g457bt+sTju58yY6+dkPGKAWyOY/GecwCGOeKJRZOo6XkLGT89 lxUpQNZoKNHgATwuD+ERmGE6f6Hx4SFYUIQgBVIv7ve5nhaRyD3c4gcxQnEEWUrcBeB0 amHEm/85B2Y65i+30pbEhjV81AOCGdX7h2yQmHBr/71Hv6AjT5S4lxOugKPhoj14VLJn bGF3AA8vynTtPimXEh/JPNQFR3fmf3uvvIYbHfT9Al+Yr6zNEMXK2R5LjRDBXtqfTlkb e7YuwXGJeaUYpwYO7+6vu7fnw02CiB0h54n3KSHtwM8yHycF98wnEAz8zYzOJ0NBxLfY DAow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716931841; x=1717536641; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=J/886KhgNlZLfUXdG7YdFOApfJCvvDP8iK4brhkLxPE=; b=uc3wjiBoy/4sWJX/zmnFPQo/TwC/8bS0K9c8tOT/I0bfYtCDpL4nB9yg1aWBKuL6sf eO5OtwGBP+VMECX9mpEC4kMnUpyHjxfC+vWLRAqNnfSDyUbJ5eSFDSra0KkwV62Ivfq+ xhRPQWnbjNNLNNs7g2mH0IcWfEmXNqv3SApwbiDULbnACu3gqnF7HDL4KOsCRJF4mcCi uvkXPWyHTaDfU7HK3IBTVh58GagQCU+e1fL2BarpEVc8cUnuMfHdpAfiNVwkgyJY7dS1 4J5tA+s+bg9WADdEGuNwhN0Pl2kOpr85yuqqdVvwWlQreMC7BNONcFva0rgTdY1fpQPZ zrlA== X-Forwarded-Encrypted: i=1; AJvYcCXyAmyCuz11/DrwYBq5MLKEFAkWFv1a7TrMRy8L85dV0LfmExo91tAA6LphcyXv23MeP1QTioDbzKq386g7YMB6d5onTmzL2bw62s5J X-Gm-Message-State: AOJu0YwiEIg8798Nns1+LAiE+diFABGnBrhLkNpqtQ2qjg7S27IIq3WA wTLkXYcQ19sLZRepahQFdhIIfGetftIblHt1wU/2KRFlN4xv6WyeIB7I+5lt/Kyh4SiDMIPEF7D R X-Received: by 2002:a17:903:2283:b0:1f2:fb89:1d3e with SMTP id d9443c01a7336-1f4486bd871mr151487525ad.7.1716931841312; Tue, 28 May 2024 14:30:41 -0700 (PDT) Received: from p14s ([2604:3d09:148c:c800:4c7:2691:aa4a:e6b7]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f44c9a50fbsm84917215ad.217.2024.05.28.14.30.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 14:30:40 -0700 (PDT) Date: Tue, 28 May 2024 15:30:38 -0600 From: Mathieu Poirier To: Arnaud Pouliquen Cc: Bjorn Andersson , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Subject: Re: [PATCH v5 5/7] remoteproc: core: support of the tee interface Message-ID: References: <20240521081001.2989417-1-arnaud.pouliquen@foss.st.com> <20240521081001.2989417-6-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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240521081001.2989417-6-arnaud.pouliquen@foss.st.com> On Tue, May 21, 2024 at 10:09:59AM +0200, Arnaud Pouliquen wrote: > 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); > + Why is this not part of the else {} above as it was the case before this patch? And why was an extra check for ->cached_table added? This should be a simple change, i.e introduce an if {} else {} block to take care of the two scenarios. Plus the comment is misplaced now. More comments tomorrow. Thanks, Mathieu > + 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 >