freebsd-dev/sys
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
..
amd64 amd64: stop re-reading curpc on subyte/suword 2018-12-08 04:53:08 +00:00
arm [mv_pci] Do not attempt to attach disabled PCI ports 2018-12-15 02:35:48 +00:00
arm64 mv_thermal: Add thermal driver for AP806 and CP110 thermal sensor 2018-12-12 22:33:05 +00:00
bsm
cam add a knob that disables detection of write protected disks 2018-12-17 16:01:37 +00:00
cddl dtrace: fix userspace access on boxes with SMAP 2018-12-13 20:09:38 +00:00
compat Remove unused argument to priv_check_cred. 2018-12-11 19:32:16 +00:00
conf powerpcspe: Don't require FPU_EMU for powerpcspe IEEE emulation 2018-12-15 04:53:02 +00:00
contrib Revert accidentally included changes in r342108 2018-12-15 05:47:22 +00:00
crypto Generalize AES iov optimization 2018-12-13 04:40:53 +00:00
ddb ddb: Enable 'thread <address>' 2018-10-20 20:45:49 +00:00
dev add support for marking interrupt handlers as suspended 2018-12-17 17:11:00 +00:00
dts arm64: allwinner: Fix pwm dtso 2018-12-12 21:10:34 +00:00
fs Remove unused argument to priv_check_cred. 2018-12-11 19:32:16 +00:00
gdb
geom gmirror: Remove a last-minute INVARIANTS breakage in r341840 2018-12-12 18:13:56 +00:00
gnu Update our devicetree to 4.19 for arm and arm64 2018-11-10 21:02:32 +00:00
i386 Merge ^/head r340918 through r341763. 2018-12-09 11:39:45 +00:00
isa Reapply, with minor tweaks, r338025, from the original commit: 2018-09-26 17:12:14 +00:00
kern add support for marking interrupt handlers as suspended 2018-12-17 17:11:00 +00:00
kgssapi OpenCrypto: Convert sessions to opaque handles instead of integers 2018-07-18 00:56:25 +00:00
libkern mcount: tidy up ANSIfication 2018-10-20 22:39:35 +00:00
mips atomic_cmpset return value is also an int. 2018-12-14 19:48:42 +00:00
modules arm64: allwinner: Add DTSO for pwm and r_pwm 2018-12-12 21:02:22 +00:00
net Remove unused argument to priv_check_cred. 2018-12-11 19:32:16 +00:00
net80211 Fix misspellings of transmitter/transmitted 2018-08-10 20:37:32 +00:00
netgraph Allow ng_nat to be attached to a ethernet interface directly via ng_ether(4) 2018-12-17 16:00:35 +00:00
netinet Revert r331567 CC Cubic: fix underflow for cubic_cwnd() 2018-12-15 17:01:16 +00:00
netinet6 Remove unused argument to priv_check_cred. 2018-12-11 19:32:16 +00:00
netipsec Remove unused argument to priv_check_cred. 2018-12-11 19:32:16 +00:00
netpfil pf: Fix endless loop on NAT exhaustion with sticky-address 2018-12-12 20:15:06 +00:00
netsmb Remove unused argument to priv_check_cred. 2018-12-11 19:32:16 +00:00
nfs Switch RIB and RADIX_NODE_HEAD lock from rwlock(9) to rmlock(9). 2018-06-16 08:26:23 +00:00
nfsclient
nfsserver
nlm
ofed ipoib: Notify on modify QP failure only when relevant 2018-12-05 13:27:17 +00:00
opencrypto Plug memory leak for AES_*_NIST_GMAC algorithms. 2018-12-13 08:59:51 +00:00
powerpc powerpc/booke: Change KERNBASE to be physical load address 2018-12-13 05:07:39 +00:00
riscv Add some more checking to the RISC-V page fault handler. 2018-12-14 21:07:12 +00:00
rpc Add kern.rpc.gss.client_max, to make it possible to bump it easily. 2018-12-15 11:32:11 +00:00
security Remove unused argument to priv_check_cred. 2018-12-11 19:32:16 +00:00
sparc64 Plug memory disclosures via ptrace(2). 2018-12-03 20:54:17 +00:00
sys add support for marking interrupt handlers as suspended 2018-12-17 17:11:00 +00:00
teken Implement ECMA-48 "REP", some Linuxen have started emitting them recently. 2018-10-21 08:29:36 +00:00
tests epoch_test: fix compile 2018-07-15 00:31:17 +00:00
tools make_dtb.sh: Use $CPP instead of assuming that cpp is in $PATH 2018-12-14 23:53:28 +00:00
ufs Ensure that the inode check-hash is not left zeroed out in the case where 2018-12-15 18:49:30 +00:00
vm Remove unused argument to priv_check_cred. 2018-12-11 19:32:16 +00:00
x86 add support for marking interrupt handlers as suspended 2018-12-17 17:11:00 +00:00
xdr
xen xen: legacy PVH fixes for the new interrupt count 2018-09-13 07:14:11 +00:00
Makefile