It has not been solved. Evgeniy would like to make use of the sysfs device management instead of the current reference counting, however I haven't heard any volunteers to do that work. I posted a quick fix patch, it was very easy to crash without this patch, it doesn't completely solve the race conditions, and I don't think it can be solved in just a slave driver change.
Are you up for the challenge? On Wed, Apr 15, 2015 at 09:52:27AM +0200, Jonathan ALIBERT wrote: > Hi, > > Do you know if the problem has been solved ? > > Cheers, > > *Jonathan ALIBERT* > *06 32 26 59 12* > *265, route de Saint Haon* > *42 370 RENAISON* > > > 2015-03-19 1:09 GMT+01:00 David Fries <da...@fries.net>: > > > On Wed, Mar 18, 2015 at 06:18:53PM +0300, Evgeniy Polyakov wrote: > > > Hi > > > > > > 18.03.2015, 07:20, "David Fries" <da...@fries.net>: > > > > static void w1_therm_remove_slave(struct w1_slave *sl) > > > > { > > > > + int refcnt = atomic_sub_return(1, THERM_REFCNT(sl->family_data)); > > > > + while(refcnt) { > > > > + msleep(1000); > > > > + refcnt = atomic_read(THERM_REFCNT(sl->family_data)); > > > > + } > > > > kfree(sl->family_data); > > > > sl->family_data = NULL; > > > > } > > > > > > Can we replace this whole atomic manipulations with kref_t and free > > family data in the place > > > which actually drops reference counter to zero? > > > > > > I.e. we return from remove_slave() function potentially leaving family > > data floating around, it will be freed > > > when the last user drops the reference. There is still a race between > > increasing reference when starting > > > reading and removing slave device, i.e. one starts reading, while > > attached slave device is being removed, > > > but that's a different problem. > > > > With the two while loops I posted, I see with two clients reading > > w1_slave, the other command to remove a slave gets permanently stuck > > in w1_therm_remove_slave, which keeps the slave around while the > > clients continue to read. I wouldn't predict things going better by > > keeping family_data around longer, the slave data would still go away > > with readers around. > > > > -- > > David Fries <da...@fries.net> PGP pub CB1EE8F0 > > http://fries.net/~david/ > > -- David Fries <da...@fries.net> PGP pub CB1EE8F0 http://fries.net/~david/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/