Linux-remoteproc Archive mirror
 help / color / mirror / Atom feed
From: Simon Maurer <mail@maurer.systems>
To: linux-remoteproc@vger.kernel.org
Subject: [PATCH] remoteproc: add optional hook for resource checking
Date: Wed, 22 Jan 2025 16:59:17 +0100	[thread overview]
Message-ID: <bc9f1dd8-92b1-4839-86c9-ac9e544648ec@maurer.systems> (raw)

This optional hook gives the remoteproc driver the opportunity to check
the resource table after parsing and to replace the allocator in
the carveouts before resource allocation. This is needed for RemoteProc
over PCIe where the carveouts are already mapped by the driver.

Signed-off-by: Simon Maurer <mail@maurer.systems>
---
  drivers/remoteproc/remoteproc_core.c | 6 ++++++
  include/linux/remoteproc.h           | 3 +++
  2 files changed, 9 insertions(+)

diff --git a/drivers/remoteproc/remoteproc_core.c 
b/drivers/remoteproc/remoteproc_core.c
index c2cf0d277729..3129c5d68770 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1423,6 +1423,12 @@ static int rproc_fw_boot(struct rproc *rproc, 
const struct firmware *fw)
  		goto clean_up_resources;
  	}

+	if (rproc->ops->check_rsc) {
+		ret = rproc->ops->check_rsc(rproc);
+		if (ret)
+			goto clean_up_resources;
+	}
+
  	/* Allocate carveout resources associated to rproc */
  	ret = rproc_alloc_registered_carveouts(rproc);
  	if (ret) {
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index b4795698d8c2..6d7d35d24dad 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -371,6 +371,8 @@ enum rsc_handling_status {
   * @handle_rsc:	optional platform hook to handle vendor resources. 
Should return
   *		RSC_HANDLED if resource was handled, RSC_IGNORED if not handled
   *		and a negative value on error
+ * @hcheck_rsc:	optional platform hook to check resources before 
allocation.
+ *		Should return 0 if resources are OK and a negative value on error
   * @find_loaded_rsc_table: find the loaded resource table from 
firmware image
   * @get_loaded_rsc_table: get resource table installed in memory
   *			  by external entity
@@ -394,6 +396,7 @@ struct rproc_ops {
  	int (*parse_fw)(struct rproc *rproc, const struct firmware *fw);
  	int (*handle_rsc)(struct rproc *rproc, u32 rsc_type, void *rsc,
  			  int offset, int avail);
+	int (*check_rsc)(struct rproc *rproc);
  	struct resource_table *(*find_loaded_rsc_table)(
  				struct rproc *rproc, const struct firmware *fw);
  	struct resource_table *(*get_loaded_rsc_table)(
-- 
2.46.0


             reply	other threads:[~2025-01-22 16:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-22 15:59 Simon Maurer [this message]
2025-01-22 18:53 ` RemoteProc over PCIe Simon Maurer
2025-01-27 16:27   ` Mathieu Poirier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bc9f1dd8-92b1-4839-86c9-ac9e544648ec@maurer.systems \
    --to=mail@maurer.systems \
    --cc=linux-remoteproc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).