From patchwork Tue Aug 7 14:52:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 175728 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 50EF62C0084 for ; Wed, 8 Aug 2012 02:26:00 +1000 (EST) Received: from localhost ([::1]:36902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SylAN-0005Ai-T5 for incoming@patchwork.ozlabs.org; Tue, 07 Aug 2012 10:53:51 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Syl9Y-0003b9-SV for qemu-devel@nongnu.org; Tue, 07 Aug 2012 10:53:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Syl9R-00008s-Rw for qemu-devel@nongnu.org; Tue, 07 Aug 2012 10:53:00 -0400 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:34681) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Syl9R-00008j-Jq for qemu-devel@nongnu.org; Tue, 07 Aug 2012 10:52:53 -0400 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 7 Aug 2012 15:52:52 +0100 Received: from d06nrmr1806.portsmouth.uk.ibm.com (9.149.39.193) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 7 Aug 2012 15:52:51 +0100 Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q77EqpcY2810030 for ; Tue, 7 Aug 2012 15:52:51 +0100 Received: from d06av01.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q77Eqo6c009372 for ; Tue, 7 Aug 2012 08:52:50 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q77EqmHp009235; Tue, 7 Aug 2012 08:52:50 -0600 From: Cornelia Huck To: KVM , linux-s390 , qemu-devel Date: Tue, 7 Aug 2012 16:52:48 +0200 Message-Id: <1344351168-2568-5-git-send-email-cornelia.huck@de.ibm.com> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1344351168-2568-1-git-send-email-cornelia.huck@de.ibm.com> References: <1344351168-2568-1-git-send-email-cornelia.huck@de.ibm.com> x-cbid: 12080714-0342-0000-0000-0000028125F1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 195.75.94.111 Cc: Carsten Otte , Anthony Liguori , Rusty Russell , Sebastian Ott , Marcelo Tosatti , Heiko Carstens , Alexander Graf , Christian Borntraeger , Avi Kivity , Martin Schwidefsky Subject: [Qemu-devel] [PATCH 4/4] s390/kvm: Split out early console code. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This code is transport agnostic and can be used by both the legacy virtio code and virtio_ccw. Signed-off-by: Cornelia Huck --- drivers/s390/kvm/Makefile | 2 +- drivers/s390/kvm/early_printk.c | 42 +++++++++++++++++++++++++++++++++++++++++ drivers/s390/kvm/kvm_virtio.c | 29 ++-------------------------- drivers/s390/kvm/virtio_ccw.c | 1 - 4 files changed, 45 insertions(+), 29 deletions(-) create mode 100644 drivers/s390/kvm/early_printk.c diff --git a/drivers/s390/kvm/Makefile b/drivers/s390/kvm/Makefile index 241891a..a3c8fc4 100644 --- a/drivers/s390/kvm/Makefile +++ b/drivers/s390/kvm/Makefile @@ -6,4 +6,4 @@ # it under the terms of the GNU General Public License (version 2 only) # as published by the Free Software Foundation. -obj-$(CONFIG_S390_GUEST) += kvm_virtio.o virtio_ccw.o +obj-$(CONFIG_S390_GUEST) += kvm_virtio.o early_printk.o virtio_ccw.o diff --git a/drivers/s390/kvm/early_printk.c b/drivers/s390/kvm/early_printk.c new file mode 100644 index 0000000..7831530 --- /dev/null +++ b/drivers/s390/kvm/early_printk.c @@ -0,0 +1,42 @@ +/* + * early_printk.c - code for early console output with virtio_console + * split off from kvm_virtio.c + * + * Copyright IBM Corp. 2008 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License (version 2 only) + * as published by the Free Software Foundation. + * + * Author(s): Christian Borntraeger + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static __init int early_put_chars(u32 vtermno, const char *buf, int count) +{ + char scratch[17]; + unsigned int len = count; + + if (len > sizeof(scratch) - 1) + len = sizeof(scratch) - 1; + scratch[len] = '\0'; + memcpy(scratch, buf, len); + kvm_hypercall1(KVM_S390_VIRTIO_NOTIFY, __pa(scratch)); + return len; +} + +static int __init s390_virtio_console_init(void) +{ + if (sclp_has_vt220() || sclp_has_linemode()) + return -ENODEV; + return virtio_cons_early_init(early_put_chars); +} +console_initcall(s390_virtio_console_init); diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c index 408447c..c693548 100644 --- a/drivers/s390/kvm/kvm_virtio.c +++ b/drivers/s390/kvm/kvm_virtio.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -25,9 +24,9 @@ #include #include #include -#include #include #include +#include #define VIRTIO_SUBCODE_64 0x0D00 @@ -461,8 +460,7 @@ static int __init kvm_devices_init(void) if (test_devices_support() < 0) { vmem_remove_mapping(real_memory_size, PAGE_SIZE); root_device_unregister(kvm_root); - /* No error. */ - return 0; + return -ENODEV; } INIT_WORK(&hotplug_work, hotplug_devices); @@ -474,29 +472,6 @@ static int __init kvm_devices_init(void) return 0; } -/* code for early console output with virtio_console */ -static __init int early_put_chars(u32 vtermno, const char *buf, int count) -{ - char scratch[17]; - unsigned int len = count; - - if (len > sizeof(scratch) - 1) - len = sizeof(scratch) - 1; - scratch[len] = '\0'; - memcpy(scratch, buf, len); - kvm_hypercall1(KVM_S390_VIRTIO_NOTIFY, __pa(scratch)); - return len; -} - -static int __init s390_virtio_console_init(void) -{ - if (sclp_has_vt220() || sclp_has_linemode()) - return -ENODEV; - return virtio_cons_early_init(early_put_chars); -} -console_initcall(s390_virtio_console_init); - - /* * We do this after core stuff, but before the drivers. */ diff --git a/drivers/s390/kvm/virtio_ccw.c b/drivers/s390/kvm/virtio_ccw.c index df0f994..c3d07db 100644 --- a/drivers/s390/kvm/virtio_ccw.c +++ b/drivers/s390/kvm/virtio_ccw.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include