[ltp] RE: Gen 2 (Haswell) X1 Carbon suspend to RAM hang
Tue, 06 May 2014 15:08:06 +0200
dagb <firstname.lastname@example.org> writes:
> The proces for compiling the kernel for each Linux distro may vary. I am =
> a experiences kernel guy, but what I did was following this procedure
> (loosely cut and paste from here
> <https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel> )
> sudo apt-get build-dep linux-image-$(uname -r)
> Patch the Thinkpad driver with this patch:
> Thinkpad Adaptive keys on Linux
> fakeroot debian/rules clean
> fakeroot debian/rules binary-headers binary-generic
> The name of the kernel package will vary, so amend to to your local system
> sudo dpkg -i linux*2.6.38-7.37*.deb
> sudo reboot
Note that you don't necessarily need to rebuild the kernel to patch a
driver, as long as that driver is somewhat standalone and built as a
module. And of course, as long as the patch doesn't touch any other
parts of the kernel to support the changes in the driver. This case is
such an example.
Something like this should work, keeping the distro kernel and not even
needing a reboot:
1) get the kernel source, approximately the same version as your distro
kernel. This doesn't need to be a perfect match, unless there are
plenty of API changes affecting the driver in question. Download a copy
from www.kernel.org or clone a repo or whatever.
2) get the kernel headers matching the distro-kernel you are running.
This will depend on distro of course. Debian example:
apt-get install linux-headers-`uname -r`
3) get the patch. I prefer lkml.org, because it's easier to access the
bjorn@nemi:/usr/local/src/git/linux$ wget -O /tmp/foo https://lkml.org/lkm=
--2014-05-06 14:42:58-- https://lkml.org/lkml/diff/2014/3/11/167/1
Resolving lkml.org (lkml.org)... 2a01:7c8:c061:1303::7, 126.96.36.199
Connecting to lkml.org (lkml.org)|2a01:7c8:c061:1303::7|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2898 (2.8K) [text/plain]
Saving to: `/tmp/foo'
100%[=====================================================================================================================================================================>] 2,898 --.-K/s in 0s
2014-05-06 14:42:59 (13.2 MB/s) - `/tmp/foo' saved [2898/2898]
4) patch the driver - ignoring warnings, but not errors (this step and
the next assumes that your working directory is the top level of the
kernel source tree):
bjorn@nemi:/usr/local/src/git/linux$ patch -p1 < /tmp/foo
patching file drivers/platform/x86/thinkpad_acpi.c
Hunk #1 succeeded at 3471 (offset 34 lines).
Hunk #2 succeeded at 3590 (offset 34 lines).
patch unexpectedly ends in middle of line
5) build *only* the patched driver using the distro headers:
bjorn@nemi:/usr/local/src/git/linux$ make -C /lib/modules/`uname -r`/build SUBDIRS=`pwd`/drivers/platform/x86 thinkpad_acpi.ko
make: Entering directory `/usr/src/linux-headers-3.2.0-4-amd64'
CC [M] /usr/local/src/git/linux/drivers/platform/x86/thinkpad_acpi.o
MODPOST 1 modules
LD [M] /usr/local/src/git/linux/drivers/platform/x86/thinkpad_acpi.ko
make: Leaving directory `/usr/src/linux-headers-3.2.0-4-amd64'
6) test it:
7) if it worked, then install your special driver where it will
automatically be used instead of the distro packaged driver:
mkdir /lib/modules/`uname -r`/updates
cp /usr/local/src/git/linux/drivers/platform/x86/thinkpad_acpi.ko /lib/modules/`uname -r`/updates/
That's it! OK, it is a few steps, but all of them are really
quick. Especially if you want to repeat this to test more changes. And the rest of
your kernel still comes from your distro.