[Bug 262734] LinuxKPI: [patch] call dev_pm_ops::prepare() upon suspend to prevent Xorg from crashing after resume

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 23 Mar 2022 09:48:17 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=262734

            Bug ID: 262734
           Summary: LinuxKPI: [patch] call dev_pm_ops::prepare() upon
                    suspend to prevent Xorg from crashing after resume
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: taku@tackymt.homeip.net

Created attachment 232653
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=232653&action=edit
Call dev_pm_ops::prepare() from linux_pci_suspend()

The dev_pm_ops' prepare() method should be called prior to its suspend()
method,
according to the Linux documentation:
https://www.kernel.org/doc/html/v5.4/driver-api/pm/types.html#c.dev_pm_ops

Without doing so, at least on my X1 Carbon 6th gen., Xorg usually (but not
always) crashes after resume.

I also suspect that the lacking of calling prepare() contributes to the hang
on resume, infrequent but not rare, albeit no evidence.

I have a couple of variants to call prepare() method at the time:

* call prepare() via power_suspend_early eventhandler:
  stucks inside switch_to_kernel_context_sync() once per several trials.
* (patch attached) call prepare() directly from linux_pci_suspend():
  survives at least 10 trials, no failures yet.

-- 
You are receiving this mail because:
You are the assignee for the bug.