Re: [PATCH] w1: Introduce a slave mutex for serializing IO.
From: Evgeniy Polyakov
Date: Thu May 03 2012 - 13:59:01 EST
On Wed, May 02, 2012 at 04:26:27PM +1000, NeilBrown (neilb@xxxxxxx) wrote:
> Take takes me back to the deadlock.
> To be precise:
> while scanning the w1 bus - with master->mutex held - w1_attach_slave_device
> eventually calls into bq27000_battery_probe which calls
> power_supply_register -> device_add -> kobject_uevent_env
>
> and the to get all the data for the uevent, power_supply_uevent calls
> the get_property callback which tries to read from the w1 bus and so
> needs the master->mutex. Which is held. Deadlock.
>
> So options seems to be:
> - drop the lock while attaching slave devices
> - create a list of slave devices, then attach them after the bus scan has
> finished.
> - have device_add run the kobject_uevent in a separate task (work_queue)
> - or maybe the following which feels ugly but is easy. Mark the bq27000 as
> not ready until after the power_supply_register, and if get_property is
> called before the device is ready, return ENODATA.
> Simple and works. Maybe horrible.
> power_supply_register will have scheduled a power_supply_changed() which
> will poll
You can check mutex owner - and if it is you who holds it, then dig into
low-level function without lock.
--
Evgeniy Polyakov
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/