Linux-remoteproc Archive mirror
 help / color / mirror / Atom feed
From: Daniel Baluta <daniel.baluta@nxp.com>
To: andersson@kernel.org, mathieu.poirier@linaro.org
Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org,
	imx@lists.linux.dev, iuliana.prodan@nxp.com, peng.fan@nxp.com,
	Daniel Baluta <daniel.baluta@nxp.com>,
	Alexandru Lastur <alexandru.lastur@nxp.com>
Subject: [RFC PATCH] remoteproc: core: Add support for predefined notifyids
Date: Fri, 18 Oct 2024 14:09:29 +0300	[thread overview]
Message-ID: <20241018110929.1646410-1-daniel.baluta@nxp.com> (raw)

Currently we generate notifyids in the linux kernel and override
those found in rsc_table.

This doesn't play well with users expecting to use the exact ids
from rsc_table.

So, use predefined notifyids found in rsc_table if any. Otherwise,
let Linux generate the ids as before.

Keypoint is we also define an invalid notifid as 0xFFFFFFFFU. This
should be placed as notifids if users want Linux to generate the ids.

Signed-off-by: Alexandru Lastur <alexandru.lastur@nxp.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
 drivers/remoteproc/remoteproc_core.c | 14 ++++++++++++--
 include/linux/remoteproc.h           |  1 +
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index f276956f2c5c..9f00fe16da38 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -332,6 +332,7 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i)
 	int ret, notifyid;
 	struct rproc_mem_entry *mem;
 	size_t size;
+	int start, end;
 
 	/* actual size of vring (in bytes) */
 	size = PAGE_ALIGN(vring_size(rvring->num, rvring->align));
@@ -363,9 +364,18 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i)
 	/*
 	 * Assign an rproc-wide unique index for this vring
 	 * TODO: assign a notifyid for rvdev updates as well
-	 * TODO: support predefined notifyids (via resource table)
 	 */
-	ret = idr_alloc(&rproc->notifyids, rvring, 0, 0, GFP_KERNEL);
+
+	start = 0;
+	end = 0;
+
+	/* use id if specified in rsc table */
+	if (rsc->vring[i].notifyid != RSC_INVALID_NOTIFYID) {
+		start = rsc->vring[i].notifyid;
+		end = start + 1;
+	}
+
+	ret = idr_alloc(&rproc->notifyids, rvring, start, end, GFP_KERNEL);
 	if (ret < 0) {
 		dev_err(dev, "idr_alloc failed: %d\n", ret);
 		return ret;
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index b4795698d8c2..98c3e181086e 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -238,6 +238,7 @@ struct fw_rsc_trace {
 	u8 name[32];
 } __packed;
 
+#define RSC_INVALID_NOTIFYID 0xFFFFFFFFU
 /**
  * struct fw_rsc_vdev_vring - vring descriptor entry
  * @da: device address
-- 
2.43.0


             reply	other threads:[~2024-10-18 11:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-18 11:09 Daniel Baluta [this message]
2024-10-23 15:32 ` [RFC PATCH] remoteproc: core: Add support for predefined notifyids Mathieu Poirier
2024-10-25 20:38   ` Arnaud POULIQUEN
2024-10-30 14:04   ` Daniel Baluta

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=20241018110929.1646410-1-daniel.baluta@nxp.com \
    --to=daniel.baluta@nxp.com \
    --cc=alexandru.lastur@nxp.com \
    --cc=andersson@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=iuliana.prodan@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=peng.fan@nxp.com \
    /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).