Re: [linux-usb-devel] Re: [OOPS, usbcore, releaseintf] 2.6.0-test10-mm1

From: Duncan Sands
Date: Mon Dec 08 2003 - 14:56:55 EST


Hi Alan,

> But usbfs may suffer from complications as a result of its unorthodox
> approach to device ownership.

Yes, you have put your finger on it.

> > Currently ps->dev is set to NULL in
> > the devio.c usbfs disconnect method (if some interface is claimed) or in
> > inode.c on device disconnect, making it hard to lock with
> > ps->dev->serialize :) Thus disconnect should no longer be signalled by
> > setting ps->dev to NULL.
>
> If you would keep the ps->devsem lock, would there be any problem in
> setting ps->dev to NULL to indicate disconnection?

You can't keep the ps->devsem lock and use ps->dev->serialize, because it
leads to deadlock. Actually, simply replacing ps->devsem with ps->dev->serialize
cannot lead to any new deadlocks, it makes deadlocks that could occasionally
happen always happen (such deadlocks exist right now in usbfs). Some of the
current deadlocks can be eliminated without giving up ps->devsem, but not all.
So the question is: must ps->dev->serialize be used?

> Are they any reasons for not keeping ps->devsem? Since usbfs generally
> acts as a driver and drivers generally don't have to concern themselves
> with usbdev->serialize (the core handles it for them), shouldn't usbfs
> also be able to ignore ps->dev->serialize?

No, because it needs to do operations on interfaces it hasn't claimed (such
as looking them up and claiming them). This is why it needs to protect
itself, at least momentarily, against configurations shifting under it. This
can be done by using the BKL more. However it can be done more simply
using ps->dev->serialize (in fact it is simpler than what is there now).

By the way, if it is somehow fatal to do usb_put_dev after disconnect,
what is the point of referencing counting at all? You might as well
free up the usb_device structure immediately after disconnect, since
there is sure to be a reference before disconnect, and (apparently)
there had better not be a reference after disconnect...

All the best,

Duncan.
-
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/