Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Apr 2006 01:21:56 +0900 (JST)
From:      Mitsuru IWASAKI <iwasaki@jp.FreeBSD.org>
To:        nate@root.org
Cc:        acpi@freebsd.org, current@freebsd.org
Subject:   Re: CFR: ACPI Dock driver
Message-ID:  <20060413.012156.56054177.iwasaki@jp.FreeBSD.org>
In-Reply-To: <443C027B.7050002@root.org>
References:  <20060408.032151.07645075.iwasaki@jp.FreeBSD.org> <20060410.215024.32344167.iwasaki@jp.FreeBSD.org> <443C027B.7050002@root.org>

next in thread | previous in thread | raw e-mail | index | archive | help
----Next_Part(Thu_Apr_13_01:21:56_2006_680)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi, Thanks for your comments.  Patches for acpi_dock.c are attached.

One thing,

> * There also might be an acpi_GetReference() helper function to use.  (I 
> think I wrote one)

Sorry, I can't get this.  Could you point this out in detail?

Thanks!



----Next_Part(Thu_Apr_13_01:21:56_2006_680)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="acpi_dock.c-20060413.diff"

--- acpi_dock.c.20060410	Mon Apr 10 03:34:35 2006
+++ acpi_dock.c	Thu Apr 13 01:06:04 2006
@@ -143,36 +143,21 @@
 acpi_dock_execute_lck(device_t dev, int lock)
 {
 	ACPI_HANDLE	h;
-	ACPI_OBJECT	argobj;
-	ACPI_OBJECT_LIST args;
-	ACPI_STATUS	status;
 
 	h = acpi_get_handle(dev);
-
-	argobj.Type = ACPI_TYPE_INTEGER;
-	argobj.Integer.Value = lock;
-	args.Count = 1;
-	args.Pointer = &argobj;
-	status = AcpiEvaluateObject(h, "_LCK", &args, NULL);
+	acpi_SetInteger(h, "_LCK", lock);
 }
 
 static int
 acpi_dock_execute_ejx(device_t dev, int eject, int state)
 {
 	ACPI_HANDLE	h;
-	ACPI_OBJECT	argobj;
-	ACPI_OBJECT_LIST args;
 	ACPI_STATUS	status;
 	char		ejx[5];
 
 	h = acpi_get_handle(dev);
-
-	argobj.Type = ACPI_TYPE_INTEGER;
-	argobj.Integer.Value = eject;
-	args.Count = 1;
-	args.Pointer = &argobj;
 	snprintf(ejx, sizeof(ejx), "_EJ%d", state);
-	status = AcpiEvaluateObject(h, ejx, &args, NULL);
+	status = acpi_SetInteger(h, ejx, eject);
 
 	if (ACPI_SUCCESS(status)) {
 		return (0);
@@ -228,7 +213,9 @@
 		device_enable(dev);
 	}
 
+	mtx_lock(&Giant);
 	device_probe_and_attach(dev);
+	mtx_unlock(&Giant);
 }
 
 static ACPI_STATUS
@@ -247,7 +234,15 @@
 	ACPI_VPRINT(dock_dev, acpi_device_get_parent_softc(dock_dev),
 		    "inserting device for %s\n", acpi_name(handle));
 
-#if (ACPI_CA_VERSION <= 0x20041119)
+#if 0
+	/*
+	 * If the system boot up w/o Docking, the devices under the dock
+	 * still un-initialized, also control methods such as _INI, _STA
+	 * are not executed.
+	 * Normal devices are initialized at booting by calling
+	 * AcpiInitializeObjects(), however the devices under the dock
+	 * need to be initialized here on the scheme of ACPICA.
+	 */
 	ACPI_INIT_WALK_INFO	Info;
 
 	AcpiNsWalkNamespace(ACPI_TYPE_ANY, handle,
@@ -262,7 +257,7 @@
 		goto out;
 	}
 
-	timeout(acpi_dock_attach_later, (caddr_t)dev, hz*3);
+	AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_dock_attach_later, dev);
 
 out:
 	return (AE_OK);
@@ -285,6 +280,8 @@
 	struct acpi_dock_softc *sc;
 	ACPI_HANDLE	h;
 
+	ACPI_SERIAL_ASSERT(dock);
+
 	sc = device_get_softc(dev);
 	h = acpi_get_handle(dev);
 
@@ -313,8 +310,6 @@
 {
 	device_t	dock_dev, dev;
 	ACPI_HANDLE	dock_handle;
-	ACPI_OBJECT	argobj;
-	ACPI_OBJECT_LIST args;
 
 	dock_dev = *(device_t *)context;
 	dock_handle = acpi_get_handle(dock_dev);
@@ -333,12 +328,7 @@
 		mtx_unlock(&Giant);
 	}
 
-	argobj.Type = ACPI_TYPE_INTEGER;
-	argobj.Integer.Value = 0;
-	args.Count = 1;
-	args.Pointer = &argobj;
-	AcpiEvaluateObject(handle, "_EJ0", &args, NULL);
-
+	acpi_SetInteger(handle, "_EJ0", 0);
 out:
 	return (AE_OK);
 }
@@ -359,6 +349,8 @@
 {
 	struct acpi_dock_softc *sc;
 
+	ACPI_SERIAL_ASSERT(dock);
+
 	sc = device_get_softc(dev);
 	if (acpi_dock_status == ACPI_DOCK_STATUS_DOCKED ||
 	    acpi_dock_status == ACPI_DOCK_STATUS_UNKNOWN) {
@@ -392,6 +384,8 @@
 {
 	struct acpi_dock_softc *sc;
 
+	ACPI_SERIAL_ASSERT(dock);
+
 	sc = device_get_softc(dev);
 	acpi_dock_get_info(dev);
 
@@ -399,7 +393,7 @@
 	 * If the _STA indicates 'present' and 'functioning',
 	 * the system is docked.
 	 */
-	if (sc->_sta & 0x9) {
+	if (ACPI_DEVICE_PRESENT(sc->_sta)) {
 		acpi_dock_insert(dev);
 	}
 	if (sc->_sta == 0x0) {
@@ -420,6 +414,7 @@
 	ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev),
 		    "got notification %#x\n", notify);
 
+	ACPI_SERIAL_BEGIN(dock);
 	switch (notify) {
 	case ACPI_DOCK_NOTIFY_BUS_CHECK:
 	case ACPI_DOCK_NOTIFY_DEVICE_CHECK:
@@ -434,6 +429,7 @@
 		device_printf(dev, "unknown notify %#x\n", notify);
 		break;
 	}
+	ACPI_SERIAL_END(dock);
 }
 
 /*
@@ -530,9 +526,10 @@
 	sc->status = ACPI_DOCK_STATUS_UNKNOWN;
 
 	AcpiEvaluateObject(h, "_INI", NULL, NULL);
-	acpi_dock_device_check(dev);
 
 	ACPI_SERIAL_BEGIN(dock);
+
+	acpi_dock_device_check(dev);
 
         /* Get the sysctl tree */
 	sc->sysctl_ctx = device_get_sysctl_ctx(dev);

----Next_Part(Thu_Apr_13_01:21:56_2006_680)----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060413.012156.56054177.iwasaki>