Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp613179pxf; Wed, 10 Mar 2021 13:12:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJyj4EYFrOvzcsMMYfh1TrSCwhFSsOTelILMD1f5AhohCEPjJaLcdsie65TJsIY175NWmhQE X-Received: by 2002:a17:906:ecf3:: with SMTP id qt19mr321760ejb.467.1615410749621; Wed, 10 Mar 2021 13:12:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615410749; cv=none; d=google.com; s=arc-20160816; b=InB0xLjpfsJVfWu/isBM1ivWY9BExHwvve9/odzAQdwrI5Leks6rt0ZOlpQT4JT97v eUSEjueWF4H9oIWuRM9Wn26rtwNGXvjUH0VYsKjd0VzEK1aEUFU456BGpKl0WBHqtRmw K9alpxSsxi2M8QDPE+Vt2AR0xEMn4RlIHb+Ga3+Ks7UEHr/G4KP3YqhqkAINUdFZRxjW eRtAzOVF3Qz34GWud3UqW/rDGxe7G/C6aaaQCW16F9/gz+e0OnEjAsR/zCAOJP+1METq Zv0UC1csrO+hExcjctaxhjANYJLXDNfYl4Z++034YOWSHYkK0DH3bRVjb9xbcxaduhyI 7GRA== 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=V6QBix4Xk7mXD3k02J6NEnaLX2tt4w4cfwoG6OuF1xs=; b=WtqV/HXxvr5xOSiOqAikaHhPwEUHkodKPc0SOcandJ2+C2byRQiLZxGQaFZV3krIA9 nsKttiCqPeIug8AX8HgfPwbEVuFQoxwLJTFT7ddL3EAgc+vRy8AjuKyuwWy83Nj87SAh +txP0IB4A+SYY7b8E8YWgyfwwC7Ea5vyzCI9tIfYMQSJs6YQe7V7FhfwmDKDVdrLPRyv kf5LFdIzRisIHJ6Xt8DkrQ7P+DPhGxnz8bcafLo6dNC5sLmYROojnowoda9Y7HuAtk2o uIZylMO9zmjGuUFEf1qfgLaHnNICgi4kXPRFxoMsEnjFabh/gedkIe6W0XP9a6fwF3gl Gwmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XBOQZTyM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bg8si351323ejb.188.2021.03.10.13.11.52; Wed, 10 Mar 2021 13:12:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XBOQZTyM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232966AbhCJVLB (ORCPT + 99 others); Wed, 10 Mar 2021 16:11:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232133AbhCJVKi (ORCPT ); Wed, 10 Mar 2021 16:10:38 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E48FC061762 for ; Wed, 10 Mar 2021 13:10:38 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id x7so9542512pfi.7 for ; Wed, 10 Mar 2021 13:10: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=V6QBix4Xk7mXD3k02J6NEnaLX2tt4w4cfwoG6OuF1xs=; b=XBOQZTyM8nIn5p7W3WoJQHNoDPEeTgJoCkbMRlrhihBOKSUUsGzsltCNK+Py2hDomH g8+uigl7mIc33oR4q22Q2aH7GKjhhGcAiucwQ6CyPctgKMJi1pWVcsvITWMv9OQhO3yQ 9B3QytYl2LqUQMwUomptLoJX/1KNynNGdB80fjwIE40jAw00EuNwr15ptC2egbZp1Oo+ fIEiHW7iDqlYvQnNMXaHhdSBbPUHoTRqz2MR2YePTFi9beO1Zlf8d53wORGPPMzQfiqQ U+hUnSOgXCQGez8/KgSt2UhQ3JLs6AzP81MqQ6yxvoHEh+tDsUJxcfwuIcQxHlXb9Ydg fY+Q== 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=V6QBix4Xk7mXD3k02J6NEnaLX2tt4w4cfwoG6OuF1xs=; b=aQjKR2dymIWl4Cl2AAwXZxCx/fv4Gx6bzNFI/zCoEWKAdByj9gSsfR134mZY7zrEIs jJNTp80WF8laeFIHCm0tcqwJ7Mo34l7Qm4W5xoEJ2566mpkkZux+m5PapiJywpPcLGzS f56WFp4dTyJWY9cu06Lhqi5+zJ48BG62IUm6Z1f/F0vlBY5O4kFjlInSjRwJv/feO/jX frT0vXM6GWooUroMpW9BlXbjRiohq42DtUAIR9fAYhp2HXAkjEXpswlJj+nfSdqotaUV RuKVNh7exQ0zjluGrpDoljKXuNmSr3PR6dmdEf1kxpOQs5Y3GuCjjKocMCVMl4mpWh1i b2vQ== X-Gm-Message-State: AOAM533w6qqukckSiN/vd7SocOX05J5bYRfXeUR9R1VhQQmpNvZCNU2V EZFz846yRP04VPyv/fH3xhWqXQ== X-Received: by 2002:a63:4513:: with SMTP id s19mr4246505pga.229.1615410637808; Wed, 10 Mar 2021 13:10:37 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:37 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 07/17] remoteproc: stm32: Move memory parsing to rproc_ops Date: Wed, 10 Mar 2021 14:10:15 -0700 Message-Id: <20210310211025.1084636-8-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index bf6f6d15b1c3..1d8bb588d996 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1582,10 +1582,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_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 */ @@ -1602,7 +1609,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 */ @@ -1621,6 +1628,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 f647e565014b..3d45f51de4d0 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) @@ -614,6 +603,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, @@ -796,14 +786,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) { -- 2.25.1