# suspend to RAM works, but not suspend to disk

## renkinjutsu

I'm trying to get suspend to disk to work, but I can't. It's strange though, since suspend to ram works just fine.

When I try to suspend to disk, it just brings me to a blank framebuffer with a blinking cursor, and stays there forever.

```
$ free -m

             total       used       free     shared    buffers     cached

Mem:          5456        790       4666          0          0        413

-/+ buffers/cache:        376       5080

Swap:         7999          0       7999

```

```
$ cat /proc/swaps 

Filename                                Type            Size    Used    Priority

/dev/sda5                               partition       8191996 0       -1

```

```
$ cat /sys/power/state

mem disk
```

I experimented with the kernel parameter acpi=off and mem disappeared from /sys/power/state (expected). Then I tried 

```
echo disk > /sys/power/state
```

 and instead of being stuck at the framebuffer forever, it brings me back after 20 seconds with with this outputted in dmesg/kmsg

```
<7>[  153.256650] PM: Marking nosave pages: 000000000009f000 - 0000000000100000

<7>[  153.256662] PM: Marking nosave pages: 00000000bfb3f000 - 00000000bfef6000

<7>[  153.256697] PM: Marking nosave pages: 00000000bff00000 - 0000000100000000

<7>[  153.260668] PM: Basic memory bitmaps created

<6>[  153.260672] PM: Syncing filesystems ... done.

<4>[  153.383741] Freezing user space processes ... (elapsed 0.01 seconds) done.

<4>[  153.397297] Freezing remaining freezable tasks ... 

<3>[  173.413484] Freezing of tasks failed after 20.01 seconds (1 tasks refusing to freeze, wq_busy=0):

<6>[  173.413502] khubd           D 0000000000000000  5840   342      2 0x00800000

<4>[  173.413515]  ffff88019810db90 0000000000000046 ffff880196f753c0 ffff8801975feae0

<4>[  173.413524]  ffff880196d84898 ffff88019810c010 ffff880198101560 0000000000010880

<4>[  173.413533]  ffff88019810dfd8 ffff88019810dfd8 0000000000010880 ffff880198101560

<4>[  173.413541] Call Trace:

<4>[  173.413557]  [<ffffffff81085039>] ? prepare_to_wait+0x71/0x7c

<4>[  173.413568]  [<ffffffff813f97d0>] usb_kill_urb+0xa3/0xc3

<4>[  173.413575]  [<ffffffff81084df7>] ? wake_up_bit+0x25/0x25

<4>[  173.413583]  [<ffffffff813fa797>] usb_start_wait_urb+0x85/0xc2

<4>[  173.413591]  [<ffffffff813f9daf>] ? usb_alloc_urb+0x19/0x42

<4>[  173.413599]  [<ffffffff813fa9f1>] usb_control_msg+0xd8/0xfc

<4>[  173.413607]  [<ffffffff813f3ea2>] hub_port_init+0x26a/0x5fe

<4>[  173.413616]  [<ffffffff8139ddba>] ? pm_runtime_set_autosuspend_delay+0x3a/0x46

<4>[  173.413624]  [<ffffffff813f6149>] hub_thread+0x8f8/0xfa9

<4>[  173.413633]  [<ffffffff8105f387>] ? __dequeue_entity+0x2e/0x33

<4>[  173.413641]  [<ffffffff81064e28>] ? pick_next_task_fair+0xbe/0x10d

<4>[  173.413649]  [<ffffffff81084df7>] ? wake_up_bit+0x25/0x25

<4>[  173.413656]  [<ffffffff813f5851>] ? hub_disconnect+0xe6/0xe6

<4>[  173.413663]  [<ffffffff8108499c>] kthread+0x7d/0x85

<4>[  173.413671]  [<ffffffff8169b914>] kernel_thread_helper+0x4/0x10

<4>[  173.413679]  [<ffffffff8108491f>] ? kthread_worker_fn+0x13a/0x13a

<4>[  173.413686]  [<ffffffff8169b910>] ? gs_change+0xb/0xb

<4>[  173.413698] 

<4>[  173.413701] Restarting tasks ... done.

<7>[  173.414064] PM: Basic memory bitmaps freed
```

Apparently it's having trouble freezing a task. How is suspend to ram working? doesn't suspending to ram also need to freeze tasks?

----------

## eccerr0r

Are you using swsusp in kernel or something else?

Seems to be dealing with USB stuff by the log, do you have unusual USB hardware?

I've used swsusp (in-kernel) with swap partitions and swap files, seems to be working for the most part for me...  I suppose it's kind of strange, my dell laptop actually works with swsusp and does not resume from suspend to RAM properly, go figure...

----------

## renkinjutsu

I don't use swsusp.. Or at least I don't think I do.. I use the vanilla kernel and I can't find swsusp anywhere in the config. And about the weird USB hardware, my laptop has USB3.0 hardware + USB2.0 hardware.. I heard there were problems with the xhci USB3 drivers, so I recompiled my kernel to not have them built in, that way I can modprobe -r whenever I want to hibernate.. unfortunately, it doesn't work even with the xhci_hcd module unloaded

----------

## renkinjutsu

I recompiled my kernel with all the usb controller drivers as modules so I can unload them

I tried suspending to disk with none of the drivers loaded. This worked only ONCE and failed all the other times.. When I boot the kernel with acpi=off on the other hand, suspend to disk works reliably, though I have to manually halt the system myself once the system image was written to disk..

So does this reek of buggy acpi?

----------

## renkinjutsu

Ahh I found my problem.. it was caused by the accelerometer in my laptop. The driver seems kinda buggy.

(hp_accel lis3lv02d)

Anyway. Need to mark this as solved

----------

## renkinjutsu

If you have the kernel sources available, go to that directory. Go to Documentation/power and read basic-pm-debugging.txt..

After reading and understanding that doc, systematically test all modes of hiberation to see where which step it fails (freezer, devices, platform, processors, core..)

Mentioned in the Doc is that failure when testing 'devices' usually means a faulty driver that isn't suspending correctly (this was my problem). It might be helpful to save the dmesg output of each test.

----------

## syn0ptik

my last post here about it

https://forums.gentoo.org/viewtopic-t-953300.html

----------

