On 17.12.2011 17:27, Anssi Hannula wrote:
> On 16.12.2011 20:16, Colin Guthrie wrote:
>> Hi
>>
>> Just in case you didn't notice, X11 now starts on tty1 by default.
>>
>> So if you want a text login shell, make sure you go to tty2!
>>
>> I've not actually updated it for sysvinit now I think about it, so I'll
>> have to update the default inittab, but the principle is the same. We
>> want X there, not a login.
> 
> I wonder why that is needed...
> 
> If it is to prevent flickering when switching tty1->tty7, can't we just
> e.g. make the kernel use tty7 by default if needed?

For the record, attached are three alternative [1] untested
proof-of-concept patches that make kernel start on vt7.

It doesn't seem to be as simple as I had hoped, but if this is something
we want to do, I can come up with cleaner versions and see what upstream
thinks.

BTW, I know fedora uses vt1 for X, but what about other distros, e.g.
Ubuntu/Debian?


[1] by default only the first vt is initialized on early boot, the rest
are initialized on-demand. Since vt7 is not initialized, the patches
take different approaches: (1) allocate 7 vt's on early boot, (2)
allocate vt7 in addition to vt1, (3) only allocate vt7

-- 
Anssi Hannula
>From 3647fb1d98ef0bbd9fac4ea44a868835bada0a69 Mon Sep 17 00:00:00 2001
From: Anssi Hannula <anssi.hann...@iki.fi>
Date: Sun, 18 Dec 2011 11:56:38 +0200
Subject: [PATCH] set default console as vt7 (proof-of-concept)

---
 drivers/tty/vt/vt.c |    2 +-
 include/linux/vt.h  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index e716839..4c2782c 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -2923,7 +2923,7 @@ static int __init con_init(void)
 		vc_init(vc, vc->vc_rows, vc->vc_cols,
 			currcons || !vc->vc_sw->con_save_screen);
 	}
-	currcons = fg_console = 0;
+	currcons = fg_console = 6;
 	master_display_fg = vc = vc_cons[currcons].d;
 	set_origin(vc);
 	save_screen(vc);
diff --git a/include/linux/vt.h b/include/linux/vt.h
index 30a8dd9..663308a 100644
--- a/include/linux/vt.h
+++ b/include/linux/vt.h
@@ -6,7 +6,7 @@
  * These constants are also useful for user-level apps (e.g., VC
  * resizing).
  */
-#define MIN_NR_CONSOLES 1       /* must be at least 1 */
+#define MIN_NR_CONSOLES 7       /* must be at least 1 */
 #define MAX_NR_CONSOLES	63	/* serial lines start at 64 */
 #define MAX_NR_USER_CONSOLES 63	/* must be root to allocate above this */
 		/* Note: the ioctl VT_GETSTATE does not work for
-- 
1.7.7.2

>From 96d4ca3852279b0ae85b8b4ea1031fda2574d610 Mon Sep 17 00:00:00 2001
From: Anssi Hannula <anssi.hann...@iki.fi>
Date: Sun, 18 Dec 2011 12:16:18 +0200
Subject: [PATCH] set default console as vt7 (proof-of-concept)

---
 drivers/tty/vt/vc_screen.c |    1 +
 drivers/tty/vt/vt.c        |   24 ++++++++++++++++--------
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c
index 7a367ff..cdab4d5 100644
--- a/drivers/tty/vt/vc_screen.c
+++ b/drivers/tty/vt/vc_screen.c
@@ -662,5 +662,6 @@ int __init vcs_init(void)
 	device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
 	for (i = 0; i < MIN_NR_CONSOLES; i++)
 		vcs_make_sysfs(i);
+	vcs_make_sysfs(6);
 	return 0;
 }
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index e716839..72733ce 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -2871,6 +2871,19 @@ static void vc_init(struct vc_data *vc, unsigned int rows,
 	reset_terminal(vc, do_clear);
 }
 
+static void __init con_init_early_cons(unsigned int cons)
+{
+	struct vc_data *vc;
+
+	vc_cons[cons].d = vc = kzalloc(sizeof(struct vc_data), GFP_NOWAIT);
+	INIT_WORK(&vc_cons[cons].SAK_work, vc_SAK);
+	tty_port_init(&vc->port);
+	visual_init(vc, cons, 1);
+	vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT);
+	vc_init(vc, vc->vc_rows, vc->vc_cols,
+		cons || !vc->vc_sw->con_save_screen);
+}
+
 /*
  * This routine initializes console interrupts, and does nothing
  * else. If you want the screen to clear, call tty_write with
@@ -2915,15 +2928,10 @@ static int __init con_init(void)
 	}
 
 	for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) {
-		vc_cons[currcons].d = vc = kzalloc(sizeof(struct vc_data), GFP_NOWAIT);
-		INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK);
-		tty_port_init(&vc->port);
-		visual_init(vc, currcons, 1);
-		vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT);
-		vc_init(vc, vc->vc_rows, vc->vc_cols,
-			currcons || !vc->vc_sw->con_save_screen);
+		con_init_early_cons(currcons);
 	}
-	currcons = fg_console = 0;
+	con_init_early_cons(6);
+	currcons = fg_console = 6;
 	master_display_fg = vc = vc_cons[currcons].d;
 	set_origin(vc);
 	save_screen(vc);
-- 
1.7.7.2

>From 83cb8160a3bd07138adc6a8938d6067f44a6cf22 Mon Sep 17 00:00:00 2001
From: Anssi Hannula <anssi.hann...@iki.fi>
Date: Sun, 18 Dec 2011 12:24:04 +0200
Subject: [PATCH] set default console as vt7 (proof-of-concept)

---
 drivers/tty/vt/vc_screen.c |    3 +--
 drivers/tty/vt/vt.c        |    8 ++++----
 include/linux/vt.h         |    2 +-
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c
index 7a367ff..8d7dd54 100644
--- a/drivers/tty/vt/vc_screen.c
+++ b/drivers/tty/vt/vc_screen.c
@@ -660,7 +660,6 @@ int __init vcs_init(void)
 
 	device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
 	device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
-	for (i = 0; i < MIN_NR_CONSOLES; i++)
-		vcs_make_sysfs(i);
+	vcs_make_sysfs(DEFAULT_CONSOLE);
 	return 0;
 }
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index e716839..af6b932 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1018,7 +1018,7 @@ void vc_deallocate(unsigned int currcons)
 		put_pid(vc->vt_pid);
 		module_put(vc->vc_sw->owner);
 		kfree(vc->vc_screenbuf);
-		if (currcons >= MIN_NR_CONSOLES)
+		if (currcons != DEFAULT_CONSOLE)
 			kfree(vc);
 		vc_cons[currcons].d = NULL;
 	}
@@ -2914,7 +2914,7 @@ static int __init con_init(void)
 		mod_timer(&console_timer, jiffies + (blankinterval * HZ));
 	}
 
-	for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) {
+	currcons = DEFAULT_CONSOLE;
 		vc_cons[currcons].d = vc = kzalloc(sizeof(struct vc_data), GFP_NOWAIT);
 		INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK);
 		tty_port_init(&vc->port);
@@ -2922,8 +2922,8 @@ static int __init con_init(void)
 		vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT);
 		vc_init(vc, vc->vc_rows, vc->vc_cols,
 			currcons || !vc->vc_sw->con_save_screen);
-	}
-	currcons = fg_console = 0;
+
+	fg_console = currcons;
 	master_display_fg = vc = vc_cons[currcons].d;
 	set_origin(vc);
 	save_screen(vc);
diff --git a/include/linux/vt.h b/include/linux/vt.h
index 30a8dd9..6abf4fb 100644
--- a/include/linux/vt.h
+++ b/include/linux/vt.h
@@ -6,7 +6,7 @@
  * These constants are also useful for user-level apps (e.g., VC
  * resizing).
  */
-#define MIN_NR_CONSOLES 1       /* must be at least 1 */
+#define DEFAULT_CONSOLE 6
 #define MAX_NR_CONSOLES	63	/* serial lines start at 64 */
 #define MAX_NR_USER_CONSOLES 63	/* must be root to allocate above this */
 		/* Note: the ioctl VT_GETSTATE does not work for
-- 
1.7.7.2

Reply via email to