Subject: Re: panic in ACPI configuration
To: Quentin Garnier <cube@cubidou.net>
From: Arne H. Juul <arnej@pvv.ntnu.no>
List: current-users
Date: 08/25/2007 12:42:16
On Fri, 24 Aug 2007, Quentin Garnier wrote:
>>> Yes.  Try the attached patch (in sys/dev/acpi/acpica).
>>
>> thanks - that works!  dmesg at the end.
>
> Try the attached patch instead.

that does not seem to work :-(
I've combined the two and added some debug printing, and it looks
like it claims to have valid _STA, even though it's just -1:

get_bus_number with: Valid=23, CurrentStatus=ffffffff, bus=0, device=9, function=0
get_bus_number with: Valid=23, CurrentStatus=ffffffff, bus=2, device=0, function=ffff
get_bus_number with: Valid=23, CurrentStatus=ffffffff, bus=0, device=b, function=0
get_bus_number with: Valid=23, CurrentStatus=ffffffff, bus=3, device=0, function=ffff
get_bus_number with: Valid=23, CurrentStatus=ffffffff, bus=0, device=1, function=0

that's with this diff:

Index: OsdHardware.c
===================================================================
RCS file: /usr/cvs/src/sys/dev/acpi/acpica/OsdHardware.c,v
retrieving revision 1.2
diff -u -r1.2 OsdHardware.c
--- OsdHardware.c	14 May 2006 21:42:26 -0000	1.2
+++ OsdHardware.c	25 Aug 2007 10:23:02 -0000
@@ -51,6 +51,7 @@

  #include <dev/acpi/acpica.h>
  #include <dev/acpi/acpivar.h>
+#include <dev/acpi/acpireg.h>

  #include <machine/acpi_machdep.h>

@@ -285,6 +286,11 @@
  	ACPI_OBJECT_TYPE type;
  	ACPI_PCI_ID *id;
  	ACPI_INTEGER v;
+	UINT16 d,f;
+	UINT32 validness;
+	UINT32 statuswas;
+	ACPI_BUFFER buf;
+	ACPI_DEVICE_INFO *devinfo;
  	int bus;

  	id = *PciId;
@@ -305,14 +311,41 @@
  		if (ACPI_FAILURE(rv) || type != ACPI_TYPE_DEVICE)
  			return bus;

+		buf.Pointer = NULL;
+		buf.Length = ACPI_ALLOCATE_BUFFER;
+		rv = AcpiGetObjectInfo(handle, &buf);
+		if (ACPI_FAILURE(rv))
+			return bus;
+
+		devinfo = buf.Pointer;
+		validness = devinfo->Valid;
+		statuswas = devinfo->CurrentStatus;
+		AcpiOsFree(buf.Pointer);
+
  		rv = acpi_eval_integer(handle, METHOD_NAME__ADR, &v);

  		if (ACPI_FAILURE(rv))
  			return bus;

+		d = ACPI_HIWORD((ACPI_INTEGER)v);
+		f = ACPI_LOWORD((ACPI_INTEGER)v);
+
+		printf("get_bus_number with:"
+			" Valid=%x, CurrentStatus=%x,"
+			" bus=%x, device=%x, function=%x\n",
+			(int)validness, (int)statuswas,
+			(int)bus, (int)d, (int)f);
+
+		if ((validness & ACPI_VALID_STA) != ACPI_VALID_STA
+                    || (statuswas & ACPI_STA_DEV_OK) != ACPI_STA_DEV_OK
+                    || d >= 32 || f >= 8)
+		{
+			return bus;
+		}
+
  		id->Bus = bus;
-		id->Device = ACPI_HIWORD((ACPI_INTEGER)v);
-		id->Function = ACPI_LOWORD((ACPI_INTEGER)v);
+		id->Device = d;
+		id->Function = f;

  		/* read HDR_TYPE register */
  		rv = AcpiOsReadPciConfiguration(id, 0x0e, &v, 8);