On Sun, 19 Apr 2020 at 17:40:41 +0200, Mark Kettenis wrote:
It's crashing on line 166 of acpivout.c:

       if (level < sc->sc_bcl[0])

(Note there was a diff in snaps that is now committed).

Apparently sc_bcl is NULL.  That shouldn't happen but we have no
protection against it.  Diff below should make sure things don't go
off the rails.

Bigger question is why the _BCL method isn't returning a proper list
of values.  Judging from the included acpi dump it should...

I think these devices have some bogus AML that is causing _BCL not to return a proper package.

    Method (_BCL, 0, NotSerialized)  // _BCL: Brightness Control Levels
    {
        If (CondRefOf (\PBCL))
        {
            PBCL ()
        }
        Else
        {
            Return (Package (0x67)
            {
0x50, [...]

I think that "PBCL()" needs to be "Return (PBCL)", otherwise it doesn't return what PBCL() returns.

ACPICA seems to agree:

- eval _SB.PCI0.GFX0.DD1F._BCL
Evaluating \_SB.PCI0.GFX0.DD1F._BCL
ACPI Warning: \_SB.PCI0.GFX0.DD1F._BCL: Missing expected return value 
(20200214/nsrepair-347)
ACPI Warning: \_SB.PCI0.GFX0.DD1F._BCL: Expected return object of type Package 
(20200214/nspredef-416)
No object was returned from evaluation of \_SB.PCI0.GFX0.DD1F._BCL

The acpivout fix looks correct to me, most other methods in there check for sc_bcl_len.


Index: dev/acpi/acpivout.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/acpivout.c,v
retrieving revision 1.22
diff -u -p -r1.22 acpivout.c
--- dev/acpi/acpivout.c 19 Apr 2020 15:05:14 -0000      1.22
+++ dev/acpi/acpivout.c 19 Apr 2020 15:38:31 -0000
@@ -114,12 +114,14 @@ acpivout_attach(struct device *parent, s
            ws_get_param || ws_set_param)
                return;

-       ws_get_param = acpivout_get_param;
-       ws_set_param = acpivout_set_param;
-
        acpivout_get_bcl(sc);
+       if (sc->sc_bcl_len == 0)
+               return;

        sc->sc_brightness = acpivout_get_brightness(sc);
+
+       ws_get_param = acpivout_get_param;
+       ws_set_param = acpivout_set_param;
}

int


Reply via email to