From abde4af00f9d48a3a85e9d28965be15ed7312313 Mon Sep 17 00:00:00 2001 From: marco Date: Tue, 3 Aug 2010 16:55:06 +0000 Subject: [PATCH] Add busy flag so that we don't act on a SCI until a command in progress completes. Written with jordan. ok deraadt --- sys/dev/acpi/acpidev.h | 4 +++- sys/dev/acpi/acpiec.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sys/dev/acpi/acpidev.h b/sys/dev/acpi/acpidev.h index a3b2166917f..b0e2d425a3e 100644 --- a/sys/dev/acpi/acpidev.h +++ b/sys/dev/acpi/acpidev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpidev.h,v 1.30 2010/07/27 01:21:19 jordan Exp $ */ +/* $OpenBSD: acpidev.h,v 1.31 2010/08/03 16:55:06 marco Exp $ */ /* * Copyright (c) 2005 Marco Peereboom * Copyright (c) 2005 Thorsten Lockert @@ -317,6 +317,8 @@ struct acpiec_event { struct acpiec_softc { struct device sc_dev; + int sc_ecbusy; + /* command/status register */ bus_space_tag_t sc_cmd_bt; bus_space_handle_t sc_cmd_bh; diff --git a/sys/dev/acpi/acpiec.c b/sys/dev/acpi/acpiec.c index 53f278affe5..87aef517b30 100644 --- a/sys/dev/acpi/acpiec.c +++ b/sys/dev/acpi/acpiec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpiec.c,v 1.41 2010/08/02 17:13:57 deraadt Exp $ */ +/* $OpenBSD: acpiec.c,v 1.42 2010/08/03 16:55:06 marco Exp $ */ /* * Copyright (c) 2006 Can Erkin Acar * @@ -217,10 +217,14 @@ acpiec_read(struct acpiec_softc *sc, u_int8_t addr, int len, u_int8_t *buffer) * transaction does not get interrupted. */ dnprintf(20, "%s: read %d, %d\n", DEVNAME(sc), (int)addr, len); + sc->sc_ecbusy = 1; acpiec_burst_enable(sc); for (reg = 0; reg < len; reg++) buffer[reg] = acpiec_read_1(sc, addr + reg); acpiec_burst_disable(sc); + sc->sc_ecbusy = 0; + if (sc->sc_gotsci) + acpiec_sci_event(sc); } void @@ -234,10 +238,14 @@ acpiec_write(struct acpiec_softc *sc, u_int8_t addr, int len, u_int8_t *buffer) * transaction does not get interrupted. */ dnprintf(20, "%s: write %d, %d\n", DEVNAME(sc), (int)addr, len); + sc->sc_ecbusy = 1; acpiec_burst_enable(sc); for (reg = 0; reg < len; reg++) acpiec_write_1(sc, addr + reg, buffer[reg]); acpiec_burst_disable(sc); + sc->sc_ecbusy = 0; + if (sc->sc_gotsci) + acpiec_sci_event(sc); } int @@ -316,7 +324,7 @@ acpiec_gpehandler(struct acpi_softc *acpi_sc, int gpe, void *arg) dnprintf(10, "ACPIEC: got gpe\n"); do { - if (sc->sc_gotsci) + if (sc->sc_gotsci && !sc->sc_ecbusy) acpiec_sci_event(sc); stat = acpiec_status(sc); -- 2.20.1