freebsd-skq/sys/dev/pci
Andriy Gapon 82a5a27527 add support for marking interrupt handlers as suspended
The goal of this change is to fix a problem with PCI shared interrupts
during suspend and resume.

I have observed a couple of variations of the following scenario.
Devices A and B are on the same PCI bus and share the same interrupt.
Device A's driver is suspended first and the device is powered down.
Device B generates an interrupt. Interrupt handlers of both drivers are
called. Device A's interrupt handler accesses registers of the powered
down device and gets back bogus values (I assume all 0xff). That data is
interpreted as interrupt status bits, etc. So, the interrupt handler
gets confused and may produce some noise or enter an infinite loop, etc.

This change affects only PCI devices.  The pci(4) bus driver marks a
child's interrupt handler as suspended after the child's suspend method
is called and before the device is powered down.  This is done only for
traditional PCI interrupts, because only they can be shared.

At the moment the change is only for x86.

Notable changes in core subsystems / interfaces:
- BUS_SUSPEND_INTR and BUS_RESUME_INTR methods are added to bus
  interface along with convenience functions bus_suspend_intr and
  bus_resume_intr;
- rman_set_irq_cookie and rman_get_irq_cookie functions are added to
  provide a way to associate an interrupt resource with an interrupt
  cookie;
- intr_event_suspend_handler and intr_event_resume_handler functions
  are added to the MI interrupt handler interface.

I added two new interrupt handler flags, IH_SUSP and IH_CHANGED, to
implement the new intr_event functions.  IH_SUSP marks a suspended
interrupt handler.  IH_CHANGED is used to implement a barrier that
ensures that a change to the interrupt handler's state is visible
to future interrupts.
While there, I fixed some whitespace issues in comments and changed a
couple of logically boolean variables to be bool.

MFC after:	1 month (maybe)
Differential Revision: https://reviews.freebsd.org/D15755
2018-12-17 17:11:00 +00:00
..
fixup_pci.c
hostb_pci.c
ignore_pci.c
isa_pci.c
pci_host_generic_acpi.c pci_host_generic : move activate/release to generic code 2018-11-19 03:43:10 +00:00
pci_host_generic_fdt.c pci_host_generic : move activate/release to generic code 2018-11-19 03:43:10 +00:00
pci_host_generic_fdt.h
pci_host_generic.c pci_host_generic : move activate/release to generic code 2018-11-19 03:43:10 +00:00
pci_host_generic.h pci_host_generic*: basic implementation of bus range 2018-11-19 02:55:18 +00:00
pci_if.m
pci_iov_if.m
pci_iov_private.h
pci_iov_schema.c
pci_iov.c
pci_iov.h
pci_pci.c Sprinkle EARLY_DRIVER_MODULE around the tree 2018-12-04 04:55:49 +00:00
pci_private.h
pci_subr.c
pci_user.c Fix stray tab. 2018-11-17 00:03:04 +00:00
pci.c add support for marking interrupt handlers as suspended 2018-12-17 17:11:00 +00:00
pcib_if.m
pcib_private.h
pcib_support.c
pcireg.h Add PCIV_INVALID definition 2018-09-26 13:16:55 +00:00
pcivar.h Reapply, with minor tweaks, r338025, from the original commit: 2018-09-26 17:12:14 +00:00
schema_private.h
vga_pci.c