mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] ARM: Rockchip: bbu: rename rk3568_bbu_mmc_register to rockchip_*
@ 2024-04-15  5:28 Ahmad Fatoum
  2024-04-15  5:28 ` [PATCH 2/3] ARM: Rockchip: bbu: output unallocated space size on error Ahmad Fatoum
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2024-04-15  5:28 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The update handler isn't restricted to the RK3568, but is also usable
for other RKNS SoCs. With minor modification, it is also usable for the
RK3399 and perhaps even older SoCs, so let's rename it to
rockchip_bbu_mmc_handler instead. We can always do SoC-type checks
inside to handle differences.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/boards/radxa-cm3/board.c                 |  6 +++---
 arch/arm/boards/radxa-rock3/board.c               |  4 ++--
 arch/arm/boards/radxa-rock5/board.c               |  4 ++--
 arch/arm/boards/rockchip-rk3568-bpi-r2pro/board.c |  5 ++---
 arch/arm/boards/rockchip-rk3568-evb/board.c       |  5 ++---
 arch/arm/mach-rockchip/bbu.c                      | 10 +++++-----
 include/mach/rockchip/bbu.h                       |  6 ++++--
 7 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/arch/arm/boards/radxa-cm3/board.c b/arch/arm/boards/radxa-cm3/board.c
index 14b678417910..19d37e31d9b0 100644
--- a/arch/arm/boards/radxa-cm3/board.c
+++ b/arch/arm/boards/radxa-cm3/board.c
@@ -26,9 +26,9 @@ static int cm3_probe(struct device *dev)
 	else
 		of_device_enable_path("/chosen/environment-emmc");
 
-	rk3568_bbu_mmc_register("emmc", BBU_HANDLER_FLAG_DEFAULT,
-				"/dev/mmc0");
-	rk3568_bbu_mmc_register("sd", 0, "/dev/mmc1");
+	rockchip_bbu_mmc_register("emmc", BBU_HANDLER_FLAG_DEFAULT,
+				  "/dev/mmc0");
+	rockchip_bbu_mmc_register("sd", 0, "/dev/mmc1");
 
 	return 0;
 }
diff --git a/arch/arm/boards/radxa-rock3/board.c b/arch/arm/boards/radxa-rock3/board.c
index 0d425e266755..df99eded2ca8 100644
--- a/arch/arm/boards/radxa-rock3/board.c
+++ b/arch/arm/boards/radxa-rock3/board.c
@@ -26,8 +26,8 @@ static int rock3_probe(struct device *dev)
 	else
 		of_device_enable_path("/chosen/environment-emmc");
 
-	rk3568_bbu_mmc_register("emmc", BBU_HANDLER_FLAG_DEFAULT, "/dev/mmc0");
-	rk3568_bbu_mmc_register("sd", 0, "/dev/mmc1");
+	rockchip_bbu_mmc_register("emmc", BBU_HANDLER_FLAG_DEFAULT, "/dev/mmc0");
+	rockchip_bbu_mmc_register("sd", 0, "/dev/mmc1");
 
 	return 0;
 }
diff --git a/arch/arm/boards/radxa-rock5/board.c b/arch/arm/boards/radxa-rock5/board.c
index 6ea6ffeaaf4e..eab0c0104000 100644
--- a/arch/arm/boards/radxa-rock5/board.c
+++ b/arch/arm/boards/radxa-rock5/board.c
@@ -23,8 +23,8 @@ static int rock5_probe(struct device *dev)
 	else
 		of_device_enable_path("/chosen/environment-emmc");
 
-	rk3568_bbu_mmc_register("emmc", BBU_HANDLER_FLAG_DEFAULT, "/dev/mmc0");
-	rk3568_bbu_mmc_register("sd", 0, "/dev/mmc1");
+	rockchip_bbu_mmc_register("emmc", BBU_HANDLER_FLAG_DEFAULT, "/dev/mmc0");
+	rockchip_bbu_mmc_register("sd", 0, "/dev/mmc1");
 
 	return 0;
 }
diff --git a/arch/arm/boards/rockchip-rk3568-bpi-r2pro/board.c b/arch/arm/boards/rockchip-rk3568-bpi-r2pro/board.c
index 94d1dac2c2d1..7178c02d8f09 100644
--- a/arch/arm/boards/rockchip-rk3568-bpi-r2pro/board.c
+++ b/arch/arm/boards/rockchip-rk3568-bpi-r2pro/board.c
@@ -28,9 +28,8 @@ static int rk3568_bpi_r2pro_probe(struct device *dev)
 	else
 		of_device_enable_path("/chosen/environment-emmc");
 
-	rk3568_bbu_mmc_register("sd", 0, "/dev/mmc0");
-	rk3568_bbu_mmc_register("emmc", BBU_HANDLER_FLAG_DEFAULT,
-				"/dev/mmc1");
+	rockchip_bbu_mmc_register("sd", 0, "/dev/mmc0");
+	rockchip_bbu_mmc_register("emmc", BBU_HANDLER_FLAG_DEFAULT, "/dev/mmc1");
 
 	return 0;
 }
diff --git a/arch/arm/boards/rockchip-rk3568-evb/board.c b/arch/arm/boards/rockchip-rk3568-evb/board.c
index f404af217bb7..9659bd69c5b8 100644
--- a/arch/arm/boards/rockchip-rk3568-evb/board.c
+++ b/arch/arm/boards/rockchip-rk3568-evb/board.c
@@ -28,9 +28,8 @@ static int rk3568_evb_probe(struct device *dev)
 	else
 		of_device_enable_path("/chosen/environment-emmc");
 
-	rk3568_bbu_mmc_register("sd", 0, "/dev/mmc0");
-	rk3568_bbu_mmc_register("emmc", BBU_HANDLER_FLAG_DEFAULT,
-				"/dev/mmc1");
+	rockchip_bbu_mmc_register("sd", 0, "/dev/mmc0");
+	rockchip_bbu_mmc_register("emmc", BBU_HANDLER_FLAG_DEFAULT, "/dev/mmc1");
 
 	return 0;
 }
diff --git a/arch/arm/mach-rockchip/bbu.c b/arch/arm/mach-rockchip/bbu.c
index 3ab6c1e68502..0f50fd1282ed 100644
--- a/arch/arm/mach-rockchip/bbu.c
+++ b/arch/arm/mach-rockchip/bbu.c
@@ -36,8 +36,8 @@
  * leaves the previously written inactive image as a fallback in case writing the
  * first one gets interrupted.
  */
-static int rk3568_bbu_mmc_handler(struct bbu_handler *handler,
-				  struct bbu_data *data)
+static int rockchip_bbu_mmc_handler(struct bbu_handler *handler,
+				    struct bbu_data *data)
 {
 	enum filetype filetype;
 	int ret, fd, wr0, wr1;
@@ -113,8 +113,8 @@ static int rk3568_bbu_mmc_handler(struct bbu_handler *handler,
 	return ret;
 }
 
-int rk3568_bbu_mmc_register(const char *name, unsigned long flags,
-                const char *devicefile)
+int rockchip_bbu_mmc_register(const char *name, unsigned long flags,
+			      const char *devicefile)
 {
 	struct bbu_handler *handler;
 	int ret;
@@ -124,7 +124,7 @@ int rk3568_bbu_mmc_register(const char *name, unsigned long flags,
 	handler->flags = flags;
 	handler->devicefile = devicefile;
 	handler->name = name;
-	handler->handler = rk3568_bbu_mmc_handler;
+	handler->handler = rockchip_bbu_mmc_handler;
 
 	ret = bbu_register_handler(handler);
 	if (ret)
diff --git a/include/mach/rockchip/bbu.h b/include/mach/rockchip/bbu.h
index 2cc9b74081e4..9ae137b0e6ab 100644
--- a/include/mach/rockchip/bbu.h
+++ b/include/mach/rockchip/bbu.h
@@ -6,14 +6,16 @@
 #include <bbu.h>
 
 #ifdef CONFIG_BAREBOX_UPDATE
-int rk3568_bbu_mmc_register(const char *name, unsigned long flags,
+int rockchip_bbu_mmc_register(const char *name, unsigned long flags,
                 const char *devicefile);
 #else
-static inline int rk3568_bbu_mmc_register(const char *name, unsigned long flags,
+static inline int rockchip_bbu_mmc_register(const char *name, unsigned long flags,
                 const char *devicefile)
 {
 	return -ENOSYS;
 }
 #endif
 
+#define rk3568_bbu_mmc_register rockchip_bbu_mmc_register
+
 # endif /* __MACH_ROCKCHIP_BBU_H */
-- 
2.39.2




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

* [PATCH 2/3] ARM: Rockchip: bbu: output unallocated space size on error
  2024-04-15  5:28 [PATCH 1/3] ARM: Rockchip: bbu: rename rk3568_bbu_mmc_register to rockchip_* Ahmad Fatoum
@ 2024-04-15  5:28 ` Ahmad Fatoum
  2024-04-15  5:28 ` [PATCH 3/3] ARM: Rockchip: bbu: allow forcing barebox update handler despite size Ahmad Fatoum
  2024-04-16 11:05 ` [PATCH 1/3] ARM: Rockchip: bbu: rename rk3568_bbu_mmc_register to rockchip_* Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2024-04-15  5:28 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

While devinfo can be used to deduce the unallocated size before the
first partition, let's just print it out on error to improve the user
experience.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/mach-rockchip/bbu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-rockchip/bbu.c b/arch/arm/mach-rockchip/bbu.c
index 0f50fd1282ed..f9681aad1aa4 100644
--- a/arch/arm/mach-rockchip/bbu.c
+++ b/arch/arm/mach-rockchip/bbu.c
@@ -63,8 +63,8 @@ static int rockchip_bbu_mmc_handler(struct bbu_handler *handler,
 	space = cdev_unallocated_space(cdev_by_name(cdevname));
 
 	if (space < IMG_OFFSET_0 + data->len) {
-		pr_err("Unallocated space on %s is too small for one image\n",
-		       data->devicefile);
+		pr_err("Unallocated space on %s (%lld) is too small for one image\n",
+		       data->devicefile, space);
 		return -ENOSPC;
 	}
 
-- 
2.39.2




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

* [PATCH 3/3] ARM: Rockchip: bbu: allow forcing barebox update handler despite size
  2024-04-15  5:28 [PATCH 1/3] ARM: Rockchip: bbu: rename rk3568_bbu_mmc_register to rockchip_* Ahmad Fatoum
  2024-04-15  5:28 ` [PATCH 2/3] ARM: Rockchip: bbu: output unallocated space size on error Ahmad Fatoum
@ 2024-04-15  5:28 ` Ahmad Fatoum
  2024-04-16 11:05 ` [PATCH 1/3] ARM: Rockchip: bbu: rename rk3568_bbu_mmc_register to rockchip_* Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2024-04-15  5:28 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The update handler correctly refuses to write a bootloader when it would
interfere with partitioning.

Depending on use case, the user may want to override this check though,
so allow the barebox update force parameter to override it.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/mach-rockchip/bbu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-rockchip/bbu.c b/arch/arm/mach-rockchip/bbu.c
index f9681aad1aa4..f15b32937c3e 100644
--- a/arch/arm/mach-rockchip/bbu.c
+++ b/arch/arm/mach-rockchip/bbu.c
@@ -63,9 +63,9 @@ static int rockchip_bbu_mmc_handler(struct bbu_handler *handler,
 	space = cdev_unallocated_space(cdev_by_name(cdevname));
 
 	if (space < IMG_OFFSET_0 + data->len) {
-		pr_err("Unallocated space on %s (%lld) is too small for one image\n",
-		       data->devicefile, space);
-		return -ENOSPC;
+		if (!bbu_force(data, "Unallocated space on %s (%lld) is too small for one image\n",
+			       data->devicefile, space))
+			return -ENOSPC;
 	}
 
 	fd = open(data->devicefile, O_WRONLY);
-- 
2.39.2




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

* Re: [PATCH 1/3] ARM: Rockchip: bbu: rename rk3568_bbu_mmc_register to rockchip_*
  2024-04-15  5:28 [PATCH 1/3] ARM: Rockchip: bbu: rename rk3568_bbu_mmc_register to rockchip_* Ahmad Fatoum
  2024-04-15  5:28 ` [PATCH 2/3] ARM: Rockchip: bbu: output unallocated space size on error Ahmad Fatoum
  2024-04-15  5:28 ` [PATCH 3/3] ARM: Rockchip: bbu: allow forcing barebox update handler despite size Ahmad Fatoum
@ 2024-04-16 11:05 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2024-04-16 11:05 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Mon, 15 Apr 2024 07:28:13 +0200, Ahmad Fatoum wrote:
> The update handler isn't restricted to the RK3568, but is also usable
> for other RKNS SoCs. With minor modification, it is also usable for the
> RK3399 and perhaps even older SoCs, so let's rename it to
> rockchip_bbu_mmc_handler instead. We can always do SoC-type checks
> inside to handle differences.
> 
> 
> [...]

Applied, thanks!

[1/3] ARM: Rockchip: bbu: rename rk3568_bbu_mmc_register to rockchip_*
      https://git.pengutronix.de/cgit/barebox/commit/?id=66e0e8536986 (link may not be stable)
[2/3] ARM: Rockchip: bbu: output unallocated space size on error
      https://git.pengutronix.de/cgit/barebox/commit/?id=702504f04c78 (link may not be stable)
[3/3] ARM: Rockchip: bbu: allow forcing barebox update handler despite size
      https://git.pengutronix.de/cgit/barebox/commit/?id=30558b84d1bb (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

end of thread, other threads:[~2024-04-16 11:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-15  5:28 [PATCH 1/3] ARM: Rockchip: bbu: rename rk3568_bbu_mmc_register to rockchip_* Ahmad Fatoum
2024-04-15  5:28 ` [PATCH 2/3] ARM: Rockchip: bbu: output unallocated space size on error Ahmad Fatoum
2024-04-15  5:28 ` [PATCH 3/3] ARM: Rockchip: bbu: allow forcing barebox update handler despite size Ahmad Fatoum
2024-04-16 11:05 ` [PATCH 1/3] ARM: Rockchip: bbu: rename rk3568_bbu_mmc_register to rockchip_* Sascha Hauer

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