Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#7525 closed bug (fixed)

Setting backlight brightness doesn't work.

Reported by: pulkomandy Owned by: tqh
Priority: normal Milestone: R1
Component: Drivers/ACPI Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

The shortcut (function key + home/end) used to work fine, now they don't. My BIOS defaults to low brightness so it's quite annoying.

I think this went in in r41xxx. Will try to affine that if I get some time.

Anything I can do to help with it ?

Attachments (6)

acpi_init_as_ioapic_int.patch (1.1 KB ) - added by tqh 14 years ago.
A crude patch that sets arch_int_set_interrupt_controller(ioapicController) before acpi is initialised.
r41667_syslog.txt (142.4 KB ) - added by luroh 14 years ago.
r41682_syslog_IO-APIC_disabled.txt (142.6 KB ) - added by luroh 14 years ago.
r41684_ints_with_IO-APIC.jpg (273.0 KB ) - added by luroh 14 years ago.
r41684_ints_without_IO-APIC.jpg (296.0 KB ) - added by luroh 14 years ago.
r41685_syslog.txt (152.2 KB ) - added by luroh 14 years ago.

Download all attachments as: .zip

Change History (33)

comment:1 by luroh, 14 years ago

Owner: changed from tqh to mmlr
Status: newassigned

I confirm, disabling IO-APIC makes the brightness buttons work again on my T60 laptop.

comment:2 by mmlr, 14 years ago

Not an IO-APIC problem. It just means now that the system is in real ACPI mode, it'll require ACPI brightness controls. I think we have some kind of driver concerning that already, don't know in what state it is though.

comment:3 by mmlr, 14 years ago

Owner: changed from mmlr to tqh

comment:4 by tqh, 14 years ago

Was ACPI-module loaded fine and backlight working before? If it was it sounds like ACPI or its embedded controller handler are not setup correctly. A guess would be that something is not right when it is setup before the ioapic int controller. I'll provide a patch that is a big hack (only apply if you can run with ioapic atm) to see if setting up ACPI with the ioapic controller works better. Please test.

by tqh, 14 years ago

A crude patch that sets arch_int_set_interrupt_controller(ioapicController) before acpi is initialised.

comment:5 by tqh, 14 years ago

patch: 01

comment:6 by luroh, 14 years ago

Not sure how I'd check for a successfully loaded ACPI module, but yes, backlight adjustment worked fine before and with your patch it does so again.

comment:7 by pulkomandy, 14 years ago

Works with the patch here too. (also a T60, FWIW).

comment:8 by mmlr, 14 years ago

This patch can't possibly work correctly. What happens now is that the SCI is installed incorrectly and/or not enabled anymore as the interrupt setup will run into the void (i.e. non-setup IO-APIC). I've implemented legacy PIC to IO-APIC handover as well as interrupt source overrides, so the SCI should be routed and enabled in all cases. Maybe that's actually the "problem" here, that with a working SCI the OS is now responsible for these brightness settings (which is likely not implemented).

comment:9 by mmlr, 14 years ago

Please try the KDL "ints" command after pushing the brightness controls both with and without this patch. If they are implemented through the SCI then you might see that in the handled/unhandled count of the corresponding handler (if it is set up correctly in either case).

comment:10 by tqh, 14 years ago

Perhaps a patch with just _PIC = 1 before installing the int handlers works just as well.

I think the issue here is that _PIC = 0 and _PIC = 1 can be completly different configurations in the vendors ACPI impl, so migrating the interrupt handlers over isn't enough, you probably need to reinit the handlers or modify how ACPI and embedded controller init or install their handlers so that they do that with _PIC set correctly.

in reply to:  10 comment:11 by mmlr, 14 years ago

Replying to tqh:

Perhaps a patch with just _PIC = 1 before installing the int handlers works just as well.

I think the issue here is that _PIC = 0 and _PIC = 1 can be completly different configurations in the vendors ACPI impl, so migrating the interrupt handlers over isn't enough, you probably need to reinit the handlers or modify how ACPI and embedded controller init or install their handlers so that they do that with _PIC set correctly.

The problem is that if this was the case we wouldn't be able to fall back to the other PIC model, we either go full on IO-APIC or we don't, only depending on the IO-APIC presence and IO-APIC safemode setting.

Referencing FreeBSD though, that can't really be it. Their acpi_attach method...

http://fxr.watson.org/fxr/source/dev/acpica/acpi.c#L431

... has both, the call to AcpiEnableSubsystem() ...

http://fxr.watson.org/fxr/source/dev/acpica/acpi.c#L521

... which in turn installs the SCI interrupt handler ...

http://fxr.watson.org/fxr/source/contrib/dev/acpica/utilities/utxface.c#L244

... and the _PIC setting through the call to acpi_machdep_init() ...

http://fxr.watson.org/fxr/source/dev/acpica/acpi.c#L661

... which in turn calls acpi_SetIntrModel() ...

http://fxr.watson.org/fxr/source/dev/acpica/acpi.c#L2322

... with the "default" interrupt model set up on MADT parsing. But if you look at the sequence of things here, the AcpiEnableSubsystem() (called with flags 0, so really installing the interrupt handler) happens far earlier than setting the _PIC model. The model to be used may be decided earlier, but it really only is set after the installation of the SCI.

The more likely scenario IMO is that the interrupts are simply broken due to either the override mechanism not working correctly (I was only able to test it using the PIT, so quite possibly there's a bug in the SCI case), or the source override that configures the SCI is bogus (seems to happen according to other implementations). FreeBSD forces the SCI to a level low interrupt (as described in the ACPI specs) whereas we currently rely on the interrupt soruce override. If the source override is simply broken, that'd explain things for example. So can the affected people please add a syslog to this ticket to see what configuration the SCI would result in and what routing table is in effect. Maybe forcing the SCI to level low would be enough. It's ugly in either case, since the code configuring the interrupts doesn't actually know the SCI, but the kernel and acpi module can work that out by the acpi module explicitly configuring the interrupt line after some kind of "interrupt config done"-callback.

comment:12 by luroh, 14 years ago

Observing the output of the "ints" command didn't yield much in my case, too many numbers fluctuating with or without the patch to make any sense to me. Attaching syslog from hrev41667 (without patch).

by luroh, 14 years ago

Attachment: r41667_syslog.txt added

in reply to:  12 comment:13 by mmlr, 14 years ago

Replying to luroh:

Observing the output of the "ints" command didn't yield much in my case, too many numbers fluctuating with or without the patch to make any sense to me. Attaching syslog from hrev41667 (without patch).

The source override in that syslog looks fine, so no non-standard config there. Can you get a syslog with this patch applied or just with IO-APICs disabled? I wonder if this error is there in that case as well:

ACPI Error: Method parse/execution failed [\_SB_.PCI0.LPC_.EC__._INI] (Node 0x82193648), AE_NOT_EXIST (20101013/psparse-633)

comment:14 by luroh, 14 years ago

Attaching syslog, IO-APIC disabled (brightness buttons working).

in reply to:  12 comment:15 by mmlr, 14 years ago

So the error is there in either case...

Replying to luroh:

Observing the output of the "ints" command didn't yield much in my case, too many numbers fluctuating with or without the patch to make any sense to me.

The only thing I'm interested in is whether or not there are any handled and/or unhandled interrupts on int 9, where the ACPI interrupt handler should be installed. The thing is that the polarity and trigger mode were previously unset when only using the PIC (and when applying this patch, as the info will get lost because there's no IO-APIC structure to hold it). It's therefore possible that ACPI SCIs simply didn't work before and therefore SMIs were generated that the BIOS then handled (adjusting the brigthness for example). With IO-APIC support on and with the source override in place that, in your case, specifies the SCI interrupt to 9, active high, level triggered it might actually work now, shutting out the BIOS and therefore leaving the buttons to the OS.

What you could try to see if the source override is the "problem" would be to comment out the line:

acpi_configure_source_overrides(madt);

In browser:haiku/trunk/src/system/kernel/arch/x86/ioapic.cpp#L743 and see if that changes things.

I have checked FreeBSD again and they only force the SCI to level/low if there is no interrupt source override or if the user explicitly demanded it via settings. So I don't think doing the configuration this way is wrong per se.

comment:16 by luroh, 14 years ago

Attaching photos of "ints", having pressed the brightness buttons a few times, with and without IO-APIC. I'll comment out that line next as suggested and revert.

by luroh, 14 years ago

by luroh, 14 years ago

comment:17 by luroh, 14 years ago

Sorry, need more directions, getting a build failure: src/system/kernel/arch/x86/ioapic.cpp:509: warning: `void acpi_configure_source_overrides(acpi_table_madt *)' defined but not used

in reply to:  17 comment:18 by mmlr, 14 years ago

Replying to luroh:

Sorry, need more directions, getting a build failure: src/system/kernel/arch/x86/ioapic.cpp:509: warning: `void acpi_configure_source_overrides(acpi_table_madt *)' defined but not used

Wrap the whole acpi_configure_source_overrides() function into an #if 0 block. To do that put #if 0 at line 506 and an #endif at line 605. Alternatively you could just delete the whole function.

comment:19 by luroh, 14 years ago

Thanks, now I'm getting: src/system/kernel/arch/x86/ioapic.cpp:387: warning: `int32 ioapic_source_override_handler(void *)' defined but not used

in reply to:  19 comment:20 by mmlr, 14 years ago

Replying to luroh:

Thanks, now I'm getting: src/system/kernel/arch/x86/ioapic.cpp:387: warning: `int32 ioapic_source_override_handler(void *)' defined but not used

Then remove that function as well. It starts at line 385.

comment:21 by luroh, 14 years ago

Ok, it now built successfully but the removed lines had seemingly no effect on the brightness adjustments or the handled/unhandled interrupts of int 9, with or without IO-APIC.

comment:22 by mmlr, 14 years ago

Can you please retry with hrev41685? It most probably fixes this. The ACPI SCI was simply not enabled because I messed up the handover.

comment:23 by luroh, 14 years ago

Indeed, that seems to have fixed it. Attaching syslog. Again, nice work!

by luroh, 14 years ago

Attachment: r41685_syslog.txt added

comment:24 by mmlr, 14 years ago

Resolution: fixed
Status: assignedclosed

Great. Thanks for the testing effort! Fixed in hrev41685.

in reply to:  2 comment:25 by dukzcry, 13 years ago

In addition to mmlr's right comment regarding ACPI mode, one should remember that there are some vendors which produce laptops without support of generic ACPI methods, using instead proprietary ones. In such case you'll need to write platform-specific driver, like i did for Fujitsu-Siemens notebooks: https://github.com/druga/haiku-stuff/tree/master/acpi_fujitsu_laptop .

comment:26 by tqh, 13 years ago

dukzcry, nice stuff. I'm happy someone else does a driver using ACPI and it also shows that it is quite simple. Well done. If I get the time I will take a closer look and move it over to Haiku if you don't mind.

in reply to:  26 comment:27 by dukzcry, 13 years ago

Great to hear that, tqh. But it's a draft in it's current form. Things to do, in descending order: 1) figure out what's wrong with HID names reading; 2) extend it to support alternative methods (SBL2 vs. SBLL, GBLS vs. GBLL) to cover more FS machines; 3) do general code cleanup (remove hacks at first) and formatting, adjust it to follow HCG.

Version 0, edited 13 years ago by dukzcry (next)
Note: See TracTickets for help on using tickets.