From patchwork Fri Apr 24 20:24:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11509255 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D84F13B2 for ; Fri, 24 Apr 2020 20:25:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4679F215A4 for ; Fri, 24 Apr 2020 20:25:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Xh2v5zI/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729375AbgDXUZJ (ORCPT ); Fri, 24 Apr 2020 16:25:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729330AbgDXUZI (ORCPT ); Fri, 24 Apr 2020 16:25:08 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3DAEC09B04A for ; Fri, 24 Apr 2020 13:25:08 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id x26so5148703pgc.10 for ; Fri, 24 Apr 2020 13:25:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=p2iTWW4nO5SL6In2uagzPcw9ivsY9NbY9ua5sw1Z8YY=; b=Xh2v5zI/BaXOCyJfw0q7LclyWcz17VcHHRAtRtzAcWv4MREiZiUr1J57Qh4LJD8BbF xVMrr3t30yanDFyJWCs1QAlhVVOPRQE1Ayy8l+zkS5hsvfZBhqo64LotHv+13vShH52s wv70aHtI8AK4YzwCCPu1bRvf4t3gI0y3Gg+gu0cfcOukzcvEoZvDZK3qlFeucEIz5Xoa p9UPO8xv7uLv96Kr6yUS5T/DFvplz/q3gISrhvhd2RZMX+4ccKZkW0qJpKovw4Wfxlaq OsHB6DdRPFDTnyMA+I0y/d1mIUtmQUeUj9fgAF7r7U7fJfvPQXzbE8lz7nSADY6zUtDu insA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p2iTWW4nO5SL6In2uagzPcw9ivsY9NbY9ua5sw1Z8YY=; b=LowMJz5mU5pUVQpJ3uEvDS0KUl1898deyNTliqfxhsYl/7/q4uvXh5L4uXs63Xy5mF 5EBxjCNGMU+g6BLnRrJDUZz4dgmDYNaYdgLw+YLI4D8gSH6Gsfd6hqZ0DeIiPAIkNJhM TAE8hvAkjW4zcL+MkYps3DZ/Gxnc1oDBeMWOYpVlwC4yd++q7sbbxkScRUp/0IeW9fwy tqSp5WGr2wphNs8qGqRNVdqYHFtrUWt4oS1aHPCx5OhxRDjXlj4olqbPQx6X0Djf0ief dazpuzdJYapHezZZFFf5W49YudFq3vtWWGpuc1EQVHaaNJjP+2nZABpy+GpIWd8ODYxR N5uA== X-Gm-Message-State: AGi0PuY2K0NDWKZo64RXE2jUIEAnheTfS6v1HNnfx+j/nztqhwVneqSX XOye8NRSbt3Z3Mj+wmk4P3VoUw== X-Google-Smtp-Source: APiQypJDYCDbHcowl3s80XHCz3TTRatT6q2ZhtMCaPAqLRA3rMW4yZfkqAlnuY7yy/eBSoya9iCBlw== X-Received: by 2002:a63:5a50:: with SMTP id k16mr9509922pgm.171.1587759908429; Fri, 24 Apr 2020 13:25:08 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c1sm6553245pfc.94.2020.04.24.13.25.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:25:08 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com Cc: 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: [PATCH v2 01/12] remoteproc: stm32: Decouple rproc from memory translation Date: Fri, 24 Apr 2020 14:24:54 -0600 Message-Id: <20200424202505.29562-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424202505.29562-1-mathieu.poirier@linaro.org> References: <20200424202505.29562-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Remove the remote processor from the process of parsing the memory ranges since there is no correlation between them. Signed-off-by: Mathieu Poirier Reviewed-by: Loic Pallardy Reviewed-by: Bjorn Andersson --- drivers/remoteproc/stm32_rproc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index 0f9d02ca4f5a..91fd59af0ffe 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -127,10 +127,10 @@ static int stm32_rproc_mem_release(struct rproc *rproc, return 0; } -static int stm32_rproc_of_memory_translations(struct rproc *rproc) +static int stm32_rproc_of_memory_translations(struct platform_device *pdev, + struct stm32_rproc *ddata) { - struct device *parent, *dev = rproc->dev.parent; - struct stm32_rproc *ddata = rproc->priv; + struct device *parent, *dev = &pdev->dev; struct device_node *np; struct stm32_rproc_mem *p_mems; struct stm32_rproc_mem_ranges *mem_range; @@ -606,7 +606,7 @@ static int stm32_rproc_parse_dt(struct platform_device *pdev) rproc->auto_boot = of_property_read_bool(np, "st,auto-boot"); - return stm32_rproc_of_memory_translations(rproc); + return stm32_rproc_of_memory_translations(pdev, ddata); } static int stm32_rproc_probe(struct platform_device *pdev) From patchwork Fri Apr 24 20:24:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11509229 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA32913B2 for ; Fri, 24 Apr 2020 20:25:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C35CC215A4 for ; Fri, 24 Apr 2020 20:25:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NOtPZXyi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729463AbgDXUZN (ORCPT ); Fri, 24 Apr 2020 16:25:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729431AbgDXUZL (ORCPT ); Fri, 24 Apr 2020 16:25:11 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16B36C09B048 for ; Fri, 24 Apr 2020 13:25:10 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id g6so5146643pgs.9 for ; Fri, 24 Apr 2020 13:25:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DgEz+wJcufUUG+teXaGNehTQCeHAZ7uJeYQ2NWLbdjg=; b=NOtPZXyitW1le/NvzqyO9UJvTrYAYkLFNPC5AwNo3bL0PVXogbJCl6/dVM5KWMZs36 AQJbWdPGjvUpntXrlRaguNzGZ8aLKe/4sxDm7VniYpZJ/cLHiFA8QO6i8gFG4nSzxnQn VyorVL5RRNnxMxGrG95VDkNeBgfsZ4hHEl+hKZdj489+2Nk+xbfIM71/U/QYVsh3ptkX cn7fU4XIsj8mcTPghu1b+GGHpri9b9ix4FSMu7pekIoOLzjpb4TYkNH3JLjh4scZhuIn nCz0IA5ZlFaiE5dKld6FqcyTd8y55n2ve0uyvwzkx5oQYzDyASHLvE5jsofE7Rh/NCv/ C5mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DgEz+wJcufUUG+teXaGNehTQCeHAZ7uJeYQ2NWLbdjg=; b=g257hbDHIIRSpgGSdl2CpvOsDfkZl1RXujtG1CTEWbG0ocPxdQ+znhsSrDpexsdhw0 Znnu+aQ4cSNaPFamc3WSnOwYNceMRkBmK4qHezDFVD9qJe1Jw0eMcfdnL3O6FiywWQYQ v12nR2cNnAw1y86HMXcbqXr3QIu5pbf2NXzjIzvgbMWcCEoSPj1lTLzDlSDF/ucDW7iX ljaRgnebTKfjC5WASYsIveqenqetOlWMWIIz4QMTa+53uc4DenPSbUKGFIffgm0Vh8up g1/EP5Jjx3pdS2K4NEGUCk6hD4EzGO7ebOv1vcvr2snAdFhhifv8hbM6ML59WtOMcpLp YhFw== X-Gm-Message-State: AGi0PuZi8BTebwI+Hpwp8DEOVylqVyjiWWXkCDeDAXEIPCE2K3yZ127h orTGe9KNjishY9hUFyBbTDIdOw== X-Google-Smtp-Source: APiQypJ1+f1MKeuUHrNcy2uquiy/RcZuGW6+iD8YyVNAH1nrYXeD8ZJsVVn/D5TeIgUXYDhFWGo24w== X-Received: by 2002:a63:40f:: with SMTP id 15mr10958456pge.57.1587759909609; Fri, 24 Apr 2020 13:25:09 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c1sm6553245pfc.94.2020.04.24.13.25.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:25:09 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com Cc: 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: [PATCH v2 02/12] remoteproc: stm32: Request IRQ with platform device Date: Fri, 24 Apr 2020 14:24:55 -0600 Message-Id: <20200424202505.29562-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424202505.29562-1-mathieu.poirier@linaro.org> References: <20200424202505.29562-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Request IRQ with platform device rather than remote proc in order to call stm32_rproc_parse_dt() before rproc_alloc(). That way we can know whether we need to synchronise with the MCU or not. Signed-off-by: Mathieu Poirier Reviewed-by: Loic Pallardy Reviewed-by: Bjorn Andersson --- drivers/remoteproc/stm32_rproc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index 91fd59af0ffe..1ac90adba9b1 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -261,7 +261,8 @@ static int stm32_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw) static irqreturn_t stm32_rproc_wdg(int irq, void *data) { - struct rproc *rproc = data; + struct platform_device *pdev = data; + struct rproc *rproc = platform_get_drvdata(pdev); rproc_report_crash(rproc, RPROC_WATCHDOG); @@ -553,7 +554,7 @@ static int stm32_rproc_parse_dt(struct platform_device *pdev) if (irq > 0) { err = devm_request_irq(dev, irq, stm32_rproc_wdg, 0, - dev_name(dev), rproc); + dev_name(dev), pdev); if (err) { dev_err(dev, "failed to request wdg irq\n"); return err; From patchwork Fri Apr 24 20:24:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11509233 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 22AA413B2 for ; Fri, 24 Apr 2020 20:25:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 09F06214AF for ; Fri, 24 Apr 2020 20:25:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="zhJLZdm4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729431AbgDXUZQ (ORCPT ); Fri, 24 Apr 2020 16:25:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729450AbgDXUZM (ORCPT ); Fri, 24 Apr 2020 16:25:12 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B467C09B04A for ; Fri, 24 Apr 2020 13:25:11 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id h12so2949216pjz.1 for ; Fri, 24 Apr 2020 13:25:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xbW7QKSbfjGivmoYcupmOInELZblEqFAL+Y8ISSJeX8=; b=zhJLZdm4i9zHW9J6fATQir/D5Ai12hcl4TYtW02jd8SpeKDblvWb5CS/Ycwq823GT1 cLy6r19Jj0fGjZ9X4GPUilij4LfV9mraQQx/ZkYxoYF+9TnPfcwFMCs3Ok0yJjDPMyZK /IUqfRbNNrCDFSjFouVBcaotokUvWFxq7ZRixSFaL14ce03oFMMOXh0Tfunkoyxhqxq/ pWpZufvPHGXIOvQXjWIj2X4KB5dlpQ2zn2/pRhzTYkUmnTtkeemdkS+/9COOjVIYV9gz kuDOF3IZunVa6102XlelZsHXZdFGhmZ5wD2ZjiLf6bUdabO103cCnAo3NYVP9EcuB7y6 jAZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xbW7QKSbfjGivmoYcupmOInELZblEqFAL+Y8ISSJeX8=; b=P1uQebtIrGi16gm7oMAVqS5WBzQ4/N6+4QhK6g5KtS819ui6cpCIQCbjmBnZY1mk3g dwkxbi1ikUDcJTe3pjSU9eTDVs3FjeqlLUNdx5w+7P59OlG+JKP7OOlHSdr3KlBTciR5 vegraf5KfsD4r7DKwa8dOqnsBB6qKGffHviM71a/9Cvc3HddO2IAyczcfC72C+I8se7C JxO6Aj+nvYtW/wRPqjl9fdsO1N8/P36lEiXp5XTNdRWx0MrW1xK+P6vBcSQjQozAOZ76 xa6zEytj2DzJsDy/ay9n1oMp3kurdIUzMkD/yFl20nf+WYAkattyWtbG7Yl+peRoXiiZ eimg== X-Gm-Message-State: AGi0PuZXlWDAqKVwOhmbqzcsp2BJRakKZ2GinRXKwZjVtLsVguJ5S3Fz DuE19ctU+XqZhMr3B8b9yKDuhw== X-Google-Smtp-Source: APiQypIIwwTi5PPDpuYGABCuyrPNQaN6gPmxklOQGbbWKG9LDZvIkkRNI7NFznTs3Om6Zw5dl3bZNA== X-Received: by 2002:a17:90a:a796:: with SMTP id f22mr2222697pjq.42.1587759910724; Fri, 24 Apr 2020 13:25:10 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c1sm6553245pfc.94.2020.04.24.13.25.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:25:10 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com Cc: 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: [PATCH v2 03/12] remoteproc: stm32: Decouple rproc from DT parsing Date: Fri, 24 Apr 2020 14:24:56 -0600 Message-Id: <20200424202505.29562-4-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424202505.29562-1-mathieu.poirier@linaro.org> References: <20200424202505.29562-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Remove the remote processor from the process of parsing the device tree since (1) there is no correlation between them and (2) to use the information that was gathered to make a decision on whether to synchronise with the M4 or not. Signed-off-by: Mathieu Poirier Reviewed-by: Bjorn Andersson --- drivers/remoteproc/stm32_rproc.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index 1ac90adba9b1..57a426ea620b 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -538,12 +538,11 @@ static int stm32_rproc_get_syscon(struct device_node *np, const char *prop, return err; } -static int stm32_rproc_parse_dt(struct platform_device *pdev) +static int stm32_rproc_parse_dt(struct platform_device *pdev, + struct stm32_rproc *ddata, bool *auto_boot) { struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; - struct rproc *rproc = platform_get_drvdata(pdev); - struct stm32_rproc *ddata = rproc->priv; struct stm32_syscon tz; unsigned int tzen; int err, irq; @@ -589,7 +588,7 @@ static int stm32_rproc_parse_dt(struct platform_device *pdev) err = regmap_read(tz.map, tz.reg, &tzen); if (err) { - dev_err(&rproc->dev, "failed to read tzen\n"); + dev_err(dev, "failed to read tzen\n"); return err; } ddata->secured_soc = tzen & tz.mask; @@ -605,7 +604,7 @@ static int stm32_rproc_parse_dt(struct platform_device *pdev) if (err) dev_info(dev, "failed to get pdds\n"); - rproc->auto_boot = of_property_read_bool(np, "st,auto-boot"); + *auto_boot = of_property_read_bool(np, "st,auto-boot"); return stm32_rproc_of_memory_translations(pdev, ddata); } @@ -616,6 +615,7 @@ static int stm32_rproc_probe(struct platform_device *pdev) struct stm32_rproc *ddata; struct device_node *np = dev->of_node; struct rproc *rproc; + bool auto_boot = false; int ret; ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32)); @@ -626,9 +626,16 @@ static int stm32_rproc_probe(struct platform_device *pdev) if (!rproc) return -ENOMEM; + ddata = rproc->priv; + rproc_coredump_set_elf_info(rproc, ELFCLASS32, EM_NONE); + + ret = stm32_rproc_parse_dt(pdev, ddata, &auto_boot); + if (ret) + goto free_rproc; + + rproc->auto_boot = auto_boot; rproc->has_iommu = false; - ddata = rproc->priv; ddata->workqueue = create_workqueue(dev_name(dev)); if (!ddata->workqueue) { dev_err(dev, "cannot create workqueue\n"); @@ -638,13 +645,9 @@ static int stm32_rproc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, rproc); - ret = stm32_rproc_parse_dt(pdev); - if (ret) - goto free_wkq; - ret = stm32_rproc_request_mbox(rproc); if (ret) - goto free_rproc; + goto free_wkq; ret = rproc_add(rproc); if (ret) From patchwork Fri Apr 24 20:24:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11509231 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DBB6E13B2 for ; Fri, 24 Apr 2020 20:25:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4366215A4 for ; Fri, 24 Apr 2020 20:25:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="nEIHT4o5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729464AbgDXUZP (ORCPT ); Fri, 24 Apr 2020 16:25:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729458AbgDXUZN (ORCPT ); Fri, 24 Apr 2020 16:25:13 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C93EC09B048 for ; Fri, 24 Apr 2020 13:25:12 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id n24so4142988plp.13 for ; Fri, 24 Apr 2020 13:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mrZHw3wDEqsWxtX6I3Qw+OHrqvqS6c3mqgfKBC8xSv8=; b=nEIHT4o5k+submU1rUBIRjPzreeeM7YSY4E7V1SEGu5YkKslbOpGjRxk2PVJ0e6xHd SXjmkQFR0s76Vs+SIhZbiqdwxsxXClpb114b/0W8uabUhIKFao3OKd1L4nuMX1znjiPe qQP7XgxiC4lZLDwECOiQbzUW0fEuqUgbDTn0rw28bGRcuJ7ngPnzqT2ZSGJLoxMn/PxZ fffRPF6DxDAFWbgEb6z50zzUw7NNjxuXSWuXCgJJacAYw3fPqEgIUoslVBSEZMjMwBxp BI43yLdV4LCUQzNbtcSRkmPWV1eRNty/VNcNXkODiU/gepJb91dnMBcF8aeufnmxkkCX lQGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mrZHw3wDEqsWxtX6I3Qw+OHrqvqS6c3mqgfKBC8xSv8=; b=nk4q6Wy2fGlN3tE4YrbgmGf47UnLHMku8hYjojiEZHDIZrPLLCiA3VMj8wnDAVEUN6 x8e5wVMhar4BkqHiS2uHXsgYRP0DdLGz9vTROdhzZEg5X7Em5EBre6Fq3s51imPeDU0I DyoXOvRSDtQQiXWLvZXL2RLw9Ir1HpiiQzxYNAgu00Yl/YrBehJaYTfBSQhU2e605DX5 pMzw7TDMCrqcoJQDQMliJp81gal5K9LYgqqJv3zXRFkflnY/xn+HWxdDs4oc/b53Bfye uwUVbxu+DvYGkgtJJPckRHbUbaszDTdVzAjvwsx9kckqmPNpJRugmQOLya8AIt08LzBO bgUg== X-Gm-Message-State: AGi0PuYjKDQKXZwKK7NhW0DBXEY9dnyIi5S7gK/yP3kjPZOln7X3Ixtb wa2eIXgxJSqiJi7Mgo5RnHijRQ== X-Google-Smtp-Source: APiQypIckGk/05A/UD8d3TxSQDoWu1T4/CMGlEehpQVQAKrC1wqh0IN3n+KIr7o6Kj7ucki41lXmAQ== X-Received: by 2002:a17:90a:d703:: with SMTP id y3mr8770619pju.75.1587759911901; Fri, 24 Apr 2020 13:25:11 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c1sm6553245pfc.94.2020.04.24.13.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:25:11 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com Cc: 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: [PATCH v2 04/12] remoteproc: stm32: Remove memory translation from DT parsing Date: Fri, 24 Apr 2020 14:24:57 -0600 Message-Id: <20200424202505.29562-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424202505.29562-1-mathieu.poirier@linaro.org> References: <20200424202505.29562-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Other than one has to be done after the other, there is no correlation between memory translation and DT parsing. As move function stm32_rproc_of_memory_translations() to stm32_rproc_probe() so that stm32_rproc_parse_dt() can be extended to look for synchronisation related binding in a clean way. Signed-off-by: Mathieu Poirier Reviewed-by: Loic Pallardy Reviewed-by: Bjorn Andersson --- drivers/remoteproc/stm32_rproc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index 57a426ea620b..658439d4b00a 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -606,7 +606,7 @@ static int stm32_rproc_parse_dt(struct platform_device *pdev, *auto_boot = of_property_read_bool(np, "st,auto-boot"); - return stm32_rproc_of_memory_translations(pdev, ddata); + return 0; } static int stm32_rproc_probe(struct platform_device *pdev) @@ -634,6 +634,10 @@ static int stm32_rproc_probe(struct platform_device *pdev) if (ret) goto free_rproc; + ret = stm32_rproc_of_memory_translations(pdev, ddata); + if (ret) + goto free_rproc; + rproc->auto_boot = auto_boot; rproc->has_iommu = false; ddata->workqueue = create_workqueue(dev_name(dev)); From patchwork Fri Apr 24 20:24:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11509253 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 367A11575 for ; Fri, 24 Apr 2020 20:25:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A3E8215A4 for ; Fri, 24 Apr 2020 20:25:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="bBYjk7oG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729468AbgDXUZP (ORCPT ); Fri, 24 Apr 2020 16:25:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729460AbgDXUZN (ORCPT ); Fri, 24 Apr 2020 16:25:13 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95EF6C09B04C for ; Fri, 24 Apr 2020 13:25:13 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id n24so4143012plp.13 for ; Fri, 24 Apr 2020 13:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8pkHvjPLwA96bIGz2NSSF7mXbbhD0VV71pWPGube4rE=; b=bBYjk7oGchLHLu2fhyb+5w8E3eMQmDXLajYwnSEoNKZRaYmkH0vi8FbFTDbUvVRsr8 1kQ/9bmhSE9nEd0h8GciZnigyFT77H7YY3aEtLzrHHMfMG/paQO+0fWET24ArhZqHg3c vqdwlGoPskGInUqnaGxRnd2S8rBW6Fmj3W7VsY8JPtJkKnY/T5nKIfI7iR74vB69yuvV LmlaLQ8SiaFPpCkXS+0veavIxJ+YUQQsis25rSSvRTKWi/soBPN2Bdaf8IYVJ0TNJuqM zs5BXVrG20QdavJxkRWBiRJ0w9dkN4jxu1vN6mAggY6wBIiWECeO1jFR6r+iMr8S6B1k HarA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8pkHvjPLwA96bIGz2NSSF7mXbbhD0VV71pWPGube4rE=; b=gVqOV3wctADM5H41YQgCkOsSNXm5Z4t9cHGc7fomczxu6hM/82G2nXF9dmgOnfBI8U 6TqBOvp9InZQS1nADQP8TpBM+yjJipEQE8BAFdk7gJQsCv8nj3FRP3rRkDP3TCFfvKsW AnZJnWIh/irDGgjYBSGlqVpKB3FmmX7hCbr+2FOktQd5HewqzvQAOGZUc72//M+lnWNl DqlqesNvKCxj0cEH85V8Vzok87sDG7hI4JT9RhkPFy+iyM0lGB0f7OwaDP1GjZtUB83E Jk7iSJ7iYwiVEVUatcRPZXY+aMjyCM8J49GMwaGsUiKbYKYckQH+OaRixrLHxqxhTo83 Biig== X-Gm-Message-State: AGi0PuZtziGLvGwPgCL/36VObVlXAjt6mBX43HBSrIJw5L1JI1/tytNL kCo9WNu/xYAZ0p61KyC3q33W4Q== X-Google-Smtp-Source: APiQypI45S+tU5qGacvuJcZRdZ1Rko8UnR0Z/uIU3/5Gk8Rmx2uzncC3GiqshF8IMa1UpBS4OILd+Q== X-Received: by 2002:a17:90a:101:: with SMTP id b1mr8385987pjb.154.1587759913129; Fri, 24 Apr 2020 13:25:13 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c1sm6553245pfc.94.2020.04.24.13.25.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:25:12 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com Cc: 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: [PATCH v2 05/12] remoteproc: stm32: Parse syscon that will manage M4 synchronisation Date: Fri, 24 Apr 2020 14:24:58 -0600 Message-Id: <20200424202505.29562-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424202505.29562-1-mathieu.poirier@linaro.org> References: <20200424202505.29562-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Get from the DT the syncon to probe the state of the remote processor and the location of the resource table. 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 Reviewed-by: Bjorn Andersson --- drivers/remoteproc/stm32_rproc.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index 658439d4b00a..a285f338bed8 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -70,6 +70,8 @@ struct stm32_rproc { struct reset_control *rst; struct stm32_syscon hold_boot; struct stm32_syscon pdds; + struct stm32_syscon m4_state; + struct stm32_syscon rsctbl; int wdg_irq; u32 nb_rmems; struct stm32_rproc_mem *rmems; @@ -606,6 +608,30 @@ static int stm32_rproc_parse_dt(struct platform_device *pdev, *auto_boot = of_property_read_bool(np, "st,auto-boot"); + /* + * See if we can check the M4 status, i.e if it was started + * from the boot loader or not. + */ + err = stm32_rproc_get_syscon(np, "st,syscfg-m4-state", + &ddata->m4_state); + if (err) { + /* remember this */ + ddata->m4_state.map = NULL; + /* no coprocessor state syscon (optional) */ + dev_warn(dev, "m4 state not supported\n"); + + /* no need to go further */ + return 0; + } + + /* See if we can get the resource table */ + err = stm32_rproc_get_syscon(np, "st,syscfg-rsc-tbl", + &ddata->rsctbl); + if (err) { + /* no rsc table syscon (optional) */ + dev_warn(dev, "rsc tbl syscon not supported\n"); + } + return 0; } From patchwork Fri Apr 24 20:24:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11509251 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F286813B2 for ; Fri, 24 Apr 2020 20:25:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB70A2168B for ; Fri, 24 Apr 2020 20:25:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="JeSlOzJK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729480AbgDXUZQ (ORCPT ); Fri, 24 Apr 2020 16:25:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729431AbgDXUZP (ORCPT ); Fri, 24 Apr 2020 16:25:15 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1174C09B04E for ; Fri, 24 Apr 2020 13:25:14 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id x2so1634043pfx.7 for ; Fri, 24 Apr 2020 13:25:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zvzC6gFPrPdzFl23lN2WuH5nBg+m021+fv4zS7XCe30=; b=JeSlOzJKUAlEQUUjc556FCSgmbLt7CRMMtZBI1ImTGOTQhqVQ47j1XgWFoD7gm7l3G G2OyjQRAXMotr3RA+1MdoK9ggCmO/iFqzu9YHxQkHfOhYqo39Rp0RCPnIK8k8nrt/pb/ tF7s+f7d591EiuvECYRAcbhuxwo3yLUpfrYnofrrg7WWWeZ8WjLLRuO2i3xz4j8B1jpX ENW4ZcVeUz+SrLcKK49KaAZ9/fUlBMlMTuOMcsFFrcDL/ZKi5HXmg1P8Yi6jcGAgf7Or ZUHmtP4ISsKMs/b84P2+NxEV7oiNwQ/OtOIETDBID/tue4ztejeiC3HPuVEvEJj9sgwx Ghjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zvzC6gFPrPdzFl23lN2WuH5nBg+m021+fv4zS7XCe30=; b=LxKqfcM8sK+F5XBea5BCR2ioCilIwUc5AzsBoDW0aB+E4TRWYQjasSTgcfT69lVTbW ZIHZSTmRi5qPfOCIYXMZTVA4JfT4+tQ1fpyXUxaaSunJhAhpAfPxiroK0Bk0Evgms6rF P7CPyf6JShMABdZt7bHxI1N7RUk8HKsRfLR9/pvZGcZCsLfX9xWBJYjhP32FoAYqq90C 4TRenrQH/M+51CDwrgcjU1oUzPY26Z7jNDGUST14F3voUEhZ/pxdGCXX+W7UQDb9JWdr KqrdvZUUJfNHTAuCpxD6ZEtf92yNdhSNGTbkZ/Fczyp/n14aZiOtf1HD9VMzVvF6J4pu 3mrQ== X-Gm-Message-State: AGi0PuY+dRE8FrKUM6cEpdPE5mU3b0OrU5KKKglViwAZoyyzRCi4pGA0 4pl3rOIANU9SwJUxyC9IYZmUeg== X-Google-Smtp-Source: APiQypL/FJQ9p9P0ruo1sUrpqRRDWLFXA2JvJ7Rs260rkeJu2EjUNFy/ALDcgjJW5wPGudCeO89+Yg== X-Received: by 2002:a63:1e1f:: with SMTP id e31mr3966444pge.393.1587759914468; Fri, 24 Apr 2020 13:25:14 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c1sm6553245pfc.94.2020.04.24.13.25.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:25:13 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com Cc: 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: [PATCH v2 06/12] remoteproc: stm32: Get coprocessor state Date: Fri, 24 Apr 2020 14:24:59 -0600 Message-Id: <20200424202505.29562-7-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424202505.29562-1-mathieu.poirier@linaro.org> References: <20200424202505.29562-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Introduce the required mechanic to get the state of the M4 when the remoteproc core is initialising. 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 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index a285f338bed8..89fbd2ffac93 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -38,6 +38,15 @@ #define STM32_MBX_VQ1_ID 1 #define STM32_MBX_SHUTDOWN "shutdown" +#define RSC_TBL_SIZE (1024) + +#define M4_STATE_OFF 0 +#define M4_STATE_INI 1 +#define M4_STATE_CRUN 2 +#define M4_STATE_CSTOP 3 +#define M4_STATE_STANDBY 4 +#define M4_STATE_CRASH 5 + struct stm32_syscon { struct regmap *map; u32 reg; @@ -635,12 +644,23 @@ static int stm32_rproc_parse_dt(struct platform_device *pdev, return 0; } +static int stm32_rproc_get_m4_status(struct stm32_rproc *ddata, + unsigned int *state) +{ + /* See stm32_rproc_parse_dt() */ + if (!ddata->m4_state.map) + return -EINVAL; + + return regmap_read(ddata->m4_state.map, ddata->m4_state.reg, state); +} + static int stm32_rproc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct stm32_rproc *ddata; struct device_node *np = dev->of_node; struct rproc *rproc; + unsigned int state; bool auto_boot = false; int ret; @@ -664,6 +684,15 @@ static int stm32_rproc_probe(struct platform_device *pdev) if (ret) goto free_rproc; + ret = stm32_rproc_get_m4_status(ddata, &state); + if (ret) { + /* + * We couldn't get the coprocessor's state, assume + * it is not running. + */ + state = M4_STATE_OFF; + } + rproc->auto_boot = auto_boot; rproc->has_iommu = false; ddata->workqueue = create_workqueue(dev_name(dev)); From patchwork Fri Apr 24 20:25:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11509249 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CDAA913B2 for ; Fri, 24 Apr 2020 20:25:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B59932168B for ; Fri, 24 Apr 2020 20:25:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="xQjAWYd1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729487AbgDXUZR (ORCPT ); Fri, 24 Apr 2020 16:25:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729481AbgDXUZQ (ORCPT ); Fri, 24 Apr 2020 16:25:16 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D942C09B04A for ; Fri, 24 Apr 2020 13:25:16 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id o185so5166701pgo.3 for ; Fri, 24 Apr 2020 13:25:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b/9JpqDGNjADvobyqVov6ERIhhQq5sF+ThZw9VRS9LA=; b=xQjAWYd18hiyO5V0QYqMaeY/LOdTA4JZkq26bNfHGDnNHufoeImakGwcRqMqD/UJ/i sdrA3YIk6Lfs+FNXCOoz3StXLJ4psRo+5Yh358CRePGLe7idf/RriCP5/ghspMrKrmeo T5vJhITHRiJoRuvvzHAzt6EOde+AQhFYK+U4Gb2HTyDwNV5NQdy9Iurcg1StWCblJt83 j8tWeyYw5FFZldBDlWNPMYpfW6rG+zP/mRhLcAAt9klkpEOfYlLcGkNTDK9ol2He5pM2 YMjoSOhkewz8RIFgQvMkUI9NmYLBU3RlG3KpqUH16yeJ0CnVEHCBEd4qinSRilbr0opl JxZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=b/9JpqDGNjADvobyqVov6ERIhhQq5sF+ThZw9VRS9LA=; b=bkj/LIVrbc56E13lIr1LnHrVBFGTj17ZwFciI7OM5YGjzInMuoJS9+emghtFtxejcL BbakHF2kpZ+uXuTXoRabd+2OlH/5ly41DRCgQawSwxyqT56Q3LSghk20+yX3dszycMNA 1VNr5lVyD99N1ZEVOOGme24KY/uPMsdceDpyzvp6ypl6TAypd4j9ft/rVOFS6Sjx43R5 CkV2UtLxiSfGVrNRJwMMTl/PrdswJA5WyOWNjw2zgND38dJloSRkp2r08+f3CTmAm/uj fwyv+fLERhDV99KJI5pdrYe8ikxY0j2wm+n7PZZbeePAFGNbS43SSFxfvvCXwVDwCmjB jEVA== X-Gm-Message-State: AGi0PubpVvPuQ1lyT1a9Vmgw3XeRGWdeF29dSq0V5Dq5LmQs4ckC1kjS TaxLcgOt5eJiNYvs0QPY9B3Dpw== X-Google-Smtp-Source: APiQypKvE8p2FywM7VzGssyzNtyoJ0xFr1VQpH55vlxHbQ3oxi6AN5pG5j6hhe2QldpyI8sgdKvZxQ== X-Received: by 2002:a63:b954:: with SMTP id v20mr10481894pgo.100.1587759915628; Fri, 24 Apr 2020 13:25:15 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c1sm6553245pfc.94.2020.04.24.13.25.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:25:15 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com Cc: 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: [PATCH v2 07/12] remoteproc: stm32: Get loaded resource table for synchronisation Date: Fri, 24 Apr 2020 14:25:00 -0600 Message-Id: <20200424202505.29562-8-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424202505.29562-1-mathieu.poirier@linaro.org> References: <20200424202505.29562-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Get the resource table location when synchronising with the M4 so that the remoteproc and rpmsg subsystem can be initialised properly. 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 | 66 ++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index 89fbd2ffac93..8ba69e903851 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -87,6 +87,7 @@ struct stm32_rproc { struct stm32_mbox mb[MBOX_NB_MBX]; struct workqueue_struct *workqueue; bool secured_soc; + void __iomem *rsc_va; }; static int stm32_rproc_pa_to_da(struct rproc *rproc, phys_addr_t pa, u64 *da) @@ -654,6 +655,65 @@ static int stm32_rproc_get_m4_status(struct stm32_rproc *ddata, return regmap_read(ddata->m4_state.map, ddata->m4_state.reg, state); } +static int stm32_rproc_da_to_pa(struct platform_device *pdev, + struct stm32_rproc *ddata, + u64 da, phys_addr_t *pa) +{ + struct device *dev = &pdev->dev; + struct stm32_rproc_mem *p_mem; + unsigned int i; + + for (i = 0; i < ddata->nb_rmems; i++) { + p_mem = &ddata->rmems[i]; + + if (da < p_mem->dev_addr || + da >= p_mem->dev_addr + p_mem->size) + continue; + + *pa = da - p_mem->dev_addr + p_mem->bus_addr; + dev_dbg(dev, "da %llx to pa %#x\n", da, *pa); + + return 0; + } + + dev_err(dev, "can't translate da %llx\n", da); + + return -EINVAL; +} + +static int stm32_rproc_get_loaded_rsc_table(struct platform_device *pdev, + struct stm32_rproc *ddata) +{ + struct device *dev = &pdev->dev; + phys_addr_t rsc_pa; + u32 rsc_da; + int err; + + err = regmap_read(ddata->rsctbl.map, ddata->rsctbl.reg, &rsc_da); + if (err) { + dev_err(dev, "failed to read rsc tbl addr\n"); + return err; + } + + if (!rsc_da) + /* no rsc table */ + return 0; + + err = stm32_rproc_da_to_pa(pdev, ddata, rsc_da, &rsc_pa); + if (err) + return err; + + ddata->rsc_va = devm_ioremap_wc(dev, rsc_pa, RSC_TBL_SIZE); + if (IS_ERR_OR_NULL(ddata->rsc_va)) { + dev_err(dev, "Unable to map memory region: %pa+%zx\n", + &rsc_pa, RSC_TBL_SIZE); + ddata->rsc_va = NULL; + return -ENOMEM; + } + + return 0; +} + static int stm32_rproc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -693,6 +753,12 @@ static int stm32_rproc_probe(struct platform_device *pdev) state = M4_STATE_OFF; } + if (state == M4_STATE_CRUN) { + ret = stm32_rproc_get_loaded_rsc_table(pdev, ddata); + if (ret) + goto free_rproc; + } + rproc->auto_boot = auto_boot; rproc->has_iommu = false; ddata->workqueue = create_workqueue(dev_name(dev)); From patchwork Fri Apr 24 20:25:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11509235 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6542214DD for ; Fri, 24 Apr 2020 20:25:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D45D2166E for ; Fri, 24 Apr 2020 20:25:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Gp0+Zj2A" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729522AbgDXUZT (ORCPT ); Fri, 24 Apr 2020 16:25:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729513AbgDXUZS (ORCPT ); Fri, 24 Apr 2020 16:25:18 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4478AC09B049 for ; Fri, 24 Apr 2020 13:25:17 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id e6so4335103pjt.4 for ; Fri, 24 Apr 2020 13:25:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KQbiUnUIr9QFPfrMWtrls9xYCut1DTLsNUPTpZeLJzM=; b=Gp0+Zj2AsVqjmrkROdpibc9WVlvp7tcdcOdZdQHBsR3UgKeec463gD/gEO3BwUfxId 4qs80FR5WSpzNR1SqjnslyncQsgieuO8FYOSgr5hwqOfCi41IVUjNNC5q5Zzr6j2I3yi KJjHDvIlGO48gwfAIbEwO3n5i2jge5R4cWWMaHUprhq/I4laBl8nmafuy317N+fyZmX8 gy/EOSGWad5Rt3pnr1KQ/DTkoocO+75wrBOQXlXeVt7zb1LIqqCqbavhbNh3j+XucUBk YEIf7REW3jwi9Nf2//7v64N+cSG95iVoOExMctUIfyLuDu0h5IOb/KzEZb2XNtq0cgZZ 9ypg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KQbiUnUIr9QFPfrMWtrls9xYCut1DTLsNUPTpZeLJzM=; b=WzJh90KCGlAdiD66pZbPOIrueIWJMrAXAY3RYIC8HajW/hnsusU/NmXFxZUCtEQjgl O45XS/VpyO0+BzreGSlzC7/PX0NKqRnT/E6xeVBecS2VhyFvwoDIiPh1qrhgLxFEQ/u/ XZxplUTpK9WwrZVW4f2+hur/bcCNlde5JUA5xHYcy3GNpojuyOhRJSS3zC4fC9l4s3HX v87HPSnGq1sRr31KbhUCbBgY5ng9GmrXG0jXoiDPWVgyZZGVQm0TyBk39Fyjuao67HrG eVlGuSkXFKDqnTjV8hSGAI9c7Y11APHGh7hxevoL7TvJv6NFKJz455EJ+sr1vM+u73kU iwXA== X-Gm-Message-State: AGi0PuaNvbT1k6hmItDl/N1zONdo77YiT8hzbBQauEJAlIAxWvIbchkJ yaF3LOu/pVfVmdQoSUz4xvjWkA== X-Google-Smtp-Source: APiQypIv6YWdkGqDXxYu9zKGxgTIDNuyx5qK9TgKQ6Q3MhTchnZhEiINgsaF5cc/+xunWfpXSGwU1A== X-Received: by 2002:a17:90a:1a46:: with SMTP id 6mr8190985pjl.111.1587759916801; Fri, 24 Apr 2020 13:25:16 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c1sm6553245pfc.94.2020.04.24.13.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:25:16 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com Cc: 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: [PATCH v2 08/12] remoteproc: stm32: Introduce new start ops for synchronisation Date: Fri, 24 Apr 2020 14:25:01 -0600 Message-Id: <20200424202505.29562-9-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424202505.29562-1-mathieu.poirier@linaro.org> References: <20200424202505.29562-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Introduce new start 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: Arnaud Pouliquen --- drivers/remoteproc/stm32_rproc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index 8ba69e903851..404f17a97095 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -449,6 +449,13 @@ static int stm32_rproc_start(struct rproc *rproc) return stm32_rproc_set_hold_boot(rproc, true); } +static int stm32_rproc_sync_start(struct rproc *rproc) +{ + stm32_rproc_add_coredump_trace(rproc); + + return stm32_rproc_set_hold_boot(rproc, true); +} + static int stm32_rproc_stop(struct rproc *rproc) { struct stm32_rproc *ddata = rproc->priv; @@ -522,6 +529,10 @@ static struct rproc_ops st_rproc_ops = { .get_boot_addr = rproc_elf_get_boot_addr, }; +static __maybe_unused struct rproc_ops st_rproc_sync_ops = { + .start = stm32_rproc_sync_start, +}; + static const struct of_device_id stm32_rproc_match[] = { { .compatible = "st,stm32mp1-m4" }, {}, From patchwork Fri Apr 24 20:25:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11509247 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E8A914DD for ; Fri, 24 Apr 2020 20:25:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 858F3215A4 for ; Fri, 24 Apr 2020 20:25:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iN9Rmvvn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729525AbgDXUZj (ORCPT ); Fri, 24 Apr 2020 16:25:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729512AbgDXUZS (ORCPT ); Fri, 24 Apr 2020 16:25:18 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79540C09B04A for ; Fri, 24 Apr 2020 13:25:18 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id t40so4337541pjb.3 for ; Fri, 24 Apr 2020 13:25:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=exYZpvChsSlo7lAJbJWuh/pu5cSD6aiCv7Lp3iIYni8=; b=iN9Rmvvnqh92eC4TVhJvXp9LrfV9PydbkGYoRVJklbytnIqLGmkGSkG1lI2zxCRgRF 5M53EDEEzllMIdgoLfs1/dVl8b3pTJfORPir4EQsdGV5FGTSVHYNP6wQ3KcdmPUgPpDH YJvNHFBk/YBKfcyFuLNIun9KsZvifIbnoX14xisIiPXfuVfLDlPu6+PjVy9eWJ0Pun4A 1SmSDGzlNT2UlssN6jOGylFsnYwa8kVifpktDTIW+H/dVnq36Vp+0AuTokOk9ojoWvGi cLVSm+hhmnpYe3VgiFbrN7OgP+GhT8Vp3GSAE0Q0lX+SM/8VROPHvcG/UzE1Le1Sr0m6 TPjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=exYZpvChsSlo7lAJbJWuh/pu5cSD6aiCv7Lp3iIYni8=; b=FCEYMFaktMwJYtIzXspV8zsY4nWuekM3LmvlP5LB/XwMAzzG/hf2w0AAwypmym4ZUK MpLYZQXF48W0DkktnP0VCXwd8+XjyJIh2bt6hjC1VdxqzgpK5hw+UwiKCTYc+fwY3cIB Qmn72soN2vyyWcu11t121DLqmBS2vR1eNtmRr7cUavyCE/YFDJfZusv34f3uF2vn/GBf LUOk9EMlMO4fMQhx6aUPQg1BMnxxbltlVrLxgx9CE/f91lUhdJqU0xvE1G+knhYVobGY AfsKnaiXyCLi33d4cZ8LtqrbUJylenyB1zXyK9xq62jhUCHDMinpEuPM8xFY8eOduq84 kv2A== X-Gm-Message-State: AGi0PuagZ/0O4WZBDXCRa646JBwSdkwIjOL1AJb+GMLyK6A3iCOHgd/c 2evfee2IsQzav4AzMx48o2eB3A== X-Google-Smtp-Source: APiQypL5AzMQXq3gOoXlH0PVqgL7PRKhGgSOEjwcpARkI3Rx98coNs2TcHAu6I+2Ek+Xn1y8hG4T1g== X-Received: by 2002:a17:90a:1743:: with SMTP id 3mr8488308pjm.106.1587759918032; Fri, 24 Apr 2020 13:25:18 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c1sm6553245pfc.94.2020.04.24.13.25.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:25:17 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com Cc: 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: [PATCH v2 09/12] remoteproc: stm32: Update M4 state in stm32_rproc_stop() Date: Fri, 24 Apr 2020 14:25:02 -0600 Message-Id: <20200424202505.29562-10-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424202505.29562-1-mathieu.poirier@linaro.org> References: <20200424202505.29562-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Update the M4 co-processor state in function stm32_rproc_stop() so that it can be used in synchronisation scenarios. 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: Arnaud Pouliquen --- drivers/remoteproc/stm32_rproc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index 404f17a97095..86d23c35d805 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -493,6 +493,18 @@ static int stm32_rproc_stop(struct rproc *rproc) } } + /* update coprocessor state to OFF if available */ + if (ddata->m4_state.map) { + err = regmap_update_bits(ddata->m4_state.map, + ddata->m4_state.reg, + ddata->m4_state.mask, + M4_STATE_OFF); + if (err) { + dev_err(&rproc->dev, "failed to set copro state\n"); + return err; + } + } + return 0; } @@ -531,6 +543,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, }; static const struct of_device_id stm32_rproc_match[] = { From patchwork Fri Apr 24 20:25:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11509241 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA70514DD for ; Fri, 24 Apr 2020 20:25:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C2BB32173E for ; Fri, 24 Apr 2020 20:25:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="KlbzOYZF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729588AbgDXUZa (ORCPT ); Fri, 24 Apr 2020 16:25:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729536AbgDXUZU (ORCPT ); Fri, 24 Apr 2020 16:25:20 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ECB4C09B049 for ; Fri, 24 Apr 2020 13:25:19 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id q18so5140499pgm.11 for ; Fri, 24 Apr 2020 13:25:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fqZ+BJyxifVcrtE3LQT7/v41/moffbFoiyW2JFMtzmM=; b=KlbzOYZF4XuoC0+4q2eozDIEdNHu5c84JN2Jf1E9xX5EKrw3Hnkon8pPEloKgp49+B yt4yJ04XEeH1shSmHH+bhF1X3jfdN6XbStt0azopWfmuHfy4E/gC2oIuOvSSFmYTV93O 324Qicy4CJQfu8A4yNSGQc9dbaCQL+9hbsiYPPB14/HrEBMhNau/1cn+E+2JAakqiOpT 4SU/HfyRKARtZuxSB499DIXysvhRzB1QI6EpaLSGjayRHkbn37cYV/35aYaQSm1nNBFj sCiNGzO0wbcSkC5BJgpqu1fKqXFSjHTiA+L/L1vlUWzHZek6UgAFb6k2ODMxwG+NZzy9 6R5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fqZ+BJyxifVcrtE3LQT7/v41/moffbFoiyW2JFMtzmM=; b=X6aJzabXnT6u+m2UlCAFl5iqvYtj6HGF3d4N/iEGEEvkOqNY1oANUFv1TKcUVdc6ZX fBRZEo1mL0aaXa/Lg1OQLI1dcU7tFFwjpb+ylq6MghrBmGMnzFjmSaP8ktOw5sL6nmL+ Qam2wzMF9aTHB/tTAwPBufoAHp1D14q99MtaIL8aTaS3mVQGaxzK5gRH+ct35iNeW/pz Cty79rAtDHxH+J77BdRg2CgYFDg8gpHj/RMaM78TgoFfaioJ40QveLWvyZrk3wHUHXki UvxGAD+xTJ+m9XNUvtNqFaTd9o6VwBxjiG4IShux1/t3P2KdwQ+r6PnlE/u0P4kAsBK0 Cw+w== X-Gm-Message-State: AGi0PuYwZS5IWhpwCAp4xvtQATElh0nUgNv1xx1v493QT8uIpdeQYgPo nyE11Sx3GTxJeAUsgVNG0EYYGg== X-Google-Smtp-Source: APiQypJ/18O8EzmmOyV9pza2XTZukTkmU7hCPlE0hRPLSf//lsxriH6VEC17D+y2boj6LQTLZh8jOw== X-Received: by 2002:a65:6250:: with SMTP id q16mr11309222pgv.9.1587759919091; Fri, 24 Apr 2020 13:25:19 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c1sm6553245pfc.94.2020.04.24.13.25.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:25:18 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com Cc: 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: [PATCH v2 10/12] remoteproc: stm32: Introduce new parse fw ops for synchronisation Date: Fri, 24 Apr 2020 14:25:03 -0600 Message-Id: <20200424202505.29562-11-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424202505.29562-1-mathieu.poirier@linaro.org> References: <20200424202505.29562-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org 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) { + 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); + 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) +{ + 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[] = { From patchwork Fri Apr 24 20:25:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11509243 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D65F1575 for ; Fri, 24 Apr 2020 20:25:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 565E22176D for ; Fri, 24 Apr 2020 20:25:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OBm+YaG5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729536AbgDXUZa (ORCPT ); Fri, 24 Apr 2020 16:25:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729531AbgDXUZU (ORCPT ); Fri, 24 Apr 2020 16:25:20 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F694C09B048 for ; Fri, 24 Apr 2020 13:25:20 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id a31so2454899pje.1 for ; Fri, 24 Apr 2020 13:25:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zs8zqxSLmCFU6lZYzSjBYa2nEV+/JbKTSnr0oNB1H9M=; b=OBm+YaG5e7Hf79gRnIDBZNaKsh8b7ZMTm3+BICnzVBFchzziucaX2vdz1Hv2U4wWWp EcT/3bMOuXUFNAWq5WKuengPx+5y2fcGvHKhTvEZzrMcAp9+kNgx8ULtRQaj1VsNvOpQ qj2Yrg8Vn3xU5CSUU+C/M0KviqQ0YKH++EEcCiL3V5CUSo5gfl6Zuwp+cdPpX1BkMt1+ BCTEf18ioZntEnAvgClbjfDXsHKPgGNrXVRhyrUUGe3RotINDtjIgWezMoHtIKkprwEm 52k/IRykm18cYzv6tyXkxGpk0acftWHy4zSTQ2/lKYv3MiF+lIksGYegWWlFFILFYXqk pNEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Zs8zqxSLmCFU6lZYzSjBYa2nEV+/JbKTSnr0oNB1H9M=; b=Gen048UlIOjYhnkEIJPEUGBX3jhvXkhEd0LiBaJNLr9voLQC8pZ4a3XQ2dzfVizWfz QVXLY4DhePWOGxPYK7Xlx5+7MFrJ0rwqSQF80P5G9+V51qe65EFZfKYGhffpPa7oprvh aFYo3+FEV+KYRff6+NfaRv5vODYAy2GCx+4Z8GxnB8YQY9iDkIB7p/d1ECy59RLj23dT k3jXVuUaOc6cq60knXRmNNU2yOIcl4c5AM3bQ1kupaxseacAuJLVF7rcBcMRz38uUu+0 KGDtuOLl3Nota2ScpEDZJ/HefzOXVzIMQhADHY83mSHYNtDP517T5JRVbl/hjzBMmsqX nMSQ== X-Gm-Message-State: AGi0PuYXibjO4VtD2Sb6JoESWxuBY3EpeTIV2pGjREpbYWq2N572SymF FnRvOFXqF+5v2cH6VFNwVPh5hg== X-Google-Smtp-Source: APiQypJU8nTXTveTpL95Js1RKNrdGMPxwTFKK6UCZMwcjKNmAhFJgR4kBO2M3JrCnfwpW1TsGUDwwg== X-Received: by 2002:a17:90a:82:: with SMTP id a2mr8752961pja.47.1587759920159; Fri, 24 Apr 2020 13:25:20 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c1sm6553245pfc.94.2020.04.24.13.25.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:25:19 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com Cc: 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: [PATCH v2 11/12] remoteproc: stm32: Introduce new loaded rsc ops for synchronisation Date: Fri, 24 Apr 2020 14:25:04 -0600 Message-Id: <20200424202505.29562-12-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424202505.29562-1-mathieu.poirier@linaro.org> References: <20200424202505.29562-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Introduce new elf find loaded resource table 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 Reviewed-by: Bjorn Andersson --- drivers/remoteproc/stm32_rproc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index b8ae8aed5585..dcae6103e3df 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -319,6 +319,15 @@ static int stm32_rproc_sync_parse_fw(struct rproc *rproc, return stm32_rproc_sync_elf_load_rsc_table(rproc, fw); } +static struct resource_table * +stm32_rproc_sync_elf_find_loaded_rsc_table(struct rproc *rproc, + const struct firmware *fw) +{ + struct stm32_rproc *ddata = rproc->priv; + + return (struct resource_table *)ddata->rsc_va; +} + static irqreturn_t stm32_rproc_wdg(int irq, void *data) { struct platform_device *pdev = data; @@ -593,6 +602,7 @@ 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, + .find_loaded_rsc_table = stm32_rproc_sync_elf_find_loaded_rsc_table, }; static const struct of_device_id stm32_rproc_match[] = { From patchwork Fri Apr 24 20:25:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11509239 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 91AA713B2 for ; Fri, 24 Apr 2020 20:25:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75C102173E for ; Fri, 24 Apr 2020 20:25:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="IYmAPTxM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729557AbgDXUZW (ORCPT ); Fri, 24 Apr 2020 16:25:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729552AbgDXUZV (ORCPT ); Fri, 24 Apr 2020 16:25:21 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9B4BC09B049 for ; Fri, 24 Apr 2020 13:25:21 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id j7so5141178pgj.13 for ; Fri, 24 Apr 2020 13:25:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kG2iXiDOAlrBuv2wqeB6r8YKH3F8C14k21yMdoM6KR8=; b=IYmAPTxMHxW01D1OdVg6js0cI3JraeOKhnKiDvx7CwBKWa6HBJ5zMo2JXOk06e/Sk6 z+nio/13fncpMdAUX7spt/kaAdFvjjhFr27I5IGkEnpyq5itIbJ0DZadSC1kV0kfU/VG KIXb/wx4Kwy0Mv7cMRsloIra5uyuvT9FtN9fxkamelqavtEsRm76jY+Wvkc4oyMTAquw rC3J1uAtJ2ew8ID6OijjWwnBJ8HaNk8LwVmSMfuZ5btvxQLoMOiTZl0oQtLYU4f9iD3j WRpWAniZVy7XJpx+Zexi4t9p9A9yjEGUR2K8OpOexgNyGxG/SY7LUmS5ytP8iAuFCN7J yHfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kG2iXiDOAlrBuv2wqeB6r8YKH3F8C14k21yMdoM6KR8=; b=hRktw735ugMH93FWMDEmPE0obfiNCkgPiSt/9d0d5OkoZJ49/RH2FzGGURfg5dVmnU LBB6l6XHy/JKD2bk8N0HPL3iymHTcK2lR0D9BGKGfvjsiNLzu7QraWkbn3sC1TlXh1uu SmIeVRZ2733vA2vLc712EJKylnqY4fp1nqSAGeGz8SrRkUeh3L/HV4E4KgvUWf6uE+aO 5on4ZT8mPJ80hE4A82NpSuB/+X8YmV3oC0JVhsYpBKfBsw8VfoF+RpSR9X4WUs2k90k5 iw5JC74jhfo+otgMheDVtkrdoRx9E3oXITW/FOq9kJBdHFbaKRIGqNF3gVhKJMjlhett ogkg== X-Gm-Message-State: AGi0PuZHhPMJkvT4WUA7JWCBSofU3oSOQLBoYPmVQaY/IojEsccJ4zVr DrQiBiqmpS1GxKmNpwtEgz0+6a4196w= X-Google-Smtp-Source: APiQypKviZ6PkeE83136I1kJAdKrTrljVnv7Q8b8j/LsmS+zqipjOpZk/taRmaQdP/cWXjJXLqB8TA== X-Received: by 2002:a63:4a59:: with SMTP id j25mr10666444pgl.336.1587759921334; Fri, 24 Apr 2020 13:25:21 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c1sm6553245pfc.94.2020.04.24.13.25.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:25:20 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com Cc: 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: [PATCH v2 12/12] remoteproc: stm32: Set synchronisation state machine if needed Date: Fri, 24 Apr 2020 14:25:05 -0600 Message-Id: <20200424202505.29562-13-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424202505.29562-1-mathieu.poirier@linaro.org> References: <20200424202505.29562-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Set the flags and operations to use if the M4 has been started by another entity than the remoteproc core. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/stm32_rproc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index dcae6103e3df..02dad3f51c7a 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -598,13 +598,20 @@ static struct rproc_ops st_rproc_ops = { .get_boot_addr = rproc_elf_get_boot_addr, }; -static __maybe_unused struct rproc_ops st_rproc_sync_ops = { +static struct rproc_ops st_rproc_sync_ops = { .start = stm32_rproc_sync_start, .stop = stm32_rproc_stop, + .kick = stm32_rproc_kick, .parse_fw = stm32_rproc_sync_parse_fw, .find_loaded_rsc_table = stm32_rproc_sync_elf_find_loaded_rsc_table, }; +static struct rproc_sync_flags st_sync_flags = { + .on_init = true, /* sync with MCU when the kernel boots */ + .after_stop = false, /* don't resync with MCU if stopped from sysfs */ + .after_crash = false, /* don't resync with MCU after a crash */ +}; + static const struct of_device_id stm32_rproc_match[] = { { .compatible = "st,stm32mp1-m4" }, {}, @@ -803,6 +810,7 @@ static int stm32_rproc_probe(struct platform_device *pdev) struct stm32_rproc *ddata; struct device_node *np = dev->of_node; struct rproc *rproc; + struct rproc_sync_flags sync_flags = {0}; unsigned int state; bool auto_boot = false; int ret; @@ -837,11 +845,17 @@ static int stm32_rproc_probe(struct platform_device *pdev) } if (state == M4_STATE_CRUN) { + auto_boot = true; + sync_flags = st_sync_flags; ret = stm32_rproc_get_loaded_rsc_table(pdev, ddata); if (ret) goto free_rproc; } + ret = rproc_set_state_machine(rproc, &st_rproc_sync_ops, sync_flags); + if (ret) + goto free_rproc; + rproc->auto_boot = auto_boot; rproc->has_iommu = false; ddata->workqueue = create_workqueue(dev_name(dev));