Samsung Laptops Will Soon See Better Linux Performance, Less Bugs

Written by Michael Larabel in Hardware on 5 March 2014 at 03:15 PM EST. 7 Comments
HARDWARE
The performance of several different Samsung laptop models will soon improve under Linux thanks to an important kernel fix that will appear in the Linux 3.15 kernel. This important patch addresses some ACPI issues and system performance issues for multiple Samsung laptops that have plagued Linux for at least two years.

Going back to the first half of 2013 has been Kernel.org Bug #57271. The bug initially describes an issue when an AC adapter is connected to a Samsung laptop that the system suddenly becomes a lot less responsive, but the system turns back to being more responsive if removing the AC adapter.

The system responsiveness when changing power states also correlated to differences in system performance for real-world benchmarks. The reporter of Bug #57271 was commonly using the Phoronix Test Suite and OpenBenchmarking.org for illustrating the performance issues. Here's one of the result files showing the performance drop when the Linux kernel gets confused on Samsung hardware:
charge-slow

The Samsung laptop Linux performance issue was initially believed to be a common Samsung laptop problem with a EC bug in their ACPI table. When a power adapter is connected after boot, Linux believes there's no power adapter attached, and vice versa. When Linux thinks the laptop is running on battery power, the CPU performance goes into its power-saving mode that generally leads the CPU frequency to being run in its lowest power state and thus affecting the overall system performance. However, this didn't end up being the reason for this latest round of Samsung Linux laptop troubles.


While the original thought made sense, a discovery last month for the issue is more complicated, per this bug comment on a related open Samsung Linux laptop bug. Kernel.org Bug #44161 dates back to 2012 and has seen more than 160 comments. The root cause of all these issues come down to the embedded controller on several Samsung laptops -- when the EC receives too many events, the embedded controller decides to no longer interrupt the OS with any more events until they have been queried. Linux, on the other hand, isn't proactively querying the controller since it receives no interrupts that there are new events to handle. These EC events are generated while the laptop is in its S3 sleep state, which end up being useless when the system resumes, and aren't queried by Linux when they occur with the laptop being asleep.

Essentially the embedded controller is getting stuffed with too many queries, the buffer is full, and is not emptying these events, even after reboots. The fix to the reported bug is removing the battery and hitting the reset button (on laptops with removable batteries and a reset button hidden behind there), flashing the BIOS to ultimately reset the EC, or a simple debug user-space utility was written that forces queries of the embedded controller. When that utility is run, the Samsung performance is fixed.

Besides performance, this bug was tracked down to issues of AC power not being detected, lid closures not triggering suspend, ambient light sensors not triggering the keyboard backlight, and other issues.

The work now being done within the Linux kernel is for stopping embedded controllers from generating events while sleeping and also for clearing events when the system wakes, with Microsoft Windows currently employing the former approach. Besides Kernel.org bugs #57271 and #44161, LaunchPad Bug 971061 is also in regards to a related Samsung ACPI problem and that issue has been open since 2012. Among the models believed to be impacted by this issue include the Samsung Series 5 NP530U3C / NP535U3C / NP530U3B / NP550P5C and Samsung Series 9 NP900X3F / NP900X4B / NP900X4C / NP900X4D / NP900X3C.

As of this week, there's now a patch accepted into the linux-pm next Git tree to clear stale EC events on Samsung systems. This patch will be introduced into the Linux 3.15 kernel (not 3.14) and should fix this problem for many Samsung Linux users.
A number of Samsung notebooks (530Uxx/535Uxx/540Uxx/550Pxx/900Xxx/etc) continue to log events during sleep (lid open/close, AC plug/unplug, battery level change), which accumulate in the EC until a buffer fills. After the buffer is full (tests suggest it holds 8 events), GPEs stop being triggered for new events. This state persists on wake or even on power cycle, and prevents new events from being registered until the EC is manually polled.

This is the root cause of a number of bugs, including AC not being detected properly, lid close not triggering suspend, and low ambient light not triggering the keyboard backlight. The bug also seemed to be responsible for performance issues on at least one user's machine.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week