Skip to content

Commit cf8e019

Browse files
Stefano Stabellinikonradwilk
authored andcommitted
hvc_xen: introduce HVC_XEN_FRONTEND
Introduce a new config option HVC_XEN_FRONTEND to enable/disable the xenbus based pv console frontend. Signed-off-by: Stefano Stabellini <[email protected]> Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
1 parent 02e19f9 commit cf8e019

File tree

2 files changed

+70
-54
lines changed

2 files changed

+70
-54
lines changed

drivers/tty/hvc/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ config HVC_XEN
7676
help
7777
Xen virtual console device driver
7878

79+
config HVC_XEN_FRONTEND
80+
bool "Xen Hypervisor Multiple Consoles support"
81+
depends on HVC_XEN
82+
select XEN_XENBUS_FRONTEND
83+
default y
84+
help
85+
Xen driver for secondary virtual consoles
86+
7987
config HVC_UDBG
8088
bool "udbg based fake hypervisor console"
8189
depends on PPC && EXPERIMENTAL

drivers/tty/hvc/hvc_xen.c

Lines changed: 62 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ struct xencons_info {
5555

5656
static LIST_HEAD(xenconsoles);
5757
static DEFINE_SPINLOCK(xencons_lock);
58-
static struct xenbus_driver xencons_driver;
5958

6059
/* ------------------------------------------------------------------ */
6160

@@ -298,53 +297,6 @@ static int xen_initial_domain_console_init(void)
298297
return 0;
299298
}
300299

301-
static int __init xen_hvc_init(void)
302-
{
303-
int r;
304-
struct xencons_info *info;
305-
const struct hv_ops *ops;
306-
307-
if (!xen_domain())
308-
return -ENODEV;
309-
310-
if (xen_initial_domain()) {
311-
ops = &dom0_hvc_ops;
312-
r = xen_initial_domain_console_init();
313-
if (r < 0)
314-
return r;
315-
info = vtermno_to_xencons(HVC_COOKIE);
316-
} else {
317-
ops = &domU_hvc_ops;
318-
if (xen_hvm_domain())
319-
r = xen_hvm_console_init();
320-
else
321-
r = xen_pv_console_init();
322-
if (r < 0)
323-
return r;
324-
325-
info = vtermno_to_xencons(HVC_COOKIE);
326-
info->irq = bind_evtchn_to_irq(info->evtchn);
327-
}
328-
if (info->irq < 0)
329-
info->irq = 0; /* NO_IRQ */
330-
else
331-
irq_set_noprobe(info->irq);
332-
333-
info->hvc = hvc_alloc(HVC_COOKIE, info->irq, ops, 256);
334-
if (IS_ERR(info->hvc)) {
335-
r = PTR_ERR(info->hvc);
336-
spin_lock(&xencons_lock);
337-
list_del(&info->list);
338-
spin_unlock(&xencons_lock);
339-
if (info->irq)
340-
unbind_from_irqhandler(info->irq, NULL);
341-
kfree(info);
342-
return r;
343-
}
344-
345-
return xenbus_register_frontend(&xencons_driver);
346-
}
347-
348300
void xen_console_resume(void)
349301
{
350302
struct xencons_info *info = vtermno_to_xencons(HVC_COOKIE);
@@ -392,6 +344,9 @@ static int xen_console_remove(struct xencons_info *info)
392344
return 0;
393345
}
394346

347+
#ifdef CONFIG_HVC_XEN_FRONTEND
348+
static struct xenbus_driver xencons_driver;
349+
395350
static int xencons_remove(struct xenbus_device *dev)
396351
{
397352
return xen_console_remove(dev_get_drvdata(&dev->dev));
@@ -543,6 +498,65 @@ static const struct xenbus_device_id xencons_ids[] = {
543498
};
544499

545500

501+
static DEFINE_XENBUS_DRIVER(xencons, "xenconsole",
502+
.probe = xencons_probe,
503+
.remove = xencons_remove,
504+
.resume = xencons_resume,
505+
.otherend_changed = xencons_backend_changed,
506+
);
507+
#endif /* CONFIG_HVC_XEN_FRONTEND */
508+
509+
static int __init xen_hvc_init(void)
510+
{
511+
int r;
512+
struct xencons_info *info;
513+
const struct hv_ops *ops;
514+
515+
if (!xen_domain())
516+
return -ENODEV;
517+
518+
if (xen_initial_domain()) {
519+
ops = &dom0_hvc_ops;
520+
r = xen_initial_domain_console_init();
521+
if (r < 0)
522+
return r;
523+
info = vtermno_to_xencons(HVC_COOKIE);
524+
} else {
525+
ops = &domU_hvc_ops;
526+
if (xen_hvm_domain())
527+
r = xen_hvm_console_init();
528+
else
529+
r = xen_pv_console_init();
530+
if (r < 0)
531+
return r;
532+
533+
info = vtermno_to_xencons(HVC_COOKIE);
534+
info->irq = bind_evtchn_to_irq(info->evtchn);
535+
}
536+
if (info->irq < 0)
537+
info->irq = 0; /* NO_IRQ */
538+
else
539+
irq_set_noprobe(info->irq);
540+
541+
info->hvc = hvc_alloc(HVC_COOKIE, info->irq, ops, 256);
542+
if (IS_ERR(info->hvc)) {
543+
r = PTR_ERR(info->hvc);
544+
spin_lock(&xencons_lock);
545+
list_del(&info->list);
546+
spin_unlock(&xencons_lock);
547+
if (info->irq)
548+
unbind_from_irqhandler(info->irq, NULL);
549+
kfree(info);
550+
return r;
551+
}
552+
553+
r = 0;
554+
#ifdef CONFIG_HVC_XEN_FRONTEND
555+
r = xenbus_register_frontend(&xencons_driver);
556+
#endif
557+
return r;
558+
}
559+
546560
static void __exit xen_hvc_fini(void)
547561
{
548562
struct xencons_info *entry, *next;
@@ -580,12 +594,6 @@ static int xen_cons_init(void)
580594
return 0;
581595
}
582596

583-
static DEFINE_XENBUS_DRIVER(xencons, "xenconsole",
584-
.probe = xencons_probe,
585-
.remove = xencons_remove,
586-
.resume = xencons_resume,
587-
.otherend_changed = xencons_backend_changed,
588-
);
589597

590598
module_init(xen_hvc_init);
591599
module_exit(xen_hvc_fini);

0 commit comments

Comments
 (0)