From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Anshuman Gupta <anshuman.gupta@intel.com>,
rafael@kernel.org, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH] drm/xe: Restore pci state upon resume
Date: Fri, 20 Sep 2024 13:19:06 +0300 [thread overview]
Message-ID: <Zu1MGo3YAaSeml7l@intel.com> (raw)
In-Reply-To: <ZuyhW3fymwZhoKaz@intel.com>
On Thu, Sep 19, 2024 at 06:10:35PM -0400, Rodrigo Vivi wrote:
> On Wed, Sep 18, 2024 at 12:09:40AM +0300, Ville Syrjälä wrote:
> > On Tue, Sep 17, 2024 at 02:49:37PM -0400, Rodrigo Vivi wrote:
> > > On Fri, Sep 13, 2024 at 07:54:34PM +0300, Ville Syrjälä wrote:
> > > > On Fri, Sep 13, 2024 at 11:43:52AM -0400, Rodrigo Vivi wrote:
> > > > > On Fri, Sep 13, 2024 at 02:01:49PM +0300, Ville Syrjälä wrote:
> > > > > > On Thu, Sep 12, 2024 at 03:05:30PM -0400, Rodrigo Vivi wrote:
> > > > > > > The pci state was saved, but not restored. Restore
> > > > > > > right after the power state transition request like
> > > > > > > every other driver.
> > > > > > >
> > > > > > > Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
> > > > > > > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > > > > > > ---
> > > > > > > drivers/gpu/drm/xe/xe_pci.c | 2 ++
> > > > > > > 1 file changed, 2 insertions(+)
> > > > > > >
> > > > > > > diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
> > > > > > > index 5ba4ec229494..6d29ef4b396f 100644
> > > > > > > --- a/drivers/gpu/drm/xe/xe_pci.c
> > > > > > > +++ b/drivers/gpu/drm/xe/xe_pci.c
> > > > > > > @@ -949,6 +949,8 @@ static int xe_pci_resume(struct device *dev)
> > > > > > > if (err)
> > > > > > > return err;
> > > > > > >
> > > > > > > + pci_restore_state(pdev);
> > > > > >
> > > > > > Why is xe even doing this stuff by hand instead of letting
> > > > > > the pci core handle it?
> > > > >
> > > > > That's a fair question, given that there's not much documentation
> > > > > around it.
> > > > >
> > > > > Looking the pci code, it looks that the pci core is not calling itself
> > > > > for the restoration of the config space anywhere and looking to
> > > > > other drivers around it looks like a safe thing to do.
> > > > >
> > > > > And the pci_restore_state is paired with the pci_save_state.
> > > > > Both i915 and Xe are doing the pci_save_state and not restoring
> > > > > it.
> > > >
> > > > i915 needs it because (as a side effect) it prevents the pci
> > > > code from automagically sticking the device into D3, which
> > > > apparently breaks hibernation on some old crappy laptops.
> > > > But xe shouldn't need that.
> > >
> > > Hmm, doing some archaeology here, it looks like the
> > > both pci_save and pci_restore were added together on
> > > regular system suspend-resume by Jesse from the very
> > > beginning:
> > >
> > > ba8bbcf6ff46 ("i915: add suspend/resume support")
> >
> > Pretty sure it was initially just cargo culted. Or perhaps
> > the pci code didn't do stuff back then. Shrug.
> >
> > > Then, later pci_restore was removed by Zhenyu on
> > > b7e53aba2f0e ("drm/i915: remove restore in resume")
> > > because it was hanging some platforms.
> > >
> > > The only reference to d3 related issues that I could find
> > > was this one:
> > > https://lore.kernel.org/intel-gfx/1497281047-25204-5-git-send-email-animesh.manna@intel.com/
> > >
> > > but that was trying to add the support to the the save/restore
> > > in the runtime pm side and not here in the regular system suspend/resume.
> > >
> > > Am I missing anything?
> >
> > commit ab3be73fa7b4 ("drm/i915: gen4: work around hang during
> > hibernation")
>
> but this is about the pci_set_power_state not the pci_save_state
> or pci_restore_state.
This is the side effect of pci_save_state() I mentioned.
It prevents the pci code from doing the pci_set_power_state(D3).
>
> For the set_power we are pairing them together.
> My concern is that for the save restore we are not.
> So we either remove the save or we add the restore.
The pci code always does set_power_state(D0)+restore
on resume.
>
> Pending more to remove it after Anshuman showed the log.
>
> >
> > > Empirically Anshuman showed us that PCI subsystem is indeed taking
> > > care of the save/restore.
> > >
> > > Ville, my question to you now is: can I go ahead and simply remove
> > > the pci_save_state() call from i915? Or you still believe some
> > > hibernation somewhere could be broken?
> >
> > Unless someone can figure out a way to fix those cursed
> > BIOSes (or they magically fixed themselves in the meantime)
> > it needs to stay.
> >
> > > I believe we should either remove both save and restore for both
> > > drivers or add both to both.
> >
> > I think we should try to get as close to the standard
> > driver/pci behaviour as possible. AFAICS that would be
> > achieved by moving pci_save_state()+pci_set_power()
> > (and nothing else) into the .suspend_noirq() and
> > .poweroff_noirq() hooks. And then xe wouldn't even
> > need to hook those up.
>
> yeap, but our state machinery was never good with that.
>
> >
> > But that does require some actual thougha as it would
> > change our current behaviour to not go to D3 in
> > .freeze_late() (the pci code won't put the device into
> > D3 in .freeze_noirq() either). I suppose this would
> > also let us nuke the pci_set_power_state(D0) from
> > i915_drm_resume_early()...
> >
> > And the switcheroo stuff would presumably need some
> > changes. Just calling the noirq() stuff from the
> > switcheroo suspend hook should hopefully suffice.
> > Hmm, and I guess we'd need the pci_set_power_state(D0)
> > for it stll in the resume path.
> >
> > Another thing I realized is that we never restore the
> > config space in the switcheroo resume path. I suppose
> > for our integrated GPUs it doesn't get clobbered in
> > D3 anyway so shouldn't really matter. So we could
> > technically also skip the pci_save_state() in the
> > switcheroo suspend path.
>
> yeap, not only in the switcheroo, but we are saving
> but never restoring...
>
> I have this patch that remove the save in some refactor that I'm planning:
> https://github.com/rodrigovivi/linux/tree/display-pm-reconcile
>
> >
> > We could also consider quirking the hibernate vs.
> > D3 stuff in drivers/pci. Would just need a new flag
> > on the pci_dev to skip the pci_set_power_state(),
> > or something.
> >
> > --
> > Ville Syrjälä
> > Intel
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2024-09-20 10:19 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-12 19:05 [PATCH] drm/xe: Restore pci state upon resume Rodrigo Vivi
2024-09-12 19:47 ` Cavitt, Jonathan
2024-09-12 20:05 ` ✓ CI.Patch_applied: success for " Patchwork
2024-09-12 20:05 ` ✓ CI.checkpatch: " Patchwork
2024-09-12 20:07 ` ✓ CI.KUnit: " Patchwork
2024-09-12 20:11 ` [PATCH] " Lucas De Marchi
2024-09-12 21:20 ` Rodrigo Vivi
2024-09-12 21:40 ` Lucas De Marchi
2024-09-17 21:37 ` Maarten Lankhorst
2024-09-12 20:18 ` ✓ CI.Build: success for " Patchwork
2024-09-12 20:21 ` ✓ CI.Hooks: " Patchwork
2024-09-12 20:22 ` ✓ CI.checksparse: " Patchwork
2024-09-12 20:37 ` ✓ CI.BAT: " Patchwork
2024-09-13 11:01 ` [PATCH] " Ville Syrjälä
2024-09-13 15:43 ` Rodrigo Vivi
2024-09-13 15:50 ` Gupta, Anshuman
2024-09-13 16:54 ` Ville Syrjälä
2024-09-17 18:49 ` Rodrigo Vivi
2024-09-17 21:09 ` Ville Syrjälä
2024-09-19 22:10 ` Rodrigo Vivi
2024-09-20 10:19 ` Ville Syrjälä [this message]
2024-09-13 14:10 ` ✗ CI.FULL: failure for " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2024-09-12 21:45 [PATCH] " Rodrigo Vivi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zu1MGo3YAaSeml7l@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=anshuman.gupta@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=rafael@kernel.org \
--cc=rodrigo.vivi@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox