diff mbox

[5/5] KVM: s390: Split out early console code.

Message ID 1354883369-36537-6-git-send-email-cornelia.huck@de.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Cornelia Huck Dec. 7, 2012, 12:29 p.m. UTC
This code is transport agnostic and can be used by both the legacy
virtio code and virtio_ccw.

Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 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

Comments

Alexander Graf Dec. 9, 2012, 12:45 p.m. UTC | #1
On 07.12.2012, at 13:29, Cornelia Huck wrote:

> This code is transport agnostic and can be used by both the legacy
> virtio code and virtio_ccw.

This code should die. It's a nightmare to implement in QEMU, because it ends up being a separate char device. I'd prefer if we don't carry it over to the virtio-ccw world :).


Alex

> 
> Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> ---
> 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 <borntraeger@de.ibm.com>
> + */
> +
> +#include <linux/kernel_stat.h>
> +#include <linux/init.h>
> +#include <linux/err.h>
> +#include <linux/virtio_console.h>
> +#include <linux/kvm_para.h>
> +#include <asm/kvm_virtio.h>
> +#include <asm/setup.h>
> +#include <asm/sclp.h>
> +
> +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 779e480..6ca06ed 100644
> --- a/drivers/s390/kvm/kvm_virtio.c
> +++ b/drivers/s390/kvm/kvm_virtio.c
> @@ -17,7 +17,6 @@
> #include <linux/virtio.h>
> #include <linux/virtio_config.h>
> #include <linux/slab.h>
> -#include <linux/virtio_console.h>
> #include <linux/interrupt.h>
> #include <linux/virtio_ring.h>
> #include <linux/export.h>
> @@ -25,9 +24,9 @@
> #include <asm/io.h>
> #include <asm/kvm_para.h>
> #include <asm/kvm_virtio.h>
> -#include <asm/sclp.h>
> #include <asm/setup.h>
> #include <asm/irq.h>
> +#include <asm/sclp.h>
> 
> #define VIRTIO_SUBCODE_64 0x0D00
> 
> @@ -453,8 +452,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)
> @@ -479,29 +477,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 0e98b523a..1350391 100644
> --- a/drivers/s390/kvm/virtio_ccw.c
> +++ b/drivers/s390/kvm/virtio_ccw.c
> @@ -17,7 +17,6 @@
> #include <linux/virtio.h>
> #include <linux/virtio_config.h>
> #include <linux/slab.h>
> -#include <linux/virtio_console.h>
> #include <linux/interrupt.h>
> #include <linux/virtio_ring.h>
> #include <linux/pfn.h>
> -- 
> 1.7.12.4
> 

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Cornelia Huck Dec. 10, 2012, 9:06 a.m. UTC | #2
On Sun, 9 Dec 2012 13:45:47 +0100
Alexander Graf <agraf@suse.de> wrote:

> 
> On 07.12.2012, at 13:29, Cornelia Huck wrote:
> 
> > This code is transport agnostic and can be used by both the legacy
> > virtio code and virtio_ccw.
> 
> This code should die. It's a nightmare to implement in QEMU, because it ends up being a separate char device. I'd prefer if we don't carry it over to the virtio-ccw world :).

I don't really want to kill an interface in a patchset adding a new
transport. We may kill this later on, though...

> 
> 
> Alex
> 
> > 
> > Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
> > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> > ---
> > 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 <borntraeger@de.ibm.com>
> > + */
> > +
> > +#include <linux/kernel_stat.h>
> > +#include <linux/init.h>
> > +#include <linux/err.h>
> > +#include <linux/virtio_console.h>
> > +#include <linux/kvm_para.h>
> > +#include <asm/kvm_virtio.h>
> > +#include <asm/setup.h>
> > +#include <asm/sclp.h>
> > +
> > +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 779e480..6ca06ed 100644
> > --- a/drivers/s390/kvm/kvm_virtio.c
> > +++ b/drivers/s390/kvm/kvm_virtio.c
> > @@ -17,7 +17,6 @@
> > #include <linux/virtio.h>
> > #include <linux/virtio_config.h>
> > #include <linux/slab.h>
> > -#include <linux/virtio_console.h>
> > #include <linux/interrupt.h>
> > #include <linux/virtio_ring.h>
> > #include <linux/export.h>
> > @@ -25,9 +24,9 @@
> > #include <asm/io.h>
> > #include <asm/kvm_para.h>
> > #include <asm/kvm_virtio.h>
> > -#include <asm/sclp.h>
> > #include <asm/setup.h>
> > #include <asm/irq.h>
> > +#include <asm/sclp.h>
> > 
> > #define VIRTIO_SUBCODE_64 0x0D00
> > 
> > @@ -453,8 +452,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)
> > @@ -479,29 +477,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 0e98b523a..1350391 100644
> > --- a/drivers/s390/kvm/virtio_ccw.c
> > +++ b/drivers/s390/kvm/virtio_ccw.c
> > @@ -17,7 +17,6 @@
> > #include <linux/virtio.h>
> > #include <linux/virtio_config.h>
> > #include <linux/slab.h>
> > -#include <linux/virtio_console.h>
> > #include <linux/interrupt.h>
> > #include <linux/virtio_ring.h>
> > #include <linux/pfn.h>
> > -- 
> > 1.7.12.4
> > 
> 

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexander Graf Dec. 11, 2012, 10:10 a.m. UTC | #3
On 10.12.2012, at 10:06, Cornelia Huck wrote:

> On Sun, 9 Dec 2012 13:45:47 +0100
> Alexander Graf <agraf@suse.de> wrote:
> 
>> 
>> On 07.12.2012, at 13:29, Cornelia Huck wrote:
>> 
>>> This code is transport agnostic and can be used by both the legacy
>>> virtio code and virtio_ccw.
>> 
>> This code should die. It's a nightmare to implement in QEMU, because it ends up being a separate char device. I'd prefer if we don't carry it over to the virtio-ccw world :).
> 
> I don't really want to kill an interface in a patchset adding a new
> transport. We may kill this later on, though...

I fully agree :). What I was trying to say is "leave this to die in the old code and don't bother about it in the new world order". Removing support for the old kvm virtio machine is nothing for today.


Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Cornelia Huck Dec. 11, 2012, 12:36 p.m. UTC | #4
On Tue, 11 Dec 2012 11:10:39 +0100
Alexander Graf <agraf@suse.de> wrote:

> 
> On 10.12.2012, at 10:06, Cornelia Huck wrote:
> 
> > On Sun, 9 Dec 2012 13:45:47 +0100
> > Alexander Graf <agraf@suse.de> wrote:
> > 
> >> 
> >> On 07.12.2012, at 13:29, Cornelia Huck wrote:
> >> 
> >>> This code is transport agnostic and can be used by both the legacy
> >>> virtio code and virtio_ccw.
> >> 
> >> This code should die. It's a nightmare to implement in QEMU, because it ends up being a separate char device. I'd prefer if we don't carry it over to the virtio-ccw world :).
> > 
> > I don't really want to kill an interface in a patchset adding a new
> > transport. We may kill this later on, though...
> 
> I fully agree :). What I was trying to say is "leave this to die in the old code and don't bother about it in the new world order". Removing support for the old kvm virtio machine is nothing for today.

Ah, OK. I'll merge the return -ENODEV into the first patch then and
drop this one.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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 <borntraeger@de.ibm.com>
+ */
+
+#include <linux/kernel_stat.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/virtio_console.h>
+#include <linux/kvm_para.h>
+#include <asm/kvm_virtio.h>
+#include <asm/setup.h>
+#include <asm/sclp.h>
+
+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 779e480..6ca06ed 100644
--- a/drivers/s390/kvm/kvm_virtio.c
+++ b/drivers/s390/kvm/kvm_virtio.c
@@ -17,7 +17,6 @@ 
 #include <linux/virtio.h>
 #include <linux/virtio_config.h>
 #include <linux/slab.h>
-#include <linux/virtio_console.h>
 #include <linux/interrupt.h>
 #include <linux/virtio_ring.h>
 #include <linux/export.h>
@@ -25,9 +24,9 @@ 
 #include <asm/io.h>
 #include <asm/kvm_para.h>
 #include <asm/kvm_virtio.h>
-#include <asm/sclp.h>
 #include <asm/setup.h>
 #include <asm/irq.h>
+#include <asm/sclp.h>
 
 #define VIRTIO_SUBCODE_64 0x0D00
 
@@ -453,8 +452,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)
@@ -479,29 +477,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 0e98b523a..1350391 100644
--- a/drivers/s390/kvm/virtio_ccw.c
+++ b/drivers/s390/kvm/virtio_ccw.c
@@ -17,7 +17,6 @@ 
 #include <linux/virtio.h>
 #include <linux/virtio_config.h>
 #include <linux/slab.h>
-#include <linux/virtio_console.h>
 #include <linux/interrupt.h>
 #include <linux/virtio_ring.h>
 #include <linux/pfn.h>