From patchwork Thu Feb 11 23:46:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381066 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2495845jah; Thu, 11 Feb 2021 15:49:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzUogjk2dKGOsu698TF6w1nnH7VzirBpa3OEzVXuZr/PM+l5iSQJyge6gpSl/74vwNw1vcx X-Received: by 2002:a17:907:728b:: with SMTP id dt11mr145284ejc.321.1613087398344; Thu, 11 Feb 2021 15:49:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087398; cv=none; d=google.com; s=arc-20160816; b=DkP1cKBL2CmLljt3h4hyAEiCn4dEWO2tTD+tLPwrLT4bIRwodE25hL6on8dEXB6piL 90SdqBJuKwNXwAO9AiIMBgddpO62Mb87BYWMMUK9S2OUT+t59Jya+pkZVhCv74l7Z822 7hyqYczjTIB0IKyGpLdXcnSBsfikMEpcqpzlvWtx3CgmcHmvFjmbPKuQn6ETHOteatWw sYEtl9pbP3qwgX4EL0DQVejcI3ZvtG+lL+5y7CRkjwO2mctikH0cK6VfzcWQ/oWvv62J 5WFY9xY/aZHkB02y7xbFGsPKkqQuw8GSrpuaxgaHxaZ2MxXfQluATuxOciLuWI5PO1dz 4S/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=52raNE6Ip4exp7Y9/K/NcM7vSGzuAdV+HOuZ1MCv9VM=; b=bciP4CS9KmZ3sCHQBfG3P80lEP/Sml8CIMrBT1d5FF/ZNDaZlk7Ko44acBt3gcvnxJ QXN3d8YTWmzhFZzAGsv219/MGFbz7M1k7R48/wzTD39MMWWan1mCeVnmvVDKKhmgw4Cc AUWVY0JwCh7q1p7CoN3+TEeFuv8RJDbw1DR4nDIY5uRx6rneEXWT1cfOUzbPeoGOIHO6 7MoorHciuKxhX83OQmZL0F6PpSKSfiuuphzehNVTch/dGidyzKIB0DGznCtTXw3zZBQ8 udfCPdoFNQQ26Iha4pKz7a7I8JEDP+KilijrpEqcZGDxDFVtzRUJhf96y9ysv5bBdIiU xyCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="P1J/bRhy"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot7si4969638ejb.88.2021.02.11.15.49.58; Thu, 11 Feb 2021 15:49:58 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="P1J/bRhy"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230349AbhBKXtx (ORCPT + 6 others); Thu, 11 Feb 2021 18:49:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230363AbhBKXsp (ORCPT ); Thu, 11 Feb 2021 18:48:45 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D883C061A2D for ; Thu, 11 Feb 2021 15:46:38 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id fa16so4377246pjb.1 for ; Thu, 11 Feb 2021 15:46:38 -0800 (PST) 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=52raNE6Ip4exp7Y9/K/NcM7vSGzuAdV+HOuZ1MCv9VM=; b=P1J/bRhyIkT1K7cKFoh+2BHP2oo6M/1O3Ec5B1QZogBLNdi4iWNqnLXlPvAF2WwIgM vsLEcoGS0So63cj2Nrdtf5Fvjzq4sU+97ecNOi0WSo5EcW+9WxycBRL2QSA3cD2Yxypw /4UmefrsH0MWX0WRLJvIWy++JVaJgDekpX/XeZkyhLf6LQngxfiBTxjliCGTxh1kJbf1 r+nq6s0YM8i/4cYl+GZkAwmfUQr7uH7VhnfSy9+XHwtfJQsyreZ0WlYq6GqDOICo6rDT IWtw+dsu+rsJ+lsKOJXw3tbQMgGFcXrW34S378Ilrgy49bkcjVAihx1KKSgrI/VLETK5 /X4A== 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=52raNE6Ip4exp7Y9/K/NcM7vSGzuAdV+HOuZ1MCv9VM=; b=jIX1RspMyCX4ZDbXck0LWZwUunccfcECGcwbtExsAy5er9wNq4AM4IS7Wc6wzvcjIb GLyGcEbCgmf8i2RjhA+UWpzcNNTTHAN/tk9Q4TR7ia30xJ/lSaDaE+UoedbRKugXgWnz 305rHEgwsqzWfj2rRBIF9a6a5HIrozKknTI1by+tG1o6eOI5FV9QBjDzkUW78tfc/xM5 Xsf8WVdUlSWzVifz9vvyOdvObOErDotURpmBBzsZOep8SOM/lTtu5sjz2fQ5RrXiLRCA EEs0Omw4JkpfFQeNaNtgAD6jM057pmEIVdd4CQJNeS/xI8sYX2dzjfnaPFqVDkZyqdAD aJjw== X-Gm-Message-State: AOAM533O5rCkdfkaZCXvmCVdp03HxINCmoTGmWxMvAtA3FzqGDEx1RPv a6LhD6tZm1pTzufxVTfF8qMJzg== X-Received: by 2002:a17:902:e752:b029:df:c991:8c4f with SMTP id p18-20020a170902e752b02900dfc9918c4fmr422611plf.52.1613087197818; Thu, 11 Feb 2021 15:46:37 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:37 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 09/19] remoteproc: stm32: Move memory parsing to rproc_ops Date: Thu, 11 Feb 2021 16:46:17 -0700 Message-Id: <20210211234627.2669674-10-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Arnaud POULIQUEN Some actions such as memory resources reallocation are needed when trying to reattach a co-processor. Use the prepare() operation for these actions. Co-developed-by: Mathieu Poirier Signed-off-by: Mathieu Poirier Signed-off-by: Arnaud POULIQUEN --- drivers/remoteproc/remoteproc_core.c | 14 ++++++++++++-- drivers/remoteproc/stm32_rproc.c | 27 ++++++--------------------- 2 files changed, 18 insertions(+), 23 deletions(-) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 741bc20de437..5c52c612a7f0 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1585,10 +1585,17 @@ static int rproc_attach(struct rproc *rproc) return ret; } + /* Do anything that is needed to boot the remote processor */ + ret = rproc_prepare_device(rproc); + if (ret) { + dev_err(dev, "can't prepare rproc %s: %d\n", rproc->name, ret); + goto disable_iommu; + } + ret = rproc_set_loaded_rsc_table(rproc); if (ret) { dev_err(dev, "can't load resource table: %d\n", ret); - goto disable_iommu; + goto unprepare_device; } /* reset max_notifyid */ @@ -1605,7 +1612,7 @@ static int rproc_attach(struct rproc *rproc) ret = rproc_handle_resources(rproc, rproc_loading_handlers); if (ret) { dev_err(dev, "Failed to process resources: %d\n", ret); - goto disable_iommu; + goto unprepare_device; } /* Allocate carveout resources associated to rproc */ @@ -1624,6 +1631,9 @@ static int rproc_attach(struct rproc *rproc) clean_up_resources: rproc_resource_cleanup(rproc); +unprepare_device: + /* release HW resources if needed */ + rproc_unprepare_device(rproc); disable_iommu: rproc_disable_iommu(rproc); return ret; diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index 826cb7a045df..6f0bb54dec15 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -207,16 +207,7 @@ static int stm32_rproc_mbox_idx(struct rproc *rproc, const unsigned char *name) return -EINVAL; } -static int stm32_rproc_elf_load_rsc_table(struct rproc *rproc, - const struct firmware *fw) -{ - if (rproc_elf_load_rsc_table(rproc, fw)) - dev_warn(&rproc->dev, "no resource table found for this firmware\n"); - - return 0; -} - -static int stm32_rproc_parse_memory_regions(struct rproc *rproc) +static int stm32_rproc_prepare(struct rproc *rproc) { struct device *dev = rproc->dev.parent; struct device_node *np = dev->of_node; @@ -274,12 +265,10 @@ static int stm32_rproc_parse_memory_regions(struct rproc *rproc) static int stm32_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw) { - int ret = stm32_rproc_parse_memory_regions(rproc); - - if (ret) - return ret; + if (rproc_elf_load_rsc_table(rproc, fw)) + dev_warn(&rproc->dev, "no resource table found for this firmware\n"); - return stm32_rproc_elf_load_rsc_table(rproc, fw); + return 0; } static irqreturn_t stm32_rproc_wdg(int irq, void *data) @@ -609,6 +598,7 @@ stm32_rproc_get_loaded_rsc_table(struct rproc *rproc, size_t *table_sz) } static const struct rproc_ops st_rproc_ops = { + .prepare = stm32_rproc_prepare, .start = stm32_rproc_start, .stop = stm32_rproc_stop, .attach = stm32_rproc_attach, @@ -793,14 +783,9 @@ static int stm32_rproc_probe(struct platform_device *pdev) if (ret) goto free_rproc; - if (state == M4_STATE_CRUN) { + if (state == M4_STATE_CRUN) rproc->state = RPROC_DETACHED; - ret = stm32_rproc_parse_memory_regions(rproc); - if (ret) - goto free_resources; - } - rproc->has_iommu = false; ddata->workqueue = create_workqueue(dev_name(dev)); if (!ddata->workqueue) {