freebsd-dev/sys/dev
Andriy Gapon 857bb3d01e firewire/sbp: try to improve locking, plus a few style nits
This change tries to fix the most obvious locking problems.

sbp_cam_scan_lun() is never called with the sbp lock held, so the lock
needs to be acquired internally (if it's needed at all).
Without this change a kernel with INVARIANTS panics when a firewire disk
is connected:
  panic: mutex sbp not owned at /usr/src/sys/dev/firewire/sbp.c:967
  KDB: stack backtrace:
  db_trace_self_wrapper() at 0xffffffff80420bbb = db_trace_self_wrapper+0x2b/frame 0xfffffe0504df0930
  kdb_backtrace() at 0xffffffff80670359 = kdb_backtrace+0x39/frame 0xfffffe0504df09e0
  vpanic() at 0xffffffff8063986c = vpanic+0x14c/frame 0xfffffe0504df0a20
  panic() at 0xffffffff806395b3 = panic+0x43/frame 0xfffffe0504df0a80
  __mtx_assert() at 0xffffffff8061c40d = __mtx_assert+0xed/frame 0xfffffe0504df0ac0
  sbp_cam_scan_lun() at 0xffffffff80474667 = sbp_cam_scan_lun+0x37/frame 0xfffffe0504df0af0
  xpt_done_process() at 0xffffffff802aacfa = xpt_done_process+0x2da/frame 0xfffffe0504df0b30
  xpt_done_td() at 0xffffffff802ac2e5 = xpt_done_td+0xd5/frame 0xfffffe0504df0b80
  fork_exit() at 0xffffffff805ff72f = fork_exit+0xdf/frame 0xfffffe0504df0bf0
  fork_trampoline() at 0xffffffff8082483e = fork_trampoline+0xe/frame
  0xfffffe0504df0bf0
  --- trap 0, rip = 0, rsp = 0, rbp = 0 ---

Also, I tried to reduce the scope of the sbp lock to avoid holding it
while doing bus_dma allocations.

The code badly needs some re-engineering.  SBP really should implement
a CAM transport, so that it avoids control flow inversion when re-scanning
the bus.  Also, the sbp lock seems to be too coarse.

Additionally, the commit includes some changes not related to locking.

- sbp_cam_scan_lun: restore CAM_DEV_QFREEZE before re-queueing the ccb
  because xpt_setup_ccb resets ccb_h.flags
- sbp_post_busreset: call xpt_release_simq only if it's actually frozen
- don't place private SIMQ_FREEZED flag (sic, "freezed") into sim->flags,
  use sbp->flags for that
- some style fixes and control flow enhancements

Reviewed by:	sbruno
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D9898
2017-03-07 16:07:52 +00:00
..
aac Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name) 2017-01-04 20:26:42 +00:00
aacraid Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name) 2017-01-04 20:26:42 +00:00
acpi_support Hide unneeded message under bootverbose. 2017-01-27 14:17:48 +00:00
acpica Fix startup race initialising ACPI CM battery structures on MacBookPro. 2017-02-27 08:36:51 +00:00
adb Force the setting of bit 7 in the sysmouse packet byte 1 to be unsigned. 2017-01-30 02:32:33 +00:00
adlink
advansys Remove dead mentions of CAM target mode APIs from drivers. 2017-02-19 17:27:58 +00:00
ae
age
agp sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
aha Remove dead mentions of CAM target mode APIs from drivers. 2017-02-19 17:27:58 +00:00
ahci Remove dead mentions of CAM target mode APIs from drivers. 2017-02-19 17:27:58 +00:00
aic Remove pc98 support completely. 2017-01-28 02:22:15 +00:00
aic7xxx Fix LUN enabling on wildcard target, as done by CTL. 2017-02-26 19:25:33 +00:00
al_eth sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
alc alc: Add Killer E2500 support 2017-01-16 03:03:47 +00:00
ale
alpm
altera Merge enhancements to the ALTERA Avalon bus generic device attachment 2017-01-28 13:25:06 +00:00
amd_ecc_inject add a module that provides support for DRAM ECC error injection on AMD CPUs 2017-03-03 22:51:04 +00:00
amdpm
amdsbwd
amdsmb
amdtemp
amr Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name) 2017-01-04 20:26:42 +00:00
an sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
arcmsr sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
asmc [asmc] Add support for MacBook Pro 11,2 2017-02-17 18:49:18 +00:00
ata Remove dead mentions of CAM target mode APIs from drivers. 2017-02-19 17:27:58 +00:00
ath Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
atkbdc [psm] Fix calculation for clickpad softbuttons at the top 2017-02-15 02:52:43 +00:00
auxio
axgbe Port the Linux AMX 10G network driver to FreeBSD as axgbe. It is unlikely 2017-02-15 13:56:04 +00:00
bce sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
beri sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
bfe
bge
bhnd - Allow different slicers for different flash types to be registered 2017-02-22 10:21:39 +00:00
bktr bktr(4): double assignment. 2017-02-23 16:18:57 +00:00
bm
bnxt bnxt: propagate RSS hash type to the network stack. 2017-02-28 02:27:51 +00:00
buslogic sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
bvm
bwi net80211 drivers: fix rate setup for EAPOL frames, obtain Tx parameters 2017-02-26 20:49:35 +00:00
bwn net80211 drivers: fix rate setup for EAPOL frames, obtain Tx parameters 2017-02-26 20:49:35 +00:00
bxe 1. state checks in bxe_tx_mq_start_locked() and bxe_tx_mq_start() to sync threads during interface down or detach. 2017-02-27 23:38:51 +00:00
cadence
cardbus
cas
ce dev/ce: double assignment. 2017-02-23 15:30:21 +00:00
cesa Remove remaining ifdefs from CESA header 2017-02-02 06:07:39 +00:00
cfe
cfi
chromebook_platform chromebook_platform: catch up with ig4iic -> ig4iic_pci in r310621 2017-02-25 15:55:46 +00:00
ciss In the same vein as r311350, fix whitespace in handling of XPT_PATH_INQ in 2017-01-05 03:08:57 +00:00
cm sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
cmx
coretemp
cp sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
cpuctl
cpufreq
cs
ctau sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
cx sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
cxgb Use inet_ntoa_r() instead of inet_ntoa() throughout the kernel 2017-02-16 20:47:41 +00:00
cxgbe cxgbe/iw_cxgbe: Abort connection if there is an error during c4iw_modify_qp. 2017-03-07 01:13:26 +00:00
cy
cyapa
dc
dcons
de sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
digi
dme
dpaa
dpms
dpt Remove EISA support from dpt. Remove known EISA models from 2017-02-16 21:57:13 +00:00
drm
drm2 Really revert 312923 this time 2017-01-28 16:40:51 +00:00
dwc
e1000 Restore PBA setup for igb(4) class devices. 2017-02-19 05:06:29 +00:00
ed sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
efidev
en
ep Remove EISA support for ep driver. Left in place EISA strings that are 2017-02-16 21:56:51 +00:00
esp Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name) 2017-01-04 20:26:42 +00:00
et
etherswitch etherswitch: Fix RT305x vlan group operation 2017-02-20 08:10:41 +00:00
evdev [evdev] Fix build for older versions of clang 2016-12-26 17:48:13 +00:00
ex
exca Remove pc98 support completely. 2017-01-28 02:22:15 +00:00
extres Export a sysctl dev.<clkdom>.<unit>.clocks for each clock domain containing 2017-03-05 07:13:29 +00:00
fatm sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
fb Remove pc98 support completely. 2017-01-28 02:22:15 +00:00
fdc Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
fdt - Allow different slicers for different flash types to be registered 2017-02-22 10:21:39 +00:00
fe sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
ffec Add definitions for the IEEE-1588 registers. 2017-02-18 18:27:28 +00:00
filemon
firewire firewire/sbp: try to improve locking, plus a few style nits 2017-03-07 16:07:52 +00:00
flash
fxp
gem
glxiic
glxsb
gpio [gpioths] new driver for temperature/humidity sensor DHT11 2017-01-16 15:36:36 +00:00
gxemul gxemul: 2017-02-06 11:37:20 +00:00
hatm
hdmi Add support for audio on I2S based DesignWare HDMI controllers. 2016-12-29 14:08:24 +00:00
hifn
hme
hpt27xx Clean redundant MIN/MAX declarations in some HighPoint drivers. 2017-02-10 15:18:41 +00:00
hptiop sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
hptmv sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
hptnr Clean redundant MIN/MAX declarations in some HighPoint drivers. 2017-02-10 15:18:41 +00:00
hptrr Clean redundant MIN/MAX declarations in some HighPoint drivers. 2017-02-10 15:18:41 +00:00
hwpmc Fix PMC architecture check to handle later IPAs including Skylake 2017-01-04 02:15:03 +00:00
hyperv hyperv/hn: Misaligned chimney sending buffers should not be used 2017-03-01 09:05:12 +00:00
ic Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
ichiic [ig4] Add ACPI platform support for ig4 driver 2016-12-26 22:13:43 +00:00
ichsmb
ichwd Fixed TCO v3 tick convert 2017-03-01 05:18:43 +00:00
ida Remove support for EISA in the ida driver. Remove references to 2017-02-16 21:56:57 +00:00
if_ndis
iicbus sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
iir Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name) 2017-01-04 20:26:42 +00:00
intel [intelspi] Add SPI driver for Intel BayTrail SoC 2016-12-27 22:37:24 +00:00
intpm
io
ioat ioat: don't specify inline for function with variable argument list 2017-03-04 12:51:57 +00:00
ipmi
ips
ipw
isci Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name) 2017-01-04 20:26:42 +00:00
iscsi Inline some trivial wrapper functions. 2017-03-02 16:14:15 +00:00
iscsi_initiator Use getsock_cap() instead of deprecated fgetsock(). 2017-01-13 18:36:46 +00:00
iser
isl
ismt
isp Send TERMINATE to firmware when aborting active ATIO. 2017-02-27 08:20:28 +00:00
ispfw
iwi iwi, ral, zyd: fix possible use-after-free. 2017-02-17 23:20:22 +00:00
iwm net80211 drivers: fix rate setup for EAPOL frames, obtain Tx parameters 2017-02-26 20:49:35 +00:00
iwn iwn: deduplicate (RXON + txpower + broadcast node) command sequence. 2017-03-07 07:49:25 +00:00
ixgb
ixgbe Fix reference to free memory in ixgbe/if_media.c 2017-01-20 17:16:48 +00:00
ixl ixl(4): Update to 1.7.12-k 2017-02-10 01:04:11 +00:00
jedec_ts jedec_ts: fix slave address check 2017-02-21 12:24:31 +00:00
jme
joy
kbd Remove pc98 support completely. 2017-01-28 02:22:15 +00:00
kbdmux
ksyms
le sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
led
lge
lmc
malo
mbox
mc146818
md Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
mdio
mem
mfi Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name) 2017-01-04 20:26:42 +00:00
mge
mii
mk48txx
mlx Remove references to EISA support in mlx. The driver never supported 2017-02-16 21:56:32 +00:00
mlx4 Improve code readability and fix compilation error when using clang 4.x. 2017-02-15 18:31:09 +00:00
mlx5 Make "desc" pointer non-constant inside the mlx5_core_diagnostics_entry 2017-01-30 08:35:15 +00:00
mly In the same vein as r311350, fix whitespace in handling of XPT_PATH_INQ in 2017-01-05 03:08:57 +00:00
mmc o Another round fixes for mmc(4), mmcsd(4) and sdhci(4) regarding 2017-03-06 23:47:59 +00:00
mn
mpr Import mpr(4) driver P12 to P14 diff from vendor site. 2017-03-06 19:39:31 +00:00
mps Rework the debug print API. Event printing no longer gets special handling. 2017-01-19 21:47:50 +00:00
mpt "Buses" is the preferred plural of "bus" 2017-01-15 17:54:01 +00:00
mrsas Fix a typo introduced in r306024. 2017-01-23 21:09:27 +00:00
mse Remove pc98 support completely. 2017-01-28 02:22:15 +00:00
msk
mvs Remove dead mentions of CAM target mode APIs from drivers. 2017-02-19 17:27:58 +00:00
mwl [net80211] RX parameter shuffle in net80211 in preparation for 4x4 NICs and 160MHz channels. 2017-02-20 02:08:08 +00:00
mxge
my
nand - Allow different slicers for different flash types to be registered 2017-02-22 10:21:39 +00:00
ncr sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
nctgpio
ncv
netfpga10g/nf10bmac
netmap sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
nfe
nfsmb
nge
nmdm Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
nsp
ntb Pretend we support some IOCTLs to not scary upper layers. 2017-01-11 20:23:45 +00:00
null
nvd Report random flash storage as non-rotating to GEOM_DISK. 2017-01-12 08:53:10 +00:00
nvme Remove obsolete comment after prior rev. 2017-02-19 17:38:17 +00:00
nvram
nvram2env
nxge
oce
ofw Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
otus net80211 drivers: fix rate setup for EAPOL frames, obtain Tx parameters 2017-02-26 20:49:35 +00:00
ow
patm sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
pbio
pccard sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
pccbb Remove pc98 support completely. 2017-01-28 02:22:15 +00:00
pcf
pci Fix spelling mistake in comment, firmwrae -> firmware 2017-02-28 23:55:03 +00:00
pcn
pdq Remove EISA attachment (fea) from pdq driver. Remove vestiges of 2017-02-16 21:57:08 +00:00
pms sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
powermac_nvram
ppbus sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
ppc sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
proto
psci
pst
pty
puc
qlxgb
qlxgbe add bus_dmamap_unload in ql_free_dmabuf() 2017-02-21 23:32:27 +00:00
qlxge
quicc
ral net80211 drivers: fix rate setup for EAPOL frames, obtain Tx parameters 2017-02-26 20:49:35 +00:00
random
rc
rccgpio Fix rcc_gpio_modify_bits(). Obviously (1 << 0) is not the same as 0. 2016-12-31 02:23:15 +00:00
re
rl
rndtest
rp
rt rt_attach(): double assignment. 2017-02-23 18:15:04 +00:00
rtwn net80211 drivers: fix rate setup for EAPOL frames, obtain Tx parameters 2017-02-26 20:49:35 +00:00
safe
sbni sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
scc
sdhci o Another round fixes for mmc(4), mmcsd(4) and sdhci(4) regarding 2017-03-06 23:47:59 +00:00
sec
sf
sfxge sfxge(4): compact the first hot part of RxQ control 2017-01-27 11:59:02 +00:00
sge
siba
siis Remove dead mentions of CAM target mode APIs from drivers. 2017-02-19 17:27:58 +00:00
sio Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
sis
sk
smbus
smc
sn sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
snp
sound Remove pc98 support completely. 2017-01-28 02:22:15 +00:00
speaker
spibus [spibus] small code refactoring 2017-01-16 15:23:55 +00:00
ste
stg
stge
sym sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
syscons Implement ec_putc() (emergency kernel [syscons] console putc()) and use 2017-03-04 08:47:31 +00:00
tdfx
terasic
ti
tl
tpm
trm Remove dead mentions of CAM target mode APIs from drivers. 2017-02-19 17:27:58 +00:00
tsec
twa Update tw_cl_share.h to allow 255 LUNs 2017-03-01 04:40:57 +00:00
twe
tws Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name) 2017-01-04 20:26:42 +00:00
tx
txp
uart Reconfigure the fifo watermark levels on the pl011 uart to interrupt when 2017-03-04 22:00:05 +00:00
ubsec
usb Make wsp process a single touchpad tap and interpret it as a 2017-03-01 04:27:58 +00:00
utopia
vge
viapm
viawd
videomode
virtio vtnet: don't update VLAN filter when parent is not running 2017-02-13 21:44:29 +00:00
vkbd
vmware/vmxnet3 Spell VMXNET3_LEGACY_TX correctly. 2017-02-18 06:18:14 +00:00
vnic Add the folowing set accessor functions for recently-added members of ifnet 2017-01-31 16:12:31 +00:00
vr
vt Un-break vt(4) for {powerpc,powerpc64,sparc64} LINT kernel builds 2017-02-15 17:33:03 +00:00
vte
vx sys/dev: Replace zero with NULL for pointers. 2017-02-20 03:43:12 +00:00
vxge vxge(4): Yet another (minor) mismatch. 2017-02-23 18:56:31 +00:00
watchdog
wb
wbwd
wi
wpi net80211 drivers: fix rate setup for EAPOL frames, obtain Tx parameters 2017-02-26 20:49:35 +00:00
wtap
xdma Add parenthesis. 2016-12-30 16:26:54 +00:00
xe
xen xen/netfront: fix inbound packet flags for checksum offload 2017-03-07 09:18:52 +00:00
xilinx
xl