summaryrefslogtreecommitdiffstats
path: root/sys/i386/acpica/acpi_machdep.c
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2009-08-02 14:28:40 +0000
committerattilio <attilio@FreeBSD.org>2009-08-02 14:28:40 +0000
commit7f42e47a67ad2835fbc404253f835223020256d4 (patch)
treec00d808d1df8000c2086c86613be9ec8536a5e28 /sys/i386/acpica/acpi_machdep.c
parentea03af42ccd07d2533707afe4d1ba08f34bdb2e9 (diff)
downloadFreeBSD-src-7f42e47a67ad2835fbc404253f835223020256d4.zip
FreeBSD-src-7f42e47a67ad2835fbc404253f835223020256d4.tar.gz
Make the newbus subsystem Giant free by adding the new newbus sxlock.
The newbus lock is responsible for protecting newbus internIal structures, device states and devclass flags. It is necessary to hold it when all such datas are accessed. For the other operations, softc locking should ensure enough protection to avoid races. Newbus lock is automatically held when virtual operations on the device and bus are invoked when loading the driver or when the suspend/resume take place. For other 'spourious' operations trying to access/modify the newbus topology, newbus lock needs to be automatically acquired and dropped. For the moment Giant is also acquired in some key point (modules subsystem) in order to avoid problems before the 8.0 release as module handlers could make assumptions about it. This Giant locking should go just after the release happens. Please keep in mind that the public interface can be expanded in order to provide more support, if there are really necessities at some point and also some bugs could arise as long as the patch needs a bit of further testing. Bump __FreeBSD_version in order to reflect the newbus lock introduction. Reviewed by: ed, hps, jhb, imp, mav, scottl No answer by: ariff, thompsa, yongari Tested by: pho, G. Trematerra <giovanni dot trematerra at gmail dot com>, Brandon Gooch <jamesbrandongooch at gmail dot com> Sponsored by: Yahoo! Incorporated Approved by: re (ksmith)
Diffstat (limited to 'sys/i386/acpica/acpi_machdep.c')
-rw-r--r--sys/i386/acpica/acpi_machdep.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/i386/acpica/acpi_machdep.c b/sys/i386/acpica/acpi_machdep.c
index e26cce9..4568671 100644
--- a/sys/i386/acpica/acpi_machdep.c
+++ b/sys/i386/acpica/acpi_machdep.c
@@ -164,6 +164,7 @@ acpi_capm_get_info(apm_info_t aip)
else
aip->ai_acline = acline; /* on/off */
+ newbus_slock();
if (acpi_battery_get_battinfo(NULL, &batt) != 0) {
aip->ai_batt_stat = APM_UNKNOWN;
aip->ai_batt_life = APM_UNKNOWN;
@@ -175,6 +176,7 @@ acpi_capm_get_info(apm_info_t aip)
aip->ai_batt_time = (batt.min == -1) ? -1 : batt.min * 60;
aip->ai_batteries = acpi_battery_get_units();
}
+ newbus_sunlock();
return (0);
}
@@ -190,6 +192,7 @@ acpi_capm_get_pwstatus(apm_pwstatus_t app)
(app->ap_device < PMDV_BATT0 || app->ap_device > PMDV_BATT_ALL))
return (1);
+ newbus_slock();
if (app->ap_device == PMDV_ALLDEV)
error = acpi_battery_get_battinfo(NULL, &batt);
else {
@@ -200,6 +203,7 @@ acpi_capm_get_pwstatus(apm_pwstatus_t app)
else
error = ENXIO;
}
+ newbus_sunlock();
if (error)
return (1);
@@ -283,7 +287,9 @@ apmopen(struct cdev *dev, int flag, int fmt, struct thread *td)
struct acpi_softc *acpi_sc;
struct apm_clone_data *clone;
+ newbus_slock();
acpi_sc = devclass_get_softc(devclass_find("acpi"), 0);
+ newbus_sunlock();
clone = apm_create_clone(dev, acpi_sc);
dev->si_drv1 = clone;
OpenPOWER on IntegriCloud