Re: [PATCH] usb: gadget: f_fs: add "zombie" mode

From: Michal Nazarewicz
Date: Tue Oct 07 2014 - 16:08:29 EST


> On Tue, 7 Oct 2014, Felipe Balbi wrote:
>> Right, but if we allow this, I can already see folks abusing to
>> connect to the host early and only when necessary do some trickery to
>> e.g. start adbd (not saying Android will do this, just using it as an
>> easy example).

I don't really see that happening. For the gadget to start all
descriptors need to be known. Functionfs will know the descriptors
only once the user space daemon provides them. Therefore, with the
current features (or even with addition of Robert's feature) there is no
way to let the gadget start without having the daemon running.

On Tue, Oct 07 2014, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
> We can still keep the pullup turned off until all the functions are
> ready. That's a part of normal behavior -- unlike what happens when a
> userspace component crashes or is killed.

>> Then how do we differentiate a normal close() from a "oh-crap-I-died"
>> close() ?

> We can't, so why worry about it?

We actually might be able to distinguish those cases with another ioctl
which daemon must issue on the ep0 prior to closing it. I'm not saying
that we should implement that though.

> If a file handle was closed for normal reasons then userspace probably
> in the middle of shutting down the gadget anyway. If not then the
> user will get what they deserve.
>
> If the file handle was closed for abnormal reasons, we can behave like
> crashed firmware. Which means, in the end, doing the same thing as in
> the normal-reason case -- i.e., do nothing. In particular, don't
> disconnect.
>
> If you want to allow for the possibility of orderly shutdown (and maybe
> even possible restart) of a userspace handler, the function library
> should first tell the kernel explicitly to disconnect. Then function
> components can be changed around completely, and when everything is
> ready, userspace can tell the kernel to connect again.

I'm wondering if it would be possible to support user-space daemon
restarts with O_APPEND flag. This is probably looking too far to the
future though.

--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, MichaÅ âmina86â Nazarewicz (o o)
ooo +--<mpn@xxxxxxxxxx>--<xmpp:mina86@xxxxxxxxxx>--ooO--(_)--Ooo--
--
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/