From owner-acpi-jp@jp.FreeBSD.org Sun Jul 20 15:20:56 2003
Received: (from daemon@localhost)
	by castle.jp.FreeBSD.org (8.11.6p2+3.4W/8.11.3) id h6K6KuJ93907;
	Sun, 20 Jul 2003 15:20:56 +0900 (JST)
	(envelope-from owner-acpi-jp@jp.FreeBSD.org)
Received: from rootlabs.com (root.org [67.118.192.226])
	by castle.jp.FreeBSD.org (8.11.6p2+3.4W/8.11.3) with SMTP/inet id h6K6KtT93902
	for <acpi-jp@jp.freebsd.org>; Sun, 20 Jul 2003 15:20:55 +0900 (JST)
	(envelope-from nate@rootlabs.com)
Received: (qmail 31473 invoked by uid 1000); 20 Jul 2003 06:20:51 -0000
From: Nate Lawson <nate@root.org>
To: Takanori Watanabe <takawata@init-main.com>
cc: Nate Lawson <njl@freebsd.org>, acpi-jp@jp.FreeBSD.org
In-Reply-To: <200307200258.h6K2wRNl090072@sana.init-main.com>
Message-ID: <20030719231654.S31471@root.org>
References: <200307200258.h6K2wRNl090072@sana.init-main.com>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Reply-To: acpi-jp@jp.FreeBSD.org
Precedence: list
Date: Sat, 19 Jul 2003 23:20:51 -0700
X-Sequence: acpi-jp 2475
Subject: [acpi-jp 2475] Re: cvs commit: src/sys/dev/acpica acpi.c acpi_ec.c acpivar.h
Sender: owner-acpi-jp@jp.FreeBSD.org
X-Originator: nate@root.org
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+030702

On Sun, 20 Jul 2003, Takanori Watanabe wrote:
> In message <200307200048.h6K0mcqj071205@repoman.freebsd.org>, Nate Lawson wrote:
> >  Modified files:
> >    sys/dev/acpica       acpi.c acpi_ec.c acpivar.h
> >  Log:
> >  Add ECDT (ACPI 2.0) support.  This allows the EC to be enabled before the
> >  namespace has been evaluated.  Machines with ACPI 2.0 expect this behavior
> >  and have AML which calls EC functions early in the boot process.  If the
> >  ECDT is not available, fall back to original probe behavior.
>
>  static int
>  acpi_ec_probe(device_t dev)
>  {
> -    int ret = ENXIO;
> +    ACPI_HANDLE h;
> +    ACPI_STATUS status;
> +    device_t	peer;
> +    char	desc[64];
> +    int		magic, uid, glk, gpebit, ret = ENXIO;
> +
> +    /* Check that this is an EC device and it's not disabled. */
> +    if (acpi_get_type(dev) != ACPI_TYPE_DEVICE || acpi_disabled("ec") ||
> +	!acpi_MatchHid(dev, "PNP0C09")) {
> +	return (ENXIO);
> +    }
>
> -    if (acpi_get_type(dev) == ACPI_TYPE_DEVICE && !acpi_disabled("ec") &&
> -	acpi_MatchHid(dev, "PNP0C09")) {
> +    /*
> +     * If probed via ECDT, set description and continue.  Otherwise,
> +     * we can access the namespace and make sure this is not a
> +     * duplicate probe.
> +     */
> +    magic = acpi_get_magic(dev);
> +    if ((magic & DEV_ECDT_FLAG) != 0) {
> +	snprintf(desc, sizeof(desc), "embedded controller: ECDT, GPE %#x, GLK",
> +		 DEV_GET_GPEBIT(magic));
> +	device_set_desc_copy(dev, desc);
> +	ret = 0;
> +    } else {
> +	h = acpi_get_handle(dev);
>
> Calling  acpi_MatchHid() in ECDT probe may cause problem
> because this call AcpiGetObject which implies _HID and _STA
> evaluation. This problem is also contained in my patch
> you based on.

Testing has shown no problems with this but I agree it should be changed.

I can move that call into the !DEV_ECDT_FLAG case which is only called in
the later probe after the namespace has been evaluated.  Since only a
device that has been probed via acpi_ec_ecdt_probe() should have
DEV_ECDT_FLAG set in its magic ivar, this should suffice.

Let me know if you have any other issues with this.

Thanks,
-Nate
