# A guide is for laptop sleeping  with amd vga card(vega series apu  suspending and resuming tested)



## Raffeale (Mar 12, 2020)

yesterday i finnaly finished debuging for amdgpu , i found the suspend and resume function not work for freebsd 12.1 drm5.0 ,because the linuxkpi_register_pci_drm_driver won't get suspend and resume callback .
the problem is linuxkpi compilation option is incorrect by default caus linuxkpi.ko lost some member variable of struct , amdgpu drm 5.0  driver use linuxkpi version more then 50000 .

before do following step , you have to install amdgpu drm5.0 driver for freebsd 12.1,  read this thread
https://forums.freebsd.org/threads/...for-freebsd-12-1-tutorial-for-beginner.73901/[


*to solve this issus, you shoud change    /usr/src/sys/modules/linuxkpi/Makefile like this:*

#########START############## <--- do not copy this line
KMOD=   linuxkpi
SRCS=   linux_compat.c \
        linux_current.c \
        linux_hrtimer.c \
        linux_idr.c \
        linux_kmod.c \
        linux_kthread.c \
        linux_lock.c \
        linux_page.c \
        linux_pci.c \
        linux_radix.c \
        linux_rcu.c \
        linux_schedule.c \
        linux_slab.c \
        linux_tasklet.c \
        linux_usb.c \
        linux_work.c

SRCS+=  bus_if.h \
        device_if.h \
        pci_if.h \
        vnode_if.h \
        usb_if.h \
        opt_usb.h \
        opt_stack.h

CFLAGS+= -I${SRCTOP}/sys/compat/linuxkpi/common/include *-DLINUXKPI_VERSION=50000*
CFLAGS+= -I${SRCTOP}/sys/contrib/ck/include

.include <bsd.kmod.mk>

########END################ <--- do not copy this line

*this Makefile only use for drm 5.0 driver
and then compile linuxkpi and install it. just do this*

```
rm /boot/kernel/linuxkpi.ko
rm /boot/module/linuxkpi.ko
cd /usr/src/sys/modules/linuxkpi/
make
make install
```

*put this in your /etc/sysctl.conf to close lid for suspending*


```
hw.acpi.lid_switch_state=s3
kernel.vty="vt"
kern.vty="vt"
```
*to test it ,just close your laptop lid , it works fine for amd r3500u vega8

you need restart your laptop before testing it*

how to check does it work?
look at your laptop power indicator led, it will be blinking slowly.


----------

