android_kernel_xiaomi_sm8350/drivers/ieee1394
Stefan Richter 24c7cd0630 [PATCH] sbp2: fix spinlock recursion
sbp2util_mark_command_completed takes a lock which was already taken by
sbp2scsi_complete_all_commands.  This is a regression in Linux 2.6.15.

 Reported by Kristian Harms at
	https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=187394

[ More complete commentary, as response to questions by Andrew: ]

> This changes the call environment for all implementations of
> ->Current_done().  Are they all safe to call under this lock?

Short answer: Yes, trust me.  ;-) Long answer:

The done() callbacks are passed on to sbp2 from the SCSI stack along
with each SCSI command via the queuecommand hook.  The done() callback
is safe to call in atomic context.  So does
Documentation/scsi/scsi_mid_low_api.txt say, and many if not all SCSI
low-level handlers rely on this fact.  So whatever this callback does,
it is "self-contained" and it won't conflict with sbp2's internal ORB
list handling.  In particular, it won't race with the
sbp2_command_orb_lock.

Moreover, sbp2 already calls the done() handler with
sbp2_command_orb_lock taken in sbp2scsi_complete_all_commands().  I
admit this is ultimately no proof of correctness, especially since this
portion of code introduced the spinlock recursion in the first place and
we didn't realize it since this code's submission before 2.6.15 until
now.  (I have learned a lesson from this.)

I stress-tested my patch on x86 uniprocessor with a preemptible SMP
kernel (alas I have no SMP machine yet) and made sure that all code
paths which involve the sbp2_command_orb_lock were gone through multiple
times.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-04-02 12:58:09 -07:00
..
.gitignore gitignore: misc files 2006-01-01 22:21:50 +01:00
config_roms.c
config_roms.h
csr1212.c
csr1212.h
csr.c
csr.h
dma.c
dma.h
dv1394-private.h
dv1394.c ieee1394: remove devfs support 2006-03-28 19:55:41 -05:00
dv1394.h
eth1394.c
eth1394.h
highlevel.c [PATCH] bitops: hweight() related cleanup 2006-03-26 08:57:15 -08:00
highlevel.h
hosts.c
hosts.h ieee1394: resume remote ports when starting a host (fixes device recognition) 2005-12-12 23:20:58 -05:00
ieee1394_core.c ieee1394: set read permission for parameter disable_irm 2006-03-28 20:03:34 -05:00
ieee1394_core.h ieee1394: remove amdtp remains from ieee1394_core.h 2006-03-28 19:56:45 -05:00
ieee1394_hotplug.h
ieee1394_transactions.c
ieee1394_transactions.h
ieee1394_types.h
ieee1394-ioctl.h
ieee1394.h
iso.c
iso.h
Kconfig
Makefile
nodemgr.c Merge with http://kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git 2006-01-05 08:03:40 -05:00
nodemgr.h ieee1394: remove nonexistent functions from nodemgr.h 2005-12-05 16:29:02 -05:00
ohci1394.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc 2006-03-29 11:28:30 -08:00
ohci1394.h
oui2c.sh
oui.db
pcilynx.c
pcilynx.h
raw1394-private.h
raw1394.c ieee1394: remove devfs support 2006-03-28 19:55:41 -05:00
raw1394.h
sbp2.c [PATCH] sbp2: fix spinlock recursion 2006-04-02 12:58:09 -07:00
sbp2.h sbp2: variable status FIFO address (fix login timeout) 2006-02-23 00:28:52 -05:00
video1394.c ieee1394: remove devfs support 2006-03-28 19:55:41 -05:00
video1394.h