From patchwork Tue Mar 24 22:03:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11456643 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 0FC7C139A for ; Tue, 24 Mar 2020 22:03:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E5BE82076F for ; Tue, 24 Mar 2020 22:03:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="dOy8dEbS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728337AbgCXWDg (ORCPT ); Tue, 24 Mar 2020 18:03:36 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:41706 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727496AbgCXWDg (ORCPT ); Tue, 24 Mar 2020 18:03:36 -0400 Received: by mail-pg1-f196.google.com with SMTP id b1so118808pgm.8 for ; Tue, 24 Mar 2020 15:03:34 -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=YreXIxKLQt7lYPztJKiRLUpPxJWYbnz56N0G5fHSxA0=; b=dOy8dEbSsYr6tJapR3emTDhwQQGVP6sPYKuCLhsoxdiSOWXfMmj5P0tSOA5RDuImDQ N76Mx/QnIH21hXidv0iCFeaterM4mpb+vux9IS7s3uXHFxztX/nbqr9HcPZPAJsS8eZS qmK2DZZ7ev2M3iSkRAZ/M0xY3a48kbydBpBnAXtE22v9ghBu8QCGje6bTYX1kPWbm1+P R1iRagz02dLFOvGxaLOQXwLJW6ml7m6jL1DhRrOtf5Vzkcqf7PCcyKbg8fbOxY11QwX6 0NLq0Ohdgyb7sc4qOWNjGhHHVdCYIV8irRpBaDv1BlkCCBKJpJTy4BVgzoxZ/keN1tV0 VM2w== 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=YreXIxKLQt7lYPztJKiRLUpPxJWYbnz56N0G5fHSxA0=; b=bv79bTlTIOTacL04Q2H6hJ6Usj4CluKF0GlxNJpOYpDz9zff+/E6NVZeOqzgRoDJDp vnx9HU1ykvFVbJ75kdXXER3guIfdJ9OZm5JregUK54YJ9GVQ6iXQLpcuTAgpcGHr2xfe LnK5fhfwRf8As1BzVUDi6aH12GEgorbquVd6L4VXiosUBFLMJUN0XxKgkWHVqkq9DPAn qEt/PMpczGKfyFf6yGeFeS3W6+iaPrfbL6f445DEFeYJjvHpPmOFhbpuLVyd5kfcAaRZ i7otahDFvGSJVU/eApMNbQfmYOFPPohQ4j2nEo/0kNlfzXN69rSS1TLCWVZHzW7LyfOh f81g== X-Gm-Message-State: ANhLgQ3p4NopkBXDkejNQwaT8OlbpGwPqWe6uXG4uNflhq6r5Z66z5SC f2oYe7ql/SOp28T1KMkZ44jA7w== X-Google-Smtp-Source: ADFU+vvaf+l/TTu1M9f72f5grbtLyaxHMuFlxlNV7LWHBnvnsdJxmX4WxrWjI9hiUIff7ZJSqpZ9jw== X-Received: by 2002:a63:82c6:: with SMTP id w189mr28737773pgd.357.1585087414269; Tue, 24 Mar 2020 15:03:34 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id x70sm15571199pgd.37.2020.03.24.15.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 15:03:33 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org Cc: ohad@wizery.com, loic.pallardy@st.com, s-anna@ti.com, peng.fan@nxp.com, arnaud.pouliquen@st.com, fabien.dessenne@st.com, linux-remoteproc@vger.kernel.org Subject: [PATCH 01/11] remoteproc: stm32: Decouple rproc from memory translation Date: Tue, 24 Mar 2020 16:03:19 -0600 Message-Id: <20200324220329.15523-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200324220329.15523-1-mathieu.poirier@linaro.org> References: <20200324220329.15523-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 --- 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 a18f88044111..cde4b1a56381 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 Tue Mar 24 22:03:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11456645 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 81218174A for ; Tue, 24 Mar 2020 22:03:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 601B32076F for ; Tue, 24 Mar 2020 22:03:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Am+NoDRa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727496AbgCXWDh (ORCPT ); Tue, 24 Mar 2020 18:03:37 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34620 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728330AbgCXWDh (ORCPT ); Tue, 24 Mar 2020 18:03:37 -0400 Received: by mail-pf1-f193.google.com with SMTP id 23so4943pfj.1 for ; Tue, 24 Mar 2020 15:03:36 -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=gD4LodALzmGwEFgS5fwtNqrnYj7UVPtTkyE0f/EdKkA=; b=Am+NoDRatHT6h/yfSS12DGXSW0QghcPI5B8zhX8Wylqb+EUxitBPqmkzeKpju37WxJ vYuEmxpE/VRc7x3Vqb37HeIo9+wQBpShCpynYhz/LJ+Rywi/prAz3zptuku9zMLvYWsT ZpIFbewVYYvqvLEgDkKoRkbId5YVQBz+nNqTo6IAbGJDfqxA5gUTBwT+zt4lqQBwiVsO RHHmcQ3aib2kEs0wFWMRdDXy5zLXtuJGz8z2adYWKmLfq1zYmjlue8U/M9edWsoiNICT WjYHPqeRiiCjCc8fd3pfNC7HE6oPcGIIJIGjIFj/Z8SSuxlwBzBuBZyEoGgtnwQ+WKmG LeGw== 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=gD4LodALzmGwEFgS5fwtNqrnYj7UVPtTkyE0f/EdKkA=; b=QOmkgdUBBvcR1oLFzogzTBMvTAPDbTRt0am79pegN2tDzGvvHXw50Q8PKrG+U8WUdd 8RvWTVs/XeuHBaxiFuan+Ssvg9eqTyuCcJGaWP5BiKHTXa67NdzYmCgfW9QM1MVkB+mu T3RROmdbFIRwkHnHyQhqvosxfQUDatdY0FDpz+ilCpo9P5d0GOAjhH8vfw1G/jE5sndK imP2sXHJlOIE6CTbfhxD+siBnx3Aj0Lir2+HUu4UrhH7Sh2+mpXX2MRRi28VYDg9R+08 6U2WbS0Tj3BFMWbzmMMf2XyWox6TXa/K6Os7bLpycuVwMv+Udspe4FgC9rLjUlqzT62G 3qtw== X-Gm-Message-State: ANhLgQ0MRk99l/t3t1Yr/q+yYeEDY3saSo6v0T+LS4TlChz0sUMQ19n5 OZVA0usuz9ADwbo11Y8+W3obSw== X-Google-Smtp-Source: ADFU+vuaiZJ975CPSdjsA3X95fWb680idPGcTlM8FEIHyaMDFO341NnOzCm0rjU8iAD0pS7HxltIrA== X-Received: by 2002:a63:a55d:: with SMTP id r29mr12041699pgu.248.1585087415817; Tue, 24 Mar 2020 15:03:35 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id x70sm15571199pgd.37.2020.03.24.15.03.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 15:03:35 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org Cc: ohad@wizery.com, loic.pallardy@st.com, s-anna@ti.com, peng.fan@nxp.com, arnaud.pouliquen@st.com, fabien.dessenne@st.com, linux-remoteproc@vger.kernel.org Subject: [PATCH 02/11] remoteproc: stm32: Request IRQ with platform device Date: Tue, 24 Mar 2020 16:03:20 -0600 Message-Id: <20200324220329.15523-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200324220329.15523-1-mathieu.poirier@linaro.org> References: <20200324220329.15523-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 --- 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 cde4b1a56381..0c1f0b84e057 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 Tue Mar 24 22:03:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11456647 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 7822B1392 for ; Tue, 24 Mar 2020 22:03:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 59AF42076F for ; Tue, 24 Mar 2020 22:03:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Krh9y5zh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728330AbgCXWDi (ORCPT ); Tue, 24 Mar 2020 18:03:38 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:33680 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728241AbgCXWDi (ORCPT ); Tue, 24 Mar 2020 18:03:38 -0400 Received: by mail-pf1-f193.google.com with SMTP id j1so7687pfe.0 for ; Tue, 24 Mar 2020 15:03:37 -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=9sGi2cvVt9XWEoI9j8B7I22a41zUaQ7iMJOCZgIJecU=; b=Krh9y5zhPbizuaUZ2brUYxBZOcZY6JyhvHMM+sPGOUNnSdDEtAZlblkgC4WGFCqclM /SKQjmDJsxYwNoFfCC9PbUTL/tcMAi8wgjADu95Ip3a5nriX243soerjCOkRmc+N6/A1 nlRWhQBeEXjYQeHOnMoYe5VC2kAR73uSY7m5nrp7Ft5oNE0LpR8kGLJuJA/fpUWnIgDU bCMgNsnKKPm86POMPjjmpcZsuFsv0szYWwNQnpPQz4wdRpnEcKgzjuJ3x5+FwebNKSz0 ZJHvcYJLJF2wb7ZPtDG8a2scyEa2Rgk3WpnrGINHrwB2BkfPByhTgF/eKm+NNdugy57m GsKw== 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=9sGi2cvVt9XWEoI9j8B7I22a41zUaQ7iMJOCZgIJecU=; b=JtjZcR7PU81auqhrmk4/alJ/u7bK22UuNrit1oAOlMSDaKVGn6E7W6Dc0nRK5BX2Pk e+u/ViTQJaR+xdgC4rsY22M1G1cqbhDdIuMHluE7VrN9bJ0HKTNqmYMT0RRSswwMkArv N7URDH9LODE+EOiAR72YnTGfXcjOOVoaw8lRX1IqOnimrcTYnjAzMVduzYRBtFE2bDhb Sk0V6rdFqzUXMghMY6ITbnEO4rC2wG1eWwRM5a34kjGJabCdgXBpJ0NGXRVhwcf4f9Rc PnGsaY83C36V3z1b1mpqUWGDHtSo0cRkfZL73fOhW1k3l5GCt/G8Bw+BJ3FrBMV+0HcQ gKww== X-Gm-Message-State: ANhLgQ3CI4eyXV4qGDzZhrTEXdk/9Rl6KLfC0JjzNeJtin0+r4SMgYyp TcA2/QKKb9E2zYQAz6dRl1CKcw== X-Google-Smtp-Source: ADFU+vsP3EF1jMVMtSXr/qTlQ4qVQCPIyQ+gdetAqDfqQk0+R39hx4XXxcDTa6hx38R+jPzUnP6b8A== X-Received: by 2002:a63:a351:: with SMTP id v17mr28737870pgn.319.1585087416862; Tue, 24 Mar 2020 15:03:36 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id x70sm15571199pgd.37.2020.03.24.15.03.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 15:03:36 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org Cc: ohad@wizery.com, loic.pallardy@st.com, s-anna@ti.com, peng.fan@nxp.com, arnaud.pouliquen@st.com, fabien.dessenne@st.com, linux-remoteproc@vger.kernel.org Subject: [PATCH 03/11] remoteproc: stm32: Decouple rproc from DT parsing Date: Tue, 24 Mar 2020 16:03:21 -0600 Message-Id: <20200324220329.15523-4-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200324220329.15523-1-mathieu.poirier@linaro.org> References: <20200324220329.15523-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 MCU or not. Signed-off-by: Mathieu Poirier Reviewed-by: Loic Pallardy --- drivers/remoteproc/stm32_rproc.c | 38 +++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index 0c1f0b84e057..ca60c917e218 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_warn(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,18 +615,29 @@ 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)); if (ret) return ret; - rproc = rproc_alloc(dev, np->name, &st_rproc_ops, NULL, sizeof(*ddata)); - if (!rproc) + ddata = kzalloc(sizeof(*ddata), GFP_KERNEL); + if (!ddata) return -ENOMEM; + ret = stm32_rproc_parse_dt(pdev, ddata, &auto_boot); + if (ret) + goto free_ddata; + + rproc = rproc_alloc(dev, np->name, &st_rproc_ops, NULL, sizeof(*ddata)); + if (!rproc) { + ret = -ENOMEM; + goto free_ddata; + } + + 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"); @@ -635,20 +645,20 @@ static int stm32_rproc_probe(struct platform_device *pdev) goto free_rproc; } - platform_set_drvdata(pdev, rproc); + memcpy(rproc->priv, ddata, sizeof(*ddata)); - ret = stm32_rproc_parse_dt(pdev); - if (ret) - goto free_wkq; + platform_set_drvdata(pdev, rproc); ret = stm32_rproc_request_mbox(rproc); if (ret) - goto free_rproc; + goto free_wkq; ret = rproc_add(rproc); if (ret) goto free_mb; + kfree(ddata); + return 0; free_mb: @@ -661,6 +671,8 @@ static int stm32_rproc_probe(struct platform_device *pdev) device_init_wakeup(dev, false); } rproc_free(rproc); +free_ddata: + kfree(ddata); return ret; } From patchwork Tue Mar 24 22:03:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11456649 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 B226B139A for ; Tue, 24 Mar 2020 22:03:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9430A2076F for ; Tue, 24 Mar 2020 22:03:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jn48v702" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728338AbgCXWDj (ORCPT ); Tue, 24 Mar 2020 18:03:39 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36467 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728241AbgCXWDj (ORCPT ); Tue, 24 Mar 2020 18:03:39 -0400 Received: by mail-pf1-f194.google.com with SMTP id i13so10035681pfe.3 for ; Tue, 24 Mar 2020 15:03:38 -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=CtvrAu1ne+DSrciXhJ4DGNMZef5eMvYJ7Dz7YK+J18s=; b=jn48v702rLRzTGt9j2DJcPSv1ky1MNddFrTRGWcJNXpDtI0yXer/DWmT+NLuiCIIgQ WsqCRPdYtSBk6b+/EKx1hK7QvtKZQaCXdEaDm0D38hRgQIeRzihQd5dIDUqN9qNdpvoW h4nXL79HosDLwXcRA9nBSYn7gBhbQTLANlDqdOWtLbDHQ5zSJpC4XnOakVKSWh8tXl3D nCjwcuaaGoljJ9gf6ufObA1FLpoxoH3FlfousKPkJjtW2rDUkHi30XhyU4KLALLEVH0W k/hpYQVu8Ou2vnbf9kXN8wRtrp2CQmR4e0z8Zt3E10dpYfF7yLuoXa3xVQxd9pnecl8Y 16fg== 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=CtvrAu1ne+DSrciXhJ4DGNMZef5eMvYJ7Dz7YK+J18s=; b=IXNuss+AFvTX8QkvB5L0v0fEVdzsm/8meJUdMy+X3C7RcABAcwJFcZaoWBT7NXdr5/ vqiyrqPEwm8leYFROMcTLv5ZTLwPLWg7jMdsKKWWJdJKHpKR/dlasNIo2leZCks97ReX QLvZOEb4rn7keFWp+cNg92FyPm2EG5EhohE0rVxy9iaUcc+uH0yjdFlsGG4GTMHnmDhq 9qp6A8xyfOolWPSOKYGyyjDihcOgni7L4pU2zTzMkePf+u3mTU8fBL3ywIsdK31cbySj 4pLGW5MbJIizu6h55wiHTbNKQgi1ZcEujysPcqy+E2ZVjwjHntfuwVwTMIY53NjJJzju vtwg== X-Gm-Message-State: ANhLgQ0XlkhE+IB7slTtM0X0q21v13eHRGFNG6Oc4piudhg4Ws12m+Mp vnanzUJGenMxhVoGk9frua1Jcw== X-Google-Smtp-Source: ADFU+vtheaFsfEkbtzFt0/y69dOfwA7mT0o3NqKwiEAcCkqdvJu40Szr8XQHAFk/KScRa5UKhmU2Yg== X-Received: by 2002:aa7:9e82:: with SMTP id p2mr32163065pfq.46.1585087417903; Tue, 24 Mar 2020 15:03:37 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id x70sm15571199pgd.37.2020.03.24.15.03.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 15:03:37 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org Cc: ohad@wizery.com, loic.pallardy@st.com, s-anna@ti.com, peng.fan@nxp.com, arnaud.pouliquen@st.com, fabien.dessenne@st.com, linux-remoteproc@vger.kernel.org Subject: [PATCH 04/11] remoteproc: stm32: Remove memory translation from DT parsing Date: Tue, 24 Mar 2020 16:03:22 -0600 Message-Id: <20200324220329.15523-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200324220329.15523-1-mathieu.poirier@linaro.org> References: <20200324220329.15523-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 --- 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 ca60c917e218..a3e278490bb4 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) @@ -630,6 +630,10 @@ static int stm32_rproc_probe(struct platform_device *pdev) if (ret) goto free_ddata; + ret = stm32_rproc_of_memory_translations(pdev, ddata); + if (ret) + goto free_ddata; + rproc = rproc_alloc(dev, np->name, &st_rproc_ops, NULL, sizeof(*ddata)); if (!rproc) { ret = -ENOMEM; From patchwork Tue Mar 24 22:03:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11456651 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 943F9139A for ; Tue, 24 Mar 2020 22:03:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 761F72076F for ; Tue, 24 Mar 2020 22:03:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="c1QvcWyf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728340AbgCXWDk (ORCPT ); Tue, 24 Mar 2020 18:03:40 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:34705 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728241AbgCXWDk (ORCPT ); Tue, 24 Mar 2020 18:03:40 -0400 Received: by mail-pg1-f195.google.com with SMTP id t3so135512pgn.1 for ; Tue, 24 Mar 2020 15:03:39 -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=guFt8oGFuo3gPPM+xBh+k6k6Nv14RJK4O+Zn8ic0KVU=; b=c1QvcWyfWv7e1xyoWH+FMhYS2NsRqbKYi1wSUQtcFUs+xqznsPa7zQTrk8yzXFhTgB mk03JTELTSw5SYu8aOYb2Ae+HmBvBApatR4J07W8fQgDm0QVIrCVgWU6dpOakqOXJ5fg /dg2mAh00EMmerTh/WnqvicVLhzleeQps51nw7v1HAH/re7GoBAffN3fKVTPTx2YJGRY kWOisnyKs8rmFL+C7JRqOPoYMIRLWK3pgFuMfoZUllmxSsSwA7TnT6WisKG6wDzJvp8Q 6a7m9LF5IkAouhJmQn9vWUJfR5FuNPusNoSk0biM/r4LkGc5V2vMUFRHaF20lM08Xwbj QeUA== 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=guFt8oGFuo3gPPM+xBh+k6k6Nv14RJK4O+Zn8ic0KVU=; b=IofSfrKZmHV73D0h3K3UOJivNiG0/aVJi4ATCOVbLejm8+0RFNccLGx8b2L9TRzwZh ecyqqKg0GkFSe1okV3GaFpFtPKa+o5nmGt6zCLO9bfKIOfDMPO0AQgUnzIWI944Hl4E5 DcB2oJ5BPP3HZcN8GTNv/irZdXD6nGJDyPP7xG5pWlqr9WAgVlHEzUEWTudqYjlhKa6L UCvFIEEqOG94ziO/EeNKWShFnOuO96NeDscBS2aOGMkKDMV8vlp6QbLgcjicxyOf3F47 vAFWAs/NOhULN3jsUmMnCUav+xnwKs0mgCzozpFs/piTtbaDyRem7JCSBiN/LibFIj0f 6e9Q== X-Gm-Message-State: ANhLgQ3wBu8ywEEj+F1pJ/myvnfVl1LftsLL/bbz1pSrdpkViJBq+Etr mtkcK034/efnFqKXEm3rXDfKXg== X-Google-Smtp-Source: ADFU+vtTdxmv//ElJ3Ml9Jhfv4fLUxbT6lugU7ITWyt58qmRzcbWgRobP/bn9c4k4Sa/jJBRYiBbkA== X-Received: by 2002:aa7:9e46:: with SMTP id z6mr32471807pfq.17.1585087418994; Tue, 24 Mar 2020 15:03:38 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id x70sm15571199pgd.37.2020.03.24.15.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 15:03:38 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org Cc: ohad@wizery.com, loic.pallardy@st.com, s-anna@ti.com, peng.fan@nxp.com, arnaud.pouliquen@st.com, fabien.dessenne@st.com, linux-remoteproc@vger.kernel.org Subject: [PATCH 05/11] remoteproc: stm32: Parse syscon that will manage M4 synchronisation Date: Tue, 24 Mar 2020 16:03:23 -0600 Message-Id: <20200324220329.15523-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200324220329.15523-1-mathieu.poirier@linaro.org> References: <20200324220329.15523-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 --- 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 a3e278490bb4..7d5d4a7dbb04 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 Tue Mar 24 22:03:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11456653 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 1DBDA1392 for ; Tue, 24 Mar 2020 22:03:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F312A2076F for ; Tue, 24 Mar 2020 22:03:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ZRI7+w8E" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728347AbgCXWDl (ORCPT ); Tue, 24 Mar 2020 18:03:41 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:38350 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728241AbgCXWDl (ORCPT ); Tue, 24 Mar 2020 18:03:41 -0400 Received: by mail-pg1-f193.google.com with SMTP id x7so125358pgh.5 for ; Tue, 24 Mar 2020 15:03:40 -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=aRsPqWT6vmGZz/3jq1BhRl7LiRSK/M8TMnFnWtPZ1Kg=; b=ZRI7+w8EIpIM7WTHHJFrqA99kQVHK8QWr1zfP0VNdd1KrGgyWykMrUXSgwptl9G7E1 mtbFApOujppNm+I7w6iUkEzEZHqG5n2rzp2mIP5WQRJKyk0olVXWijhyMUZXrFj5fho9 Nleoz2vH4Wl1dEwYo1Nd6BFOMeQIOJ+eByz9fV2S12uNJUJlAKQ6cFzZrztxbCYDLYW+ INV5c0/u85N6tfABErEzddZbxxO1v+2Cyh8WQg+U6dlIhxLr5mXc3cvEHFasYxEpNSpn F+rMVCld5kQcz2PR8NRFNO1k9lQlmJXxnsZCf57uHGLQjFcRudCL5VUH/B7GLmoOvc8t ZMYg== 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=aRsPqWT6vmGZz/3jq1BhRl7LiRSK/M8TMnFnWtPZ1Kg=; b=dnmq2lzFtlU0nerRgzfABNQI96byP5MVlxdNpdNKjwCfrjLspwA2QYF2pDaCXg3BgH 0dXnKod5BY7peIBjHtPv/mfzB6xPNMOzKLlTsxJ6dhGaFejm/2Hyl3Bcw1/uThtu+awc 02LrMNWmTqlIK1D6R9ByGQ7qG+ZvMOz934S6rwRI3ABzWC04YLSnOY+A5BpuYTfVhlf8 ITwwynQKL9mKYPDsF9cs597D3sANy9m4kcM4dPkYlylIagiTZ2vuy4QgXq4Qle6EsTp5 NNt8SE4bTNf3juiRgAnU6c179cW5Ka8/Z+UXDke1EKJkymhl42uzaE7r7T7+L/46jiYu TBZw== X-Gm-Message-State: ANhLgQ1w27mP897mB3zS6owHGeKzZaF0hsaoDUqWsWABrigijE7e1t8b phEYSRoZ4GtD/g76Owo79eIufltikR8= X-Google-Smtp-Source: ADFU+vuRQtWfgQEtf/qFi9xkFs1QtZKM9ng21j1xrRMcaYotaAClGZZgCIPIkYFN/b588cAUk4dNUg== X-Received: by 2002:aa7:9e4d:: with SMTP id z13mr32215089pfq.6.1585087420015; Tue, 24 Mar 2020 15:03:40 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id x70sm15571199pgd.37.2020.03.24.15.03.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 15:03:39 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org Cc: ohad@wizery.com, loic.pallardy@st.com, s-anna@ti.com, peng.fan@nxp.com, arnaud.pouliquen@st.com, fabien.dessenne@st.com, linux-remoteproc@vger.kernel.org Subject: [PATCH 06/11] remoteproc: stm32: Get coprocessor state Date: Tue, 24 Mar 2020 16:03:24 -0600 Message-Id: <20200324220329.15523-7-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200324220329.15523-1-mathieu.poirier@linaro.org> References: <20200324220329.15523-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 7d5d4a7dbb04..b8af15dd0510 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; @@ -660,6 +680,15 @@ static int stm32_rproc_probe(struct platform_device *pdev) if (ret) goto free_ddata; + 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 = rproc_alloc(dev, np->name, &st_rproc_ops, NULL, sizeof(*ddata)); if (!rproc) { ret = -ENOMEM; From patchwork Tue Mar 24 22:03:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11456655 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 0176C1392 for ; Tue, 24 Mar 2020 22:03:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D52112076F for ; Tue, 24 Mar 2020 22:03:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="KHGQbZRy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728241AbgCXWDm (ORCPT ); Tue, 24 Mar 2020 18:03:42 -0400 Received: from mail-pj1-f67.google.com ([209.85.216.67]:35909 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728343AbgCXWDm (ORCPT ); Tue, 24 Mar 2020 18:03:42 -0400 Received: by mail-pj1-f67.google.com with SMTP id nu11so137639pjb.1 for ; Tue, 24 Mar 2020 15:03:41 -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=wm2/c43XLKQLZdmKqDIyd+QRT6a53rrkW0k1kyN2WTo=; b=KHGQbZRyU0qKpPHYO7Iw891NZc86TZBYMcX5ix4jv6/Y+2gYE/v1msJhWxogEY3fsm IQlFC8Nf1l4Pm5oG4k/kJzl1gpAqFJsdGgUbqroyuF9vpD3xF7VhJgULxrN+eAa+vS8O nlqox4al9Ocbeo8l0hlnAyAzEA3mUls/f5gHTuJ+r++iFm2fyPoiZ8m5qEBu1p+sBaum 5uMK7QlbFKsq13yX/qbiry+BMpzf9ilX/GZZmoXxqtwPX74bQSbiWmvyufPzmEZ4gUfq nHYcEYQc3V076Wmw++TwnnP+K3WPTHaKDH97Ww8rlqMK9MLtGvpJodTFjl5uaz3xClqy +CyQ== 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=wm2/c43XLKQLZdmKqDIyd+QRT6a53rrkW0k1kyN2WTo=; b=D7aFyMpyOBz4vEfr3bxXzCfCwLwolfU4mxwBDcSlxtitqql7b5w40xfoOvZoMtndc+ iFdxSasgmruj+AotnZ1AKEnJ5NCGP4KV5134zmLgp5J5HDZgiVEBNStiVBiiu1+X2PX/ DF2YKhT0/fimIvtJBNbWG3+Mp0nhaChFXMy3hG7rLo+3znWy5rA4LeIIPLS5pAh9XFxH X6kxJZNJ+rOoJJt52XQRj7xunwVkt5MQOCTHgeWeYSvVxivA/MDye5NdWpE1z2G8Txfy rs0XXpmXHflSp/0jf915sdOfc7c+Sp0JpxqOTHsKAcLAiotWyzetgTGd+MqzeRVDend5 54hw== X-Gm-Message-State: ANhLgQ2kLQJVdEfSNCxi0bj8+IZC4XLE9OSm3dGvoEcbt0Tz/BiMOOxe lWSIrYNn0L3Z8QKmkb539nYoUVBtmLA= X-Google-Smtp-Source: ADFU+vvDIncx8bBiJdzpN8fICcVxfuZoti1nsG4BaSFLu5qEaZaJf/XjXtxHpq0BGBE7LKvrKkRCnA== X-Received: by 2002:a17:90a:1784:: with SMTP id q4mr38680pja.174.1585087421115; Tue, 24 Mar 2020 15:03:41 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id x70sm15571199pgd.37.2020.03.24.15.03.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 15:03:40 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org Cc: ohad@wizery.com, loic.pallardy@st.com, s-anna@ti.com, peng.fan@nxp.com, arnaud.pouliquen@st.com, fabien.dessenne@st.com, linux-remoteproc@vger.kernel.org Subject: [PATCH 07/11] remoteproc: stm32: Get loaded resource table for synchronisation Date: Tue, 24 Mar 2020 16:03:25 -0600 Message-Id: <20200324220329.15523-8-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200324220329.15523-1-mathieu.poirier@linaro.org> References: <20200324220329.15523-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 b8af15dd0510..5bac0baf8f4c 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; @@ -689,6 +749,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_ddata; + } + rproc = rproc_alloc(dev, np->name, &st_rproc_ops, NULL, sizeof(*ddata)); if (!rproc) { ret = -ENOMEM; From patchwork Tue Mar 24 22:03:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11456657 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 37918174A for ; Tue, 24 Mar 2020 22:03:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 19C4C2076F for ; Tue, 24 Mar 2020 22:03:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mK+pFgyI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728349AbgCXWDo (ORCPT ); Tue, 24 Mar 2020 18:03:44 -0400 Received: from mail-pj1-f68.google.com ([209.85.216.68]:34611 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728343AbgCXWDo (ORCPT ); Tue, 24 Mar 2020 18:03:44 -0400 Received: by mail-pj1-f68.google.com with SMTP id q16so1611326pje.1 for ; Tue, 24 Mar 2020 15:03:42 -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=DF6ut+sIjxCo1vYVUNvb1kGsbVUugsDLID5ZsQOGmMA=; b=mK+pFgyIPI92Ul0mJlK/vgwhdWnxVTNscH8ueyJXKuq9SZHbFmbRt1BJUXHpn/bnwA rv/yFTHMJIGcNGf1kRWbHdoj3QlFgQaiE3OWVGBQplLL++jq1BQIkzshoohfqFO271LI xg4lKW/zAy34IwIF/y6KFYgdpa30uaBN0km9LKYIADTX7dqE2fV7Ascv4E4OxgMm/p5n KAxSAgkpEOjUAxqKkLsbf5hhlGPNX+P0CJq0bJBeQrySeTsfO8oi7M0nlqyjYpujN9A6 LWi1yVT7U1OQ3pu0Qh8YXYjZJRkkCWkQHdwW03gEqhBV/IP6I06K16W+CLVy5U/sml08 pRjg== 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=DF6ut+sIjxCo1vYVUNvb1kGsbVUugsDLID5ZsQOGmMA=; b=UHkFbfE3rnK1jyck28XddeW2OMkX27ptjsuCGxNYxXAdz19LMzeC0LEMteOncSVSsW I3eMGB78wsXB4SDhn41xqggbBoZELYIcJ7FCcGwPP5k31nIZNYm5UwnTHxg/UzehQpJT sOM5M7pI05kBk9WxjVl9M67IHZ4TpM5VXsaCnKgNVCFpkoU0V9WFbmX//OSSYEm16ZJJ 8Y0+LvxmSSLZVJzWzGNb623FnPE35vzlR6VsAWqcvge6FAEex75eNVZO3qdPOuMyQG4x g0nuAHLs2PRTzMDDvWt3aDjg8GsefGUuay1dXIBujR67P8KGzydKVSwQKH8/sMongo0Y skzg== X-Gm-Message-State: ANhLgQ1CyHM22ZB17IqV8RlJNWtyjJX6eaLmTilRzNGf38QwzLn8FNd4 4vwBNY6+iLjYeChX4+LWSbRWD1lkwhM= X-Google-Smtp-Source: ADFU+vuCa1KOnFgQj8YIxLv2THmgFu83DUIbZOQf3a7UoMhQ6Dh40lETyXNVj4m7Vm5VNvTFf0K7pw== X-Received: by 2002:a17:90b:1b04:: with SMTP id nu4mr22645pjb.81.1585087422177; Tue, 24 Mar 2020 15:03:42 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id x70sm15571199pgd.37.2020.03.24.15.03.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 15:03:41 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org Cc: ohad@wizery.com, loic.pallardy@st.com, s-anna@ti.com, peng.fan@nxp.com, arnaud.pouliquen@st.com, fabien.dessenne@st.com, linux-remoteproc@vger.kernel.org Subject: [PATCH 08/11] remoteproc: stm32: Introduce new start and stop ops for synchronisation Date: Tue, 24 Mar 2020 16:03:26 -0600 Message-Id: <20200324220329.15523-9-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200324220329.15523-1-mathieu.poirier@linaro.org> References: <20200324220329.15523-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 and stop 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 --- drivers/remoteproc/stm32_rproc.c | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index 5bac0baf8f4c..734605a9223e 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; @@ -489,6 +496,30 @@ static int stm32_rproc_stop(struct rproc *rproc) return 0; } +static int stm32_rproc_sync_stop(struct rproc *rproc) +{ + struct stm32_rproc *ddata = rproc->priv; + int err; + + err = stm32_rproc_stop(rproc); + if (err) + return err; + + /* update copro state to OFF */ + 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; +} + static void stm32_rproc_kick(struct rproc *rproc, int vqid) { struct stm32_rproc *ddata = rproc->priv; @@ -522,6 +553,12 @@ 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, + .stop = stm32_rproc_sync_stop, + .kick = stm32_rproc_kick, +}; + static const struct of_device_id stm32_rproc_match[] = { { .compatible = "st,stm32mp1-m4" }, {}, From patchwork Tue Mar 24 22:03:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11456659 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 09363139A for ; Tue, 24 Mar 2020 22:03:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DF77D2076F for ; Tue, 24 Mar 2020 22:03:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="nxVkTqdq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728350AbgCXWDp (ORCPT ); Tue, 24 Mar 2020 18:03:45 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:41439 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728348AbgCXWDp (ORCPT ); Tue, 24 Mar 2020 18:03:45 -0400 Received: by mail-pl1-f196.google.com with SMTP id t16so7977964plr.8 for ; Tue, 24 Mar 2020 15:03:44 -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=53Pt2UxbJ0AcOc/SylPuZOGJYQb+/r7CHW3XYFqP5OA=; b=nxVkTqdqwjdMkgPNQ7QHDCWeVZvkhTf7gxg2URNe2pUB7oAok5uoZRzxFtXBCdCQfZ zKI8sfraQ1GOmBjST6CQjcSqIeZDXwluxn6VwvH6QXLNQ5MuGP29r7Vu8q06yLSKEdvq WBmPwVqczfRVs52CKVDiCZFjseANmXnaDIdOcB9psAaJRm6oOM2DFCVkKBcmFxXXTHLD ifcQH9CfkBRifq9JHDk0LZ/Zd+5hwgS2zu4eCidBDZIgUk5KSR8BOkDDFMMqfIJSEOPJ atXg3CYo9q1VG/Yb7xQqJhg/q393kaNw7MhfVHSD5uZUtvxB5aoTZ7mQShf/HedOebAX S1Zg== 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=53Pt2UxbJ0AcOc/SylPuZOGJYQb+/r7CHW3XYFqP5OA=; b=qGBqL7piLUxHT64xaenxmUTRuvoVxxJYS/I5aSe2HSuYx1KM2e0KUz5eyB+WaYx3wy N+12NDn/fyIP0kdxn2kA+brhW9NvmS95xvSEzE/mfWh5xJC9rkQKEZz0vZdyg4l88Jjf 9KmuFXWvS+1ofXOUcsdAISPhzKB/mVkCYOinJeQHFBMIUBooZ08R84KhUlTTRAcNlRvt +X23B+C8Yau+B9kYkFXgmdJ3niCPQqT9oKBdI5CdKzhOrmSBkeFP4sbJeNIN/hvRoJ+S tUyq1CDwBJaTXofFeaEP+qvUa7hEig2g8+2xo1tRRZ6KLG5M/W012vAfwQ6J4dC9Ggte v6oA== X-Gm-Message-State: ANhLgQ2sozrYEO2nfqWNoRUGxxxipuu39vzeo8oBHgyAXdpk0pl2BB5e mBH7Dcd5Kp9hON9myWa+BTodtg== X-Google-Smtp-Source: ADFU+vt8xHIO05Qv970vtKtT+VAk08PdzIHKwwZoTykDGE8HkfCJD2ViyHtaFGkBFnwXjvsSHjLdCw== X-Received: by 2002:a17:90a:f50b:: with SMTP id cs11mr16254pjb.145.1585087423798; Tue, 24 Mar 2020 15:03:43 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id x70sm15571199pgd.37.2020.03.24.15.03.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 15:03:43 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org Cc: ohad@wizery.com, loic.pallardy@st.com, s-anna@ti.com, peng.fan@nxp.com, arnaud.pouliquen@st.com, fabien.dessenne@st.com, linux-remoteproc@vger.kernel.org Subject: [PATCH 09/11] remoteproc: stm32: Introduce new parse fw ops for synchronisation Date: Tue, 24 Mar 2020 16:03:27 -0600 Message-Id: <20200324220329.15523-10-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200324220329.15523-1-mathieu.poirier@linaro.org> References: <20200324220329.15523-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 | 49 +++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index 734605a9223e..4268d71f191d 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,28 @@ 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; @@ -557,6 +603,7 @@ static __maybe_unused struct rproc_ops st_rproc_sync_ops = { .start = stm32_rproc_sync_start, .stop = stm32_rproc_sync_stop, .kick = stm32_rproc_kick, + .parse_fw = stm32_rproc_sync_parse_fw, }; static const struct of_device_id stm32_rproc_match[] = { From patchwork Tue Mar 24 22:03:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11456661 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 A012D1392 for ; Tue, 24 Mar 2020 22:03:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8224A2076F for ; Tue, 24 Mar 2020 22:03:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="gzMsHTsV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728348AbgCXWDq (ORCPT ); Tue, 24 Mar 2020 18:03:46 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:46712 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728343AbgCXWDq (ORCPT ); Tue, 24 Mar 2020 18:03:46 -0400 Received: by mail-pl1-f194.google.com with SMTP id s23so920097plq.13 for ; Tue, 24 Mar 2020 15:03:45 -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=PKFUCHXycedKqG9pECFjQS1acORaTZjCEUQUtaelduI=; b=gzMsHTsVyIUTei6peXf0dv2b63rz5xBe7VrXDVor696ijcCZpxKMx5kGqYBm7D6MfJ FsgrO9nyGmJPE8Cn3H4JR7z62QKzyxd9MDaNNTVtHcBIm46xHUrRnVsf01/Hr0X+ct1z Lir8Hy2cxlx8jBc5ts4Ugze0tjShpSpH2+iSqMoJ6+AY/fV4LeDlWM+PNOLkGd13K9Li j0N3FpaD+y/8gEo/ier8nlnLAIf8LzcZjjI513H+eXt/KYjuj/WUXAvfYBrT4M/tjFlm qB6N9/DotKH7TPTwA1Jo5tjPAMlirL40ncrJAwkTq1WrqdifW4zwTGvadu1kt83pA4/m UBNA== 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=PKFUCHXycedKqG9pECFjQS1acORaTZjCEUQUtaelduI=; b=R9g2dwdKOgh/9bCY0gYTP7BESo0ucg/DdA+EEF9DnAB5C+DR2w86N+KPEXJyT8/o2/ P5GVTxgJNLv8G3U44qcZXK48s8Zq8gLxn50W/U+fz/9LmZ0HTiU7Cjxhx9AxVz1/ezHY 7CbSIQ3U1qC6zhYpPRo+ZfFCSiLOz/NIKeQm9NhdVeGVXTXvbPHKvf6lmlo3sYCCwHm9 Zdew7Hc1Vmcb/BZK7u6hR5rUkJodYAmHLrv9Tldg5a5efF+5sT5phslOvcLcVj2vr7X0 /RlItI5wkvae3oJp9ORja2hXJwoPfyBmGKp2s7seNUBUWqfcrsqpjbHaLtcvUV+/WsOt u6oQ== X-Gm-Message-State: ANhLgQ3taxN/Uui9GOAS+98CCDsOrH4etDzpG3fb9JCgiM4IySYVdM/J KZKvHmA4bOrF+zBv6piALTuefw== X-Google-Smtp-Source: ADFU+vuufWxTBzrJ5IbvPv66AqqjzhSCg3mJ/5FnkckEJ3Q7p35Xxmnlc08HtevYBAvN6lFyZCzEHw== X-Received: by 2002:a17:902:b90c:: with SMTP id bf12mr157451plb.152.1585087424956; Tue, 24 Mar 2020 15:03:44 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id x70sm15571199pgd.37.2020.03.24.15.03.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 15:03:44 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org Cc: ohad@wizery.com, loic.pallardy@st.com, s-anna@ti.com, peng.fan@nxp.com, arnaud.pouliquen@st.com, fabien.dessenne@st.com, linux-remoteproc@vger.kernel.org Subject: [PATCH 10/11] remoteproc: stm32: Introduce new loaded rsc ops for synchronisation Date: Tue, 24 Mar 2020 16:03:28 -0600 Message-Id: <20200324220329.15523-11-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200324220329.15523-1-mathieu.poirier@linaro.org> References: <20200324220329.15523-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 --- 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 4268d71f191d..07be306c0fb1 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -317,6 +317,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; @@ -604,6 +613,7 @@ static __maybe_unused struct rproc_ops st_rproc_sync_ops = { .stop = stm32_rproc_sync_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 const struct of_device_id stm32_rproc_match[] = { From patchwork Tue Mar 24 22:03:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11456663 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 57737139A for ; Tue, 24 Mar 2020 22:03:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 396E72076F for ; Tue, 24 Mar 2020 22:03:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="b8VH10bj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728352AbgCXWDr (ORCPT ); Tue, 24 Mar 2020 18:03:47 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:45241 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728343AbgCXWDq (ORCPT ); Tue, 24 Mar 2020 18:03:46 -0400 Received: by mail-pf1-f196.google.com with SMTP id j10so10011726pfi.12 for ; Tue, 24 Mar 2020 15:03:46 -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=dpQ6DnVKReCVQYB7WrPmTF5WmM2Jp/tQZ5tQKf9eucg=; b=b8VH10bjVHWs3gk4X1Hb+zvtzwCIwi9N+T9wf9apMhAj51QYYmvu8ZAMpS97n+hw74 UROYpYZGi+uP8jr6ZHUwAQFUJkzPgzp4zw+Y3G0mGB6NMqf0LIao9Sqcnq5LfGJvLIPy jlJXXxpQ7ebBiOFJRVCiOo90UX2W3LFiGw866GWvyh/WW202ZRogMs6HBF7z94HnvLFD 1jqsC7jIXODFUdzPg5JLZ4+pbgKXflvjnxGumfgXFQzqpnkvUb6/HXGGH7bN8RZ5TK4z G4I9zJhMB98NQj7x2GojLZNEgv84vmaw9CXSQ2KvJtcI8cX6E6gnweknLFDWRGTHbIrF Ywxw== 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=dpQ6DnVKReCVQYB7WrPmTF5WmM2Jp/tQZ5tQKf9eucg=; b=L4wzb8jphD/jm8TkuJrEJAW4QQidY4Rgr2v3fEHxgpChdF8MK2hNxyeXJg/72jo1jG oAPFUaG39oEEq+YJta8ypvj9Hm5Na9J4d2CfD+0ZhH87FfZ0VAIIIlHfex5B/wy0H9ck AcZcX537xN1J1jNZNqhcn5byqPLoQ0QduxUZHYvE7sfiOfMVINoLz08Kv8WBEYBvx/59 /dZGOKeKiGo6V9p/NOiOY6tli/CktNTFJOitaW9F/pf5ijjwEDXRpucmF/Ywe37FrGTy kKsAZzani91AThYZePxju0weBGwZqgEpMJzY7m7s+aNcO12uwWwLhR237wOsY4DTeMQN VZtw== X-Gm-Message-State: ANhLgQ1DZYFSFoI3O5d16u+rkous1s7bMtrcRvnmJqeBfaK029JrYen2 Vq6wIgUg+IFkL1NMf/oBtQkoHQ== X-Google-Smtp-Source: ADFU+vtA0Wpdsd6L18vppl4CAKw+SExpj66BPvCiR3yMofb89yJcVQTOV2JgIaDXdkcvPAi/OYS7Nw== X-Received: by 2002:a62:5c07:: with SMTP id q7mr32300396pfb.200.1585087425979; Tue, 24 Mar 2020 15:03:45 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id x70sm15571199pgd.37.2020.03.24.15.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 15:03:45 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org Cc: ohad@wizery.com, loic.pallardy@st.com, s-anna@ti.com, peng.fan@nxp.com, arnaud.pouliquen@st.com, fabien.dessenne@st.com, linux-remoteproc@vger.kernel.org Subject: [PATCH 11/11] remoteproc: stm32: Allocate rproc for synchronisation with MCU Date: Tue, 24 Mar 2020 16:03:29 -0600 Message-Id: <20200324220329.15523-12-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200324220329.15523-1-mathieu.poirier@linaro.org> References: <20200324220329.15523-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 Allocate remote processor structure with state machine if the MCU has already been started by an external entity. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/stm32_rproc.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index 07be306c0fb1..f320ef9ee286 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -608,7 +608,7 @@ 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_sync_stop, .kick = stm32_rproc_kick, @@ -616,6 +616,12 @@ static __maybe_unused struct rproc_ops st_rproc_sync_ops = { .find_loaded_rsc_table = stm32_rproc_sync_elf_find_loaded_rsc_table, }; +static struct rproc_sync_states st_sync_states = { + .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" }, {}, @@ -847,15 +853,22 @@ static int stm32_rproc_probe(struct platform_device *pdev) ret = stm32_rproc_get_loaded_rsc_table(pdev, ddata); if (ret) goto free_ddata; + + rproc = rproc_alloc_state_machine(dev, np->name, &st_rproc_ops, + &st_rproc_sync_ops, + &st_sync_states, NULL, + sizeof(*ddata)); + } else { + rproc = rproc_alloc(dev, np->name, &st_rproc_ops, + NULL, sizeof(*ddata)); + rproc->auto_boot = auto_boot; } - rproc = rproc_alloc(dev, np->name, &st_rproc_ops, NULL, sizeof(*ddata)); if (!rproc) { ret = -ENOMEM; goto free_ddata; } - rproc->auto_boot = auto_boot; rproc->has_iommu = false; ddata->workqueue = create_workqueue(dev_name(dev)); if (!ddata->workqueue) {