Skip to contentSkip to conversation

Simplefb and fb reservation related updates

PATCH In review Devarsh Thakkar 3 participants 12 messages Feb 22, 2024 – Apr 20, 2024 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

cover Simplefb and fb reservation related updates

This adds support for simple-framebuffer reservation using video handoff when splash is enabled at SPL stage.

Also adds helper function to only enable framebuffer reservation without enabling simple-framebuffer in case user want to continue display bootloader splash without displaying anything else in between until kernel boots up.

Lastly, it enables above support on AM62x.

Devarsh Thakkar (4):
boot: fdt_simplefb: Enumerate framebuffer info from video handoff
video: Assume video to be active if SPL is passing video hand-off
boot: Move framebuffer reservation to separate helper
board: ti: am62x: evm: Update simple-framebuffer node in device-tree

 board/ti/am62x/evm.c         | 19 +++++++++++++++
 boot/fdt_simplefb.c          | 46 ++++++++++++++++++++----------------
 boot/fdt_support.c           | 21 ++++++++++++++++
 drivers/video/video-uclass.c |  4 ++++
 include/fdt_support.h        |  2 ++
 5 files changed, 72 insertions(+), 20 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/4 boot: fdt_simplefb: Enumerate framebuffer info from video handoff

Enable and update simple-framebuffer node using the video handoff bloblist if video was enabled at SPL stage and corresponding video bloblist was received at u-boot proper with necessary parameters.

---
 boot/fdt_simplefb.c | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)
boot/fdt_simplefb.c +25 -9
index 069ced75a7..b0221eaf2a 100644
@@ -12,6 +12,8 @@
 #include <asm/global_data.h>
 #include <linux/libfdt.h>
 #include <video.h>
+#include <spl.h>
+#include <bloblist.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -26,15 +28,29 @@ static int fdt_simplefb_configure_node(void *blob, int off)
 	struct udevice *dev;
 	int ret;
 
-	ret = uclass_first_device_err(UCLASS_VIDEO, &dev);
-	if (ret)
-		return ret;
-	uc_priv = dev_get_uclass_priv(dev);
-	plat = dev_get_uclass_plat(dev);
-	xsize = uc_priv->xsize;
-	ysize = uc_priv->ysize;
-	bpix = uc_priv->bpix;
-	fb_base = plat->base;
+	if (IS_ENABLED(CONFIG_SPL_VIDEO_HANDOFF) && spl_phase() > PHASE_SPL) {
+		struct video_handoff *ho;
+
+		ho = bloblist_find(BLOBLISTT_U_BOOT_VIDEO, sizeof(*ho));
+		if (!ho)
+			return log_msg_ret("Missing video bloblist", -ENOENT);
+
+		xsize = ho->xsize;
+		ysize = ho->ysize;
+		bpix = ho->bpix;
+		fb_base = ho->fb;
+	} else {
+		ret = uclass_first_device_err(UCLASS_VIDEO, &dev);
+		if (ret)
+			return ret;
+		uc_priv = dev_get_uclass_priv(dev);
+		plat = dev_get_uclass_plat(dev);
+		xsize = uc_priv->xsize;
+		ysize = uc_priv->ysize;
+		bpix = uc_priv->bpix;
+		fb_base = plat->base;
+	}
+
 	switch (bpix) {
 	case 4: /* VIDEO_BPP16 */
 		name = "r5g6b5";
Signature · 1 line
2.34.1
#3 lore raw

PATCH 2/4 video: Assume video to be active if SPL is passing video hand-off

In reply to Devarsh Thakkar

If SPL is passing video handoff structure to U-boot then it is safe to assume that SPL has already enabled video and that's why it is passing video handoff structure to U-boot so that U-boot can preserve the framebuffer.

---
 drivers/video/video-uclass.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/video/video-uclass.c +4 -0
index 3571e62ba2..7b5d1dfbb3 100644
@@ -404,6 +404,10 @@ bool video_is_active(void)
 {
 	struct udevice *dev;
 
+	/* Assume video to be active if SPL passed video hand-off to U-boot */
+	if (IS_ENABLED(CONFIG_SPL_VIDEO_HANDOFF) && spl_phase() > PHASE_SPL)
+		return true;
+
 	for (uclass_find_first_device(UCLASS_VIDEO, &dev);
 	     dev;
 	     uclass_find_next_device(&dev)) {
Signature · 1 line
2.34.1
#5 lore raw

PATCH 3/4 boot: Move framebuffer reservation to separate helper

In reply to Devarsh Thakkar

Create separate helper for just reserving framebuffer region without creating or enabling simple-framebuffer node.

This is useful for scenarios where user want to preserve the bootloader splash screen till OS boots up and display server gets started without displaying anything else in between and thus not requiring simple-framebuffer.

---
 boot/fdt_simplefb.c   | 12 +-----------
 boot/fdt_support.c    | 21 +++++++++++++++++++++
 include/fdt_support.h |  2 ++
 3 files changed, 24 insertions(+), 11 deletions(-)
boot/fdt_simplefb.c +1 -11
index b0221eaf2a..837920bd3a 100644
@@ -107,7 +107,6 @@ static int fdt_simplefb_enable_existing_node(void *blob)
 #if IS_ENABLED(CONFIG_VIDEO)
 int fdt_simplefb_enable_and_mem_rsv(void *blob)
 {
-	struct fdt_memory mem;
 	int ret;
 
 	/* nothing to do when video is not active */
@@ -118,15 +117,6 @@ int fdt_simplefb_enable_and_mem_rsv(void *blob)
 	if (ret)
 		return ret;
 
-	/* nothing to do when the frame buffer is not defined */
-	if (gd->video_bottom == gd->video_top)
-		return 0;
-
-	/* reserved with no-map tag the video buffer */
-	mem.start = gd->video_bottom;
-	mem.end = gd->video_top - 1;
-
-	return fdtdec_add_reserved_memory(blob, "framebuffer", &mem, NULL, 0, NULL,
-					  FDTDEC_RESERVED_MEMORY_NO_MAP);
+	return fdt_add_fb_mem_rsv(blob);
 }
 #endif
boot/fdt_support.c +21 -0
index 090d82ee80..07aa7337e8 100644
@@ -22,6 +22,9 @@
 #include <exports.h>
 #include <fdtdec.h>
 #include <version.h>
+#include <video.h>
+
+DECLARE_GLOBAL_DATA_PTR;
 
 /**
  * fdt_getprop_u32_default_node - Return a node's property or a default
@@ -2042,6 +2045,24 @@ int fdt_setup_simplefb_node(void *fdt, int node, u64 base_address, u32 width,
 	return 0;
 }
 
+#if IS_ENABLED(CONFIG_VIDEO)
+int fdt_add_fb_mem_rsv(void *blob)
+{
+	struct fdt_memory mem;
+
+	/* nothing to do when the frame buffer is not defined */
+	if (gd->video_bottom == gd->video_top)
+		return 0;
+
+	/* reserved with no-map tag the video buffer */
+	mem.start = gd->video_bottom;
+	mem.end = gd->video_top - 1;
+
+	return fdtdec_add_reserved_memory(blob, "framebuffer", &mem, NULL, 0, NULL,
+					  FDTDEC_RESERVED_MEMORY_NO_MAP);
+}
+#endif
+
 /*
  * Update native-mode in display-timings from display environment variable.
  * The node to update are specified by path.
include/fdt_support.h +2 -0
index 25600d62f2..4b71b8948d 100644
@@ -423,6 +423,8 @@ int arch_fixup_memory_node(void *blob);
 int fdt_setup_simplefb_node(void *fdt, int node, u64 base_address, u32 width,
 			    u32 height, u32 stride, const char *format);
 
+int fdt_add_fb_mem_rsv(void *blob);
+
 int fdt_overlay_apply_verbose(void *fdt, void *fdto);
 
 int fdt_valid(struct fdt_header **blobp);
Signature · 1 line
2.34.1
#7 lore raw

PATCH 4/4 board: ti: am62x: evm: Update simple-framebuffer node in device-tree

In reply to Devarsh Thakkar

Update simple-framebuffer device-tree node by enumerating framebuffer related information in existing simple-framebuffer node in Linux device-tree file and enabling it.

In case there is no simple-framebuffer stub detected in Linux kernel device-tree and video is still active, then update the device-tree to reserve the framebuffer region for the active splash screen.

This helps preserve the splash screen till the display server takes over after OS is booted.

---
 board/ti/am62x/evm.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
board/ti/am62x/evm.c +19 -0
index 88e02155ee..c825af3368 100644
@@ -15,6 +15,7 @@
 #include <cpu_func.h>
 #include <k3-ddrss.h>
 #include <fdt_support.h>
+#include <fdt_simplefb.h>
 #include <asm/io.h>
 #include <asm/arch/hardware.h>
 #include <dm/uclass.h>
@@ -118,3 +119,21 @@ void spl_perform_fixups(struct spl_image_info *spl_image)
 #endif
 }
 #endif
+
+#if defined(CONFIG_OF_BOARD_SETUP)
+int ft_board_setup(void *blob, struct bd_info *bd)
+{
+	int ret = -1;
+
+	if (IS_ENABLED(CONFIG_FDT_SIMPLEFB))
+		ret = fdt_simplefb_enable_and_mem_rsv(blob);
+
+	/* If simplefb is not enabled and video is active, then at least reserve
+	 * the framebuffer region to preserve the splash screen while OS is booting
+	 */
+	if (ret && video_is_active())
+		return fdt_add_fb_mem_rsv(blob);
+
+	return 0;
+}
+#endif
Signature · 1 line
2.34.1
#8 lore raw

Re: [PATCH 4/4] board: ti: am62x: evm: Update simple-framebuffer node in device-tree

Hi,

Quoted 31 lines · Devarsh Thakkar

Update simple-framebuffer device-tree node by enumerating framebuffer related information in existing simple-framebuffer node in Linux device-tree file and enabling it.

In case there is no simple-framebuffer stub detected in Linux kernel device-tree and video is still active, then update the device-tree to reserve the framebuffer region for the active splash screen.

This helps preserve the splash screen till the display server takes over after OS is booted.

---
 board/ti/am62x/evm.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
board/ti/am62x/evm.c +1 -0
index 88e02155ee..c825af3368 100644
@@ -15,6 +15,7 @@
 #include <cpu_func.h>
 #include <k3-ddrss.h>
 #include <fdt_support.h>
+#include <fdt_simplefb.h>
 #include <asm/io.h>
 #include <asm/arch/hardware.h>
 #include <dm/uclass.h>
@@ -118,3 +119,21 @@ void spl_perform_fixups(struct spl_image_info *spl_image)
 #endif
 }

board/ti/am62x/evm.c void spl_perform_fixups(struct spl_image_info *spl_image) · line 130

Quoted 10 lines
board/ti/am62x/evm.c +9 -0
 #endif
+
+#if defined(CONFIG_OF_BOARD_SETUP)
+int ft_board_setup(void *blob, struct bd_info *bd)
+{
+	int ret = -1;
+
+	if (IS_ENABLED(CONFIG_FDT_SIMPLEFB))
+		ret = fdt_simplefb_enable_and_mem_rsv(blob);
+

This needs to be protected with IS_ENABLED(CONFIG_VIDEO) too to avoid below errors when CONFIG_VIDEO is disabled :

/home/devarsht/ti/ti-u-boot/board/ti/am62x/evm.c:102: undefined reference to `video_is_active'

aarch64-none-linux-gnu-ld.bfd:
/home/devarsht/ti/ti-u-boot/board/ti/am62x/evm.c:104: undefined reference to `fdt_add_fb_mem_rsv' \

I will send out a V2 of this patch.

Regards
Devarsh

Quoted 9 lines
board/ti/am62x/evm.c +9 -0
+	/* If simplefb is not enabled and video is active, then at least reserve
+	 * the framebuffer region to preserve the splash screen while OS is booting
+	 */
+	if (ret && video_is_active())
+		return fdt_add_fb_mem_rsv(blob);
+
+	return 0;
+}
+#endif
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] boot: fdt_simplefb: Enumerate framebuffer info from video handoff

In reply to Devarsh Thakkar

Hi Devarsh,

Quoted 8 lines · Devarsh Thakkar

Enable and update simple-framebuffer node using the video handoff bloblist if video was enabled at SPL stage and corresponding video bloblist was received at u-boot proper with necessary parameters.

---
 boot/fdt_simplefb.c | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)
Quoted 43 lines
boot/fdt_simplefb.c +18 -9
index 069ced75a7..b0221eaf2a 100644
@@ -12,6 +12,8 @@
 #include <asm/global_data.h>
 #include <linux/libfdt.h>
 #include <video.h>
+#include <spl.h>
+#include <bloblist.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -26,15 +28,29 @@ static int fdt_simplefb_configure_node(void *blob, int off)
 	struct udevice *dev;
 	int ret;
 
-	ret = uclass_first_device_err(UCLASS_VIDEO, &dev);
-	if (ret)
-		return ret;
-	uc_priv = dev_get_uclass_priv(dev);
-	plat = dev_get_uclass_plat(dev);
-	xsize = uc_priv->xsize;
-	ysize = uc_priv->ysize;
-	bpix = uc_priv->bpix;
-	fb_base = plat->base;
+	if (IS_ENABLED(CONFIG_SPL_VIDEO_HANDOFF) && spl_phase() > PHASE_SPL) {
+		struct video_handoff *ho;
+
+		ho = bloblist_find(BLOBLISTT_U_BOOT_VIDEO, sizeof(*ho));
+		if (!ho)
+			return log_msg_ret("Missing video bloblist", -ENOENT);
+
+		xsize = ho->xsize;
+		ysize = ho->ysize;
+		bpix = ho->bpix;
+		fb_base = ho->fb;
+	} else {
+		ret = uclass_first_device_err(UCLASS_VIDEO, &dev);
+		if (ret)
+			return ret;
+		uc_priv = dev_get_uclass_priv(dev);

boot/fdt_simplefb.c static int fdt_simplefb_configure_node(void *blob, int off) · line 56

Quoted 10 lines
boot/fdt_simplefb.c +7 -0
+		plat = dev_get_uclass_plat(dev);
+		xsize = uc_priv->xsize;
+		ysize = uc_priv->ysize;
+		bpix = uc_priv->bpix;
+		fb_base = plat->base;
+	}
+
 	switch (bpix) {
 	case 4: /* VIDEO_BPP16 */
 		name = "r5g6b5";

Thanks,

Nikhil

Reviewed-by on v1 2/4
#4 lore raw

Re: [PATCH 2/4] video: Assume video to be active if SPL is passing video hand-off

In reply to Devarsh Thakkar

Hi Devarsh,

Quoted 9 lines · Devarsh Thakkar

If SPL is passing video handoff structure to U-boot then it is safe to assume that SPL has already enabled video and that's why it is passing video handoff structure to U-boot so that U-boot can preserve the framebuffer.

---
 drivers/video/video-uclass.c | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 6 lines
drivers/video/video-uclass.c +0 -0
index 3571e62ba2..7b5d1dfbb3 100644

drivers/video/video-uclass.c bool video_is_active(void) · line 413

Quoted 10 lines
drivers/video/video-uclass.c +4 -0
@@ -404,6 +404,10 @@ bool video_is_active(void)
 {
 	struct udevice *dev;
 
+	/* Assume video to be active if SPL passed video hand-off to U-boot */
+	if (IS_ENABLED(CONFIG_SPL_VIDEO_HANDOFF) && spl_phase() > PHASE_SPL)
+		return true;
+
 	for (uclass_find_first_device(UCLASS_VIDEO, &dev);
 	     dev;
 	     uclass_find_next_device(&dev)) {

Thanks,

Nikhil

Reviewed-by on v1 3/4
#6 lore raw

Re: [PATCH 3/4] boot: Move framebuffer reservation to separate helper

In reply to Devarsh Thakkar

Hi Devarsh,

Quoted 8 lines · Devarsh Thakkar

Create separate helper for just reserving framebuffer region without creating or enabling simple-framebuffer node.

This is useful for scenarios where user want to preserve the bootloader splash screen till OS boots up and display server gets started without displaying anything else in between and thus not requiring simple-framebuffer.

Quoted 6 lines
---
 boot/fdt_simplefb.c   | 12 +-----------
 boot/fdt_support.c    | 21 +++++++++++++++++++++
 include/fdt_support.h |  2 ++
 3 files changed, 24 insertions(+), 11 deletions(-)
Quoted 74 lines
boot/fdt_simplefb.c +1 -11
index b0221eaf2a..837920bd3a 100644
@@ -107,7 +107,6 @@ static int fdt_simplefb_enable_existing_node(void *blob)
 #if IS_ENABLED(CONFIG_VIDEO)
 int fdt_simplefb_enable_and_mem_rsv(void *blob)
 {
-	struct fdt_memory mem;
 	int ret;
 
 	/* nothing to do when video is not active */
@@ -118,15 +117,6 @@ int fdt_simplefb_enable_and_mem_rsv(void *blob)
 	if (ret)
 		return ret;
 
-	/* nothing to do when the frame buffer is not defined */
-	if (gd->video_bottom == gd->video_top)
-		return 0;
-
-	/* reserved with no-map tag the video buffer */
-	mem.start = gd->video_bottom;
-	mem.end = gd->video_top - 1;
-
-	return fdtdec_add_reserved_memory(blob, "framebuffer", &mem, NULL, 0, NULL,
-					  FDTDEC_RESERVED_MEMORY_NO_MAP);
+	return fdt_add_fb_mem_rsv(blob);
 }
 #endif
boot/fdt_support.c +21 -0
index 090d82ee80..07aa7337e8 100644
@@ -22,6 +22,9 @@
 #include <exports.h>
 #include <fdtdec.h>
 #include <version.h>
+#include <video.h>
+
+DECLARE_GLOBAL_DATA_PTR;
 
 /**
  * fdt_getprop_u32_default_node - Return a node's property or a default
@@ -2042,6 +2045,24 @@ int fdt_setup_simplefb_node(void *fdt, int node, u64 base_address, u32 width,
 	return 0;
 }
 
+#if IS_ENABLED(CONFIG_VIDEO)
+int fdt_add_fb_mem_rsv(void *blob)
+{
+	struct fdt_memory mem;
+
+	/* nothing to do when the frame buffer is not defined */
+	if (gd->video_bottom == gd->video_top)
+		return 0;
+
+	/* reserved with no-map tag the video buffer */
+	mem.start = gd->video_bottom;
+	mem.end = gd->video_top - 1;
+
+	return fdtdec_add_reserved_memory(blob, "framebuffer", &mem, NULL, 0, NULL,
+					  FDTDEC_RESERVED_MEMORY_NO_MAP);
+}
+#endif
+
 /*
  * Update native-mode in display-timings from display environment variable.
  * The node to update are specified by path.
include/fdt_support.h +0 -0
index 25600d62f2..4b71b8948d 100644

include/fdt_support.h int arch_fixup_memory_node(void *blob); · line 430

Quoted 8 lines
include/fdt_support.h +2 -0
@@ -423,6 +423,8 @@ int arch_fixup_memory_node(void *blob);
 int fdt_setup_simplefb_node(void *fdt, int node, u64 base_address, u32 width,
 			    u32 height, u32 stride, const char *format);
 
+int fdt_add_fb_mem_rsv(void *blob);
+
 int fdt_overlay_apply_verbose(void *fdt, void *fdto);
 
 int fdt_valid(struct fdt_header **blobp);

Thanks,
Nikhil

#9 lore raw
In reply to Devarsh Thakkar

Hi Tom, Anatolij, Simon,

Quoted 10 lines · Devarsh Thakkar

This adds support for simple-framebuffer reservation using video handoff when splash is enabled at SPL stage.

Also adds helper function to only enable framebuffer reservation without enabling simple-framebuffer in case user want to continue display bootloader splash without displaying anything else in between until kernel boots up.

Lastly, it enables above support on AM62x.

I saw a RB on first 3 patches so just wanted to check if it looks good to you too then is it possible to pull in the first 3 patches if no further comments ?

Regards
Devarsh

Quoted 13 lines

Devarsh Thakkar (4):
boot: fdt_simplefb: Enumerate framebuffer info from video handoff
video: Assume video to be active if SPL is passing video hand-off
boot: Move framebuffer reservation to separate helper
board: ti: am62x: evm: Update simple-framebuffer node in device-tree

 board/ti/am62x/evm.c         | 19 +++++++++++++++
 boot/fdt_simplefb.c          | 46 ++++++++++++++++++++----------------
 boot/fdt_support.c           | 21 ++++++++++++++++
 drivers/video/video-uclass.c |  4 ++++
 include/fdt_support.h        |  2 ++
 5 files changed, 72 insertions(+), 20 deletions(-)
#10 lore raw

Gentle Reminder.

Quoted 33 lines · Devarsh Thakkar

Hi Tom, Anatolij, Simon,

Quoted 10 lines · Devarsh Thakkar

This adds support for simple-framebuffer reservation using video handoff when splash is enabled at SPL stage.

Also adds helper function to only enable framebuffer reservation without enabling simple-framebuffer in case user want to continue display bootloader splash without displaying anything else in between until kernel boots up.

Lastly, it enables above support on AM62x.

I saw a RB on first 3 patches so just wanted to check if it looks good to you too then is it possible to pull in the first 3 patches if no further comments ?

Regards
Devarsh

Quoted 13 lines

Devarsh Thakkar (4):
boot: fdt_simplefb: Enumerate framebuffer info from video handoff
video: Assume video to be active if SPL is passing video hand-off
boot: Move framebuffer reservation to separate helper
board: ti: am62x: evm: Update simple-framebuffer node in device-tree

 board/ti/am62x/evm.c         | 19 +++++++++++++++
 boot/fdt_simplefb.c          | 46 ++++++++++++++++++++----------------
 boot/fdt_support.c           | 21 ++++++++++++++++
 drivers/video/video-uclass.c |  4 ++++
 include/fdt_support.h        |  2 ++
 5 files changed, 72 insertions(+), 20 deletions(-)
#11 lore raw
In reply to Devarsh Thakkar
Quoted 11 lines · On Fri, 8 Mar 2024 16:38:28 +0530 Devarsh Thakkar [email protected] wrote:

Hi Tom, Anatolij, Simon,

Quoted 8 lines · Devarsh Thakkar

This adds support for simple-framebuffer reservation using video handoff when splash is enabled at SPL stage.

Also adds helper function to only enable framebuffer reservation without enabling simple-framebuffer in case user want to continue display bootloader splash without displaying anything else in between until kernel boots up.

Quoted 5 lines
Quoted 2 lines

Lastly, it enables above support on AM62x.

I saw a RB on first 3 patches so just wanted to check if it looks good to you too then is it possible to pull in the first 3 patches if no further comments ?

patches 1 to 3 applied to u-boot-video. Fixed build errors with patch 3.

--
Anatolij