- Add or change memory barrier to reflect the related operation

- In xencons_handler(), update in_cons inside the loop, otherwise,
  we would trigger the xenconscn_getc() workaround wich reset cons and prod
  to their original values, and this creates an infinite loop

Should fix the console hang reported by several users on port-xen@.
This commit is contained in:
bouyer 2007-01-07 00:02:36 +00:00
parent 83aa19e1b0
commit 1073d668ed

View File

@ -1,4 +1,4 @@
/* $NetBSD: xencons.c,v 1.19 2006/10/01 19:28:43 elad Exp $ */
/* $NetBSD: xencons.c,v 1.20 2007/01/07 00:02:36 bouyer Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@ -63,7 +63,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.19 2006/10/01 19:28:43 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.20 2007/01/07 00:02:36 bouyer Exp $");
#include "opt_xen.h"
@ -387,6 +387,7 @@ xencons_start(struct tty *tp)
#define XNC_OUT (xencons_interface->out)
cons = xencons_interface->out_cons;
prod = xencons_interface->out_prod;
x86_lfence();
while (prod != cons + sizeof(xencons_interface->out)) {
if (MASK_XENCONS_IDX(prod, XNC_OUT) <
MASK_XENCONS_IDX(cons, XNC_OUT)) {
@ -402,9 +403,9 @@ xencons_start(struct tty *tp)
break;
prod = prod + len;
}
x86_lfence();
x86_sfence();
xencons_interface->out_prod = prod;
x86_lfence();
x86_sfence();
hypervisor_notify_via_evtchn(xen_start_info.console_evtchn);
#undef XNC_OUT
#else /* XEN3 */
@ -482,12 +483,13 @@ xencons_handler(void *arg)
cons = xencons_interface->in_cons;
prod = xencons_interface->in_prod;
x86_lfence();
} else
} else {
cons += len;
x86_sfence();
xencons_interface->in_cons = cons;
x86_sfence();
}
}
x86_lfence();
xencons_interface->in_cons = cons;
x86_lfence();
hypervisor_notify_via_evtchn(xen_start_info.console_evtchn);
splx(s);
return 1;