Re: gadgetfs USB2.0 Chapter 9 Tests: Test after "Addressed State" fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 24 2013, roshan.jhalani@xxxxxxxxxxxx wrote:
> I agree with your point. But this doesn’t work when used this driver
> in Android platform.  Kernel driver sends USB_DISCONNECT event even in
> BUS reset case and by that time USB disconnect is not expected from
> FunctionFs driver.
>
> Moreover consider a case where SET_CONFIG(Config#0) commands comes
> from HOST. As per the composite driver, reset_config will be called.
> In this case FunctionFs driver sends FUNCTIONFS_DISABLE event which
> makes all ep files release and leads to USB disconnect.

This is a bug in user space.  FUNCTIONFS_DISABLE event means the host
has chosen a configuration with given function disabled.  User-space
should clean up it's state, as any pending requests of any kind are now
invalid.  It should not close all of the ep files.

User space should release all of the ep files only once it's done
handling functionality of the USB function.  (A special case of this is
of course if the user space daemon crashes or is killed by a signal).

> BTW, why it is expected to do USB disconnect from FunctionFs just to
> clean state for new user space program.  Is it really requirement or
> FunctionFs driver? I mean to say what is expectation from
> functionfs_ready_callback and functionfs_closed_callback??

No bus event on it's own will cause FunctionFS to clean it's state.

FunctionFS cleans it's state when user-space releases all of the ep
files.  As described above, user-space should not release all of the ep
files when it gets indication of an USB disconnect (namely
FUNCTIONFS_DISABLE event).

So yes, if, like you described, user space releases all the ep files
upon receiving FUNCTIONFS_DISABLE event, FunctionFS will clean it's
state, but as described above this is not what user space should do in
response to FUNCTIONFS_DISABLE.

Once user space closes all the ep files and FunctionFS proceeds to
cleaning it's state, this will cause the gadget to be unregistered,
since the assumption FunctionFS is making is that the user space program
that was handling the USB function functionality is no longer present
and cannot serve requests from host any more.  If FunctionFS did not
cause USB disconnect at that moment, gadget driver would end up having
a useless USB function in its configuration.

-- 
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--

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux