Bug 10998 (applesmc_MBP4.1) - applesmc - Sudden motion sensor not recognized on newer versions of MacBook Pro
Summary: applesmc - Sudden motion sensor not recognized on newer versions of MacBook Pro
Status: RESOLVED CODE_FIX
Alias: applesmc_MBP4.1
Product: Drivers
Classification: Unclassified
Component: Hardware Monitoring (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Nicolas Boichat
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-28 01:43 UTC by Harald Psaier
Modified: 2009-09-07 17:51 UTC (History)
4 users (show)

See Also:
Kernel Version: 2.6.25.9
Subsystem:
Regression: No
Bisected commit-id:


Attachments
applesmc-accel-create-check.patch (2.08 KB, patch)
2008-07-19 02:56 UTC, Nicolas Boichat
Details | Diff
test suite (5.59 KB, text/x-csrc)
2008-07-19 06:49 UTC, Harald Psaier
Details

Description Harald Psaier 2008-06-28 01:43:55 UTC
Latest working kernel version:2.6.25.9
Earliest failing kernel version:2.6.23.*
Distribution: Gentoo / homebrowen kernel
Hardware Environment: MacBook Pro 4.1 of Feb. 2008
Software Environment: Gentoo Stage 3 environment
Problem Description: 
On boot all MBP features (backlight control, temperature sensors, ...) are recogized correctly EXCEPT the sudden motion sensor. However as another user descibes: 
This only occurs if I hard boot to linux.  If I first boot to osx, and
then soft boot (restart) to linux, the motion sensor works as
expected.
Now, I don't know how the kernel developer of the module came up with the init magic, but I am of course ready to supply any debugging/system information available.
Steps to reproduce:
mainstream kernel 2.6.25.9 on loading the applesmc driver:
applesmc: Apple MacBook Pro detected: 
applesmc: - Model with accelerometer applesmc: - 
Model with light sensors and backlight applesmc: - 
Model with 12 temperature sensors 
applesmc: wait status failed: c != 8 
applesmc: wait status failed: c != 8 
applesmc: wait status failed: c != 8 
... (endless same lines)

mactel patched kernel 2.6.25.9 on loading the applesmc driver:
applesmc: Cannot set motion sensor. might not receive some interrupts.
Comment 1 Nicolas Boichat 2008-07-19 02:56:47 UTC
Created attachment 16885 [details]
applesmc-accel-create-check.patch
Comment 2 Nicolas Boichat 2008-07-19 03:03:41 UTC
This patch should fix the problem.
It disables the accelerometer input device if the accelerometer cannot be calibrated during initialization (if it fails the first time it is read, it is likely to fail again later).
I am not so clear about why it froze your system though (I guess it is related to input-polldev somehow...).
And it is obviously not an optimal fix since we would like to have support for the accelerometer on newer Apple devices, but there isn't much I can do with having one of these Macs...
Comment 3 Harald Psaier 2008-07-19 06:49:52 UTC
Created attachment 16889 [details]
test suite
Comment 4 Harald Psaier 2008-07-19 06:59:54 UTC
In order to contribute some information from a MacBook Pro 4.1 I c&p this c-file with code from applesmc module. The while (__wait_status(0x0c)) hack works great, but doesn't solve the problem. The coordinates remain "0,0" despite moving or swinging around the macbook. So... I am still convinced there is a "secret" initalization sequence on start up of the MacOs which hasn't been reverse engineered yet. I know of this page by Johannes Berg about the Apple Motion Sensor Specification. But it doesn't say much about how he did reverse engineere the driver. If someone could point me in the right direction, maybe I would be able to do it myself and commit the results. 
Comment 5 Nicolas Boichat 2008-07-19 07:13:59 UTC
Have you tried the patch I attached here?

There are 2 issues in this bug report:
 1. The system freezes when applesmc is loaded.
 2. The accelerometer is not recognized.

1. is a severe issue, which we need to fix ASAP, if my patch works, I will send it upstream (since the system freezes I think it is a candidate for 2.6.26.x).

2. is a potential improvement, and I would be glad to talk with you about it, but I think it is better to do it on mactel-linux devel list (or privately) rather than on this bug tracking system...
Comment 6 Nicolas Boichat 2008-07-19 07:18:56 UTC
Just realised you never stated your system freezes (don't know where I got that idea from...). Anyway, sending tons of messages to the kernel log is not great either .-)
Comment 7 Jean Delvare 2009-09-06 14:53:34 UTC
Nicolas, any progress on this?
Comment 8 Harald Psaier 2009-09-07 17:51:20 UTC
I can confirm that the problem is solved for MBP4.1 with newer Kernels (probably >=2.6.28)

Note You need to log in before you can comment on or make changes to this bug.