Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1058146ybk; Wed, 13 May 2020 22:19:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1qlUZaG6u8rXzRTUd7Zvz02+cdFyB2STCySOnd0k8o5pjJvJx0HFs5ANFxrkkJr12S1s2 X-Received: by 2002:a17:906:b217:: with SMTP id p23mr2199687ejz.136.1589433546775; Wed, 13 May 2020 22:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589433546; cv=none; d=google.com; s=arc-20160816; b=uuaLS6z31kn6FgeaJKtsMEgiYCLCqnOKx/SY5ztuwd5w8KgT46orKGG0v7BbbE9Cgb uKUr6FW+z64VvawfJbCfnvE9mdp018H4LzD1QBanXQnH/VABfqcjY/3iN4Ix0tgXxNrm +GXoV6uXcMYRz6JtQgXwXTEAHOId8QSMdj+uXJYhHcCQJ6KsWeQiU7coKUXhXydMxg6/ WNB4PwMTBCYXRQnUXkzD0PIyqiWbUArmLWxkZHtviPsv1WjdZHDP7Qemjd+eORmeLuGE iu+jMUiNWOyB/qvdqwk41Bv27nnmpd3ZA96c+4wyOoO0aEq3NDSOAXN4MIpXQOtzCeqH A45g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=2yXsWHQlHZFO6uOvXrEaZ/pS+PzZxIKV+dtwFcRxe6w=; b=OQYLdyqcrYngYpI+oRsYY/GGmv9Qgt7tNqCMyC9k02sTnvBd0dJ42gcsBTsF2bjZ+l 8aE4Ds3SbEtFBw5qBGv0rknEBEf8EATBFxkd8e4bAFP3cSYD6l7bSiUkmWpDtH6SKZvh aAmU8AXRpoyj5qrQZ76Ibu4hQFb+c8Yryio2UnWtpY3astanYqitsaqgViltkxYLS3Pg pjFRxeHxpwzGwlKYvVXc/qYKDvh7Z9RYzswtX8KZR9l6DDr1AxH1kZBD/20UohIGz2am Q1hkaDGfnnomsOLwkULBouTrKGR24+pRYOjf+ZtmbEds7VuW5pBJgpRIOS7plgDhm5Sk aS0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WaEy+o54; 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 dn10si1452715ejc.89.2020.05.13.22.18.43; Wed, 13 May 2020 22:19:06 -0700 (PDT) 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=WaEy+o54; 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 S1725976AbgENFPI (ORCPT + 99 others); Thu, 14 May 2020 01:15:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725876AbgENFPI (ORCPT ); Thu, 14 May 2020 01:15:08 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5000C061A0E for ; Wed, 13 May 2020 22:15:07 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id s69so3765642pjb.4 for ; Wed, 13 May 2020 22:15:07 -0700 (PDT) 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=2yXsWHQlHZFO6uOvXrEaZ/pS+PzZxIKV+dtwFcRxe6w=; b=WaEy+o54dBSzmlKivA2IuiMCd2bVGyN/8T4tkjvVvubQFLn97LTv0O/ySe1z/fH/u3 MdiddCBwUdTikQYAt7mfPDkzu9K9YRsM1a26eZ7vgwdrfxQv9Ly8One/CWbQuwXe2QWZ d0wpkTf3Mt09I3QJARIvSlOGK8APyyQJweufAlgEfoyZZIzX+H4XMEuIHKwZR17+8Z8/ bi2lE6JgFaPYNKf+KBzn/yQpi6Zom8tNmikCY+c6swEltzuP43VRUoGOCOcl8nf6vKEK 6DJYLSPYRQRB76ESJr8A6lis27zwZihNf3FK1kdonfvLWja9w4FSmZlr+nveVp58bUwL 7EIg== 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=2yXsWHQlHZFO6uOvXrEaZ/pS+PzZxIKV+dtwFcRxe6w=; b=SFTtSsol7mRr5oAIdviwXLJXhbh5+xAGlzNEGJaf6ZYdxS4uTIw1NEV51RqBwgbX+D 4UNzGiPcdLRPWQKH09J2x/RR0iO5B09N1J788mN9u5AtND35qBc0h6BglLsiCPxC10cE NxA1WcjReJU/Rik/N9cCFoISfpTK/FBa1K7UKz/Wkvar18f0XtAp0WRxOjPjRxUf8+Wl aZdE9ZNPHMBygTtN0g0ASmJyT4GRuZ3tf5JZI2234CqTMBYt5u9c4ezap2qrmi3dWNVB MgHXxfF7lvwl/9R5loYh1jfFyCGfgZS8bGfmyN+QS5haPrP5V2RvCBrXM8qiQ7Qil8Zr IK6g== X-Gm-Message-State: AOAM5322NoCQ4RCRlGbV6wK9AMk1DUXD73uIrYTm2eiml8Kr5ktVWnc8 jM0EpvLe6KSbvRFy42E3Y8tClQ== X-Received: by 2002:a17:90b:f86:: with SMTP id ft6mr7177214pjb.49.1589433307144; Wed, 13 May 2020 22:15:07 -0700 (PDT) Received: from builder.lan (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id w14sm1084582pgo.75.2020.05.13.22.15.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 22:15:06 -0700 (PDT) Date: Wed, 13 May 2020 22:13:36 -0700 From: Bjorn Andersson To: Mathieu Poirier Cc: ohad@wizery.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, loic.pallardy@st.com, arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 10/12] remoteproc: stm32: Introduce new parse fw ops for synchronisation Message-ID: <20200514051336.GA396285@builder.lan> References: <20200424202505.29562-1-mathieu.poirier@linaro.org> <20200424202505.29562-11-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200424202505.29562-11-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 24 Apr 13:25 PDT 2020, Mathieu Poirier wrote: > Introduce new parse firmware rproc_ops functions to be used when > synchonising with an MCU. > > Mainly based on the work published by Arnaud Pouliquen [1]. > > [1]. https://patchwork.kernel.org/project/linux-remoteproc/list/?series=239877 > > Signed-off-by: Mathieu Poirier > Reviewed-by: Loic Pallardy > --- > drivers/remoteproc/stm32_rproc.c | 51 +++++++++++++++++++++++++++++++- > 1 file changed, 50 insertions(+), 1 deletion(-) > > diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c > index 86d23c35d805..b8ae8aed5585 100644 > --- a/drivers/remoteproc/stm32_rproc.c > +++ b/drivers/remoteproc/stm32_rproc.c > @@ -215,7 +215,34 @@ static int stm32_rproc_elf_load_rsc_table(struct rproc *rproc, > return 0; > } > > -static int stm32_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw) > +static int stm32_rproc_sync_elf_load_rsc_table(struct rproc *rproc, > + const struct firmware *fw) > +{ > + struct resource_table *table = NULL; > + struct stm32_rproc *ddata = rproc->priv; > + > + if (ddata->rsc_va) { Does it really make sense to try to sync with a remote that doesn't have a resource table? > + table = (struct resource_table *)ddata->rsc_va; > + /* Assuming that the resource table fits in 1kB is fair */ > + rproc->cached_table = kmemdup(table, RSC_TBL_SIZE, GFP_KERNEL); It's unfortunate that we need to create a clone of the resource table that we found in ram, and then return the original memory when the core ask for the loaded table... I wonder if we somehow can avoid this in the core (i.e. skip overwriting table_ptr with the cached_table during stop) > + if (!rproc->cached_table) > + return -ENOMEM; > + > + rproc->table_ptr = rproc->cached_table; > + rproc->table_sz = RSC_TBL_SIZE; > + return 0; > + } > + > + rproc->cached_table = NULL; > + rproc->table_ptr = NULL; > + rproc->table_sz = 0; > + > + dev_warn(&rproc->dev, "no resource table found for this firmware\n"); > + return 0; > +} > + > +static int stm32_rproc_parse_memory_regions(struct rproc *rproc, > + const struct firmware *fw) > { > struct device *dev = rproc->dev.parent; > struct device_node *np = dev->of_node; > @@ -268,9 +295,30 @@ static int stm32_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw) > index++; > } > > + return 0; > +} > + > +static int stm32_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw) > +{ > + int ret = stm32_rproc_parse_memory_regions(rproc, fw); > + > + if (ret) > + return ret; > + > return stm32_rproc_elf_load_rsc_table(rproc, fw); > } > > +static int stm32_rproc_sync_parse_fw(struct rproc *rproc, > + const struct firmware *fw) Rather than having a function parse_fw that is passed no fw and return some state that was setup in probe, how about just do this during probe? Regards, Bjorn > +{ > + int ret = stm32_rproc_parse_memory_regions(rproc, fw); > + > + if (ret) > + return ret; > + > + return stm32_rproc_sync_elf_load_rsc_table(rproc, fw); > +} > + > static irqreturn_t stm32_rproc_wdg(int irq, void *data) > { > struct platform_device *pdev = data; > @@ -544,6 +592,7 @@ static struct rproc_ops st_rproc_ops = { > static __maybe_unused struct rproc_ops st_rproc_sync_ops = { > .start = stm32_rproc_sync_start, > .stop = stm32_rproc_stop, > + .parse_fw = stm32_rproc_sync_parse_fw, > }; > > static const struct of_device_id stm32_rproc_match[] = { > -- > 2.20.1 >