Potential fsg->state problem at file_storage.c

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

 



Hi Alan,

One of my colleagues reports a problem that the enumeration will fail if
the storage has some problems. I can re-produce this problem if I add a
big delay (like 500ms) at handle_exception, at condition FSG_STATE_DISCONNECT,
please see below code: 

3050         case FSG_STATE_DISCONNECT:
3051                 for (i = 0; i < fsg->nluns; ++i)
3052                         fsg_lun_fsync_sub(fsg->luns + i);
3053                 mdelay(500);
3054                 do_set_config(fsg, 0);          // Unconfigured state
3055                 break;

When the problem occurs, the call sequence like below:

reset interrupt-> fsg->disconnect-> handle_exception
reset interrupt-> fsg->disconnect
...
udc setup package -> USB_REQ_SET_CONFIGURATION -> raise_exception(fsg, FSG_STATE_CONFIG_CHANGE);

The reason why this problem occurs is that the first fsg_lun_fsync_sub(fsg->luns + i) consumes too
much times, the fsg->state is changed by raise_exception (2nd reset interrupt), but the handle_exception
(2nd reset interrupt) is not called after raise_exception(fsg, FSG_STATE_CONFIG_CHANGE) is called.
The fsg->state is still FSG_STATE_DISCONNECT when raise_exception(fsg, FSG_STATE_CONFIG_CHANGE) is called,
Since FSG_STATE_DISCONNECT > FSG_STATE_CONFIG_CHANGE, the SET_CONFIGURATION will never be handled,
the enumeration will be failed.

A workaround for this problem is:

3050         case FSG_STATE_DISCONNECT:
3051                 if (fsg->config != 0)
3052                         for (i = 0; i < fsg->nluns; ++i)
3053                                 fsg_lun_fsync_sub(fsg->luns + i);
3054                 do_set_config(fsg, 0);          // Unconfigured state
3055                 break;

But it can't handle the problem that the reset occurs during the transfer due to some timeout.
(bus reset -> bus reset -> SET_CONFIGURATION)

Best regards,
Peter Chen

MAD Linux BSP Team
Freescale Semiconductor Ltd.


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

  Powered by Linux