From patchwork Tue Sep 4 15:13:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 1402871 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 3D575402E1 for ; Tue, 4 Sep 2012 15:14:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932521Ab2IDPN4 (ORCPT ); Tue, 4 Sep 2012 11:13:56 -0400 Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:42599 "EHLO e06smtp12.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757269Ab2IDPNv (ORCPT ); Tue, 4 Sep 2012 11:13:51 -0400 Received: from /spool/local by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Sep 2012 16:13:50 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 4 Sep 2012 16:13:47 +0100 Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q84FDeZl44695602; Tue, 4 Sep 2012 15:13:40 GMT Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q84Eidbw024929; Tue, 4 Sep 2012 10:44:40 -0400 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q84Eiajv024630; Tue, 4 Sep 2012 10:44:38 -0400 From: Cornelia Huck To: KVM , linux-s390 , qemu-devel Cc: Avi Kivity , Marcelo Tosatti , Anthony Liguori , Rusty Russell , Christian Borntraeger , Carsten Otte , Alexander Graf , Heiko Carstens , Martin Schwidefsky , Sebastian Ott Subject: [PATCH v2 4/4] s390/kvm: Split out early console code. Date: Tue, 4 Sep 2012 17:13:42 +0200 Message-Id: <1346771622-52763-5-git-send-email-cornelia.huck@de.ibm.com> X-Mailer: git-send-email 1.7.11.5 In-Reply-To: <1346771622-52763-1-git-send-email-cornelia.huck@de.ibm.com> References: <1346771622-52763-1-git-send-email-cornelia.huck@de.ibm.com> x-cbid: 12090415-8372-0000-0000-000003A6CD1C Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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 76b95f3..6cdc66a 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 @@ -450,8 +449,7 @@ static int __init kvm_devices_init(void) return -ENODEV; if (test_devices_support(real_memory_size) < 0) - /* No error. */ - return 0; + return -ENODEV; rc = vmem_add_mapping(real_memory_size, PAGE_SIZE); if (rc) @@ -476,29 +474,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 1c9af22..14ae293 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