public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Support remoteproc fixed device index from DT aliases
@ 2026-01-28 10:31 Arnaud Pouliquen
  2026-01-28 10:31 ` [PATCH v2 1/2] remoteproc: core: support " Arnaud Pouliquen
  2026-01-28 10:31 ` [PATCH v2 2/2] remoteproc: keystone: use RPROC_ALIAS definition Arnaud Pouliquen
  0 siblings, 2 replies; 5+ messages in thread
From: Arnaud Pouliquen @ 2026-01-28 10:31 UTC (permalink / raw)
  To: Bjorn Andersson, Mathieu Poirier
  Cc: linux-remoteproc, linux-kernel, linux-stm32, Andrew Davis,
	arnaud.pouliquen

On systems with multiple remote processors, the remoteproc device
enumeration is not stable as it depends on the probe ordering.
As a result, the /sys/class/remoteproc/remoteproc<x> entries do not
always refer to the same remote processor instance, which complicates
userspace applications.

This series:

- Introduces support for "rproc" device tree aliases to fix remoteproc device
  names and their corresponding /sys/class/remoteproc/remoteproc<x> entries.
- Updates the keystone_remoteproc driver, which also uses DT aliases, to adopt
  a common RPROC_ALIAS definition. Although it already uses the "rproc" alias
  to construct the firmware name, the change proposed in this series should be
  compatible.

Please refer to the patch commit messages for details on the implementation.

Arnaud Pouliquen (2):
  remoteproc: core: support fixed device index from DT aliases
  remoteproc: keystone: use RPROC_ALIAS definition

 drivers/remoteproc/keystone_remoteproc.c |  2 +-
 drivers/remoteproc/remoteproc_core.c     | 40 ++++++++++++++++++++++--
 include/linux/remoteproc.h               |  3 ++
 3 files changed, 42 insertions(+), 3 deletions(-)


base-commit: 63804fed149a6750ffd28610c5c1c98cce6bd377
-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] remoteproc: core: support fixed device index from DT aliases
  2026-01-28 10:31 [PATCH v2 0/2] Support remoteproc fixed device index from DT aliases Arnaud Pouliquen
@ 2026-01-28 10:31 ` Arnaud Pouliquen
  2026-02-04  0:57   ` Peng Fan
  2026-01-28 10:31 ` [PATCH v2 2/2] remoteproc: keystone: use RPROC_ALIAS definition Arnaud Pouliquen
  1 sibling, 1 reply; 5+ messages in thread
From: Arnaud Pouliquen @ 2026-01-28 10:31 UTC (permalink / raw)
  To: Bjorn Andersson, Mathieu Poirier
  Cc: linux-remoteproc, linux-kernel, linux-stm32, Andrew Davis,
	arnaud.pouliquen

On systems with multiple remote processors, the remoteproc device
enumeration is not stable as it depends on the probe ordering.
As a result, the /sys/class/remoteproc/remoteproc<x> entries do not
always refer to the same remote processor instance, which complicates
userspace applications.

Inspired by the SPI implementation, this commit allows board-specific
numbering to be defined in device tree while still supporting dynamically
registered remote processors.

For instance, on STM32MP25 Soc this can be used by defining:

    aliases {
        rproc0 = &m33_rproc;
        rproc1 = &m0_rproc;
    };

When a "rproc<x>" DT alias is present, use it to assign a fixed
"/sys/class/remoteproc/remoteproc<x>" entry.
If no remoteproc alias is defined, keep the legacy index allocation.
If only some remoteproc instances have an alias, allocate dynamic
index starting after the highest alias index declared.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
---
V2:
- Introduces rproc_get_index based on Mathieu Poirier's suggestion.
  An update compared to Mathieu's version is that the call to
  ida_alloc_range is retained if an alias is found for the remote device,
  to balance with ida_free().
- Rename DT alias stem from "remoteproc" to "rproc" to be consistent with
  keytone driver.
---
 drivers/remoteproc/remoteproc_core.c | 40 ++++++++++++++++++++++++++--
 include/linux/remoteproc.h           |  3 +++
 2 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index aada2780b343..38d6eb1c9483 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -2433,6 +2433,43 @@ static int rproc_alloc_ops(struct rproc *rproc, const struct rproc_ops *ops)
 	return 0;
 }
 
+/**
+ * rproc_get_index - assign a unique device index for a remote processor
+ * @dev: device associated with the remote processor
+ *
+ * Look for a static index coming from the "rproc" DT alias
+ * (e.g. "rproc0"). If none is found, start allocating
+ * dynamic IDs after the highest alias in use.
+ *
+ * Return: a non-negative index on success, or a negative error code on failure.
+ */
+static int rproc_get_index(struct device *dev)
+{
+	int index;
+
+	/* No DT to deal with */
+	if (!dev->of_node)
+		goto legacy;
+
+	/* See if an alias has been assigned to this remoteproc */
+	index = of_alias_get_id(dev->of_node, RPROC_ALIAS);
+	if (index >= 0)
+		return  ida_alloc_range(&rproc_dev_index, index, index,
+					GFP_KERNEL);
+	/*
+	 * No alias has been assigned to this remoteproc device. See if any
+	 * "rproc" aliases have been assigned and start allocating after
+	 * the highest one if it is the case.
+	 */
+	index = of_alias_get_highest_id(RPROC_ALIAS);
+	if (index >= 0)
+		return ida_alloc_range(&rproc_dev_index, index + 1, ~0,
+				       GFP_KERNEL);
+
+legacy:
+	return ida_alloc(&rproc_dev_index, GFP_KERNEL);
+}
+
 /**
  * rproc_alloc() - allocate a remote processor handle
  * @dev: the underlying device
@@ -2481,8 +2518,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
 	rproc->dev.driver_data = rproc;
 	idr_init(&rproc->notifyids);
 
-	/* Assign a unique device index and name */
-	rproc->index = ida_alloc(&rproc_dev_index, GFP_KERNEL);
+	rproc->index = rproc_get_index(dev);
 	if (rproc->index < 0) {
 		dev_err(dev, "ida_alloc failed: %d\n", rproc->index);
 		goto put_device;
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index b4795698d8c2..3feb2456ecc4 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -503,6 +503,9 @@ enum rproc_features {
 	RPROC_MAX_FEATURES,
 };
 
+ /* device tree remoteproc Alias stem */
+ #define RPROC_ALIAS "rproc"
+
 /**
  * struct rproc - represents a physical remote processor device
  * @node: list node of this rproc object
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] remoteproc: keystone: use RPROC_ALIAS definition
  2026-01-28 10:31 [PATCH v2 0/2] Support remoteproc fixed device index from DT aliases Arnaud Pouliquen
  2026-01-28 10:31 ` [PATCH v2 1/2] remoteproc: core: support " Arnaud Pouliquen
@ 2026-01-28 10:31 ` Arnaud Pouliquen
  1 sibling, 0 replies; 5+ messages in thread
From: Arnaud Pouliquen @ 2026-01-28 10:31 UTC (permalink / raw)
  To: Bjorn Andersson, Mathieu Poirier
  Cc: linux-remoteproc, linux-kernel, linux-stm32, Andrew Davis,
	arnaud.pouliquen

The RPROC_ALIAS definition was introduced in remoteproc.h.
Reuse it for of_alias_get_id()to to align alias handling across
the code.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
---
 drivers/remoteproc/keystone_remoteproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/remoteproc/keystone_remoteproc.c b/drivers/remoteproc/keystone_remoteproc.c
index 4d6550b48567..cf8288d17afd 100644
--- a/drivers/remoteproc/keystone_remoteproc.c
+++ b/drivers/remoteproc/keystone_remoteproc.c
@@ -378,7 +378,7 @@ static int keystone_rproc_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	dsp_id = of_alias_get_id(np, "rproc");
+	dsp_id = of_alias_get_id(np, RPROC_ALIAS);
 	if (dsp_id < 0) {
 		dev_warn(dev, "device does not have an alias id\n");
 		return dsp_id;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] remoteproc: core: support fixed device index from DT aliases
  2026-01-28 10:31 ` [PATCH v2 1/2] remoteproc: core: support " Arnaud Pouliquen
@ 2026-02-04  0:57   ` Peng Fan
  2026-02-04  8:21     ` Arnaud POULIQUEN
  0 siblings, 1 reply; 5+ messages in thread
From: Peng Fan @ 2026-02-04  0:57 UTC (permalink / raw)
  To: Arnaud Pouliquen
  Cc: Bjorn Andersson, Mathieu Poirier, linux-remoteproc, linux-kernel,
	linux-stm32, Andrew Davis

On Wed, Jan 28, 2026 at 11:31:17AM +0100, Arnaud Pouliquen wrote:
>On systems with multiple remote processors, the remoteproc device
>enumeration is not stable as it depends on the probe ordering.
>As a result, the /sys/class/remoteproc/remoteproc<x> entries do not
>always refer to the same remote processor instance, which complicates
>userspace applications.
>
>Inspired by the SPI implementation, this commit allows board-specific
>numbering to be defined in device tree while still supporting dynamically
>registered remote processors.
>
>For instance, on STM32MP25 Soc this can be used by defining:
>
>    aliases {
>        rproc0 = &m33_rproc;
>        rproc1 = &m0_rproc;
>    };
>
>When a "rproc<x>" DT alias is present, use it to assign a fixed
>"/sys/class/remoteproc/remoteproc<x>" entry.
>If no remoteproc alias is defined, keep the legacy index allocation.
>If only some remoteproc instances have an alias, allocate dynamic
>index starting after the highest alias index declared.
>
>Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>

Tested this patch on i.MX943-EVK(patches for this platform still in my local)
with dual CM7 and one CM33S:
/sys/devices/platform/imx943-cm70/remoteproc/remoteproc1/firmware
/sys/devices/platform/imx943-cm33s/remoteproc/remoteproc0/firmware
/sys/devices/platform/imx943-cm71/remoteproc/remoteproc2/firmware

Tested-by: Peng Fan <peng.fan@nxp.com>

One nit below:

>---
>V2:
>- Introduces rproc_get_index based on Mathieu Poirier's suggestion.
>  An update compared to Mathieu's version is that the call to
>  ida_alloc_range is retained if an alias is found for the remote device,
>  to balance with ida_free().
>- Rename DT alias stem from "remoteproc" to "rproc" to be consistent with
>  keytone driver.
>---
> drivers/remoteproc/remoteproc_core.c | 40 ++++++++++++++++++++++++++--
> include/linux/remoteproc.h           |  3 +++
> 2 files changed, 41 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
>index aada2780b343..38d6eb1c9483 100644
>--- a/drivers/remoteproc/remoteproc_core.c
>+++ b/drivers/remoteproc/remoteproc_core.c
>@@ -2433,6 +2433,43 @@ static int rproc_alloc_ops(struct rproc *rproc, const struct rproc_ops *ops)
> 	return 0;
> }
> 
>+/**
>+ * rproc_get_index - assign a unique device index for a remote processor
>+ * @dev: device associated with the remote processor
>+ *
>+ * Look for a static index coming from the "rproc" DT alias
>+ * (e.g. "rproc0"). If none is found, start allocating
>+ * dynamic IDs after the highest alias in use.
>+ *
>+ * Return: a non-negative index on success, or a negative error code on failure.
>+ */
>+static int rproc_get_index(struct device *dev)
>+{
>+	int index;
>+
>+	/* No DT to deal with */
>+	if (!dev->of_node)
>+		goto legacy;
>+
>+	/* See if an alias has been assigned to this remoteproc */
>+	index = of_alias_get_id(dev->of_node, RPROC_ALIAS);
>+	if (index >= 0)
>+		return  ida_alloc_range(&rproc_dev_index, index, index,
>+					GFP_KERNEL);

Nit: "return ida_alloc_range"

Regards,
Peng

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] remoteproc: core: support fixed device index from DT aliases
  2026-02-04  0:57   ` Peng Fan
@ 2026-02-04  8:21     ` Arnaud POULIQUEN
  0 siblings, 0 replies; 5+ messages in thread
From: Arnaud POULIQUEN @ 2026-02-04  8:21 UTC (permalink / raw)
  To: Peng Fan
  Cc: Bjorn Andersson, Mathieu Poirier, linux-remoteproc, linux-kernel,
	linux-stm32, Andrew Davis

Hi Peng,

On 2/4/26 01:57, Peng Fan wrote:
> On Wed, Jan 28, 2026 at 11:31:17AM +0100, Arnaud Pouliquen wrote:
>> On systems with multiple remote processors, the remoteproc device
>> enumeration is not stable as it depends on the probe ordering.
>> As a result, the /sys/class/remoteproc/remoteproc<x> entries do not
>> always refer to the same remote processor instance, which complicates
>> userspace applications.
>>
>> Inspired by the SPI implementation, this commit allows board-specific
>> numbering to be defined in device tree while still supporting dynamically
>> registered remote processors.
>>
>> For instance, on STM32MP25 Soc this can be used by defining:
>>
>>     aliases {
>>         rproc0 = &m33_rproc;
>>         rproc1 = &m0_rproc;
>>     };
>>
>> When a "rproc<x>" DT alias is present, use it to assign a fixed
>> "/sys/class/remoteproc/remoteproc<x>" entry.
>> If no remoteproc alias is defined, keep the legacy index allocation.
>> If only some remoteproc instances have an alias, allocate dynamic
>> index starting after the highest alias index declared.
>>
>> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
> 
> Tested this patch on i.MX943-EVK(patches for this platform still in my local)
> with dual CM7 and one CM33S:
> /sys/devices/platform/imx943-cm70/remoteproc/remoteproc1/firmware
> /sys/devices/platform/imx943-cm33s/remoteproc/remoteproc0/firmware
> /sys/devices/platform/imx943-cm71/remoteproc/remoteproc2/firmware
> 
> Tested-by: Peng Fan <peng.fan@nxp.com>
> 
> One nit below:
> 
>> ---
>> V2:
>> - Introduces rproc_get_index based on Mathieu Poirier's suggestion.
>>   An update compared to Mathieu's version is that the call to
>>   ida_alloc_range is retained if an alias is found for the remote device,
>>   to balance with ida_free().
>> - Rename DT alias stem from "remoteproc" to "rproc" to be consistent with
>>   keytone driver.
>> ---
>> drivers/remoteproc/remoteproc_core.c | 40 ++++++++++++++++++++++++++--
>> include/linux/remoteproc.h           |  3 +++
>> 2 files changed, 41 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
>> index aada2780b343..38d6eb1c9483 100644
>> --- a/drivers/remoteproc/remoteproc_core.c
>> +++ b/drivers/remoteproc/remoteproc_core.c
>> @@ -2433,6 +2433,43 @@ static int rproc_alloc_ops(struct rproc *rproc, const struct rproc_ops *ops)
>> 	return 0;
>> }
>>
>> +/**
>> + * rproc_get_index - assign a unique device index for a remote processor
>> + * @dev: device associated with the remote processor
>> + *
>> + * Look for a static index coming from the "rproc" DT alias
>> + * (e.g. "rproc0"). If none is found, start allocating
>> + * dynamic IDs after the highest alias in use.
>> + *
>> + * Return: a non-negative index on success, or a negative error code on failure.
>> + */
>> +static int rproc_get_index(struct device *dev)
>> +{
>> +	int index;
>> +
>> +	/* No DT to deal with */
>> +	if (!dev->of_node)
>> +		goto legacy;
>> +
>> +	/* See if an alias has been assigned to this remoteproc */
>> +	index = of_alias_get_id(dev->of_node, RPROC_ALIAS);
>> +	if (index >= 0)
>> +		return  ida_alloc_range(&rproc_dev_index, index, index,
>> +					GFP_KERNEL);
> 
> Nit: "return ida_alloc_range"

Thanks for the test and the review!
I will send a V3

Arnaud

> 
> Regards,
> Peng


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-02-04  8:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-28 10:31 [PATCH v2 0/2] Support remoteproc fixed device index from DT aliases Arnaud Pouliquen
2026-01-28 10:31 ` [PATCH v2 1/2] remoteproc: core: support " Arnaud Pouliquen
2026-02-04  0:57   ` Peng Fan
2026-02-04  8:21     ` Arnaud POULIQUEN
2026-01-28 10:31 ` [PATCH v2 2/2] remoteproc: keystone: use RPROC_ALIAS definition Arnaud Pouliquen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox