Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 689588 - x11-drivers/nvidia-drivers-430.* : add new power management functions
Summary: x11-drivers/nvidia-drivers-430.* : add new power management functions
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Jeroen Roovers
Keywords: NeedPatch
Depends on:
Reported: 2019-07-10 08:57 UTC by Maik
Modified: 2019-07-19 16:59 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---

working (for me) (,868 bytes, text/plain)
2019-07-13 12:21 UTC, Maik

Note You need to log in before you can comment on or make changes to this bug.
Description Maik 2019-07-10 08:57:49 UTC
Starting with the v430 driver, the new kernel driver callback /proc/driver/nvidia/suspend was added to save/restore video memory on suspend/hibernate/resume to mitigate FBO corruption on resume:
The driver package contains systemd units and a script.
Comment 1 Maik 2019-07-13 12:21:15 UTC
Created attachment 582756 [details]
working (for me)

The script included in the driver package is unusable, attaching a much simpler, working one which using chvt and fgconsole for vt switching.
Comment 2 Jeroen Roovers gentoo-dev 2019-07-13 12:35:03 UTC
Comment on attachment 582756 [details]
working (for me)

Comments below the lines they relate to.


Nothing in particular should require bash specific features.


1) Shouldn't that be /run/... ?
2) It doesn't seem to make sense to me to create a directory in which a single temporary file will be placed.

>case "$1" in
>    suspend|hibernate)
>        /bin/mkdir -p "${RUN_DIR}"
>        /usr/bin/fgconsole > "${XORG_VT_FILE}"
>        /usr/bin/chvt 63
>        if [[ $? -ne 0 ]]; then

This should be replaced with a non-bash test.

>                exit $?
>        fi
>        /bin/echo "$1" > /proc/driver/nvidia/suspend
>        exit $?
>        ;;
>    resume)
>        /bin/echo "$1" > /proc/driver/nvidia/suspend 

1) Looks like the line ends with a space.
2) What if this fails?

>        #
>        # Check if Xorg was determined to be running at the time
>        # of suspend, and whether its VT was recorded.  If so,
>        # attempt to switch back to this VT.
>        #
>        if [[ -f "${XORG_VT_FILE}" ]]; then
>            XORG_PID=$(cat "${XORG_VT_FILE}")
>            /bin/rm "${XORG_VT_FILE}"
>            /usr/bin/chvt "${XORG_PID}"
>        fi
>        exit 0
>        ;;
>    *)
>        exit 1
Comment 3 Maik 2019-07-13 12:50:17 UTC
(In reply to Jeroen Roovers from comment #2)
> Comment on attachment 582756 [details]
> >    resume)
> >        /bin/echo "$1" > /proc/driver/nvidia/suspend 
> 2) What if this fails?
If what fails? echoing? Please clarify.
echoing "resume" to that handle is instructing the driver to restore the video memory from tmp file. If that fails, the result would be the same corruption as it is now without that function. But there's no call back to get the result, AFAIK. Would be informational only, anyway, since you can literally see that it didn't work.
This is just the original script, I basically only replaced a lot of crap with that fgconsole line to get it to work at all, call it WIP.
Comment 4 Maik 2019-07-13 12:55:56 UTC
On second thought: those handles of course only exist if the nvidia driver is loaded so there has to be a check at the start of the script so it bails out if that isn't the case.
Comment 5 Maik 2019-07-13 14:34:09 UTC
A little ToDo-list for besides the changes from post #2:
- make sure the handle /proc/driver/nvidia/suspend exists, i.e. the (correct) driver is loaded
- check /proc/driver/nvidia/params that the correct module parameter NVreg_PreserveVideoMemoryAllocations=1 is set
- make sure no Xorg is started on vt63, otherwise use other vt# and make note of it.
- writing to that handle only ever errors out if anything else than suspend,resume or hibernate is written to it, shouldn't happen due to switch case and previous check.