linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Bjorn Helgaas <helgaas@kernel.org>,
	Maarten Lankhorst <dev@mblankhorst.nl>,
	Michal Hocko <mhocko@kernel.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Andy Lutomirski <luto@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	the arch/x86 maintainers <x86@kernel.org>,
	Daniel Vetter <daniel.vetter@intel.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	linux-pci@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: Linux 4.15-rc2: Regression in resume from ACPI S3
Date: Thu, 14 Dec 2017 12:54:05 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.20.1712132211570.1885@nanos> (raw)
In-Reply-To: <alpine.DEB.2.20.1712132201380.1885@nanos>

On Wed, 13 Dec 2017, Thomas Gleixner wrote:
> On Wed, 13 Dec 2017, Thomas Gleixner wrote:
> > On Wed, 13 Dec 2017, Thomas Gleixner wrote:
> > > On Wed, 13 Dec 2017, Linus Torvalds wrote:
> > > 
> > > > On Wed, Dec 13, 2017 at 8:41 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> > > > >
> > > > > Definitely. That was fragile forever but puzzles me is that I can't figure
> > > > > out what now causes that spurious interrupt to surface out of the blue.
> > > > 
> > > > Perhaps just timing?
> > > 
> > > That's what I'm trying to figure out right now, because that is the only
> > > sensible explanation left. The whole machinery of suspend is exactly the
> > > same with and without the vector changes. I instrumented all functions
> > > involved and the picture is the same. I even do not see any fundamental
> > > timing differences where one would say: That's it.
> > > 
> > > What puzzles me even more is that in the range of commits I'm fiddling with
> > > there is no other change than the vector management stuff and the point
> > > where it breaks makes no sense at all. The point Maarten bisected it to
> > > works nicely here, so that might just point to a very subtle timing issue.
> > 
> > After doing more debugging on this it turns out that this looks like a
> > legacy interrupt coming in. The vector number is always 55, which is legacy
> > IRQ 7 as seen from the PIC. The corresponding IOAPIC interrupt pin is
> > masked and vector 55 is completely unused.
> > 
> > More questions than answers. Still investigating.

At least that one could be explained by the changes. In the previous
management scheme the IOAPIC interrupts were always allocated even when the
interrupt was not in use. The new scheme does not longer do that because
people complained about the vector waste (16 vectors on each CPU) and it
got rid of all the special casing of IRQ0-15.

So the old scheme silently consumed the spurious vector. I added debug code
to that effect to 4.14 and on that machine IRQ7 is triggered at the same
point post resume and the core code drops it silently because the interrupt
is marked masked and no action assigned.

So the only difference to today is that the new code complains, while the
old one does an extra mask of the already masked IOAPIC pin and silently
returns.

After quite some investigation I found out that its independent of the
graphics thing. That's a genuine issue on that platform which seems to emit
random legacy vectors which were never ever used for unknown reasons. I
verified that both the IOAPIC and the PIC are masked, so they cannot send
crap. Though it turned out that the silly firmware unmasks the PIC and
leaves it that way when it returns from suspend. Now there is a race
whether the kernel resume path manages to mask the PIC again early enough
before something triggers IRQ7 or not. Adding/removing debug code makes the
problem come and go. So I really don't worry about that one and rather
prefer to have the spurious interrupt printed than silently consumed by
chance.

Now the graphics issue is a different story. That only happens on
hibernation after doing the snapshot. There all non boot cpus are onlined
again and after that the devices are 'thawed'. The following reenable of
interrupts fails because i915 is not in PCI_D0 state.

Suspend:

   irq_migrate_all_off_this_cpu: Mask 125 pci_msi_mask_irq+0x0/0x10
   __pci_write_msi_msg: 0000:00:02.0 00000000fee0100c 0000412a
   __pci_write_msi_msg: Not written <- Device not in PCI_D0
   ....
   device_pm_callback_start: i915 0000:00:02.0, parent: pci0000:00, noirq bus [resume]
   pci_pm_resume_noirq <-dpm_run_callback
   pci_pm_resume_noirq <-dpm_run_callback
   pci_pm_default_resume_early <-pci_pm_resume_noirq
   pci_pm_default_resume_early <-pci_pm_resume_noirq
   __pci_write_msi_msg: 0000:00:02.0 00000000fee0100c 0000412a  <-- Set the new affinity
   device_pm_callback_end: i915 0000:00:02.0, err=0

Hibernate:

   irq_migrate_all_off_this_cpu: Mask 125 pci_msi_mask_irq+0x0/0x10
   __pci_write_msi_msg: 0000:00:02.0 00000000fee0100c 0000412a
   __pci_write_msi_msg: Not written <- Device not in PCI_D0
   ....
   device_pm_callback_start: i915 0000:00:02.0, parent: pci0000:00, noirq bus [thaw]
   pci_pm_thaw_noirq <-dpm_run_callback
   __pci_write_msi_msg: 0000:00:02.0 00000000fee0100c 0000412a
   __pci_write_msi_msg: Not written  <--- Device is not in PCI_D0
   device_pm_callback_end: i915 0000:00:02.0, err=0

So that code path fails to set the new affinity because at the point where
the MSI msg should be written the device state is != PCI_D0.

Now, what's different vs. 4.14:

The 4.14 code accidentaly had the irq descriptor for this vector still
populated in the old CPU due to the convoluted way the vector allocation
worked. I have still to investigate if one of those cases is actually
leaking the descriptor, which would be a fatal bug.

But the new code does a proper cleanup and does not repopulate it on the
offline CPU. So that unearthes the issue. I'm handing that over to the PM
folks to look at. I got lost in that maze of callbacks.

Thanks,

	tglx

  parent reply	other threads:[~2017-12-14 11:54 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-03 16:22 Linux 4.15-rc2 Linus Torvalds
2017-12-04 22:25 ` Linux 4.15-rc2: Regression in resume from ACPI S3 Rafael J. Wysocki
2017-12-04 22:36   ` Linus Torvalds
2017-12-04 22:38     ` Thomas Gleixner
2017-12-04 22:41       ` Rafael J. Wysocki
2017-12-05  0:25         ` Rafael J. Wysocki
2017-12-09 10:33           ` Pavel Machek
2017-12-09 11:41             ` Pavel Machek
     [not found]             ` <CA+55aFw8tuoJ2gcXx3K2sKFf2Y9hXX4naMVQNqGOUivnjwhjkg@mail.gmail.com>
2017-12-09 22:01               ` Pavel Machek
     [not found]                 ` <CA+55aFySAdiBZhZ0PSDjH5PuvPPcMsBRXbxCkObfm1eY7gHDbQ@mail.gmail.com>
2017-12-10 16:23                   ` Pavel Machek
2017-12-10 16:37                     ` Linus Torvalds
2017-12-10 18:56                       ` Pavel Machek
2017-12-10 20:30                         ` Linus Torvalds
2017-12-10 20:43                           ` Pavel Machek
2017-12-10 21:28                             ` Linus Torvalds
2017-12-10 21:35                               ` Pavel Machek
2017-12-12 17:27                               ` Linus Torvalds
2017-12-12 18:05                                 ` Andy Lutomirski
2017-12-12 18:36                                   ` Linus Torvalds
2017-12-12 22:10                                     ` Andy Lutomirski
2017-12-12 22:33                                       ` Linus Torvalds
2017-12-12 23:10                                         ` Andy Lutomirski
2017-12-13 11:16                                       ` Jarkko Nikula
2017-12-13 12:40                                         ` Ingo Molnar
2017-12-13 18:50                                         ` Andy Lutomirski
2017-12-10 21:38                           ` [PATCH] Fix resume on x86-32 machines Pavel Machek
2017-12-10 21:58                             ` Andy Lutomirski
2017-12-10 22:20                               ` Pavel Machek
2017-12-11  9:25                                 ` Jarkko Nikula
2017-12-11 14:22                               ` Rafael J. Wysocki
2017-12-11 14:43                                 ` Rafael J. Wysocki
2017-12-11 14:59                                 ` Jarkko Nikula
2017-12-11 18:31                                 ` Linus Torvalds
2017-12-11 18:41                                   ` Andy Lutomirski
2017-12-11 19:12                                     ` Linus Torvalds
2017-12-14 20:38                                     ` Pavel Machek
2017-12-14 20:47                                       ` Linus Torvalds
2017-12-14 21:20                                         ` Andy Lutomirski
2017-12-14 22:22                                         ` Pavel Machek
2017-12-11 15:13                               ` Ingo Molnar
2017-12-11 16:26                                 ` Andy Lutomirski
2017-12-11 14:09                           ` Linux 4.15-rc2: Regression in resume from ACPI S3 Zhang Rui
2017-12-11 16:28                             ` Andy Lutomirski
2017-12-12  8:00                             ` Pavel Machek
2017-12-06 12:15     ` Michal Hocko
2017-12-06 12:23       ` Thomas Gleixner
2017-12-06 14:04         ` Rafael J. Wysocki
2017-12-06 12:31       ` Maarten Lankhorst
2017-12-06 12:46         ` Thomas Gleixner
2017-12-06 13:09           ` Maarten Lankhorst
2017-12-06 14:15             ` Thomas Gleixner
2017-12-07 13:33               ` Maarten Lankhorst
2017-12-08 10:30                 ` Thomas Gleixner
2017-12-13 15:57                   ` Thomas Gleixner
2017-12-13 16:23                     ` Bjorn Helgaas
2017-12-13 16:41                       ` Thomas Gleixner
2017-12-13 17:45                         ` Linus Torvalds
2017-12-13 18:19                           ` Thomas Gleixner
2017-12-13 20:52                             ` Thomas Gleixner
2017-12-13 21:06                               ` Thomas Gleixner
2017-12-13 22:48                                 ` Rafael J. Wysocki
2017-12-14 11:54                                 ` Thomas Gleixner [this message]
2017-12-14 12:12                                   ` Rafael J. Wysocki
2017-12-14 12:30                                     ` Thomas Gleixner
2017-12-14 15:30                                       ` Rafael J. Wysocki
2017-12-14 15:52                                         ` Thomas Gleixner
2017-12-14 15:54                                           ` Rafael J. Wysocki
2017-12-14 16:17                                             ` Maarten Lankhorst
2017-12-15  2:07                                             ` [PATCH] PCI / PM: Force devices to D0 in pci_pm_thaw_noirq() Rafael J. Wysocki
2017-12-15 14:28                                               ` Rafael J. Wysocki
2017-12-15 18:30                                               ` Bjorn Helgaas
2017-12-15 23:44                                                 ` Rafael J. Wysocki
2017-12-14 13:24                                   ` Linux 4.15-rc2: Regression in resume from ACPI S3 Thomas Gleixner
2017-12-14 19:03                                   ` Linus Torvalds
2017-12-14 22:36                                     ` Thomas Gleixner
2017-12-14 22:47                                       ` Linus Torvalds
2017-12-15  9:05                                         ` Thomas Gleixner
2017-12-15  0:34                                       ` Rafael J. Wysocki
2017-12-13 22:39                             ` Rafael J. Wysocki
2017-12-13 23:26                               ` Rafael J. Wysocki
2017-12-07  7:55       ` Michal Hocko
2017-12-10 20:30         ` Michal Hocko
2018-02-21 18:36 ` Linux 4.15-rc2 Eugene Syromiatnikov

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=alpine.DEB.2.20.1712132211570.1885@nanos \
    --to=tglx@linutronix.de \
    --cc=bhelgaas@google.com \
    --cc=daniel.vetter@intel.com \
    --cc=dev@mblankhorst.nl \
    --cc=helgaas@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mhocko@kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rjw@rjwysocki.net \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).