From patchwork Tue Oct 30 15:56:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 1670701 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 D05CC3FD8C for ; Tue, 30 Oct 2012 15:57:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933906Ab2J3P5E (ORCPT ); Tue, 30 Oct 2012 11:57:04 -0400 Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:40909 "EHLO e06smtp12.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933884Ab2J3P4v (ORCPT ); Tue, 30 Oct 2012 11:56: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, 30 Oct 2012 15:56:50 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 30 Oct 2012 15:56:48 -0000 Received: from d06av08.portsmouth.uk.ibm.com (d06av08.portsmouth.uk.ibm.com [9.149.37.249]) by b06cxnps4076.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q9UFueMp46661700; Tue, 30 Oct 2012 15:56:40 GMT Received: from d06av08.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q9UFul87010686; Tue, 30 Oct 2012 09:56:47 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q9UFuhrU010531; Tue, 30 Oct 2012 09:56:46 -0600 From: Cornelia Huck To: Avi Kivity , Marcelo Tosatti Cc: KVM , linux-s390 , Christian Borntraeger , Carsten Otte , Alexander Graf , Heiko Carstens , Martin Schwidefsky , Sebastian Ott Subject: [PATCH v2 5/5] KVM: s390: Split out early console code. Date: Tue, 30 Oct 2012 16:56:43 +0100 Message-Id: <1351612603-31036-6-git-send-email-cornelia.huck@de.ibm.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1351612603-31036-1-git-send-email-cornelia.huck@de.ibm.com> References: <1351612603-31036-1-git-send-email-cornelia.huck@de.ibm.com> x-cbid: 12103015-8372-0000-0000-0000042C8C7D 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..915d687 --- /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 587f97e..5e06f70 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