ACPI Fixes

Craig Dooley craig at xlnx-x.net
Fri Feb 20 04:32:52 PST 2004


Here is a better patch which properly initializes the token.
	
-Craig
	
On Thu, Feb 19, 2004 at 12:20:58PM -0800, Matthew Dillon wrote:
> :	Hmm, which makes me wonder.  How can lwkt_{get|rel}token()
> :	accept an uninitialised token?  As far as I can tell, every
> :	LWKT token needs to be initialised with lwkt_inittoken().
> :
> :	I tried grep'ing for lwkt_inittoken() in your patch, but I
> :	did not get any results.
> :
> :		-Hiten
> :		Hiten Pandya (hmp at xxxxxxxxxxxxx)
> 
>     It can't, now.  The old version of the token code stored a cpuid
>     in the token, so a zero'd token was in fact a valid token.
>     The new version stores a globaldata_t (pointer) in the token, so
>     a zero'd token is *NOT* valid.
> 
>     This has revealed that quite a bit of code does not properly initialize
>     the tokens they use.
> 
> 					-Matt
> 					Matthew Dillon 
> 					<dillon at xxxxxxxxxxxxx>

-- 
------------------------------------------------------------------------
Craig Dooley                                            craig at xxxxxxxxxx
------------------------------------------------------------------------
Index: dev/acpica/acpi.c
===================================================================
RCS file: /home/dcvs/src/sys/dev/acpica/acpi.c,v
retrieving revision 1.3
diff -u -r1.3 acpi.c
--- dev/acpica/acpi.c	13 Feb 2004 00:25:17 -0000	1.3
+++ dev/acpica/acpi.c	19 Feb 2004 20:48:39 -0000
@@ -99,6 +99,10 @@
 /* this has to be static, as the softc is gone when we need it */
 static int acpi_off_state = ACPI_STATE_S5;
 
+#if defined(__DragonFly__)
+struct lwkt_token acpi_token;
+#endif
+
 #if defined(__FreeBSD__) && __FreeBSD_version >= 500000
 struct mtx	acpi_mutex;
 #endif
@@ -242,6 +246,10 @@
     mtx_init(&acpi_mutex, "ACPI global lock", NULL, MTX_DEF);
 #endif
 
+#if defined(__DragonFly__)
+	lwkt_inittoken(&acpi_token);
+#endif
+
     /*
      * Start up the ACPI CA subsystem.
      */
Index: dev/acpica/acpi_acad.c
===================================================================
RCS file: /home/dcvs/src/sys/dev/acpica/acpi_acad.c,v
retrieving revision 1.1
diff -u -r1.1 acpi_acad.c
--- dev/acpica/acpi_acad.c	24 Sep 2003 03:32:16 -0000	1.1
+++ dev/acpica/acpi_acad.c	19 Feb 2004 15:57:15 -0000
@@ -50,6 +50,9 @@
 #define _COMPONENT	ACPI_AC_ADAPTER
 ACPI_MODULE_NAME("AC_ADAPTER")
 
+/* Number of times to retry initialization before giving up. */
+#define ACPI_ACAD_RETRY_MAX	6
+
 #define ACPI_DEVICE_CHECK_PNP		0x00
 #define ACPI_DEVICE_CHECK_EXISTENCE	0x01
 #define ACPI_POWERSOURCE_STAT_CHANGE	0x80
@@ -233,7 +236,6 @@
 	int		status;
 	device_t	dev = (device_t)arg;
 	struct acpi_acad_softc	*sc = device_get_softc(dev);
-#define ACPI_ACAD_RETRY_MAX	6
 
 	if (sc->initializing) {
 		return;
Index: dev/acpica/acpi_button.c
===================================================================
RCS file: /home/dcvs/src/sys/dev/acpica/acpi_button.c,v
retrieving revision 1.1
diff -u -r1.1 acpi_button.c
--- dev/acpica/acpi_button.c	24 Sep 2003 03:32:16 -0000	1.1
+++ dev/acpica/acpi_button.c	19 Feb 2004 15:56:06 -0000
@@ -52,6 +52,9 @@
     boolean_t	button_type;	/* Power or Sleep Button */
 };
 
+#define ACPI_NOTIFY_BUTTON_PRESSED_FOR_SLEEP	0x80
+#define ACPI_NOTIFY_BUTTON_PRESSED_FOR_WAKEUP	0x02
+
 static int	acpi_button_probe(device_t dev);
 static int	acpi_button_attach(device_t dev);
 static int	acpi_button_suspend(device_t dev);
@@ -166,7 +169,6 @@
     default:
 	break;		/* unknown button type */
     }
-    return_VOID;
 }
 
 static void
@@ -195,13 +197,8 @@
     default:
 	break;		/* unknown button type */
     }
-    return_VOID;
 }
 
-/* XXX maybe not here */
-#define ACPI_NOTIFY_BUTTON_PRESSED_FOR_SLEEP	0x80
-#define ACPI_NOTIFY_BUTTON_PRESSED_FOR_WAKEUP	0x02
-
 static void 
 acpi_button_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context)
 {
@@ -219,7 +216,6 @@
     default:
 	break;		/* unknown notification value */
     }
-    return_VOID;
 }
 
 
Index: dev/acpica/acpi_cpu.c
===================================================================
RCS file: /home/dcvs/src/sys/dev/acpica/acpi_cpu.c,v
retrieving revision 1.1
diff -u -r1.1 acpi_cpu.c
--- dev/acpica/acpi_cpu.c	24 Sep 2003 03:32:16 -0000	1.1
+++ dev/acpica/acpi_cpu.c	15 Feb 2004 20:26:16 -0000
@@ -330,7 +330,7 @@
 	if (speed < CPU_MAX_SPEED) {
 
 	    /* mask the old CLK_VAL off and or-in the new value */
-	    clk_val = CPU_MAX_SPEED << cpu_duty_offset;
+	    clk_val = (CPU_MAX_SPEED - 1) << cpu_duty_offset;
 	    p_cnt &= ~clk_val;
 	    p_cnt |= (speed << cpu_duty_offset);
 	
Index: dev/acpica/acpi_timer.c
===================================================================
RCS file: /home/dcvs/src/sys/dev/acpica/acpi_timer.c,v
retrieving revision 1.3
diff -u -r1.3 acpi_timer.c
--- dev/acpica/acpi_timer.c	13 Feb 2004 00:25:17 -0000	1.3
+++ dev/acpica/acpi_timer.c	19 Feb 2004 17:13:20 -0000
@@ -124,7 +124,6 @@
 	return (tv);
 }
 
-#define N 2000
 static int
 test_counter()
 {
@@ -134,7 +133,7 @@
 	min = 10000000;
 	max = 0;
 	last = read_counter();
-	for (n = 0; n < N; n++) {
+	for (n = 0; n < 2000; n++) {
 		this = read_counter();
 		delta = (this - last) & 0xffffff;
 		if (delta > max)
@@ -170,10 +169,7 @@
 
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
 
-    if (acpi_disabled("timer"))
-	return_VOID;
-
-    if (AcpiGbl_FADT == NULL)
+    if (acpi_disabled("timer") || (AcpiGbl_FADT == NULL))
 	return_VOID;
     
     if ((dev = BUS_ADD_CHILD(parent, 0, "acpi_timer", 0)) == NULL) {
@@ -377,10 +373,10 @@
     vendor = pci_get_vendor(dev);
     device = pci_get_device(dev);
     revid  = pci_get_revid(dev);
-    
-    if (((vendor == 0x8086) && (device == 0x7113) && (revid >= 0x03))	|| /* PIIX4M */
-	((vendor == 0x8086) && (device == 0x719b)) 			|| /* i440MX */
-	0) {
+   
+    /* PIIX4M or i440MX	
+    if (((vendor == 0x8086) && (device == 0x7113) && (revid >= 0x03)) ||
+	((vendor == 0x8086) && (device == 0x719b))) {
 
 	acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount;
 	acpi_timer_timecounter.tc_name = "ACPI-fast";
Index: dev/acpica/acpivar.h
===================================================================
RCS file: /home/dcvs/src/sys/dev/acpica/acpivar.h,v
retrieving revision 1.2
diff -u -r1.2 acpivar.h
--- dev/acpica/acpivar.h	13 Feb 2004 00:25:17 -0000	1.2
+++ dev/acpica/acpivar.h	19 Feb 2004 16:56:19 -0000
@@ -89,8 +89,16 @@
     struct resource_list	ad_rl;
 
 };
-
-#if defined(__DragonFly__) || __FreeBSD_version < 500000
+#if defined(__DragonFly__)
+extern struct lwkt_token	acpi_token;
+# define ACPI_LOCK				lwkt_gettoken(&acpi_token)
+# define ACPI_UNLOCK			lwkt_reltoken(&acpi_token)
+# define ACPI_ASSERTLOCK
+# define ACPI_MSLEEP(a, b, c, d, e)	tsleep(a, c, d, e)
+# define ACPI_LOCK_DECL			int s
+# define kthread_create(a, b, c, d, e, f)	kthread_create(a, b, c, f)
+# define tc_init(a)			init_timecounter(a)
+#elif __FreeBSD_version < 500000
 /*
  * In 4.x, ACPI is protected by splhigh().
  */
@@ -142,37 +150,6 @@
 #define	ACPI_INTR_APIC		1
 #define	ACPI_INTR_SAPIC		2
 
-/* XXX this is no longer referenced anywhere, remove? */
-#if 0
-/*
- * This is a cheap and nasty way to get around the horrid counted list
- * argument format that AcpiEvalateObject uses.
- */
-#define ACPI_OBJECTLIST_MAX	16
-struct acpi_object_list {
-    UINT32	count;
-    ACPI_OBJECT	*pointer[ACPI_OBJECTLIST_MAX];
-    ACPI_OBJECT	object[ACPI_OBJECTLIST_MAX];
-};
-
-static __inline struct acpi_object_list *
-acpi_AllocObjectList(int nobj)
-{
-    struct acpi_object_list	*l;
-    int				i;
-
-    if (nobj > ACPI_OBJECTLIST_MAX)
-	return(NULL);
-    if ((l = AcpiOsAllocate(sizeof(*l))) == NULL)
-	return(NULL);
-    bzero(l, sizeof(*l));
-    for (i = 0; i < ACPI_OBJECTLIST_MAX; i++)
-	l->pointer[i] = &l->object[i];
-    l->count = nobj;
-    return(l);
-}
-#endif /* unused */
-
 /*
  * Note that the low ivar values are reserved to provide
  * interface compatibility with ISA drivers which can also
Attachment:
pgp00007.pgp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgp00007.pgp
Type: application/octet-stream
Size: 187 bytes
Desc: "Description: PGP signature"
URL: <http://lists.dragonflybsd.org/pipermail/submit/attachments/20040220/cd53e559/attachment-0014.obj>


More information about the Submit mailing list