summaryrefslogtreecommitdiffstats
path: root/sys/dev/acpica/acpi_cmbat.c
diff options
context:
space:
mode:
authoriwasaki <iwasaki@FreeBSD.org>2001-12-22 16:05:41 +0000
committeriwasaki <iwasaki@FreeBSD.org>2001-12-22 16:05:41 +0000
commit4c7abcd3372368396a11a120c259afdb0fe2b015 (patch)
tree7c96c678372cc5f9e23154023196e80b72311f86 /sys/dev/acpica/acpi_cmbat.c
parent23a35cbf8dc1e76d3a4e856806e0ee472c65e5af (diff)
downloadFreeBSD-src-4c7abcd3372368396a11a120c259afdb0fe2b015.zip
FreeBSD-src-4c7abcd3372368396a11a120c259afdb0fe2b015.tar.gz
Add OS layer ACPI mutex and threading support.
- Temporary fix a bug of Intel ACPI CA core code. - Add OS layer ACPI mutex support. This can be disabled by specifying option ACPI_NO_SEMAPHORES. - Add ACPI threading support. Now that we have a dedicate taskqueue for ACPI tasks and more ACPI task threads can be created by specifying option ACPI_MAX_THREADS. - Change acpi_EvaluateIntoBuffer() behavior slightly to reuse given caller's buffer unless AE_BUFFER_OVERFLOW occurs. Also CM battery's evaluations were changed to use acpi_EvaluateIntoBuffer(). - Add new utility function acpi_ConvertBufferToInteger(). - Add simple locking for CM battery and temperature updating. - Fix a minor problem on EC locking. - Make the thermal zone polling rate to be changeable. - Change minor things on AcpiOsSignal(); in ACPI_SIGNAL_FATAL case, entering Debugger is easier to investigate the problem rather than panic.
Diffstat (limited to 'sys/dev/acpica/acpi_cmbat.c')
-rw-r--r--sys/dev/acpica/acpi_cmbat.c83
1 files changed, 19 insertions, 64 deletions
diff --git a/sys/dev/acpica/acpi_cmbat.c b/sys/dev/acpica/acpi_cmbat.c
index dc78c42..ccab956 100644
--- a/sys/dev/acpica/acpi_cmbat.c
+++ b/sys/dev/acpica/acpi_cmbat.c
@@ -108,6 +108,8 @@ struct acpi_cmbat_softc {
ACPI_BUFFER bst_buffer;
struct timespec bif_lastupdated;
struct timespec bst_lastupdated;
+ int bif_updating;
+ int bst_updating;
int not_present;
int cap;
@@ -195,42 +197,17 @@ acpi_cmbat_get_bst(void *context)
return;
}
- untimeout(acpi_cmbat_timeout, (caddr_t)dev, sc->cmbat_timeout);
-retry:
- if (sc->bst_buffer.Length == 0) {
- if (sc->bst_buffer.Pointer != NULL) {
- free(sc->bst_buffer.Pointer, M_ACPICMBAT);
- sc->bst_buffer.Pointer = NULL;
- }
- as = AcpiEvaluateObject(h, "_BST", NULL, &sc->bst_buffer);
- if (as != AE_BUFFER_OVERFLOW) {
- ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev),
- "couldn't find _BST - %s\n", AcpiFormatException(as));
- goto end;
- }
-
- sc->bst_buffer.Pointer = malloc(sc->bst_buffer.Length, M_ACPICMBAT, M_NOWAIT);
- if (sc->bst_buffer.Pointer == NULL) {
- device_printf(dev, "malloc failed");
- goto end;
- }
+ if (sc->bst_updating) {
+ return;
}
+ sc->bst_updating = 1;
- bzero(sc->bst_buffer.Pointer, sc->bst_buffer.Length);
- as = AcpiEvaluateObject(h, "_BST", NULL, &sc->bst_buffer);
+ untimeout(acpi_cmbat_timeout, (caddr_t)dev, sc->cmbat_timeout);
- if (as == AE_BUFFER_OVERFLOW) {
- if (sc->bst_buffer.Pointer != NULL) {
- free(sc->bst_buffer.Pointer, M_ACPICMBAT);
- sc->bst_buffer.Pointer = NULL;
- }
- ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev),
- "bst size changed to %d\n", sc->bst_buffer.Length);
- sc->bst_buffer.Length = 0;
- goto retry;
- } else if (as != AE_OK) {
+ if ((as = acpi_EvaluateIntoBuffer(h, "_BST", NULL, &sc->bst_buffer)) != AE_OK) {
ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev),
- "couldn't find _BST - %s\n", AcpiFormatException(as));
+ "error fetching current battery status -- %s\n",
+ AcpiFormatException(as));
goto end;
}
@@ -248,6 +225,7 @@ retry:
PKG_GETINT(res, tmp, 3, sc->bst.volt, end);
acpi_cmbat_info_updated(&sc->bst_lastupdated);
end:
+ sc->bst_updating = 0;
sc->cmbat_timeout = timeout(acpi_cmbat_timeout, dev, CMBAT_POLLRATE);
}
@@ -268,42 +246,17 @@ acpi_cmbat_get_bif(void *context)
return;
}
- untimeout(acpi_cmbat_timeout, (caddr_t)dev, sc->cmbat_timeout);
-retry:
- if (sc->bif_buffer.Length == 0) {
- if (sc->bif_buffer.Pointer != NULL) {
- free(sc->bif_buffer.Pointer, M_ACPICMBAT);
- sc->bif_buffer.Pointer = NULL;
- }
- as = AcpiEvaluateObject(h, "_BIF", NULL, &sc->bif_buffer);
- if (as != AE_BUFFER_OVERFLOW) {
- ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev),
- "couldn't find _BIF - %s\n", AcpiFormatException(as));
- goto end;
- }
-
- sc->bif_buffer.Pointer = malloc(sc->bif_buffer.Length, M_ACPICMBAT, M_NOWAIT);
- if (sc->bif_buffer.Pointer == NULL) {
- device_printf(dev, "malloc failed");
- goto end;
- }
+ if (sc->bif_updating) {
+ return;
}
+ sc->bif_updating = 1;
- bzero(sc->bif_buffer.Pointer, sc->bif_buffer.Length);
- as = AcpiEvaluateObject(h, "_BIF", NULL, &sc->bif_buffer);
+ untimeout(acpi_cmbat_timeout, (caddr_t)dev, sc->cmbat_timeout);
- if (as == AE_BUFFER_OVERFLOW) {
- if (sc->bif_buffer.Pointer != NULL) {
- free(sc->bif_buffer.Pointer, M_ACPICMBAT);
- sc->bif_buffer.Pointer = NULL;
- }
- ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev),
- "bif size changed to %d\n", sc->bif_buffer.Length);
- sc->bif_buffer.Length = 0;
- goto retry;
- } else if (as != AE_OK) {
+ if ((as = acpi_EvaluateIntoBuffer(h, "_BIF", NULL, &sc->bif_buffer)) != AE_OK) {
ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev),
- "couldn't find _BIF - %s\n", AcpiFormatException(as));
+ "error fetching current battery info -- %s\n",
+ AcpiFormatException(as));
goto end;
}
@@ -330,6 +283,7 @@ retry:
PKG_GETSTR(res, tmp, 12, sc->bif.oeminfo, ACPI_CMBAT_MAXSTRLEN, end);
acpi_cmbat_info_updated(&sc->bif_lastupdated);
end:
+ sc->bif_updating = 0;
sc->cmbat_timeout = timeout(acpi_cmbat_timeout, dev, CMBAT_POLLRATE);
}
@@ -391,6 +345,7 @@ acpi_cmbat_attach(device_t dev)
bzero(&sc->bif_buffer, sizeof(sc->bif_buffer));
bzero(&sc->bst_buffer, sizeof(sc->bst_buffer));
+ sc->bif_updating = sc->bst_updating = 0;
sc->dev = dev;
timespecclear(&sc->bif_lastupdated);
OpenPOWER on IntegriCloud