# gentoo-dev-sources-2.6.7 and swsusp2

## epall

Has anybody been successful at patching gentoo-dev-sources-2.6.7 with the swsusp2 patches? I've seen a lot about gentoo-dev-sources-2.6.5 (esp. https://forums.gentoo.org/viewtopic.php?t=170548), but nothing about 2.6.7. When I try to patch, I get a whole bunch of errors and the compile doesn't work. Any ideas?

----------

## epall

Okay, I tried it on vanilla sources 2.6.7 and got errors too. I think the issue is that the kernel already has swsusp patched in and I'm trying to mess with it by patching in swsusp2. Any ideas?

----------

## jdong

I just cleanly patched it; I'm building/testing it too. (Gentoo-dev-sources 2.6.7-r6)

You need  to grab http://prdownloads.sourceforge.net/swsusp/software-suspend-2.0.0.88-for-2.6.7.tar.bz2?use_mirror=heanet

un-tar it.

You don't need to patch  everything...

Here's what's required, in this order:

20-software-suspend-linux-2.6.7-rev1-whole

30-software-suspend-core-2.0-whole

31-software-suspend-core-2.0.0.88-incremental

The patch should turn up a reject at drivers/char/keyboard.c.rej. Manually patch it in -- there's one #include statement and an #ifdef #endif clause that needs to be inserted.

Then, follow that HOWTO for the rest.

----------

## jdong

Update: Doesn't look too good:

Dunno why it'd mess up SCSI... I'm just ommiting SCSI/SATA support from my kernel for now. And trying again.

```

CC [M]  drivers/scsi/sym53c8xx_2/sym_misc.o

  CC [M]  drivers/scsi/sym53c8xx_2/sym_nvram.o

  LD [M]  drivers/scsi/sym53c8xx_2/sym53c8xx.o

  CC      drivers/scsi/dmx3191d.o

drivers/scsi/NCR5380.c:756: warning: `NCR5380_print_options' defined but not used

drivers/scsi/NCR5380.c:396: warning: `phases' defined but not used

drivers/scsi/NCR5380.c:699: warning: `NCR5380_probe_irq' defined but not used

  CC      drivers/scsi/ide-scsi.o

  LD      drivers/scsi/sd_mod.o

  LD      drivers/scsi/sr_mod.o

  CC      drivers/scsi/sg.o

  LD      drivers/scsi/built-in.o

  CC [M]  drivers/scsi/scsi_transport_spi.o

  CC [M]  drivers/scsi/advansys.o

drivers/scsi/advansys.c: In function `advansys_detect':

drivers/scsi/advansys.c:4622: warning: `check_region' is deprecated (declared at include/linux/ioport.h:121)

drivers/scsi/advansys.c: In function `AscSearchIOPortAddr11':

drivers/scsi/advansys.c:10006: warning: `check_region' is deprecated (declared at include/linux/ioport.h:121)

  CC [M]  drivers/scsi/u14-34f.o

  CC [M]  drivers/scsi/ultrastor.o

  CC [M]  drivers/scsi/aha152x.o

  CC [M]  drivers/scsi/aha1542.o

In file included from drivers/scsi/aha1542.c:43:

include/linux/mca-legacy.h:12:2: warning: #warning "MCA legacy - please move your driver to the new sysfs api"

  CC [M]  drivers/scsi/aic7xxx_old.o

  CC [M]  drivers/scsi/ips.o

  CC [M]  drivers/scsi/fdomain.o

drivers/scsi/fdomain.c: In function `fdomain_isa_detect':

drivers/scsi/fdomain.c:763: warning: `check_region' is deprecated (declared at include/linux/ioport.h:121)

  CC [M]  drivers/scsi/g_NCR5380.o

  CC [M]  drivers/scsi/g_NCR5380_mmio.o

  CC [M]  drivers/scsi/NCR53c406a.o

drivers/scsi/NCR53c406a.c:610: warning: `NCR53c406a_setup' defined but not used

  CC [M]  drivers/scsi/sym53c416.o

drivers/scsi/sym53c416.c: In function `sym53c416_probe':

drivers/scsi/sym53c416.c:627: warning: `check_region' is deprecated (declared at include/linux/ioport.h:121)

drivers/scsi/sym53c416.c: In function `sym53c416_detect':

drivers/scsi/sym53c416.c:715: warning: `check_region' is deprecated (declared at include/linux/ioport.h:121)

  CC [M]  drivers/scsi/dtc.o

drivers/scsi/NCR5380.c:396: warning: `phases' defined but not used

  CC [M]  drivers/scsi/eata_pio.o

drivers/scsi/eata_pio.c: In function `get_pio_conf_PIO':

drivers/scsi/eata_pio.c:596: warning: `check_region' is deprecated (declared at include/linux/ioport.h:121)

  CC [M]  drivers/scsi/eata.o

  CC [M]  drivers/scsi/dc395x.o

  CC [M]  drivers/scsi/tmscsim.o

drivers/scsi/tmscsim.c:521: warning: `dc390_setup' defined but not used

  CC [M]  drivers/scsi/megaraid.o

  CC [M]  drivers/scsi/gdth.o

  CC [M]  drivers/scsi/libata-core.o

drivers/scsi/libata-core.c:3441:40: macro "create_workqueue" requires 2 arguments, but only 1 given

drivers/scsi/libata-core.c: In function `ata_init':

drivers/scsi/libata-core.c:3441: error: `create_workqueue' undeclared (first use in this function)

drivers/scsi/libata-core.c:3441: error: (Each undeclared identifier is reported only once

drivers/scsi/libata-core.c:3441: error: for each function it appears in.)

make[2]: *** [drivers/scsi/libata-core.o] Error 1

make[1]: *** [drivers/scsi] Error 2

make: *** [drivers] Error 2

```

----------

## Romses

@jdong

i have this problem, but no idea, what i have to insert...

Can you post the file or the manual patch?

Greetz Romses

----------

## aloha99

 *Romses wrote:*   

> @jdong
> 
> i have this problem, but no idea, what i have to insert...
> 
> Can you post the file or the manual patch?
> ...

 

Ditto that.  I'm comfortable with C, but am clueless about kernel programming.  I too would greatly appreciate a brief explanation of what you did to patch gentoo-dev-sources.

----------

## epall

okay, so I've successfully patched vanilla-sources-2.6.7 and have a nice, working kernel. I can even hibernate. The only problem is, when I try to come out of hibernation, my system hangs on trying to "load the old kernel" or something. It says something about no status because it's tricky, but I get a hang. I've tried giving it more time (1min+) but no use. What's wrong?

----------

## spiceweasel

I tried to apply those patches to gentoo-dev-sources-2.6.7-r5 (don't know where to get r6) and I got the following error :

```
  CC      drivers/char/keyboard.o

drivers/char/keyboard.c: In function `kbd_keycode':

drivers/char/keyboard.c:1099: error: `software_suspend_state' undeclared (first use in this function)

drivers/char/keyboard.c:1099: error: (Each undeclared identifier is reported only once

drivers/char/keyboard.c:1099: error: for each function it appears in.)

drivers/char/keyboard.c:1099: error: `SOFTWARE_SUSPEND_RUNNING' undeclared (first use in this function)

drivers/char/keyboard.c:1105: error: `SOFTWARE_SUSPEND_SANITY_CHECK_PROMPT' undeclared (first use in this function)

drivers/char/keyboard.c:1107: warning: implicit declaration of function `wakeup_suspend'

drivers/char/keyboard.c:1109: error: `SOFTWARE_SUSPEND_CONTINUE_REQ' undeclared (first use in this function)

drivers/char/keyboard.c:1130: error: `SUSPEND_REBOOT' undeclared (first use in this function)

drivers/char/keyboard.c:1131: warning: implicit declaration of function `schedule_suspend_message'

make[2]: *** [drivers/char/keyboard.o] Error 1

make[1]: *** [drivers/char] Error 2

make: *** [drivers] Error 2

```

How did others get this to work?

----------

## jdong

Ok, here we go, a little patching tutorial.

Issue the patch command: sudo patch -p1 </home/jdong/software-suspend-2.0.0.88-for-2.6.7/20-software-suspend-linux-2.6.7-rev1-whole

You get output like:

```

patching file arch/arm/kernel/ecard.c

patching file arch/i386/kernel/apm.c

patching file arch/i386/kernel/cpu/mcheck/non-fatal.c

patching file arch/i386/kernel/io_apic.c

patching file arch/i386/kernel/process.c

patching file arch/i386/kernel/signal.c

patching file arch/i386/kernel/smp.c

patching file arch/i386/mm/init.c

patching file arch/i386/mm/pageattr.c

patching file arch/i386/power/cpu.c

patching file arch/i386/power/Makefile

patching file arch/i386/power/suspend2.c

patching file arch/ppc/Kconfig

patching file arch/ppc/kernel/signal.c

patching file arch/ppc/kernel/vmlinux.lds.S

patching file arch/ppc/Makefile

patching file arch/ppc/mm/init.c

patching file arch/ppc/platforms/pmac_feature.c

patching file arch/ppc/power/cpu.c

patching file arch/ppc/power/cpu_reg.S

..blah...

patching file drivers/char/keyboard.c

Hunk #2 FAILED at 42.

```

Note the FAILED hunk. If you can't see it, do a find . -name "*.rej".

Now, open up both the .rej and the corresponding .c file into an editor of your choice.

In this case, it's ./drivers/char/keyboard.c.rej and ./drivers/char/keyboard.c

Here's the contents of the rej:

```
***************

*** 41,49 ****

  #include <linux/sysrq.h>

  #include <linux/input.h>

  static void kbd_disconnect(struct input_handle *handle);

  extern void ctrl_alt_del(void);

  /*

   * Exported functions/variables

   */

--- 42,56 ----

  #include <linux/sysrq.h>

  #include <linux/input.h>

+ #include <linux/suspend.h>

+

  static void kbd_disconnect(struct input_handle *handle);

  extern void ctrl_alt_del(void);

+ #ifdef CONFIG_PM

+ extern void wakeup_suspend(void);

+ #endif

+

  /*

   * Exported functions/variables

   */

```

Basic rules of PATCHes: The - sign means to remove a line, the + sign means to add a line. The --- separates the - section from the + section.

So, interpreting this patch, it wants to add #include <linux/suspend.h> and, add

 #ifdef CONFIG_PM

 extern void wakeup_suspend(void);

 #endif

after the declaration of ctrl_alt_del(void);

Now, look at the keyboard.c file.

Here's a snippet of the beginning:

```

#include <linux/config.h>

#include <linux/module.h>

#include <linux/sched.h>

#include <linux/tty.h>

#include <linux/tty_flip.h>

#include <linux/mm.h>

#include <linux/string.h>

#include <linux/random.h>

#include <linux/init.h>

#include <linux/completion.h>

#include <linux/slab.h>

#include <linux/kbd_kern.h>

#include <linux/kbd_diacr.h>

#include <linux/vt_kern.h>

#include <linux/sysrq.h>

#include <linux/input.h>

#include <linux/speakup.h>

#ifdef CONFIG_SPEAKUP_MODULE

spk_key_func addr_spk_key = NULL;

#endif

static void kbd_disconnect(struct input_handle *handle);

extern void ctrl_alt_del(void);

/*

 * Exported functions/variables

 */

```

Now, we can see why the patch failed. The real keyboard.c contains a whole hell of a lot more code than what the patch expected -- probably Gentoo patched features, like Speakup (CONFIG_SPEAKUP_MODULE).

Now, let's add in the two blocks we need. 

C Programmers: You will probably understand what the two things are. One's an include statement for the header file of the swsusp2 code. The other is a function declaration, and only do it if a certain macro is defined. You'll know that these can go virtually anywhere -- you got it easy!!

So, final beginning:

```

#include <linux/config.h>

#include <linux/module.h>

#include <linux/sched.h>

#include <linux/tty.h>

#include <linux/tty_flip.h>

#include <linux/mm.h>

#include <linux/string.h>

#include <linux/random.h>

#include <linux/init.h>

#include <linux/completion.h>

#include <linux/slab.h>

#include <linux/kbd_kern.h>

#include <linux/kbd_diacr.h>

#include <linux/vt_kern.h>

#include <linux/sysrq.h>

#include <linux/input.h>

#include <linux/suspend.h>

#include <linux/speakup.h>

#ifdef CONFIG_SPEAKUP_MODULE

spk_key_func addr_spk_key = NULL;

#endif

static void kbd_disconnect(struct input_handle *handle);

 #ifdef CONFIG_PM

 extern void wakeup_suspend(void);

 #endif

extern void ctrl_alt_del(void);

/*

 * Exported functions/variables

 */

```

Now, the only problem is in the SCSI modules -- somehow they're messed up. Since I don't use SCSI/SATA, I just unchecked all the SCSI components. I don't have a fix for the SCSI errors.

----------

## Romses

I solved the scsi-problem with a little workaround.

i noticed, that i have activates SATA in the scsi-section.

This is stupid, because i didn't have SATA.

After disabeling SATA, my kernel compiles

Greetz from Germany  Romses

----------

## jdong

 *Romses wrote:*   

> I solved the scsi-problem with a little workaround.
> 
> i noticed, that i have activates SATA in the scsi-section.
> 
> This is stupid, because i didn't have SATA.
> ...

 

I actually have a SATA card (two, to be exact) but I don't have any drives yet. No swsusp works for me, amd64_agp (Athlon64/Opteron AGPGART) always causes video corruption on resume, and disabling AGPGART impacts 3d performance too much...

----------

## val

I used software-suspend-2.0.0.93-for-2.6.7.tar.bz2 and it patched cleanly but won't compile.  The compile errors are:

```
arch/i386/kernel/process.c: In function `sys_fork':

arch/i386/kernel/process.c:583: error: `DECLARE_SWSUSP_LOCAL_VAR' undeclared (first use in this function)

arch/i386/kernel/process.c:583: error: (Each undeclared identifier is reported only once

arch/i386/kernel/process.c:583: error: for each function it appears in.)

arch/i386/kernel/process.c:584: warning: implicit declaration of function `SWSUSP_ACTIVITY_START'

arch/i386/kernel/process.c:586: error: `SWSUSP_ACTIVITY_END' undeclared (first use in this function)

arch/i386/kernel/process.c: In function `sys_clone':

arch/i386/kernel/process.c:596: error: `DECLARE_SWSUSP_LOCAL_VAR' undeclared (first use in this function)

arch/i386/kernel/process.c:607: error: `SWSUSP_ACTIVITY_END' undeclared (first use in this function)

arch/i386/kernel/process.c: In function `sys_vfork':

arch/i386/kernel/process.c:625: error: `DECLARE_SWSUSP_LOCAL_VAR' undeclared (first use in this function)

arch/i386/kernel/process.c:629: error: `SWSUSP_ACTIVITY_END' undeclared (first use in this function)

make[1]: *** [arch/i386/kernel/process.o] Error 1

make: *** [arch/i386/kernel] Error 2

```

The offending code is in process.c:

```
asmlinkage int sys_fork(struct pt_regs regs)

{

   int result;

   DECLARE_SWSUSP_LOCAL_VAR;

   SWSUSP_ACTIVITY_START(0);

   result = do_fork(SIGCHLD, regs.esp, &regs, 0, NULL, NULL);

   SWSUSP_ACTIVITY_END;

   return result;

}
```

Looking for the missing variables:

```
root@patsy linux # pwd

/usr/src/linux/include/linux

root@patsy linux # grep DECLARE_SWSUSP *.h

root@patsy linux # grep SWSUSP_ACTIVITY *.h

root@patsy linux #

```

 :Sad: 

Anybody?

----------

## BigGerman

I used vanilla 2.6.7 sources from kernel.org and .98 patches from swsusp. Patched and compiled without error. Hibernates fine; KDE, wireless, sound - all works on resume.

Laptop is Fujitsu E7110. Amazing, I was looking for this for long time.

I did encounter a few problems: couple times I had to reboot again to get it to wake up.

----------

## loony

Thank you, thank you and again thank you!!! Finally I got it to work with your little tutorial!!!

 *jdong wrote:*   

> Ok, here we go, a little patching tutorial.
> 
> 

 

loony

----------

## epall

My issue was USB. Compiling usb stuff (including ohci-hcd) as modules made everything work beautifully! 2.0.0.100 is great!

----------

## aloha99

I finally had enough time to do this ... and in not very much time at all I had suspend-to-disk finally working!  Thanks go to Tuxlover's how-to, but also big shoutouts to jdong.

Thanks again!

----------

## wap32.

Ok, I patched the kernel with software-suspend-2.0.0.88-for-2.6.7 and it compiled cleanly(thanks to jdong) , I can even hibernate =D.

I only have one problem, after patching the kernel, I can no longer load the ndiswrapper module, which I need to get my wireless card working.

When I compile my kernel it gives me this error:

```
if [ -r System.map ]; then /sbin/depmod -ae -F System.map  2.6.7-gentoo-r11; fi

WARNING: /lib/modules/2.6.7-gentoo-r11/misc/ndiswrapper.ko needs unknown symbol __per_cpu_offset

WARNING: /lib/modules/2.6.7-gentoo-r11/misc/ndiswrapper.ko needs unknown symbol __preempt_spin_lock

WARNING: /lib/modules/2.6.7-gentoo-r11/misc/ndiswrapper.ko needs unknown symbol del_timer_sync

```

I had no idea what the problem was(I am not exactly new to linux, but I'm a bit of a n00b), so I started messing up with things, seeing if I could get it working, and while doing it, I copied the old System.map(the one I had before patching the kernel) and it no longer gave me an error.

I thought "Yes!!", but that thought turned into the opposite when I rebooted.

I still couldn't(and still can't =) load the ndiswrapper module.

When I do "modprobe ndiswrapper" it says the module has an invalid format.

Does anyone have a clue what the problem is, and if there is a solution??

----------

## Wilko

I was getting the same errors with a 2.6.8.1 kernel, however I haven't applied the software suspend patch (maybe its in 2.6.8? maybe not)

These errors

```

WARNING: /lib/modules/2.6.7-gentoo-r11/misc/ndiswrapper.ko needs unknown symbol __per_cpu_offset

WARNING: /lib/modules/2.6.7-gentoo-r11/misc/ndiswrapper.ko needs unknown symbol __preempt_spin_lock

WARNING: /lib/modules/2.6.7-gentoo-r11/misc/ndiswrapper.ko needs unknown symbol del_timer_sync 
```

They went away when I upgraded ndiswrapper to version 0.10, maybe that can help?

----------

## Cheesepie

 :Crying or Very sad: 

root@blip linux # make && make modules_install

  SPLIT   include/linux/autoconf.h -> include/config/*

make[1]: `arch/i386/kernel/asm-offsets.s' is up to date.

  CHK     include/linux/compile.h

  CC      arch/i386/mm/init.o

  LD      arch/i386/mm/built-in.o

  CC      kernel/power/main.o

  LD      kernel/power/built-in.o

  LD      kernel/built-in.o

  CC      mm/page_io.o

  LD      mm/built-in.o

  CC      arch/i386/power/suspend2.o

arch/i386/power/suspend2.c: In function `do_suspend2_lowlevel':

arch/i386/power/suspend2.c:566: error: too few arguments to function `kmap_atomic'

arch/i386/power/suspend2.c:569: error: too few arguments to function `kunmap_atomic'

make[1]: *** [arch/i386/power/suspend2.o] Error 1

make: *** [arch/i386/power] Error 2

Edit: nevermind, I was using version .88 of the kernel patches. Newer versions are available.

----------

## el*Loco

 *wap32. wrote:*   

> I only have one problem, after patching the kernel, I can no longer load the ndiswrapper module, which I need to get my wireless card working.

 

Same problem here  :Sad: 

Ich weiss auch nicht wie ich da drumherum komme ...

----------

