Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Sep 2007 13:10:29 -0700
From:      Nate Lawson <nate@root.org>
To:        current@FreeBSD.org,  acpi@freebsd.org
Subject:   patch: change in acpi taskq behavior
Message-ID:  <470002B5.6030002@root.org>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------010009080907080806050809
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Attached is a patch (one for 6, one for 7) that shouldn't break anything
for most people and may fix some battery status issues for others.  It
changes how we run tasks during boot.  It seems some hardware expects
synchronous access but our taskq is not running until after interrupts
are enabled.  This patch bounces calls through a wrapper that executes
the callback directly if we're not booted yet.

Please let me know if it breaks anything for you.

Thanks,
Nate


--------------010009080907080806050809
Content-Type: text/x-patch;
 name="taskq6a.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="taskq6a.diff"

Index: sys/dev/acpica/acpi_acad.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpi_acad.c,v
retrieving revision 1.33.2.2
diff -u -r1.33.2.2 acpi_acad.c
--- sys/dev/acpica/acpi_acad.c	5 Nov 2005 23:48:38 -0000	1.33.2.2
+++ sys/dev/acpica/acpi_acad.c	30 Sep 2007 19:24:23 -0000
@@ -181,7 +181,7 @@
      */
     AcpiInstallNotifyHandler(handle, ACPI_ALL_NOTIFY,
 			     acpi_acad_notify_handler, dev);
-    AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_acad_init_acline, dev);
+    acpi_queue_task(OSD_PRIORITY_LO, acpi_acad_init_acline, dev);
 
     return (0);
 }
Index: sys/dev/acpica/acpi_cmbat.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpi_cmbat.c,v
retrieving revision 1.39.2.5
diff -u -r1.39.2.5 acpi_cmbat.c
--- sys/dev/acpica/acpi_cmbat.c	11 Jun 2006 20:50:08 -0000	1.39.2.5
+++ sys/dev/acpica/acpi_cmbat.c	30 Sep 2007 19:25:16 -0000
@@ -149,7 +149,7 @@
     AcpiInstallNotifyHandler(handle, ACPI_ALL_NOTIFY,
 	acpi_cmbat_notify_handler, dev);
 
-    AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_cmbat_init_battery, dev);
+    acpi_queue_task(OSD_PRIORITY_LO, acpi_cmbat_init_battery, dev);
 
     return (0);
 }
Index: sys/dev/acpica/acpi_cpu.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpi_cpu.c,v
retrieving revision 1.57.2.3
diff -u -r1.57.2.3 acpi_cpu.c
--- sys/dev/acpica/acpi_cpu.c	11 Jun 2007 18:54:09 -0000	1.57.2.3
+++ sys/dev/acpica/acpi_cpu.c	30 Sep 2007 19:25:26 -0000
@@ -313,7 +313,7 @@
 	    CTLFLAG_RD, 0, "node for CPU children");
 
 	/* Queue post cpu-probing task handler */
-	AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_cpu_startup, NULL);
+	acpi_queue_task(OSD_PRIORITY_LO, acpi_cpu_startup, NULL);
     }
 
     /*
Index: sys/dev/acpica/acpi_dock.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpi_dock.c,v
retrieving revision 1.5.2.1
diff -u -r1.5.2.1 acpi_dock.c
--- sys/dev/acpica/acpi_dock.c	23 Mar 2007 19:45:52 -0000	1.5.2.1
+++ sys/dev/acpica/acpi_dock.c	30 Sep 2007 19:25:31 -0000
@@ -238,7 +238,7 @@
 		goto out;
 	}
 
-	AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_dock_attach_later, dev);
+	acpi_queue_task(OSD_PRIORITY_LO, acpi_dock_attach_later, dev);
 
 out:
 	return (AE_OK);
Index: sys/dev/acpica/acpi_perf.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpi_perf.c,v
retrieving revision 1.21.2.4
diff -u -r1.21.2.4 acpi_perf.c
--- sys/dev/acpica/acpi_perf.c	23 Jan 2007 07:21:23 -0000	1.21.2.4
+++ sys/dev/acpica/acpi_perf.c	30 Sep 2007 19:25:56 -0000
@@ -221,7 +221,7 @@
 	sc->px_curr_state = CPUFREQ_VAL_UNKNOWN;
 	if (acpi_perf_evaluate(dev) != 0)
 		return (ENXIO);
-	AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_px_startup, NULL);
+	acpi_queue_task(OSD_PRIORITY_LO, acpi_px_startup, NULL);
 	if (!sc->info_only)
 		cpufreq_register(dev);
 
Index: sys/dev/acpica/acpivar.h
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpivar.h,v
retrieving revision 1.95.2.6
diff -u -r1.95.2.6 acpivar.h
--- sys/dev/acpica/acpivar.h	17 Jun 2007 17:28:41 -0000	1.95.2.6
+++ sys/dev/acpica/acpivar.h	30 Sep 2007 19:29:59 -0000
@@ -390,6 +415,8 @@
 int		acpi_sleep_machdep(struct acpi_softc *sc, int state);
 int		acpi_table_quirks(int *quirks);
 int		acpi_machdep_quirks(int *quirks);
+ACPI_STATUS	acpi_queue_task(UINT32 Priority,
+		    ACPI_OSD_EXEC_CALLBACK Function, void *Context);
 
 /* Battery Abstraction. */
 struct acpi_battinfo;
Index: sys/dev/acpica/Osd/OsdSchedule.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/Osd/OsdSchedule.c,v
retrieving revision 1.32.2.6
diff -u -r1.32.2.6 OsdSchedule.c
--- sys/dev/acpica/Osd/OsdSchedule.c	6 Jul 2006 08:32:49 -0000	1.32.2.6
+++ sys/dev/acpica/Osd/OsdSchedule.c	30 Sep 2007 19:23:24 -0000
@@ -83,11 +83,33 @@
 }
 
 /*
+ * If we're up and running, queue the task for our taskq.  It will run
+ * shortly.  If we're booting and we had queued it, it would not actually run
+ * until interrupts are enabled later in boot.  So in that case, run it
+ * directly instead.  If a driver really wants the task delayed until boot,
+ * they can use acpi_queue_task() below.
+ */
+ACPI_STATUS
+AcpiOsQueueForExecution(UINT32 Priority, ACPI_OSD_EXEC_CALLBACK Function,
+    void *Context)
+{
+    ACPI_STATUS status;
+
+    if (!(cold || rebooting))
+	status = acpi_queue_task(Priority, Function, Context);
+    else {
+	Function(Context);
+	status = AE_OK;
+    }
+    return (status);
+}
+
+/*
  * This function may be called in interrupt context, i.e. when a GPE fires.
  * We allocate and queue a task for one of our taskqueue threads to process.
  */
 ACPI_STATUS
-AcpiOsQueueForExecution(UINT32 Priority, ACPI_OSD_EXEC_CALLBACK Function,
+acpi_queue_task(UINT32 Priority, ACPI_OSD_EXEC_CALLBACK Function,
     void *Context)
 {
     struct acpi_task_ctx *at;


--------------010009080907080806050809
Content-Type: text/x-patch;
 name="taskq7a.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="taskq7a.diff"

Index: sys/dev/acpica/acpi_acad.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpi_acad.c,v
retrieving revision 1.38
diff -u -r1.38 acpi_acad.c
--- sys/dev/acpica/acpi_acad.c	22 Mar 2007 18:16:40 -0000	1.38
+++ sys/dev/acpica/acpi_acad.c	30 Sep 2007 19:42:09 -0000
@@ -181,7 +181,7 @@
      */
     AcpiInstallNotifyHandler(handle, ACPI_ALL_NOTIFY,
 			     acpi_acad_notify_handler, dev);
-    AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_acad_init_acline, dev);
+    acpi_queue_task(OSL_NOTIFY_HANDLER, acpi_acad_init_acline, dev);
 
     return (0);
 }
Index: sys/dev/acpica/acpi_cmbat.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpi_cmbat.c,v
retrieving revision 1.46
diff -u -r1.46 acpi_cmbat.c
--- sys/dev/acpica/acpi_cmbat.c	22 Mar 2007 18:16:40 -0000	1.46
+++ sys/dev/acpica/acpi_cmbat.c	30 Sep 2007 19:42:26 -0000
@@ -149,7 +149,7 @@
     AcpiInstallNotifyHandler(handle, ACPI_ALL_NOTIFY,
 	acpi_cmbat_notify_handler, dev);
 
-    AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_cmbat_init_battery, dev);
+    acpi_queue_task(OSL_NOTIFY_HANDLER, acpi_cmbat_init_battery, dev);
 
     return (0);
 }
Index: sys/dev/acpica/acpi_cpu.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpi_cpu.c,v
retrieving revision 1.67
diff -u -r1.67 acpi_cpu.c
--- sys/dev/acpica/acpi_cpu.c	30 Aug 2007 21:18:42 -0000	1.67
+++ sys/dev/acpica/acpi_cpu.c	30 Sep 2007 19:42:31 -0000
@@ -318,7 +318,7 @@
 	    CTLFLAG_RD, 0, "node for CPU children");
 
 	/* Queue post cpu-probing task handler */
-	AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_cpu_startup, NULL);
+	acpi_queue_task(OSL_NOTIFY_HANDLER, acpi_cpu_startup, NULL);
     }
 
     /*
Index: sys/dev/acpica/acpi_dock.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpi_dock.c,v
retrieving revision 1.6
diff -u -r1.6 acpi_dock.c
--- sys/dev/acpica/acpi_dock.c	31 May 2007 08:49:51 -0000	1.6
+++ sys/dev/acpica/acpi_dock.c	30 Sep 2007 19:42:34 -0000
@@ -233,7 +233,7 @@
 		goto out;
 	}
 
-	AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_dock_attach_later, dev);
+	acpi_queue_task(OSL_NOTIFY_HANDLER, acpi_dock_attach_later, dev);
 
 out:
 	return (AE_OK);
Index: sys/dev/acpica/acpi_perf.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpi_perf.c,v
retrieving revision 1.26
diff -u -r1.26 acpi_perf.c
--- sys/dev/acpica/acpi_perf.c	22 Mar 2007 18:16:40 -0000	1.26
+++ sys/dev/acpica/acpi_perf.c	30 Sep 2007 19:42:38 -0000
@@ -221,7 +221,7 @@
 	sc->px_curr_state = CPUFREQ_VAL_UNKNOWN;
 	if (acpi_perf_evaluate(dev) != 0)
 		return (ENXIO);
-	AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_px_startup, NULL);
+	acpi_queue_task(OSL_NOTIFY_HANDLER, acpi_px_startup, NULL);
 	if (!sc->info_only)
 		cpufreq_register(dev);
 
Index: sys/dev/acpica/acpivar.h
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpivar.h,v
retrieving revision 1.107
diff -u -r1.107 acpivar.h
--- sys/dev/acpica/acpivar.h	21 Jun 2007 22:50:37 -0000	1.107
+++ sys/dev/acpica/acpivar.h	30 Sep 2007 19:43:42 -0000
@@ -417,6 +417,8 @@
 int		acpi_sleep_machdep(struct acpi_softc *sc, int state);
 int		acpi_table_quirks(int *quirks);
 int		acpi_machdep_quirks(int *quirks);
+ACPI_STATUS	acpi_queue_task(ACPI_EXECUTE_TYPE Type,
+		    ACPI_OSD_EXEC_CALLBACK Function, void *Context);
 
 /* Battery Abstraction. */
 struct acpi_battinfo;
Index: sys/dev/acpica/Osd/OsdSchedule.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/Osd/OsdSchedule.c,v
retrieving revision 1.39
diff -u -r1.39 OsdSchedule.c
--- sys/dev/acpica/Osd/OsdSchedule.c	22 Mar 2007 18:16:41 -0000	1.39
+++ sys/dev/acpica/Osd/OsdSchedule.c	30 Sep 2007 19:40:59 -0000
@@ -83,11 +83,33 @@
 }
 
 /*
+ * If we're up and running, queue the task for our taskq.  It will run
+ * shortly.  If we're booting and we had queued it, it would not actually run
+ * until interrupts are enabled later in boot.  So in that case, run it
+ * directly instead.  If a driver really wants the task delayed until boot,
+ * they can use acpi_queue_task() below.
+ */
+ACPI_STATUS
+AcpiOsExecute(ACPI_EXECUTE_TYPE Type, ACPI_OSD_EXEC_CALLBACK Function,
+    void *Context)
+{
+    ACPI_STATUS status;
+
+    if (!(cold || rebooting))
+	status = acpi_queue_task(Type, Function, Context);
+    else {
+	Function(Context);
+	status = AE_OK;
+    }
+    return (status);
+}
+
+/*
  * This function may be called in interrupt context, i.e. when a GPE fires.
  * We allocate and queue a task for one of our taskqueue threads to process.
  */
 ACPI_STATUS
-AcpiOsExecute(ACPI_EXECUTE_TYPE Type, ACPI_OSD_EXEC_CALLBACK Function,
+acpi_queue_task(ACPI_EXECUTE_TYPE Type, ACPI_OSD_EXEC_CALLBACK Function,
     void *Context)
 {
     struct acpi_task_ctx *at;


--------------010009080907080806050809--



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