Skip to contentSkip to conversation

xenconsole: fix xencons=tty[0-9]+ param

PATCH In review Mark McLoughlin 2 participants 5 messages Jun 30, 2006 – Jul 2, 2006 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xenconsole: fix xencons=tty[0-9]+ param

Hi,
If you boot with e.g. xencons=tty3, then tty1/tty2 aren't valid
devices.

Attached patch makes it always create valid devices on tty1-tty63, but
all but the one specified by xencons are dummy devices.

Cheers,
Mark.

drivers/xen/console/console.c renamed from drivers/xen/console/console.c.markmc +14 -14
@@ -391,7 +391,7 @@
 {
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (TTY_INDEX(tty) != (xc_num - DRV(tty->driver)->minor_start))
 		return;
 
 	spin_lock_irqsave(&xencons_lock, flags);
@@ -402,7 +402,7 @@
 
 static void xencons_throttle(struct tty_struct *tty)
 {
-	if (TTY_INDEX(tty) != 0)
+	if (TTY_INDEX(tty) != (xc_num - DRV(tty->driver)->minor_start))
 		return;
 
 	if (I_IXOFF(tty))
@@ -411,7 +411,7 @@
 
 static void xencons_unthrottle(struct tty_struct *tty)
 {
-	if (TTY_INDEX(tty) != 0)
+	if (TTY_INDEX(tty) != (xc_num - DRV(tty->driver)->minor_start))
 		return;
 
 	if (I_IXOFF(tty)) {
@@ -426,7 +426,7 @@
 {
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (TTY_INDEX(tty) != (xc_num - DRV(tty->driver)->minor_start))
 		return;
 
 	spin_lock_irqsave(&xencons_lock, flags);
@@ -451,7 +451,7 @@
 	int i;
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (TTY_INDEX(tty) != (xc_num - DRV(tty->driver)->minor_start))
 		return count;
 
 	spin_lock_irqsave(&xencons_lock, flags);
@@ -472,7 +472,7 @@
 {
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (TTY_INDEX(tty) != (xc_num - DRV(tty->driver)->minor_start))
 		return;
 
 	spin_lock_irqsave(&xencons_lock, flags);
@@ -484,7 +484,7 @@
 {
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (TTY_INDEX(tty) != (xc_num - DRV(tty->driver)->minor_start))
 		return;
 
 	spin_lock_irqsave(&xencons_lock, flags);
@@ -496,7 +496,7 @@
 {
 	unsigned long orig_jiffies = jiffies;
 
-	if (TTY_INDEX(tty) != 0)
+	if (TTY_INDEX(tty) != (xc_num - DRV(tty->driver)->minor_start))
 		return;
 
 	while (DRV(tty->driver)->chars_in_buffer(tty)) {
@@ -515,7 +515,7 @@
 {
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (TTY_INDEX(tty) != (xc_num - DRV(tty->driver)->minor_start))
 		return 0;
 
 	spin_lock_irqsave(&xencons_lock, flags);
@@ -532,7 +532,7 @@
 {
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (TTY_INDEX(tty) != (xc_num - DRV(tty->driver)->minor_start))
 		return;
 
 	if (tty->count == 1) {
@@ -595,12 +595,12 @@
 
 	if (xc_mode == XC_SERIAL) {
 		DRV(xencons_driver)->name        = "ttyS";
-		DRV(xencons_driver)->minor_start = 64 + xc_num;
-		DRV(xencons_driver)->name_base   = 0 + xc_num;
+		DRV(xencons_driver)->minor_start = 64;
+		DRV(xencons_driver)->name_base   = 0;
 	} else {
 		DRV(xencons_driver)->name        = "tty";
-		DRV(xencons_driver)->minor_start = xc_num;
-		DRV(xencons_driver)->name_base   = xc_num;
+		DRV(xencons_driver)->minor_start = 1;
+		DRV(xencons_driver)->name_base   = 1;
 	}
 
 	tty_set_operations(xencons_driver, &xencons_ops);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 5 lines · Mark McLoughlin

If you boot with e.g. xencons=tty3, then tty1/tty2 aren't valid
devices.

Attached patch makes it always create valid devices on tty1-tty63, but
all but the one specified by xencons are dummy devices.

Is your change to ttyS correct for anything other than ttyS0? Looks like you'd incorrectly bind on ttyS0.

Also I see you made a predicate more complicated which is repeated many times. Could you hide it behind a suitably named macro? You may need to make it more complicated still to fix ttyS case...

-- Keir

#2 lore raw

Hi,

Quoted 8 lines · Keir Fraser
Quoted 5 lines · Mark McLoughlin

If you boot with e.g. xencons=tty3, then tty1/tty2 aren't valid
devices.

Attached patch makes it always create valid devices on tty1-tty63, but
all but the one specified by xencons are dummy devices.

Quoted 6 lines

Is your change to ttyS correct for anything other than ttyS0? Looks like you'd incorrectly bind on ttyS0.

Also I see you made a predicate more complicated which is repeated many times. Could you hide it behind a suitably named macro? You may need to make it more complicated still to fix ttyS case...

Good points. How about this?

Thanks,
Mark.

linux-2.6.16.x86_64/drivers/xen/console/console.c renamed from linux-2.6.16.x86_64/drivers/xen/console/console.c.xencons +15 -16
@@ -267,7 +267,7 @@
 /******************** User-space console driver (/dev/console) ************/
 
 #define DRV(_d)         (_d)
-#define TTY_INDEX(_tty) ((_tty)->index)
+#define DUMMY_TTY(_tty) (xc_mode != XC_SERIAL && (_tty)->index != (xc_num - 1))
 
 static struct termios *xencons_termios[MAX_NR_CONSOLES];
 static struct termios *xencons_termios_locked[MAX_NR_CONSOLES];
@@ -391,7 +391,7 @@
 {
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return;
 
 	spin_lock_irqsave(&xencons_lock, flags);
@@ -402,7 +402,7 @@
 
 static void xencons_throttle(struct tty_struct *tty)
 {
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return;
 
 	if (I_IXOFF(tty))
@@ -411,7 +411,7 @@
 
 static void xencons_unthrottle(struct tty_struct *tty)
 {
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return;
 
 	if (I_IXOFF(tty)) {
@@ -426,7 +426,7 @@
 {
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return;
 
 	spin_lock_irqsave(&xencons_lock, flags);
@@ -451,7 +451,7 @@
 	int i;
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return count;
 
 	spin_lock_irqsave(&xencons_lock, flags);
@@ -472,7 +472,7 @@
 {
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return;
 
 	spin_lock_irqsave(&xencons_lock, flags);
@@ -484,7 +484,7 @@
 {
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return;
 
 	spin_lock_irqsave(&xencons_lock, flags);
@@ -496,7 +496,7 @@
 {
 	unsigned long orig_jiffies = jiffies;
 
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return;
 
 	while (DRV(tty->driver)->chars_in_buffer(tty)) {
@@ -515,7 +515,7 @@
 {
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return 0;
 
 	spin_lock_irqsave(&xencons_lock, flags);
@@ -532,7 +532,7 @@
 {
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return;
 
 	if (tty->count == 1) {
@@ -599,8 +599,8 @@
 		DRV(xencons_driver)->name_base   = 0 + xc_num;
 	} else {
 		DRV(xencons_driver)->name        = "tty";
-		DRV(xencons_driver)->minor_start = xc_num;
-		DRV(xencons_driver)->name_base   = xc_num;
+		DRV(xencons_driver)->minor_start = 1;
+		DRV(xencons_driver)->name_base   = 1;
 	}
 
 	tty_set_operations(xencons_driver, &xencons_ops);
@@ -615,7 +615,7 @@
 		return rc;
 	}
 
-	tty_register_device(xencons_driver, 0, NULL);
+	tty_register_device(xencons_driver, XC_SERIAL ? 0 : xc_num - 1, NULL);
 
 	if (xen_start_info->flags & SIF_INITDOMAIN) {
 		xencons_priv_irq = bind_virq_to_irqhandler(
@@ -629,8 +629,7 @@
 	}
 
 	printk("Xen virtual console successfully installed as %s%d\n",
-	       DRV(xencons_driver)->name,
-	       DRV(xencons_driver)->name_base );
+	       DRV(xencons_driver)->name, xc_num);
 
 	return 0;
 }

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
Quoted 9 lines
Quoted 6 lines

Is your change to ttyS correct for anything other than ttyS0? Looks like you'd incorrectly bind on ttyS0.

Also I see you made a predicate more complicated which is repeated many times. Could you hide it behind a suitably named macro? You may need to make it more complicated still to fix ttyS case...

Good points. How about this?

All looks okay except the following change:

- tty_register_device(xencons_driver, 0, NULL);
+ tty_register_device(xencons_driver, XC_SERIAL ? 0 : xc_num - 1, NULL);

First, it ought to be (xc_mode == XC_SERIAL) right? Secondly, is registering just one of the tty devices what you want to do? Do you not need to register the 'dummy' ones for this trick to work?

-- Keir

#4 lore raw
Quoted 17 lines · Keir Fraser
Quoted 11 lines
Quoted 8 lines

Is your change to ttyS correct for anything other than ttyS0? Looks like you'd incorrectly bind on ttyS0.

Also I see you made a predicate more complicated which is repeated many
times. Could you hide it behind a suitably named macro? You may need to
make it more complicated still to fix ttyS case...

Good points. How about this?

All looks okay except the following change:

(quoted diff) +1 -1
-	tty_register_device(xencons_driver, 0, NULL);
+	tty_register_device(xencons_driver, XC_SERIAL ? 0 : xc_num - 1, NULL);
Quoted 1 line

First, it ought to be (xc_mode == XC_SERIAL) right?

Doh, yes.

Quoted 3 lines

Secondly, is registering just one of the tty devices what you want to do? Do you not need to register the 'dummy' ones for this trick to work?

The previous behaviour was to only register the real tty, so I didn't
want to change that.

It seems that tty_register_device() only registers the device with
devfs and sysfs. Since we don't use devfs, I wasn't seeing any real side effects in testing, but I guess if you're using devfs you want the dummy devices registered too.

Removing the TTY_NO_DEVFS flag so that tty_register_driver() registers
the devices automatically seems to be the best thing to do?

Cheers,
Mark.

linux-2.6.16.x86_64/drivers/xen/console/console.c renamed from linux-2.6.16.x86_64/drivers/xen/console/console.c.xencons +15 -19
@@ -267,7 +267,7 @@
 /******************** User-space console driver (/dev/console) ************/
 
 #define DRV(_d)         (_d)
-#define TTY_INDEX(_tty) ((_tty)->index)
+#define DUMMY_TTY(_tty) (xc_mode != XC_SERIAL && (_tty)->index != (xc_num - 1))
 
 static struct termios *xencons_termios[MAX_NR_CONSOLES];
 static struct termios *xencons_termios_locked[MAX_NR_CONSOLES];
@@ -391,7 +391,7 @@
 {
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return;
 
 	spin_lock_irqsave(&xencons_lock, flags);
@@ -402,7 +402,7 @@
 
 static void xencons_throttle(struct tty_struct *tty)
 {
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return;
 
 	if (I_IXOFF(tty))
@@ -411,7 +411,7 @@
 
 static void xencons_unthrottle(struct tty_struct *tty)
 {
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return;
 
 	if (I_IXOFF(tty)) {
@@ -426,7 +426,7 @@
 {
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return;
 
 	spin_lock_irqsave(&xencons_lock, flags);
@@ -451,7 +451,7 @@
 	int i;
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return count;
 
 	spin_lock_irqsave(&xencons_lock, flags);
@@ -472,7 +472,7 @@
 {
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return;
 
 	spin_lock_irqsave(&xencons_lock, flags);
@@ -484,7 +484,7 @@
 {
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return;
 
 	spin_lock_irqsave(&xencons_lock, flags);
@@ -496,7 +496,7 @@
 {
 	unsigned long orig_jiffies = jiffies;
 
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return;
 
 	while (DRV(tty->driver)->chars_in_buffer(tty)) {
@@ -515,7 +515,7 @@
 {
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return 0;
 
 	spin_lock_irqsave(&xencons_lock, flags);
@@ -532,7 +532,7 @@
 {
 	unsigned long flags;
 
-	if (TTY_INDEX(tty) != 0)
+	if (DUMMY_TTY(tty))
 		return;
 
 	if (tty->count == 1) {
@@ -588,8 +588,7 @@
 	DRV(xencons_driver)->init_termios    = tty_std_termios;
 	DRV(xencons_driver)->flags           =
 		TTY_DRIVER_REAL_RAW |
-		TTY_DRIVER_RESET_TERMIOS |
-		TTY_DRIVER_NO_DEVFS;
+		TTY_DRIVER_RESET_TERMIOS;
 	DRV(xencons_driver)->termios         = xencons_termios;
 	DRV(xencons_driver)->termios_locked  = xencons_termios_locked;
 
@@ -599,8 +598,8 @@
 		DRV(xencons_driver)->name_base   = 0 + xc_num;
 	} else {
 		DRV(xencons_driver)->name        = "tty";
-		DRV(xencons_driver)->minor_start = xc_num;
-		DRV(xencons_driver)->name_base   = xc_num;
+		DRV(xencons_driver)->minor_start = 1;
+		DRV(xencons_driver)->name_base   = 1;
 	}
 
 	tty_set_operations(xencons_driver, &xencons_ops);
@@ -615,8 +614,6 @@
 		return rc;
 	}
 
-	tty_register_device(xencons_driver, 0, NULL);
-
 	if (xen_start_info->flags & SIF_INITDOMAIN) {
 		xencons_priv_irq = bind_virq_to_irqhandler(
 			VIRQ_CONSOLE,
@@ -629,8 +626,7 @@
 	}
 
 	printk("Xen virtual console successfully installed as %s%d\n",
-	       DRV(xencons_driver)->name,
-	       DRV(xencons_driver)->name_base );
+	       DRV(xencons_driver)->name, xc_num);
 
 	return 0;
 }

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel