Skip to contentSkip to conversation

sunxi: Set SYS_MALLOC_CLEAR_ON_INIT to n

PATCH New Hans de Goede 3 participants 6 messages May 5, 2015 – May 10, 2015 Arm/Allwinner sunXi SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 sunxi: Set SYS_MALLOC_CLEAR_ON_INIT to n

We don't need this on sunxi, and not having is shaves some time of out boot time.

---
 board/sunxi/Kconfig | 3 +++
 1 file changed, 3 insertions(+)
board/sunxi/Kconfig +3 -0
index bd1e988..940b6c7 100644
@@ -549,6 +549,9 @@ config GMAC_TX_DELAY
 	---help---
 	Set the GMAC Transmit Clock Delay Chain value.
 
+config SYS_MALLOC_CLEAR_ON_INIT
+	default n
+
 config NET
 	default y
 
Signature · 1 line
2.3.6
#1 lore raw

PATCH 2/2 console: Fix pre-console flushing via cfb_console being very slow

On my A10 OlinuxIno Lime I noticed a huge (5+ seconds) delay coming from console_init_r. This turns out to be caused by the preconsole buffer flushing to the cfb_console. The Lime only has a 16 bit memory bus and that is already heavy used to scan out the 1920x1080 framebuffer.

The problem is that print_pre_console_buffer() was printing the buffer once character at a time and the cfb_console code then ends up doing a cache-flush for touched display lines for each character.

This commit fixes this by first building a 0 terminated buffer and then printing it in one puts() call, avoiding unnecessary cache flushes.

This changes the time for the flush from 5+ seconds to not noticable.

The downside of this approach is that the pre-console buffer needs to fit on the stack, this is not that much to ask since we are talking about plain text here. This commit also adjusts the sunxi CONFIG_PRE_CON_BUF_SZ to actually fit on the stack. Sunxi currently is the only user of the pre-console code so no other boards need to be adjusted.

---
 README                         |  3 +++
 common/console.c               | 40 ++++++++++++++++++++++------------------
 include/configs/sunxi-common.h |  2 +-
 3 files changed, 26 insertions(+), 19 deletions(-)
README +3 -0
index ee65fdb..4e67c93 100644
@@ -948,6 +948,9 @@ The following options need to be configured:
 		bytes are output before the console is initialised, the
 		earlier bytes are discarded.
 
+		Note that when printing the buffer a copy is made on the
+		stack so CONFIG_PRE_CON_BUF_SZ must fit on the stack.
+
 		'Sane' compilers will generate smaller code if
 		CONFIG_PRE_CON_BUF_SZ is a power of 2
 
common/console.c +22 -18
index 3f25e76..0058222 100644
@@ -200,15 +200,15 @@ static void console_putc(int file, const char c)
 }
 
 #ifdef CONFIG_PRE_CONSOLE_BUFFER
-static void console_putc_noserial(int file, const char c)
+static void console_puts_noserial(int file, const char *s)
 {
 	int i;
 	struct stdio_dev *dev;
 
 	for (i = 0; i < cd_count[file]; i++) {
 		dev = console_devices[file][i];
-		if (dev->putc != NULL && strcmp(dev->name, "serial") != 0)
-			dev->putc(dev, c);
+		if (dev->puts != NULL && strcmp(dev->name, "serial") != 0)
+			dev->puts(dev, s);
 	}
 }
 #endif
@@ -251,10 +251,10 @@ static inline void console_putc(int file, const char c)
 }
 
 #ifdef CONFIG_PRE_CONSOLE_BUFFER
-static inline void console_putc_noserial(int file, const char c)
+static inline void console_puts_noserial(int file, const char *s)
 {
 	if (strcmp(stdio_devices[file]->name, "serial") != 0)
-		stdio_devices[file]->putc(stdio_devices[file], c);
+		stdio_devices[file]->puts(stdio_devices[file], s);
 }
 #endif
 
@@ -425,22 +425,26 @@ static void pre_console_puts(const char *s)
 
 static void print_pre_console_buffer(int flushpoint)
 {
-	unsigned long i = 0;
-	char *buffer = (char *)CONFIG_PRE_CON_BUF_ADDR;
+	unsigned long in = 0, out = 0;
+	char *buf_in = (char *)CONFIG_PRE_CON_BUF_ADDR;
+	char buf_out[CONFIG_PRE_CON_BUF_SZ + 1];
 
 	if (gd->precon_buf_idx > CONFIG_PRE_CON_BUF_SZ)
-		i = gd->precon_buf_idx - CONFIG_PRE_CON_BUF_SZ;
+		in = gd->precon_buf_idx - CONFIG_PRE_CON_BUF_SZ;
 
-	while (i < gd->precon_buf_idx)
-		switch (flushpoint) {
-		case PRE_CONSOLE_FLUSHPOINT1_SERIAL:
-			putc(buffer[CIRC_BUF_IDX(i++)]);
-			break;
-		case PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL:
-			console_putc_noserial(stdout,
-					      buffer[CIRC_BUF_IDX(i++)]);
-			break;
-		}
+	while (in < gd->precon_buf_idx)
+		buf_out[out++] = buf_in[CIRC_BUF_IDX(in++)];
+
+	buf_out[out] = 0;
+
+	switch (flushpoint) {
+	case PRE_CONSOLE_FLUSHPOINT1_SERIAL:
+		puts(buf_out);
+		break;
+	case PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL:
+		console_puts_noserial(stdout, buf_out);
+		break;
+	}
 }
 #else
 static inline void pre_console_putc(const char c) {}
include/configs/sunxi-common.h +1 -1
index c78141e..5d77e71 100644
@@ -402,7 +402,7 @@ extern int soft_i2c_gpio_scl;
 
 /* Enable pre-console buffer to get complete log on the VGA console */
 #define CONFIG_PRE_CONSOLE_BUFFER
-#define CONFIG_PRE_CON_BUF_SZ		(1024 * 1024)
+#define CONFIG_PRE_CON_BUF_SZ		4096 /* Aprox 2 80*25 screens */
 #ifdef CONFIG_MMC
 #define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0)
 #else
Signature · 1 line
2.3.6
#2 lore raw

PATCH 2/2 console: Fix pre-console flushing via cfb_console being very slow

Quoted 20 lines · Hans de Goede

On my A10 OlinuxIno Lime I noticed a huge (5+ seconds) delay coming from console_init_r. This turns out to be caused by the preconsole buffer flushing to the cfb_console. The Lime only has a 16 bit memory bus and that is already heavy used to scan out the 1920x1080 framebuffer.

The problem is that print_pre_console_buffer() was printing the buffer once character at a time and the cfb_console code then ends up doing a cache-flush for touched display lines for each character.

This commit fixes this by first building a 0 terminated buffer and then printing it in one puts() call, avoiding unnecessary cache flushes.

This changes the time for the flush from 5+ seconds to not noticable.

The downside of this approach is that the pre-console buffer needs to fit on the stack, this is not that much to ask since we are talking about plain text here. This commit also adjusts the sunxi CONFIG_PRE_CON_BUF_SZ to actually fit on the stack. Sunxi currently is the only user of the pre-console code so no other boards need to be adjusted.

Quoted 4 lines
---
 README                         |  3 +++
 common/console.c               | 40 ++++++++++++++++++++++------------------

I think you need an ack from the maintainer of this file more than you do from me. I'm happy for you to enable this option if that maintainer is happy for it to exist in the first place.

include/configs/sunxi-common.h extern int soft_i2c_gpio_scl; · line 405

Quoted 13 lines
 include/configs/sunxi-common.h |  2 +-
 3 files changed, 26 insertions(+), 19 deletions(-)

[...]

include/configs/sunxi-common.h +1 -1
index c78141e..5d77e71 100644
@@ -402,7 +402,7 @@ extern int soft_i2c_gpio_scl;
 
 /* Enable pre-console buffer to get complete log on the VGA console */
 #define CONFIG_PRE_CONSOLE_BUFFER
-#define CONFIG_PRE_CON_BUF_SZ		(1024 * 1024)
+#define CONFIG_PRE_CON_BUF_SZ		4096 /* Aprox 2 80*25 screens */

"Approx".

#3 lore raw

PATCH 2/2 console: Fix pre-console flushing via cfb_console being very slow

Hi,

Quoted 21 lines · Ian Campbell
Quoted 20 lines · Hans de Goede

On my A10 OlinuxIno Lime I noticed a huge (5+ seconds) delay coming from console_init_r. This turns out to be caused by the preconsole buffer flushing to the cfb_console. The Lime only has a 16 bit memory bus and that is already heavy used to scan out the 1920x1080 framebuffer.

The problem is that print_pre_console_buffer() was printing the buffer once character at a time and the cfb_console code then ends up doing a cache-flush for touched display lines for each character.

This commit fixes this by first building a 0 terminated buffer and then printing it in one puts() call, avoiding unnecessary cache flushes.

This changes the time for the flush from 5+ seconds to not noticable.

The downside of this approach is that the pre-console buffer needs to fit on the stack, this is not that much to ask since we are talking about plain text here. This commit also adjusts the sunxi CONFIG_PRE_CON_BUF_SZ to actually fit on the stack. Sunxi currently is the only user of the pre-console code so no other boards need to be adjusted.

Quoted 8 lines
Quoted 4 lines
---
  README                         |  3 +++
  common/console.c               | 40 ++++++++++++++++++++++------------------

I think you need an ack from the maintainer of this file more than you do from me. I'm happy for you to enable this option if that maintainer is happy for it to exist in the first place.

I do not believe that anyone is actively maintaining this file. Last time we had changes to it we upstreamed them through the sunxi tree with Tom's ack.

Tom can we have your ack for this patch ? :

http://patchwork.ozlabs.org/patch/468076/

Quoted 9 lines
Quoted 9 lines
  include/configs/sunxi-common.h |  2 +-
  3 files changed, 26 insertions(+), 19 deletions(-)

[...]

include/configs/sunxi-common.h +0 -0
index c78141e..5d77e71 100644
@@ -402,7 +402,7 @@ extern int soft_i2c_gpio_scl;
 
Quoted 6 lines

include/configs/sunxi-common.h extern int soft_i2c_gpio_scl; · line 405

Quoted 4 lines
include/configs/sunxi-common.h +1 -1
  /* Enable pre-console buffer to get complete log on the VGA console */
  #define CONFIG_PRE_CONSOLE_BUFFER
-#define CONFIG_PRE_CON_BUF_SZ		(1024 * 1024)
+#define CONFIG_PRE_CON_BUF_SZ		4096 /* Aprox 2 80*25 screens */

"Approx".

Will fix.

Regards,

Hans

#4 lore raw

PATCH 2/2 console: Fix pre-console flushing via cfb_console being very slow

In reply to Hans de Goede
Quoted 14 lines · Hans de Goede

On my A10 OlinuxIno Lime I noticed a huge (5+ seconds) delay coming from console_init_r. This turns out to be caused by the preconsole buffer flushing to the cfb_console. The Lime only has a 16 bit memory bus and that is already heavy used to scan out the 1920x1080 framebuffer.

The problem is that print_pre_console_buffer() was printing the buffer once character at a time and the cfb_console code then ends up doing a cache-flush for touched display lines for each character.

This commit fixes this by first building a 0 terminated buffer and then printing it in one puts() call, avoiding unnecessary cache flushes.

This changes the time for the flush from 5+ seconds to not noticable.

Quoted 7 lines

The downside of this approach is that the pre-console buffer needs to fit on the stack, this is not that much to ask since we are talking about plain text here. This commit also adjusts the sunxi CONFIG_PRE_CON_BUF_SZ to actually fit on the stack. Sunxi currently is the only user of the pre-console code so no other boards need to be adjusted.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150510/68027e43/attachment.sig>