Bug 15465 - addon-macbook-backlight fails to mmap
Summary: addon-macbook-backlight fails to mmap
Status: RESOLVED FIXED
Alias: None
Product: hal
Classification: Unclassified
Component: hald (show other bugs)
Version: unspecified
Hardware: All Linux (All)
: medium normal
Assignee: David Zeuthen (not reading bugmail)
QA Contact:
URL: https://bugs.launchpad.net/ubuntu/+so...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-12 05:15 UTC by Steffen Röcker
Modified: 2008-04-25 13:20 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Hal log (623.12 KB, text/plain)
2008-04-12 05:15 UTC, Steffen Röcker
Details
This patch makes it work again (731 bytes, patch)
2008-04-12 05:19 UTC, Steffen Röcker
Details | Splinter Review
add better debug output (585 bytes, patch)
2008-04-15 22:37 UTC, Danny Kukawka
Details | Splinter Review

Description Steffen Röcker 2008-04-12 05:15:09 UTC
Created attachment 15846 [details]
Hal log

Macbook brightness adjustment does not work because addon-macbook-backlight fails to mmap.
I have tested this under Ubuntu Hardy and Fedora Rawhide.
It worked in Hardy with hal 0.5.10+git20080301-1ubuntu3 and failed to work with
hal 0.5.11~rc2-1ubuntu1. Fedora Rawhide (as of today) didn't work either so I think the bug is in hal itself.

See https://bugs.launchpad.net/ubuntu/+source/hal/+bug/206921 for more info.

hal.log created with:

sudo /etc/init.d/hald stop
sudo hald --verbose=yes --daemon=no 2>&1 | tee /tmp/hal.log

[snippet]
21:13:46.595 [D] hald_dbus.c:3294: udi=/org/freedesktop/Hal/devices/macbook_backlight
21:13:46.595 [I] hald_dbus.c:3320: AddonIsReady on udi '/org/freedesktop/Hal/devices/macbook_backlight'
21:13:46.595 [D] hald_dbus.c:3589: singleton_addon_is_ready
21:13:46.595 [I] hald_dbus.c:3616: SingletonAddonIsReady recieved for 'hald-addon-input'
21:13:46.595 [D] hald_dbus.c:3629: Signalling device added for queued devices
21:13:46.595 [D] hald_dbus.c:3633: device added for '/org/freedesktop/Hal/devices/computer_logicaldev_input'
21:13:46.622 [D] hald_dbus.c:3429: singleton_signal_device_changed about to send message to connection 0x80b32e0

** ERROR **: failed to mmap
aborting...
21:13:46.622 [I] hald_runner.c:110: runner_server_message_handler: destination=(null) obj_path=/org/freedesktop/HalRunner interface=org.freedesktop.HalRunner method=StartedProcessExited
21:13:46.622 [I] hald_runner.c:125: Previously started process with pid 11401 exited
21:13:46.622 [I] hald.c:84: in addon_terminated for udi=/org/freedesktop/Hal/devices/macbook_backlight
21:13:46.622 [E] device.c:1705: In hal_device_inc_num_ready_addons for udi=/org/freedesktop/Hal/devices/macbook_backlight but all addons are already ready!
Comment 1 Steffen Röcker 2008-04-12 05:19:53 UTC
Created attachment 15847 [details] [review]
This patch makes it work again

If I revert the changes in hal 0.5.11~rc2-1ubuntu1 in addon-macbook-backlight.c it works again. Couldn't apply the same fix to -ubuntu5 thought.

I think the introduction of policykit broke things. Don't know why this can make mmap fail.
Comment 2 Danny Kukawka 2008-04-15 12:55:32 UTC
Your patch can't work if you compile HAL without ConsoleKit/PolicyKit support. As soon as you compile it with the support the whole fail to compile.

Btw. it does not happen on my testmachine, at least with x86_64, but we have a report on SUSE for a MacBook1,1 with ix86
Comment 3 Steffen Röcker 2008-04-15 15:26:16 UTC
Oh, I just tried the patch for that version.
Seems that when you enable ConsoleKit/PolicyKit it needs a global LibHalContext *halctx and that somehow breaks mmap.

Yep, Suse bug #380075 is definitely the same one.
Should have added that my machine is also a Macbook1,1 i686.

Why doesn't this happen on x86_64?
Comment 4 Danny Kukawka 2008-04-15 22:31:46 UTC
@Ryan: You wrote the code, do you have any idea what happens here?
Comment 5 Danny Kukawka 2008-04-15 22:37:39 UTC
Created attachment 15945 [details] [review]
add better debug output

Could you please try the patch and paste what error it prints?
Comment 6 Steffen Röcker 2008-04-18 12:25:41 UTC
Finally had time to check this (needed to #include <../../logger.h> though)
Sadly this doesn't give me any more clues:

21:18:43.394 [E] addon-macbook-backlight.c:145: failed to mmap: errno: 'Success'

** ERROR **: failed to gain access to the video card
aborting...

Looks weird,register_page looks like it is still equal to MAP_FAILED. Could this be a compiler bug?
Comment 7 Steffen Röcker 2008-04-25 09:13:42 UTC
Here is a patch that works for me:
https://bugs.launchpad.net/hal/+bug/206921/comments/27

Kudos to goodlygeek.
Comment 8 Danny Kukawka 2008-04-25 13:20:38 UTC
Okay, thanks for the info. The fix was also verified by the SUSE user. I've commited it to git master:

commit 9f5219eaa6c7423870b031fdfa07de6a84f25d6e
Author: Danny Kukawka <danny.kukawka@web.de>
Date:   Fri Apr 25 22:18:24 2008 +0200

    fix macbook-backlight for ix86

    Fixed macbook-backlight for ix86 with a patch contributed by user
    'godlygeek' via: https://bugs.launchpad.net/hal/+bug/206921

    from comment #27:
    > This patch should fix it. Problem is that we're doing bitwise
    > arithmetic on a signed long that happens to be negative.
    > Wackiness ensues, making the result an invalid offset for mmap().
    > Changing the long to unsigned fixes it.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.