From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABC39C433E0 for ; Thu, 11 Mar 2021 17:20:33 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3C9BF64FE2 for ; Thu, 11 Mar 2021 17:20:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C9BF64FE2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AK8n7vZyqfegMPUmlFd2USQCFQaLkwiK90cq/2/ZYX8=; b=At6g8r/e9I+fdsrqe+1mvVwAm NmaSgpNOLT3i/c0KcHhGjFc9pHHvxVTcaIQGRwQCadGXRwLSpUvKmgJQizCgJ+Q15fH5zvaGqKTUU MKW7VBC+TuDfGoCTvS7iWciniIkeVOXJbPTuXR8Bbmg9vHBRKoM49xxe76E0uwJzDwDi8/XEfV3Ye oWnXs4FsV66jJ345tcJrHZ58m2OasHTRaodAEOSaSNUOyjQXAmk/UFr03oU/auvek6HNwwELVme6M IY/GPyKnyI8h7eZS4Ij+vzjZ6v9MjYVuaXiRbzgYVdJBAl0FLQXtGg64T8OuSC470+tk661kr07zv iMmrFORcQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKOxd-009hUB-73; Thu, 11 Mar 2021 17:18:57 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKOsa-009gE2-ED for linux-arm-kernel@lists.infradead.org; Thu, 11 Mar 2021 17:13:47 +0000 Received: by mail-pl1-x62d.google.com with SMTP id z5so10528324plg.3 for ; Thu, 11 Mar 2021 09:13:41 -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=Al/T2sFWlvT3Vtl3R7CXJDlSotPrwvE7T7S7T8TsWxo=; b=vX5cI/xl4BhFDK1i2+FF347SCqdm4hT3gkn1huohMMQ8ojPbiVWf2kwDKNkkERnbF0 yxLKe38HJb/UYRgAEzLIRG1OUa3AJnk00ObYH8XAEWu9IC9IcLLDaBkJwYR6YAYQqlgi hBGwjYYUk4eRhYTY6IgETxzP6CStwS6fkY7bG8YPsmCOysAVg0hT+A5wcH+6iGDZIdoH qPON9ACpFALlYYGji1aUhFopwQI8S8p++mABmayygY3pU1hwcSKKBUBTABlo7BBHTOuf AzsEXlImcPG1Nl0QEisfya/cxEq3GI/WC1milcDDeSkafl2en2Sf4ErVPl5Bo/yXaS64 BRtg== 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=Al/T2sFWlvT3Vtl3R7CXJDlSotPrwvE7T7S7T8TsWxo=; b=IuqLzvntgHW5PVOXo7ayLvwIONOWx2E6TwBmVXm99PaU+L/Kxog+6/i67WKnLC0/aP 7fhVNdFFi/wRFWcHrp7i08zBQJKiwJcMz66fXkYMZ2rOA6U3X4v7ViYaQNCDrfxgsDB1 +YpbWYj/IuRiB5UumL7qOU8KXlCCHDx5PhK7Xncr33dv9ra2lwORpovmFIVOfXHlVRmw laQGmEV0AlrJrCgL0Oy5unkcrG6QyvsvsN3ecIWLwZosYXZL/+xeqPBauTq1ITpeEvYP Plt1Ur37Pyf/Ikh5KSImOw5UgmUTxZVyTQezwSpuDgcmGYODlVfUiKiHeM6+DtjNnzCy bZ/A== X-Gm-Message-State: AOAM531b2OChArJXXpr9dVYmKlauHkqaTSpX3wdEfLfIE4NXstX8F3cy 0LSvK7G+3IFsTRhMyw19bAK8GQ== X-Google-Smtp-Source: ABdhPJxXZ2mQrWMXsr2BEClDmGES5sAN9xqNAjKyB3hrk7VnzZoXr+dIKS/+ZlZKzDwWb4gBOKS0sw== X-Received: by 2002:a17:90a:9b18:: with SMTP id f24mr9511651pjp.96.1615482820187; Thu, 11 Mar 2021 09:13:40 -0800 (PST) Received: from xps15 (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id a1sm2838753pff.156.2021.03.11.09.13.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 09:13:39 -0800 (PST) Date: Thu, 11 Mar 2021 10:13:37 -0700 From: Mathieu Poirier To: Bjorn Andersson 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: <20210311171337.GA1113417@xps15> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> <20210310211025.1084636-13-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210311_171344_614916_C0002A85 X-CRM114-Status: GOOD ( 37.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Mar 10, 2021 at 05:53:04PM -0600, 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. (sigh) No matter how long you stare at a patchset there is always one that gets away. I will address Arnaud's comment and fix this in a new revision. Thanks, Mathieu > > 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 > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel