Skip to contentSkip to conversation

remoteproc: uclass: Add methods to load firmware to rproc and boot rproc

PATCH Superseded MD Danish Anwar 4 participants 13 messages Feb 28, 2024 – Mar 21, 2024

Subsystems (4)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 remoteproc: uclass: Add methods to load firmware to rproc and boot rproc

Add APIs to set a firmware_name to a rproc and boot the rproc with the same firmware.

Clients can call rproc_set_firmware() API to set firmware_name for a rproc whereas rproc_boot() will load the firmware set by rproc_set_firmware() to a buffer by calling request_firmware_into_buf(). rproc_boot() will then load the firmware file to the remote processor and start the remote processor.

Also include "fs-loader.h" and make remoteproc driver select FS_LOADER in Kconfig so that we can call request_firmware_into_buf() from remoteproc driver.

---
Changes from v5 to v6:
*) Collected Acked-by tag from Ravi Gunasekaran <[email protected]> *) Fixed few typos as pointed out by Roger Quadros <[email protected]> *) Added if condition to check if uc_pdata->fw_name exists and free it
before the strndup as suggested by Roger Quadros <[email protected]>

Changes from v4 to v5:
*) Added Kconfig option REMOTEPROC_MAX_FW_SIZE to set max firmware size
that can be loaded to a rproc.
*) Added freeing of address in rproc_boot() as pointed out by Ravi. *) Allocating the address at a later point in rproc_boot() *) Rebased on latest u-boot/master [commit
9e00b6993f724da9699ef12573307afea8c19284]

Changes from v3 to v4:
*) No functional change. Splitted the patch out of the series as suggested
by Nishant.
*) Droppped the RFC tag.

v5: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/

 drivers/remoteproc/Kconfig        |   8 +++
 drivers/remoteproc/rproc-uclass.c | 102 ++++++++++++++++++++++++++++++
 include/remoteproc.h              |  34 ++++++++++
 3 files changed, 144 insertions(+)
drivers/remoteproc/Kconfig +8 -0
index 781de530af..9f9877931c 100644
@@ -10,6 +10,7 @@ menu "Remote Processor drivers"
 # All users should depend on DM
 config REMOTEPROC
 	bool
+	select FS_LOADER
 	depends on DM
 
 # Please keep the configuration alphabetically sorted.
@@ -102,4 +103,11 @@ config REMOTEPROC_TI_IPU
 	help
 	  Say 'y' here to add support for TI' K3 remoteproc driver.
 
+config REMOTEPROC_MAX_FW_SIZE
+	hex "Maximum size of firmware file that needs to be loaded to the remote processor"
+	default 0x10000
+	help
+	  Maximum size of the firmware file (elf, binary) that needs to be
+	  loaded to the remote processor.
+
 endmenu
drivers/remoteproc/rproc-uclass.c +102 -0

111 lines not on this page · raw message

include/remoteproc.h +34 -0
index 91a88791a4..6f8068e149 100644
@@ -403,6 +403,7 @@ enum rproc_mem_type {
  * @name: Platform-specific way of naming the Remote proc
  * @mem_type: one of 'enum rproc_mem_type'
  * @driver_plat_data: driver specific platform data that may be needed.
+ * @fw_name: firmware name
  *
  * This can be accessed with dev_get_uclass_plat() for any UCLASS_REMOTEPROC
  * device.
@@ -412,6 +413,7 @@ struct dm_rproc_uclass_pdata {
 	const char *name;
 	enum rproc_mem_type mem_type;
 	void *driver_plat_data;
+	char *fw_name;
 };
 
 /**
@@ -705,6 +707,34 @@ unsigned long rproc_parse_resource_table(struct udevice *dev,
 struct resource_table *rproc_find_resource_table(struct udevice *dev,
 						 unsigned int addr,
 						 int *tablesz);
+/**
+ * rproc_set_firmware() - assign a new firmware name
+ * @rproc_dev: device for which new firmware name is being assigned
+ * @fw_name: new firmware name to be assigned
+ *
+ * This function allows remoteproc drivers or clients to configure a custom
+ * firmware name. The function does not trigger a remote processor boot,
+ * only sets the firmware name used for a subsequent boot.
+ *
+ * This function sets the fw_name field in uclass pdata of the Remote proc
+ *
+ * Return: 0 on success or a negative value upon failure
+ */
+int rproc_set_firmware(struct udevice *rproc_dev, const char *fw_name);
+
+/**
+ * rproc_boot() - boot a remote processor
+ * @rproc_dev: rproc device to boot
+ *
+ * Boot a remote processor (i.e. load its firmware, power it on, ...).
+ *
+ * This function first loads the firmware set in the uclass pdata of Remote
+ * processor to a buffer and then loads firmware to the remote processor
+ * using rproc_load().
+ *
+ * Return: 0 on success, and an appropriate error value otherwise
+ */
+int rproc_boot(struct udevice *rproc_dev);
 #else
 static inline int rproc_init(void) { return -ENOSYS; }
 static inline int rproc_dev_init(int id) { return -ENOSYS; }
@@ -744,6 +774,10 @@ static inline int rproc_elf_load_rsc_table(struct udevice *dev, ulong fw_addr,
 					   ulong fw_size, ulong *rsc_addr,
 					   ulong *rsc_size)
 { return -ENOSYS; }
+static inline int rproc_set_firmware(struct udevice *rproc_dev, const char *fw_name)
+{ return -ENOSYS; }
+static inline int rproc_boot(struct udevice *rproc_dev)
+{ return -ENOSYS; }
 #endif
 
 #endif	/* _RPROC_H_ */
Signature · 1 line
2.34.1
maintainer Reviewed-by on v6 1/1
#1 lore raw
Quoted 9 lines · MD Danish Anwar

Add APIs to set a firmware_name to a rproc and boot the rproc with the same firmware.

Clients can call rproc_set_firmware() API to set firmware_name for a rproc whereas rproc_boot() will load the firmware set by rproc_set_firmware() to a buffer by calling request_firmware_into_buf(). rproc_boot() will then load the firmware file to the remote processor and start the remote processor.

Quoted 6 lines

Also include "fs-loader.h" and make remoteproc driver select FS_LOADER in Kconfig so that we can call request_firmware_into_buf() from remoteproc driver.

#2 lore raw
Quoted 12 lines · Roger Quadros
Quoted 9 lines · MD Danish Anwar

Add APIs to set a firmware_name to a rproc and boot the rproc with the same firmware.

Clients can call rproc_set_firmware() API to set firmware_name for a rproc whereas rproc_boot() will load the firmware set by rproc_set_firmware() to a buffer by calling request_firmware_into_buf(). rproc_boot() will then load the firmware file to the remote processor and start the remote processor.

Quoted 8 lines
Quoted 6 lines

Also include "fs-loader.h" and make remoteproc driver select FS_LOADER in Kconfig so that we can call request_firmware_into_buf() from remoteproc driver.

Hi Tom,

Can you please pick this patch. There are no active comments on this patch and Roger and Ravi has reviewed / acked the patch.

Signature · 2 lines
Thanks and Regards,
Danish
#3 lore raw
Quoted 20 lines · MD Danish Anwar
Quoted 19 lines · Roger Quadros
Quoted 15 lines · MD Danish Anwar

Add APIs to set a firmware_name to a rproc and boot the rproc with the same firmware.

Clients can call rproc_set_firmware() API to set firmware_name for a rproc whereas rproc_boot() will load the firmware set by rproc_set_firmware() to a buffer by calling request_firmware_into_buf(). rproc_boot() will then load the firmware file to the remote processor and start the remote processor.

Also include "fs-loader.h" and make remoteproc driver select FS_LOADER in Kconfig so that we can call request_firmware_into_buf() from remoteproc driver.

Quoted 6 lines
Quoted 1 line

Hi Tom,

Can you please pick this patch. There are no active comments on this patch and Roger and Ravi has reviewed / acked the patch.

Yes, I'm going to give people a little longer to comment / review and will pull this to -next soon.

Signature · 1 line
Tom
#4 lore raw
In reply to MD Danish Anwar
Quoted 10 lines · MD Danish Anwar

Add APIs to set a firmware_name to a rproc and boot the rproc with the

same firmware.

Clients can call rproc_set_firmware() API to set firmware_name for a rproc whereas rproc_boot() will load the firmware set by rproc_set_firmware() to a buffer by calling request_firmware_into_buf(). rproc_boot() will then load the firmware file to the remote processor and start the remote processor.

Quoted 7 lines

Also include "fs-loader.h" and make remoteproc driver select FS_LOADER in Kconfig so that we can call request_firmware_into_buf() from remoteproc driver.

This breaks building on am64x_evm_r5 am65x_evm_r5_usbdfu am65x_evm_r5_usbmsc in next currently, thanks.

Signature · 1 line
Tom
#5 lore raw
Quoted 15 lines · Tom Rini
Quoted 14 lines · MD Danish Anwar

Add APIs to set a firmware_name to a rproc and boot the rproc with the

same firmware.

Clients can call rproc_set_firmware() API to set firmware_name for a rproc whereas rproc_boot() will load the firmware set by rproc_set_firmware() to a buffer by calling request_firmware_into_buf(). rproc_boot() will then load the firmware file to the remote processor and start the remote processor.

Also include "fs-loader.h" and make remoteproc driver select FS_LOADER in Kconfig so that we can call request_firmware_into_buf() from remoteproc driver.

Quoted 7 lines
Quoted 3 lines

This breaks building on am64x_evm_r5 am65x_evm_r5_usbdfu am65x_evm_r5_usbmsc in next currently, thanks.

I will work on fixing this build error and re-spin the patch.

Signature · 2 lines
Thanks and Regards,
Md Danish Anwar
#6 lore raw
Quoted 18 lines · Md Danish
Quoted 15 lines · Tom Rini
Quoted 14 lines · MD Danish Anwar

Add APIs to set a firmware_name to a rproc and boot the rproc with the

same firmware.

Clients can call rproc_set_firmware() API to set firmware_name for a rproc whereas rproc_boot() will load the firmware set by rproc_set_firmware() to a buffer by calling request_firmware_into_buf(). rproc_boot() will then load the firmware file to the remote processor and start the remote processor.

Also include "fs-loader.h" and make remoteproc driver select FS_LOADER in Kconfig so that we can call request_firmware_into_buf() from remoteproc driver.

Quoted 9 lines
Quoted 7 lines
Quoted 3 lines

This breaks building on am64x_evm_r5 am65x_evm_r5_usbdfu am65x_evm_r5_usbmsc in next currently, thanks.

I will work on fixing this build error and re-spin the patch.

Hi Tom, Roger,

This patch adds "request_firmware_into_buf()" in the rproc driver. To use this API, FS_LOADER is needed. So I am adding "select FS_LOADER" in REMOTEPROC Kconfig option. As a result whenever REMOTEPROC is enabled, FS_LOADER also gets enabled.

Now arch/arm/mach-k3/common.c [1] and arch/arm/mach-omap2/boot-common.c
[2] has a "load_firmware()" API which calls fs-loader APIs and they have below if condition before calling fs-loader APIs.

if (!IS_ENABLED(CONFIG_FS_LOADER))

		return 0;

Till now, CONFIG_FS_LOADER was not set as a result the load_firmware() API in above mentioned files, was returning 0.

Now as this patch enables CONFIG_FS_LOADER, as a result the code after the if check starts getting executed and it tries to look for get_fs_loader() and other fs-loader APIs but this is done at SPL and at this time FS_LOADER is not built yet as a result we see below error. The if checks only checks for CONFIG_FS_LOADER but not for CONFIG_SPL_FS_LOADER.

AR spl/boot/built-in.o
LD spl/u-boot-spl
arm-none-linux-gnueabihf-ld.bfd: arch/arm/mach-k3/common.o: in function `load_firmware':
/home/danish/workspace/u-boot/arch/arm/mach-k3/common.c:184: undefined reference to `get_fs_loader' arm-none-linux-gnueabihf-ld.bfd:
/home/danish/workspace/u-boot/arch/arm/mach-k3/common.c:185: undefined reference to `request_firmware_into_buf'
make[2]: *** [/home/danish/workspace/u-boot/scripts/Makefile.spl:527:
spl/u-boot-spl] Error 1
make[1]: *** [/home/danish/workspace/u-boot/Makefile:2055:
spl/u-boot-spl] Error 2
make[1]: Leaving directory '/home/danish/uboot_images/am64x/r5'
make: *** [Makefile:177: sub-make] Error 2

This bug has always been there but as CONFIG_FS_LOADER was never enabled, this build error was never seen as the load_firmware() API will return 0 without calling fs-loader APIs.

Now that this patch enables CONFIG_FS_LOADER, the bug gets exposed and build error is seen.

My opinion here would be, to check for CONFIG_IS_ENABLED(FS_LOADER) instead of IS_ENABLED(CONFIG_FS_LOADER) as the former will check for the appropriate config option (CONFIG_SPL_FS_LOADER / CONFIG_FS_LOADER) based on the build stage.

I tested with the below diff and I don't see build errors with am64x_evm_r5, am65x_evm_r5_usbdfu, am65x_evm_r5_usbmsc configs.

arch/arm/mach-k3/common.c +0 -0
index f411366778..6792ff7467 100644
@@ -162,7 +162,7 @@ int load_firmware(char *name_fw, char

*name_loadaddr, u32 *loadaddr)

        char *name = NULL;
        int size = 0;

- if (!IS_ENABLED(CONFIG_FS_LOADER))
+ if (!CONFIG_IS_ENABLED(FS_LOADER))

                return 0;

        *loadaddr = 0;
(quoted diff) +0 -0

b/arch/arm/mach-omap2/boot-common.c
index 57917da25c..aa0ab13d5f 100644

arch/arm/mach-omap2/boot-common.c +1 -1
@@ -190,7 +190,7 @@ int load_firmware(char *name_fw, u32 *loadaddr)
        struct udevice *fsdev;
        int size = 0;
 
-       if (!IS_ENABLED(CONFIG_FS_LOADER))
+       if (!CONFIG_IS_ENABLED(FS_LOADER))
                return 0;
 
        if (!*loadaddr)

Tom, Roger, Please let me know if this looks ok.
If it's ok, I will post this diff as a separate patch and once that is merged Tom can merge this patch or I can send a v7 if needed.

[1]
https://elixir.bootlin.com/u-boot/latest/source/arch/arm/mach-k3/common.c#L159
[2]
https://elixir.bootlin.com/u-boot/latest/source/arch/arm/mach-omap2/boot-common.c#L188

Signature · 2 lines
Thanks and Regards,
Danish
#7 lore raw
Quoted 116 lines · MD Danish Anwar
Quoted 18 lines · Md Danish
Quoted 15 lines · Tom Rini
Quoted 14 lines · MD Danish Anwar

Add APIs to set a firmware_name to a rproc and boot the rproc with the

same firmware.

Clients can call rproc_set_firmware() API to set firmware_name for a rproc whereas rproc_boot() will load the firmware set by rproc_set_firmware() to a buffer by calling request_firmware_into_buf(). rproc_boot() will then load the firmware file to the remote processor and start the remote processor.

Also include "fs-loader.h" and make remoteproc driver select FS_LOADER in Kconfig so that we can call request_firmware_into_buf() from remoteproc driver.

Quoted 9 lines
Quoted 7 lines
Quoted 3 lines

This breaks building on am64x_evm_r5 am65x_evm_r5_usbdfu am65x_evm_r5_usbmsc in next currently, thanks.

I will work on fixing this build error and re-spin the patch.

Hi Tom, Roger,

This patch adds "request_firmware_into_buf()" in the rproc driver. To use this API, FS_LOADER is needed. So I am adding "select FS_LOADER" in REMOTEPROC Kconfig option. As a result whenever REMOTEPROC is enabled, FS_LOADER also gets enabled.

Now arch/arm/mach-k3/common.c [1] and arch/arm/mach-omap2/boot-common.c
[2] has a "load_firmware()" API which calls fs-loader APIs and they have below if condition before calling fs-loader APIs.

if (!IS_ENABLED(CONFIG_FS_LOADER))

		return 0;

Till now, CONFIG_FS_LOADER was not set as a result the load_firmware() API in above mentioned files, was returning 0.

Now as this patch enables CONFIG_FS_LOADER, as a result the code after the if check starts getting executed and it tries to look for get_fs_loader() and other fs-loader APIs but this is done at SPL and at this time FS_LOADER is not built yet as a result we see below error. The if checks only checks for CONFIG_FS_LOADER but not for CONFIG_SPL_FS_LOADER.

AR spl/boot/built-in.o
LD spl/u-boot-spl
arm-none-linux-gnueabihf-ld.bfd: arch/arm/mach-k3/common.o: in function `load_firmware':
/home/danish/workspace/u-boot/arch/arm/mach-k3/common.c:184: undefined reference to `get_fs_loader' arm-none-linux-gnueabihf-ld.bfd:
/home/danish/workspace/u-boot/arch/arm/mach-k3/common.c:185: undefined reference to `request_firmware_into_buf'
make[2]: *** [/home/danish/workspace/u-boot/scripts/Makefile.spl:527:
spl/u-boot-spl] Error 1
make[1]: *** [/home/danish/workspace/u-boot/Makefile:2055:
spl/u-boot-spl] Error 2
make[1]: Leaving directory '/home/danish/uboot_images/am64x/r5'
make: *** [Makefile:177: sub-make] Error 2

This bug has always been there but as CONFIG_FS_LOADER was never enabled, this build error was never seen as the load_firmware() API will return 0 without calling fs-loader APIs.

Now that this patch enables CONFIG_FS_LOADER, the bug gets exposed and build error is seen.

My opinion here would be, to check for CONFIG_IS_ENABLED(FS_LOADER) instead of IS_ENABLED(CONFIG_FS_LOADER) as the former will check for the appropriate config option (CONFIG_SPL_FS_LOADER / CONFIG_FS_LOADER) based on the build stage.

I tested with the below diff and I don't see build errors with am64x_evm_r5, am65x_evm_r5_usbdfu, am65x_evm_r5_usbmsc configs.

arch/arm/mach-k3/common.c +1 -1
index f411366778..6792ff7467 100644
@@ -162,7 +162,7 @@ int load_firmware(char *name_fw, char
 *name_loadaddr, u32 *loadaddr)
        char *name = NULL;
        int size = 0;
 
-       if (!IS_ENABLED(CONFIG_FS_LOADER))
+       if (!CONFIG_IS_ENABLED(FS_LOADER))
                return 0;
 
        *loadaddr = 0;
arch/arm/mach-omap2/boot-common.c +1 -1
index 57917da25c..aa0ab13d5f 100644
@@ -190,7 +190,7 @@ int load_firmware(char *name_fw, u32 *loadaddr)
        struct udevice *fsdev;
        int size = 0;
 
-       if (!IS_ENABLED(CONFIG_FS_LOADER))
+       if (!CONFIG_IS_ENABLED(FS_LOADER))
                return 0;
 
        if (!*loadaddr)
Quoted 3 lines

Tom, Roger, Please let me know if this looks ok.
If it's ok, I will post this diff as a separate patch and once that is merged Tom can merge this patch or I can send a v7 if needed.

Yes, this seems like the right path, thanks.

Signature · 1 line
Tom
#8 lore raw
Quoted 114 lines · Tom Rini
Quoted 113 lines · MD Danish Anwar
Quoted 18 lines · Md Danish
Quoted 15 lines · Tom Rini
Quoted 14 lines · MD Danish Anwar

Add APIs to set a firmware_name to a rproc and boot the rproc with the

same firmware.

Clients can call rproc_set_firmware() API to set firmware_name for a rproc whereas rproc_boot() will load the firmware set by rproc_set_firmware() to a buffer by calling request_firmware_into_buf(). rproc_boot() will then load the firmware file to the remote processor and start the remote processor.

Also include "fs-loader.h" and make remoteproc driver select FS_LOADER in Kconfig so that we can call request_firmware_into_buf() from remoteproc driver.

Quoted 9 lines
Quoted 7 lines
Quoted 3 lines

This breaks building on am64x_evm_r5 am65x_evm_r5_usbdfu am65x_evm_r5_usbmsc in next currently, thanks.

I will work on fixing this build error and re-spin the patch.

Hi Tom, Roger,

This patch adds "request_firmware_into_buf()" in the rproc driver. To use this API, FS_LOADER is needed. So I am adding "select FS_LOADER" in REMOTEPROC Kconfig option. As a result whenever REMOTEPROC is enabled, FS_LOADER also gets enabled.

Now arch/arm/mach-k3/common.c [1] and arch/arm/mach-omap2/boot-common.c
[2] has a "load_firmware()" API which calls fs-loader APIs and they have below if condition before calling fs-loader APIs.

if (!IS_ENABLED(CONFIG_FS_LOADER))

		return 0;

Till now, CONFIG_FS_LOADER was not set as a result the load_firmware() API in above mentioned files, was returning 0.

Now as this patch enables CONFIG_FS_LOADER, as a result the code after the if check starts getting executed and it tries to look for get_fs_loader() and other fs-loader APIs but this is done at SPL and at this time FS_LOADER is not built yet as a result we see below error. The if checks only checks for CONFIG_FS_LOADER but not for CONFIG_SPL_FS_LOADER.

AR spl/boot/built-in.o
LD spl/u-boot-spl
arm-none-linux-gnueabihf-ld.bfd: arch/arm/mach-k3/common.o: in function `load_firmware':
/home/danish/workspace/u-boot/arch/arm/mach-k3/common.c:184: undefined reference to `get_fs_loader' arm-none-linux-gnueabihf-ld.bfd:
/home/danish/workspace/u-boot/arch/arm/mach-k3/common.c:185: undefined reference to `request_firmware_into_buf'
make[2]: *** [/home/danish/workspace/u-boot/scripts/Makefile.spl:527:
spl/u-boot-spl] Error 1
make[1]: *** [/home/danish/workspace/u-boot/Makefile:2055:
spl/u-boot-spl] Error 2
make[1]: Leaving directory '/home/danish/uboot_images/am64x/r5'
make: *** [Makefile:177: sub-make] Error 2

This bug has always been there but as CONFIG_FS_LOADER was never enabled, this build error was never seen as the load_firmware() API will return 0 without calling fs-loader APIs.

Now that this patch enables CONFIG_FS_LOADER, the bug gets exposed and build error is seen.

My opinion here would be, to check for CONFIG_IS_ENABLED(FS_LOADER) instead of IS_ENABLED(CONFIG_FS_LOADER) as the former will check for the appropriate config option (CONFIG_SPL_FS_LOADER / CONFIG_FS_LOADER) based on the build stage.

I tested with the below diff and I don't see build errors with am64x_evm_r5, am65x_evm_r5_usbdfu, am65x_evm_r5_usbmsc configs.

arch/arm/mach-k3/common.c +1 -1
index f411366778..6792ff7467 100644
@@ -162,7 +162,7 @@ int load_firmware(char *name_fw, char
 *name_loadaddr, u32 *loadaddr)
        char *name = NULL;
        int size = 0;
 
-       if (!IS_ENABLED(CONFIG_FS_LOADER))
+       if (!CONFIG_IS_ENABLED(FS_LOADER))
                return 0;
 
        *loadaddr = 0;
arch/arm/mach-omap2/boot-common.c +1 -1
index 57917da25c..aa0ab13d5f 100644
@@ -190,7 +190,7 @@ int load_firmware(char *name_fw, u32 *loadaddr)
        struct udevice *fsdev;
        int size = 0;
 
-       if (!IS_ENABLED(CONFIG_FS_LOADER))
+       if (!CONFIG_IS_ENABLED(FS_LOADER))
                return 0;
 
Quoted 9 lines
Quoted 6 lines
arch/arm/mach-omap2/boot-common.c +0 -0
        if (!*loadaddr)

Tom, Roger, Please let me know if this looks ok.
If it's ok, I will post this diff as a separate patch and once that is merged Tom can merge this patch or I can send a v7 if needed.

Yes, this seems like the right path, thanks.

Thanks Tom. Posted this diff as patch
https://lore.kernel.org/all/[email protected]/

Signature · 2 lines
Thanks and Regards,
Md Danish Anwar
#9 lore raw
In reply to MD Danish Anwar
Quoted 50 lines · MD Danish Anwar

Add APIs to set a firmware_name to a rproc and boot the rproc with the same firmware.

Clients can call rproc_set_firmware() API to set firmware_name for a rproc whereas rproc_boot() will load the firmware set by rproc_set_firmware() to a buffer by calling request_firmware_into_buf(). rproc_boot() will then load the firmware file to the remote processor and start the remote processor.

Also include "fs-loader.h" and make remoteproc driver select FS_LOADER in Kconfig so that we can call request_firmware_into_buf() from remoteproc driver.

---
Changes from v5 to v6:
*) Collected Acked-by tag from Ravi Gunasekaran <[email protected]> *) Fixed few typos as pointed out by Roger Quadros <[email protected]> *) Added if condition to check if uc_pdata->fw_name exists and free it
before the strndup as suggested by Roger Quadros <[email protected]>

Changes from v4 to v5:
*) Added Kconfig option REMOTEPROC_MAX_FW_SIZE to set max firmware size
that can be loaded to a rproc.
*) Added freeing of address in rproc_boot() as pointed out by Ravi. *) Allocating the address at a later point in rproc_boot() *) Rebased on latest u-boot/master [commit
9e00b6993f724da9699ef12573307afea8c19284]

Changes from v3 to v4:
*) No functional change. Splitted the patch out of the series as suggested
by Nishant.
*) Droppped the RFC tag.

v5: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/

 drivers/remoteproc/Kconfig        |   8 +++
 drivers/remoteproc/rproc-uclass.c | 102 ++++++++++++++++++++++++++++++
 include/remoteproc.h              |  34 ++++++++++
 3 files changed, 144 insertions(+)
drivers/remoteproc/Kconfig +0 -0
index 781de530af..9f9877931c 100644

drivers/remoteproc/Kconfig menu "Remote Processor drivers" · line 16

Quoted 7 lines
drivers/remoteproc/Kconfig +1 -0
@@ -10,6 +10,7 @@ menu "Remote Processor drivers"
 # All users should depend on DM
 config REMOTEPROC
 	bool
+	select FS_LOADER
 	depends on DM
 
 # Please keep the configuration alphabetically sorted.

Can we not make the FS_LOADER portion optional? I didn't realize how many non-TI platforms this impacted. And even then it's possible I assume that custom designs will load the firmwares in other manners.

Signature · 1 line
Tom
#10 lore raw

Hi Tom,

Quoted 58 lines · Tom Rini
Quoted 56 lines · MD Danish Anwar

Add APIs to set a firmware_name to a rproc and boot the rproc with the same firmware.

Clients can call rproc_set_firmware() API to set firmware_name for a rproc whereas rproc_boot() will load the firmware set by rproc_set_firmware() to a buffer by calling request_firmware_into_buf(). rproc_boot() will then load the firmware file to the remote processor and start the remote processor.

Also include "fs-loader.h" and make remoteproc driver select FS_LOADER in Kconfig so that we can call request_firmware_into_buf() from remoteproc driver.

---
Changes from v5 to v6:
*) Collected Acked-by tag from Ravi Gunasekaran <[email protected]> *) Fixed few typos as pointed out by Roger Quadros <[email protected]> *) Added if condition to check if uc_pdata->fw_name exists and free it
before the strndup as suggested by Roger Quadros <[email protected]>

Changes from v4 to v5:
*) Added Kconfig option REMOTEPROC_MAX_FW_SIZE to set max firmware size
that can be loaded to a rproc.
*) Added freeing of address in rproc_boot() as pointed out by Ravi. *) Allocating the address at a later point in rproc_boot() *) Rebased on latest u-boot/master [commit
9e00b6993f724da9699ef12573307afea8c19284]

Changes from v3 to v4:
*) No functional change. Splitted the patch out of the series as suggested
by Nishant.
*) Droppped the RFC tag.

v5: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/

 drivers/remoteproc/Kconfig        |   8 +++
 drivers/remoteproc/rproc-uclass.c | 102 ++++++++++++++++++++++++++++++
 include/remoteproc.h              |  34 ++++++++++
 3 files changed, 144 insertions(+)
drivers/remoteproc/Kconfig +1 -0
index 781de530af..9f9877931c 100644
@@ -10,6 +10,7 @@ menu "Remote Processor drivers"
 # All users should depend on DM
 config REMOTEPROC
 	bool
+	select FS_LOADER
 	depends on DM
 
Quoted 6 lines

drivers/remoteproc/Kconfig menu "Remote Processor drivers" · line 16

Quoted 1 line
drivers/remoteproc/Kconfig +0 -0
 # Please keep the configuration alphabetically sorted.

Can we not make the FS_LOADER portion optional? I didn't realize how many non-TI platforms this impacted. And even then it's possible I assume that custom designs will load the firmwares in other manners.

Yes we can. We can wrap the remoteproc APIs using FS_LOADER in #ifdef CONFIG_FS_LOADER. And instead of REMOTEPROC driver selecting FS_LOADER, the clinet driver (ICSSG in this case) who is calling those remoteproc APIs will select FS_LOADER and enable it.

This will make sure that other platforms (ti or non-ti) that doesn't support ICSSG but enables Remoteproc, will not enable FS_LOADER. This way we are not forcing other platforms using remoteproc to enable FS_LOADER. In this case the APIs will not get built.

Now FS_LOADER will only be enabled when there is a client driver that uses rproc_boot() APIs. It's upto the client driver to enable FS_LOADER

below is the diff,

drivers/remoteproc/Kconfig +0 -1
index 9f9877931c..a49802c132 100644
@@ -10,7 +10,6 @@ menu "Remote Processor drivers"
 # All users should depend on DM
 config REMOTEPROC
        bool
-       select FS_LOADER
        depends on DM
 
 # Please keep the configuration alphabetically sorted.
(quoted diff) +0 -0

b/drivers/remoteproc/rproc-uclass.c
index f4f22a3851..a6a8be5009 100644

drivers/remoteproc/rproc-uclass.c +0 -0
@@ -994,6 +994,7 @@ int rproc_set_firmware(struct udevice *rproc_dev,

const char *fw_name)

        return 0;

}

+#ifdef CONFIG_FS_LOADER
int rproc_boot(struct udevice *rproc_dev)

 {
        struct dm_rproc_uclass_pdata *uc_pdata;
@@ -1063,3 +1064,4 @@ free_buffer:
        free(addr);
        return ret;

}
+#endif

Let me know if this looks ok. If it's ok I will post v7 with this change.

Signature · 2 lines
Thanks and Regards,
Danish
#11 lore raw
Quoted 115 lines · MD Danish Anwar

Hi Tom,

Quoted 58 lines · Tom Rini
Quoted 56 lines · MD Danish Anwar

Add APIs to set a firmware_name to a rproc and boot the rproc with the same firmware.

Clients can call rproc_set_firmware() API to set firmware_name for a rproc whereas rproc_boot() will load the firmware set by rproc_set_firmware() to a buffer by calling request_firmware_into_buf(). rproc_boot() will then load the firmware file to the remote processor and start the remote processor.

Also include "fs-loader.h" and make remoteproc driver select FS_LOADER in Kconfig so that we can call request_firmware_into_buf() from remoteproc driver.

---
Changes from v5 to v6:
*) Collected Acked-by tag from Ravi Gunasekaran <[email protected]> *) Fixed few typos as pointed out by Roger Quadros <[email protected]> *) Added if condition to check if uc_pdata->fw_name exists and free it
before the strndup as suggested by Roger Quadros <[email protected]>

Changes from v4 to v5:
*) Added Kconfig option REMOTEPROC_MAX_FW_SIZE to set max firmware size
that can be loaded to a rproc.
*) Added freeing of address in rproc_boot() as pointed out by Ravi. *) Allocating the address at a later point in rproc_boot() *) Rebased on latest u-boot/master [commit
9e00b6993f724da9699ef12573307afea8c19284]

Changes from v3 to v4:
*) No functional change. Splitted the patch out of the series as suggested
by Nishant.
*) Droppped the RFC tag.

v5: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/

 drivers/remoteproc/Kconfig        |   8 +++
 drivers/remoteproc/rproc-uclass.c | 102 ++++++++++++++++++++++++++++++
 include/remoteproc.h              |  34 ++++++++++
 3 files changed, 144 insertions(+)
drivers/remoteproc/Kconfig +1 -0
index 781de530af..9f9877931c 100644
@@ -10,6 +10,7 @@ menu "Remote Processor drivers"
 # All users should depend on DM
 config REMOTEPROC
 	bool
+	select FS_LOADER
 	depends on DM
 
Quoted 6 lines

drivers/remoteproc/Kconfig menu "Remote Processor drivers" · line 15

Quoted 1 line
drivers/remoteproc/Kconfig +0 -0
 # Please keep the configuration alphabetically sorted.

Can we not make the FS_LOADER portion optional? I didn't realize how many non-TI platforms this impacted. And even then it's possible I assume that custom designs will load the firmwares in other manners.

Yes we can. We can wrap the remoteproc APIs using FS_LOADER in #ifdef CONFIG_FS_LOADER. And instead of REMOTEPROC driver selecting FS_LOADER, the clinet driver (ICSSG in this case) who is calling those remoteproc APIs will select FS_LOADER and enable it.

This will make sure that other platforms (ti or non-ti) that doesn't support ICSSG but enables Remoteproc, will not enable FS_LOADER. This way we are not forcing other platforms using remoteproc to enable FS_LOADER. In this case the APIs will not get built.

Now FS_LOADER will only be enabled when there is a client driver that uses rproc_boot() APIs. It's upto the client driver to enable FS_LOADER

below is the diff,

drivers/remoteproc/Kconfig +0 -1
index 9f9877931c..a49802c132 100644
@@ -10,7 +10,6 @@ menu "Remote Processor drivers"
 # All users should depend on DM
 config REMOTEPROC
        bool
-       select FS_LOADER
        depends on DM
 
 # Please keep the configuration alphabetically sorted.
drivers/remoteproc/rproc-uclass.c +1 -0
index f4f22a3851..a6a8be5009 100644
@@ -994,6 +994,7 @@ int rproc_set_firmware(struct udevice *rproc_dev,
 const char *fw_name)
        return 0;
 }
 
+#ifdef CONFIG_FS_LOADER
 int rproc_boot(struct udevice *rproc_dev)
 {
        struct dm_rproc_uclass_pdata *uc_pdata;
drivers/remoteproc/rproc-uclass.c +1 -0
@@ -1063,3 +1064,4 @@ free_buffer:
        free(addr);
        return ret;
 }
+#endif
Quoted 1 line

Let me know if this looks ok. If it's ok I will post v7 with this change.

Yes please, thanks.

Signature · 1 line
Tom
#12 lore raw
Quoted 116 lines · Tom Rini
Quoted 115 lines · MD Danish Anwar

Hi Tom,

Quoted 58 lines · Tom Rini
Quoted 56 lines · MD Danish Anwar

Add APIs to set a firmware_name to a rproc and boot the rproc with the same firmware.

Clients can call rproc_set_firmware() API to set firmware_name for a rproc whereas rproc_boot() will load the firmware set by rproc_set_firmware() to a buffer by calling request_firmware_into_buf(). rproc_boot() will then load the firmware file to the remote processor and start the remote processor.

Also include "fs-loader.h" and make remoteproc driver select FS_LOADER in Kconfig so that we can call request_firmware_into_buf() from remoteproc driver.

---
Changes from v5 to v6:
*) Collected Acked-by tag from Ravi Gunasekaran <[email protected]> *) Fixed few typos as pointed out by Roger Quadros <[email protected]> *) Added if condition to check if uc_pdata->fw_name exists and free it
before the strndup as suggested by Roger Quadros <[email protected]>

Changes from v4 to v5:
*) Added Kconfig option REMOTEPROC_MAX_FW_SIZE to set max firmware size
that can be loaded to a rproc.
*) Added freeing of address in rproc_boot() as pointed out by Ravi. *) Allocating the address at a later point in rproc_boot() *) Rebased on latest u-boot/master [commit
9e00b6993f724da9699ef12573307afea8c19284]

Changes from v3 to v4:
*) No functional change. Splitted the patch out of the series as suggested
by Nishant.
*) Droppped the RFC tag.

v5: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/

 drivers/remoteproc/Kconfig        |   8 +++
 drivers/remoteproc/rproc-uclass.c | 102 ++++++++++++++++++++++++++++++
 include/remoteproc.h              |  34 ++++++++++
 3 files changed, 144 insertions(+)
drivers/remoteproc/Kconfig +1 -0
index 781de530af..9f9877931c 100644
@@ -10,6 +10,7 @@ menu "Remote Processor drivers"
 # All users should depend on DM
 config REMOTEPROC
 	bool
+	select FS_LOADER
 	depends on DM
 
Quoted 6 lines

drivers/remoteproc/Kconfig menu "Remote Processor drivers" · line 15

Quoted 1 line
drivers/remoteproc/Kconfig +0 -0
 # Please keep the configuration alphabetically sorted.

Can we not make the FS_LOADER portion optional? I didn't realize how many non-TI platforms this impacted. And even then it's possible I assume that custom designs will load the firmwares in other manners.

Yes we can. We can wrap the remoteproc APIs using FS_LOADER in #ifdef CONFIG_FS_LOADER. And instead of REMOTEPROC driver selecting FS_LOADER, the clinet driver (ICSSG in this case) who is calling those remoteproc APIs will select FS_LOADER and enable it.

This will make sure that other platforms (ti or non-ti) that doesn't support ICSSG but enables Remoteproc, will not enable FS_LOADER. This way we are not forcing other platforms using remoteproc to enable FS_LOADER. In this case the APIs will not get built.

Now FS_LOADER will only be enabled when there is a client driver that uses rproc_boot() APIs. It's upto the client driver to enable FS_LOADER

below is the diff,

drivers/remoteproc/Kconfig +0 -1
index 9f9877931c..a49802c132 100644
@@ -10,7 +10,6 @@ menu "Remote Processor drivers"
 # All users should depend on DM
 config REMOTEPROC
        bool
-       select FS_LOADER
        depends on DM
 
 # Please keep the configuration alphabetically sorted.
drivers/remoteproc/rproc-uclass.c +1 -0
index f4f22a3851..a6a8be5009 100644
@@ -994,6 +994,7 @@ int rproc_set_firmware(struct udevice *rproc_dev,
 const char *fw_name)
        return 0;
 }
 
+#ifdef CONFIG_FS_LOADER
 int rproc_boot(struct udevice *rproc_dev)
 {
        struct dm_rproc_uclass_pdata *uc_pdata;
drivers/remoteproc/rproc-uclass.c +1 -0
@@ -1063,3 +1064,4 @@ free_buffer:
        free(addr);
        return ret;
 }
+#endif
Quoted 4 lines
Quoted 1 line

Let me know if this looks ok. If it's ok I will post v7 with this change.

Yes please, thanks.

Posted v7 with the above changes
https://lore.kernel.org/all/[email protected]/

Please check.

Signature · 2 lines
Thanks and Regards,
Danish