Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp193152pxf; Thu, 11 Mar 2021 01:17:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsgFq+SjRQNyyIOyKxWlOxjNya8bOMpVMGr9jhG0pXVnlU3i1hnIGQ5J2GM0lkaTuMrZl2 X-Received: by 2002:a17:906:ca50:: with SMTP id jx16mr2179308ejb.72.1615454272286; Thu, 11 Mar 2021 01:17:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615454272; cv=none; d=google.com; s=arc-20160816; b=NWeQ4jXQwkCW2dn1lqE3/ot1/6/zfWyB1bmuhNSxwHMPqFesaDeqoAeyILRKkrjrq1 ZmF5igZKjqVJHxC1xPDfzJN747m5+NyLopMePUaFjMFyxJVczpsbQv51dwNtk4L8nHem 69NlmhO4D2YyzspMui1WVZ3rn2nSY3tbk+5tFOBZOvVsQfAhnoaYRGKaGHVdLynA6SRR xVYLLxvX8WPPVyYPJ94rDhVLunCk3nKfEHdIW0/IPJxDz336Rs41JwfwlnJhsxb3FO3e kvlncgp15UJ0s/rJlc3w1cB2YBG8ZUvmqjcuwPz0v2+FHJ64ByHCTb230MuoXt9SLZFq qzkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=NLAxClV6LoRWqXIaz8yJbP1l3AT05LO6i1xarp6O0vM=; b=d9lsewNc8b9j4J1g6UZoLU36Y6UoNzccuPNd5ejwSgh4YsFQx5hRaBiAzgdKWSCVVB jMVe6whyu68OvV+SQAxoK4Ovnn48BCybRDElUh9DT0EtTMvNxNa36kmLeX58CkIbCYbk QQn09HGzSBvIbOKmQFv4DUwCuToIiWK+YZ8AC8lfkMKF1hcBYkxKrEi3FPWvNZBgMpCH ZuukBJs9bsDPlm2u5as4K8f9oPEJz2C7BEXS3R2mAmpLtHtjZMpQq830KhiPlYQkGtzC lvvNFz4cr28GyD1bK7LYIu+fwQPDr441iDDfvWG2xdwnkTu5BLPJO7apyF2K4BjDTmpF nB4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=W78a3qhe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ox25si1363132ejb.183.2021.03.11.01.17.29; Thu, 11 Mar 2021 01:17:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=W78a3qhe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231899AbhCKJOz (ORCPT + 99 others); Thu, 11 Mar 2021 04:14:55 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:58670 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231834AbhCKJOd (ORCPT ); Thu, 11 Mar 2021 04:14:33 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 12B9D9l2019056; Thu, 11 Mar 2021 10:14:25 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=selector1; bh=NLAxClV6LoRWqXIaz8yJbP1l3AT05LO6i1xarp6O0vM=; b=W78a3qheFvIwOR2Z/77injFR4Xslv41zIh2uEr3HA4Q153FaUqdQvZOe7ij07TYcyQLU vkUB6qMqm1WcVSdYCH7iOfqo08WIF588rxjfZYjSEir+wXZn2dM8c1zukB/PHgcd7p4S ziW/39zSJIEjP61RK0xbXzJDOEbcrb70uEjSsLMIjmyp5CYc9Kip+gm0uUbj/H2vTPm8 gZbbfjpunepH1iY7Pw+WF6m9LUnTBUoLqfYhzqRpWCZv8q0vG0v4AvxHxMpn+nglwbRC cyq7LGKFLFWP/8IbEUgjZIf/a2Nr77ug68wzcVu5VsEc8Ib70HoOEc3ATuVX+T3lp2tK 5Q== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 3741gpwpn1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Mar 2021 10:14:25 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0A6F210002A; Thu, 11 Mar 2021 10:14:25 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id ECBEA225A70; Thu, 11 Mar 2021 10:14:24 +0100 (CET) Received: from lmecxl0889.lme.st.com (10.75.127.44) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 11 Mar 2021 10:14:23 +0100 Subject: Re: [PATCH v7 12/17] remoteproc: Properly deal with the resource table when stopping To: Bjorn Andersson , Mathieu Poirier CC: , , , , , , References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> <20210310211025.1084636-13-mathieu.poirier@linaro.org> From: Arnaud POULIQUEN Message-ID: <0475be62-d08c-8844-f118-71755ba6cb0b@foss.st.com> Date: Thu, 11 Mar 2021 10:14:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-03-11_04:2021-03-10,2021-03-11 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/11/21 12:53 AM, Bjorn Andersson wrote: > On Wed 10 Mar 15:10 CST 2021, Mathieu Poirier wrote: > >> When a remote processor that was attached to is stopped, special care >> must be taken to make sure the shutdown process is similar to what >> it would be had it been started by the remoteproc core. >> >> This patch takes care of that by making a copy of the resource >> table currently used by the remote processor. From that point on >> the copy is used, as if the remote processor had been started by >> the remoteproc core. >> >> Signed-off-by: Mathieu Poirier >> --- >> New for V7: >> New Patch, used to be part of 11/16 in V6. >> --- >> drivers/remoteproc/remoteproc_core.c | 53 +++++++++++++++++++++++++++- >> 1 file changed, 52 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c >> index e9ea2558432d..c488b1aa6119 100644 >> --- a/drivers/remoteproc/remoteproc_core.c >> +++ b/drivers/remoteproc/remoteproc_core.c >> @@ -1634,6 +1634,52 @@ static int rproc_reset_rsc_table_on_detach(struct rproc *rproc) >> return 0; >> } >> >> +static int rproc_reset_rsc_table_on_stop(struct rproc *rproc) >> +{ >> + struct resource_table *table_ptr; >> + >> + /* A resource table was never retrieved, nothing to do here */ >> + if (!rproc->table_ptr) >> + return 0; >> + >> + /* >> + * If a cache table exists the remote processor was started by >> + * the remoteproc core. That cache table should be used for >> + * the rest of the shutdown process. >> + */ >> + if (rproc->cached_table) >> + goto out; >> + >> + /* Remember where the external entity installed the resource table */ >> + table_ptr = rproc->table_ptr; >> + > > Afaict this is just a remnant from the detach case. > > I think the series looks really good now, please let me know and I can > drop the local "table_ptr" as I apply the patches. > Just a minor comment on patch 11, then the series LGTM also, For this one Reviewed-by: Arnaud Pouliquen Thanks, Arnaud > Regards, > Bjorn > >> + /* >> + * If we made it here the remote processor was started by another >> + * entity and a cache table doesn't exist. As such make a copy of >> + * the resource table currently used by the remote processor and >> + * use that for the rest of the shutdown process. The memory >> + * allocated here is free'd in rproc_shutdown(). >> + */ >> + rproc->cached_table = kmemdup(rproc->table_ptr, >> + rproc->table_sz, GFP_KERNEL); >> + if (!rproc->cached_table) >> + return -ENOMEM; >> + >> + /* >> + * Since the remote processor is being switched off the clean table >> + * won't be needed. Allocated in rproc_set_rsc_table(). >> + */ >> + kfree(rproc->clean_table); >> + >> +out: >> + /* >> + * Use a copy of the resource table for the remainder of the >> + * shutdown process. >> + */ >> + rproc->table_ptr = rproc->cached_table; >> + return 0; >> +} >> + >> /* >> * Attach to remote processor - similar to rproc_fw_boot() but without >> * the steps that deal with the firmware image. >> @@ -1759,7 +1805,12 @@ static int rproc_stop(struct rproc *rproc, bool crashed) >> rproc_stop_subdevices(rproc, crashed); >> >> /* the installed resource table is no longer accessible */ >> - rproc->table_ptr = rproc->cached_table; >> + ret = rproc_reset_rsc_table_on_stop(rproc); >> + if (ret) { >> + dev_err(dev, "can't reset resource table: %d\n", ret); >> + return ret; >> + } >> + >> >> /* power off the remote processor */ >> ret = rproc->ops->stop(rproc); >> -- >> 2.25.1 >>