diff options
author | Christian Borntraeger <borntraeger@de.ibm.com> | 2008-06-20 09:24:08 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2008-07-24 22:06:06 -0400 |
commit | 611e097d7707741a336a0677d9d69bec40f29f3d (patch) | |
tree | 0b0059544914bf027ada51a1ba90f694c54df835 /drivers/char/hvc_console.h | |
parent | 066f4d82a67f621ddd547bfa4b9c94631d8457b0 (diff) |
hvc_console: rework setup to replace irq functions with callbacks
This patch tries to change hvc_console to not use request_irq/free_irq if
the backend does not use irqs. This allows virtio_console to use hvc_console
without having a linker reference to request_irq/free_irq.
In addition, together with patch 2/3 it improves the performance for virtio
console input. (an earlier version of this patch was tested by Yajin on lguest)
The irq specific code is moved to hvc_irq.c and selected by the drivers that
use irqs (System p, System i, XEN).
I replaced "int irq" with the opaque "int data". The request_irq and
free_irq calls are replaced with notifier_add and notifier_del. I have also
changed the code a bit to call the notifier_add and notifier_del inside the
spinlock area as the callbacks are found via hp->ops.
Changes since last version:
o remove ifdef
o reintroduce "irq_requested" as "notified"
o cleanups, sparse..
I did not move the timer based polling into a separate polling scheme. I
played with several variants, but it seems we need to sleep/schedule in
a thread even for irq based consoles, as there are throttleing and buffer
size constraints.
I also kept hvc_struct defined in hvc_console.h so that hvc_irq.c can access
the irq_requested element.
Feedback is appreciated. virtio_console is currently the only available console
for kvm on s390. I plan to push this change as soon as all affected parties
agree on it. I would love to get test results from System p, Xen etc.
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/char/hvc_console.h')
-rw-r--r-- | drivers/char/hvc_console.h | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/drivers/char/hvc_console.h b/drivers/char/hvc_console.h index 42ffb17e15df..d9ce10915625 100644 --- a/drivers/char/hvc_console.h +++ b/drivers/char/hvc_console.h | |||
@@ -26,6 +26,7 @@ | |||
26 | 26 | ||
27 | #ifndef HVC_CONSOLE_H | 27 | #ifndef HVC_CONSOLE_H |
28 | #define HVC_CONSOLE_H | 28 | #define HVC_CONSOLE_H |
29 | #include <linux/kref.h> | ||
29 | 30 | ||
30 | /* | 31 | /* |
31 | * This is the max number of console adapters that can/will be found as | 32 | * This is the max number of console adapters that can/will be found as |
@@ -42,24 +43,50 @@ | |||
42 | */ | 43 | */ |
43 | #define HVC_ALLOC_TTY_ADAPTERS 8 | 44 | #define HVC_ALLOC_TTY_ADAPTERS 8 |
44 | 45 | ||
46 | struct hvc_struct { | ||
47 | spinlock_t lock; | ||
48 | int index; | ||
49 | struct tty_struct *tty; | ||
50 | unsigned int count; | ||
51 | int do_wakeup; | ||
52 | char *outbuf; | ||
53 | int outbuf_size; | ||
54 | int n_outbuf; | ||
55 | uint32_t vtermno; | ||
56 | struct hv_ops *ops; | ||
57 | int irq_requested; | ||
58 | int data; | ||
59 | struct list_head next; | ||
60 | struct kref kref; /* ref count & hvc_struct lifetime */ | ||
61 | }; | ||
45 | 62 | ||
46 | /* implemented by a low level driver */ | 63 | /* implemented by a low level driver */ |
47 | struct hv_ops { | 64 | struct hv_ops { |
48 | int (*get_chars)(uint32_t vtermno, char *buf, int count); | 65 | int (*get_chars)(uint32_t vtermno, char *buf, int count); |
49 | int (*put_chars)(uint32_t vtermno, const char *buf, int count); | 66 | int (*put_chars)(uint32_t vtermno, const char *buf, int count); |
50 | }; | ||
51 | 67 | ||
52 | struct hvc_struct; | 68 | /* Callbacks for notification. Called in open and close */ |
69 | int (*notifier_add)(struct hvc_struct *hp, int irq); | ||
70 | void (*notifier_del)(struct hvc_struct *hp, int irq); | ||
71 | }; | ||
53 | 72 | ||
54 | /* Register a vterm and a slot index for use as a console (console_init) */ | 73 | /* Register a vterm and a slot index for use as a console (console_init) */ |
55 | extern int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops); | 74 | extern int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops); |
56 | 75 | ||
57 | /* register a vterm for hvc tty operation (module_init or hotplug add) */ | 76 | /* register a vterm for hvc tty operation (module_init or hotplug add) */ |
58 | extern struct hvc_struct * __devinit hvc_alloc(uint32_t vtermno, int irq, | 77 | extern struct hvc_struct * __devinit hvc_alloc(uint32_t vtermno, int data, |
59 | struct hv_ops *ops, int outbuf_size); | 78 | struct hv_ops *ops, int outbuf_size); |
60 | /* remove a vterm from hvc tty operation (modele_exit or hotplug remove) */ | 79 | /* remove a vterm from hvc tty operation (module_exit or hotplug remove) */ |
61 | extern int __devexit hvc_remove(struct hvc_struct *hp); | 80 | extern int __devexit hvc_remove(struct hvc_struct *hp); |
62 | 81 | ||
82 | /* data available */ | ||
83 | int hvc_poll(struct hvc_struct *hp); | ||
84 | void hvc_kick(void); | ||
85 | |||
86 | /* default notifier for irq based notification */ | ||
87 | extern int notifier_add_irq(struct hvc_struct *hp, int data); | ||
88 | extern void notifier_del_irq(struct hvc_struct *hp, int data); | ||
89 | |||
63 | 90 | ||
64 | #if defined(CONFIG_XMON) && defined(CONFIG_SMP) | 91 | #if defined(CONFIG_XMON) && defined(CONFIG_SMP) |
65 | #include <asm/xmon.h> | 92 | #include <asm/xmon.h> |