Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp706106pxf; Wed, 10 Mar 2021 15:57:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJwDGic7miILjiVkXY+OGYckdMTqvW24OPLl8i4Rsqt4uGRP+xMw5/2WJqPrXOtAzc043/4+ X-Received: by 2002:a05:6402:cb8:: with SMTP id cn24mr5967747edb.105.1615420627466; Wed, 10 Mar 2021 15:57:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615420627; cv=none; d=google.com; s=arc-20160816; b=ZGhKQ9RJg397UHCt8KfKRzI+vuN1h7Ayk+BOmOClj9zuWnrFFn78Ga/DlVsnZRZTWP 6GvNI2MtiR400BGtHi3Z6yH5x+h69aUT4/BaEkq4lxGU4Muj06mOChmrrJPc9xwtsOdf ewOnBnPBC2G2QTTjtpwqKS+8NFoCxJiShhjjlaqrAttvbkcL4LcvCodBH5NZAbDu7kOE omfpSf50jRyJTGK0b+OHTiDj9rfOrzX04uWC7woShnfx/rFNLKae/3gy5aOdkIpbWLtj 7fsID2OXrBOKRTTN+djp+iku8vAO1KmUFfZgQrXQ8+N1SoTaSnNc2Ao5VPmdnNJzOxX8 ZycQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=STePm3/TxG9rAAgXd9N5KIEzWISsuLXYEPo87xY5kA8=; b=NMLTnlnF764hSiVJq4YW3tvFhSmXhk62Z/62VsUYYvb9+esORbn0xMbMjOkFsL8VCD 7sGNIM8Wdf8vr8lqzA2Ns5zbBOYUbROEe4S+myjd5XsciZZXo6jtpg3U4+0Krr8iFQyE +HapCGQUuKCqBHADwM4lHDk1A60tLsIt1792gC5mRmrC0+M9foqluxMnlPT87Ix528SG 91Nf+YN7cTKCc5X+qlmzqk791vOoYOm8k1Q3y1xeseHSmqHCJYisjzxUqYSZ1wXstn/4 +Ul+4tNcncLvZzoNCx6I9l8WNd8OPBeTl9HZPVxB9fjeYNwgLAQBF5eMGNT9pNc20hOH Q6bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="K7x/Qefj"; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oz17si580048ejb.205.2021.03.10.15.56.45; Wed, 10 Mar 2021 15:57:07 -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=@linaro.org header.s=google header.b="K7x/Qefj"; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234147AbhCJXxl (ORCPT + 99 others); Wed, 10 Mar 2021 18:53:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234110AbhCJXxH (ORCPT ); Wed, 10 Mar 2021 18:53:07 -0500 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A596CC061574 for ; Wed, 10 Mar 2021 15:53:07 -0800 (PST) Received: by mail-ot1-x331.google.com with SMTP id a17so18274346oto.5 for ; Wed, 10 Mar 2021 15:53:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=STePm3/TxG9rAAgXd9N5KIEzWISsuLXYEPo87xY5kA8=; b=K7x/QefjkK5M0ZBXz9muoTBQl6/x5KpifwW1HfEsL/fgWLCpzyMOlHgg4uHWsCTikj Qq1+yp+MSlFkciO3zIbTKdDURv6eR/feyA+0C2jBIJG8VDOSSwF4+ASZXhJHB/IBLCno WDBa5/u+w4YXDwjjzJGM6Us/+zxPVDZihlbw9YErJm94fjl0SMqKeVs8qb1kyVDFW0BW +8qbR7IwgMxiuxzKme10zDiJqq4G/JOrcEjrMiXahzIC5LER9NM90/EBAqzKaFbUAYnv Fg+xG2ZaRgZrKbEoW+ZZijK88+yhI1U1OKHhJo6A61XuTiiJkW7X3dgNZtIDFRrbTchz 5tdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=STePm3/TxG9rAAgXd9N5KIEzWISsuLXYEPo87xY5kA8=; b=Dg6bIbCPSPka413tfdIaHfY2y4ZI7uS+T1baZPaAAbpEkU77Qygzs8gigd4swb4kxR XsBaAl2rnEQRV7Sz3bCJglyaRVtbO/YLnozArFrtluS/aoFprhPPIn9ZR8rtN+8a7gw0 qCSE/lXpkLrCatwaWRbhCQwaSHnKGdqLh+LeDy2Q8InLO7l4GwN/lc5ctSxiZHjdS/it QMkjhzEhWdwcUfzN4pLAUiFPXfdgtYyEqWNbxaTDL3jMDoBBjxkOM+Qq/qkOeCuSbySs TqIDI6YmiObEnhplEKt9sD0yq9xF+hZ0XVOZ/KFUKgkKYiRA8jrjKFVull1IaZbhtH8W ZrOg== X-Gm-Message-State: AOAM530fa9hZtgAVNQm5bFEJGZnzo+clsQ99Gt4VVU504l41aGkVC/4v sdVkC5h+5kzPAYA8bxijv5asSQ== X-Received: by 2002:a05:6830:225b:: with SMTP id t27mr4523378otd.73.1615420387047; Wed, 10 Mar 2021 15:53:07 -0800 (PST) Received: from builder.lan (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id g34sm278385otg.51.2021.03.10.15.53.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 15:53:06 -0800 (PST) Date: Wed, 10 Mar 2021 17:53:04 -0600 From: Bjorn Andersson To: Mathieu Poirier Cc: ohad@wizery.com, arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v7 12/17] remoteproc: Properly deal with the resource table when stopping Message-ID: References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> <20210310211025.1084636-13-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210310211025.1084636-13-mathieu.poirier@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 >