Skip to contentSkip to conversation

HVC: do not request the irq twice.

PATCH In review Ian Campbell 2 participants 3 messages Jan 22, 2009 – Jan 23, 2009 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HVC: do not request the irq twice.

Otherwise:

  root@bogga:~# tty
  /dev/hvc0
  root@bogga:~# reboot

Broadcast message from root@bogga (hvc0) (Thu Jan 22 17:51:20 2009):

The system is going down for reboot NOW!
INIT: Switching to runlevel: 6
INIT: Sending processes the TERM signal
hvc_open: request_irq failed with rc -16.

Cc Milton Miller <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Hendrik Brueckner <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Rusty Russell <[email protected]>
---
 drivers/char/hvc_irq.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/char/hvc_irq.c +4 -0
index 2623e17..8152a13 100644
@@ -28,6 +28,10 @@ int notifier_add_irq(struct hvc_struct *hp, int irq)
 		hp->irq_requested = 0;
 		return 0;
 	}
+
+	if (hp->irq_requested)
+		return 0;
+
 	rc = request_irq(irq, hvc_handle_interrupt, IRQF_DISABLED,
 			   "hvc_console", hp);
 	if (!rc)
Signature · 1 line
1.5.6.5
Reviewed-by on v1 1/1
#1 lore raw

Am Thursday 22 January 2009 18:56:08 schrieb Ian Campbell:

drivers/char/hvc_irq.c int notifier_add_irq(struct hvc_struct *hp, int irq) · line 37

Quoted 13 lines
drivers/char/hvc_irq.c +4 -0
@@ -28,6 +28,10 @@ int notifier_add_irq(struct hvc_struct *hp, int irq)
 		hp->irq_requested = 0;
 		return 0;
 	}
+
+	if (hp->irq_requested)
+		return 0;
+
 	rc = request_irq(irq, hvc_handle_interrupt, IRQF_DISABLED,
 			   "hvc_console", hp);
 	if (!rc)

Unfortunately I have no system with an irq based hvc console - I cannot test this patch. Anyway, the patch looks sane:

If this really fixes a problem, I am asking myself, if notifier_del can be called several times as well. If yes, it might be better to call free_irq at the last notifier_del - which means we need proper refcounting. Otherwise the console switches into polling mode....

Christian, blaming Rusty for using hvc_console in virtio_console which made me somehow responsible for this code... ;-)

#2 lore raw
Quoted 18 lines · Christian Borntraeger

Am Thursday 22 January 2009 18:56:08 schrieb Ian Campbell:

drivers/char/hvc_irq.c int notifier_add_irq(struct hvc_struct *hp, int irq) · line 37

Quoted 13 lines
drivers/char/hvc_irq.c +4 -0
@@ -28,6 +28,10 @@ int notifier_add_irq(struct hvc_struct *hp, int irq)
 		hp->irq_requested = 0;
 		return 0;
 	}
+
+	if (hp->irq_requested)
+		return 0;
+
 	rc = request_irq(irq, hvc_handle_interrupt, IRQF_DISABLED,
 			   "hvc_console", hp);
 	if (!rc)

Unfortunately I have no system with an irq based hvc console - I cannot test this patch. Anyway, the patch looks sane:

Quoted 6 lines

If this really fixes a problem, I am asking myself, if notifier_del can be called several times as well. If yes, it might be better to call free_irq at the last notifier_del - which means we need proper refcounting. Otherwise the console switches into polling mode....

Hmm, interesting question. It looks like the count field in struct hvc_struct is being used to count opens and closes which should reference count the IRQ usage too.

Oh, I see, hvc_hangup resets count but the Xen dom0 hv_ops was missing the hangup hook to release the IRQ -- I'll fix this.

I think this patch can be ignored, real bug is on the Xen side.

Ian.