linux/drivers/w1/slaves
NeilBrown b02f8bede2 W1: split master mutex to avoid deadlocks.
The 'mutex' in struct w1_master is use for two very different
purposes.

Firstly it protects various data structures such as the list of all
slaves.

Secondly it protects the w1 buss against concurrent accesses.

This can lead to deadlocks when the ->probe code called while adding a
slave needs to talk on the bus, as is the case for power_supply
devices.
ds2780 and ds2781 drivers contain a work around to track which
process hold the lock simply to avoid this deadlock.  bq27000 doesn't
have that work around and so deadlocks.

There are other possible deadlocks involving sysfs.
When removing a device the sysfs s_active lock is held, so the lock
that protects the slave list must take precedence over s_active.
However when access power_supply attributes via sysfs, the s_active
lock must take precedence over the lock that protects accesses to
the bus.

So to avoid deadlocks between w1 slaves and sysfs, these must be
two separate locks.  Making them separate means that the work around
in ds2780 and ds2781 can be removed.

So this patch:
 - adds a new mutex: "bus_mutex" which serialises access to the bus.
 - takes in mutex in w1_search and ds1wm_search while they access
   the bus for searching.  The mutex is dropped before calling the
   callback which adds the slave.
 - changes all slaves to use bus_mutex instead of mutex to
   protect access to the bus
 - removes w1_ds2790_io_nolock and w1_ds2781_io_nolock, and the
   related code from drivers/power/ds278[01]_battery.c which
   calls them.

Signed-off-by: NeilBrown <neilb@suse.de>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-13 16:38:40 -07:00
..
Kconfig Revert "w1: Add 1-wire slave device driver for DS28E04-100" 2012-04-29 22:12:08 -04:00
Makefile Revert "w1: Add 1-wire slave device driver for DS28E04-100" 2012-04-29 22:12:08 -04:00
w1_bq27000.c W1: split master mutex to avoid deadlocks. 2012-06-13 16:38:40 -07:00
w1_ds2408.c W1: split master mutex to avoid deadlocks. 2012-06-13 16:38:40 -07:00
w1_ds2423.c W1: split master mutex to avoid deadlocks. 2012-06-13 16:38:40 -07:00
w1_ds2431.c W1: split master mutex to avoid deadlocks. 2012-06-13 16:38:40 -07:00
w1_ds2433.c W1: split master mutex to avoid deadlocks. 2012-06-13 16:38:40 -07:00
w1_ds2760.c W1: split master mutex to avoid deadlocks. 2012-06-13 16:38:40 -07:00
w1_ds2760.h w1: ds2760_battery: add support for sleep mode feature 2009-06-08 23:25:17 +04:00
w1_ds2780.c W1: split master mutex to avoid deadlocks. 2012-06-13 16:38:40 -07:00
w1_ds2780.h W1: split master mutex to avoid deadlocks. 2012-06-13 16:38:40 -07:00
w1_ds2781.c W1: split master mutex to avoid deadlocks. 2012-06-13 16:38:40 -07:00
w1_ds2781.h W1: split master mutex to avoid deadlocks. 2012-06-13 16:38:40 -07:00
w1_smem.c MAINTAINERS: Evgeniy has moved 2011-08-25 16:25:33 -07:00
w1_therm.c W1: split master mutex to avoid deadlocks. 2012-06-13 16:38:40 -07:00