From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Borntraeger Subject: [PATCHv2] virtio-console: wait for console ports Date: Thu, 22 Sep 2011 14:19:36 +0200 Message-ID: <4E7B27D8.3020207@de.ibm.com> References: <4E7A0837.5080908@de.ibm.com> <20110922100831.GB3105@amit-x200.redhat.com> <4E7B19E7.2090602@de.ibm.com> <20110922113048.GE3105@amit-x200.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: KVM list , Rusty Russell , Carsten Otte , virtualization@lists.linux-foundation.org To: Amit Shah Return-path: Received: from mtagate3.uk.ibm.com ([194.196.100.163]:43282 "EHLO mtagate3.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750978Ab1IVMTl (ORCPT ); Thu, 22 Sep 2011 08:19:41 -0400 Received: from d06nrmr1707.portsmouth.uk.ibm.com (d06nrmr1707.portsmouth.uk.ibm.com [9.149.39.225]) by mtagate3.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p8MCJdQc032239 for ; Thu, 22 Sep 2011 12:19:39 GMT Received: from d06av12.portsmouth.uk.ibm.com (d06av12.portsmouth.uk.ibm.com [9.149.37.247]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p8MCJd7b2228390 for ; Thu, 22 Sep 2011 13:19:39 +0100 Received: from d06av12.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p8MCJc6B007571 for ; Thu, 22 Sep 2011 06:19:39 -0600 In-Reply-To: <20110922113048.GE3105@amit-x200.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On s390 I have seen some random "Warning: unable to open an initial console" boot failure. Turns out that tty_open fails, because the hvc_alloc was not yet done. In former times this could not happen, since the probe function automatically called hvc_alloc. With newer versions (multiport) some host<->guest interaction is required before hvc_alloc is called. This might be too late, especially if an initramfs is involved. Lets use a completion if we have multiport and an early console. Signed-off-by: Christian Borntraeger --- drivers/char/virtio_console.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) Index: b/drivers/char/virtio_console.c =================================================================== --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -19,6 +19,7 @@ */ #include #include +#include #include #include #include @@ -73,6 +74,7 @@ struct ports_driver_data { static struct ports_driver_data pdrvdata; DEFINE_SPINLOCK(pdrvdata_lock); +DECLARE_COMPLETION(port_added); /* This struct holds information that's relevant only for console ports */ struct console { @@ -1352,6 +1354,7 @@ static void handle_control_message(struc break; init_port_console(port); + complete(&port_added); /* * Could remove the port here in case init fails - but * have to notify the host first. @@ -1648,6 +1651,10 @@ static int __devinit virtcons_probe(stru struct ports_device *portdev; int err; bool multiport; + bool early = early_put_chars != 0; + + /* Ensure to read early_put_chars now */ + barrier(); portdev = kmalloc(sizeof(*portdev), GFP_KERNEL); if (!portdev) { @@ -1719,6 +1726,19 @@ static int __devinit virtcons_probe(stru __send_control_msg(portdev, VIRTIO_CONSOLE_BAD_ID, VIRTIO_CONSOLE_DEVICE_READY, 1); + + /* + * If there was an early virtio console, assume that there are no + * other consoles. We need to wait until the hvc_alloc matches the + * hvc_instantiate, otherwise tty_open will complain, resulting in + * a "Warning: unable to open an initial console" boot failure. + * Without multiport this is done in add_port above. With multiport + * this might take some host<->guest communication - thus we have to + * wait. + */ + if (multiport && early) + wait_for_completion(&port_added); + return 0; free_vqs: