Hi, >> May i know which part of the do_set_config() or do_set_interface() has >> to be run in process context? > > Well, it's not exactly true that the routine has to run in process > context. More accurately, it has to run at a time when the main thread > isn't using any of the endpoints or request structures, because > do_set_interface() deallocates the requests and disables the endpoints. > > For example, if the main thread was in the middle of executing a SCSI > command, do_set_config() would have to wait until it finished. The > easiest way to do this is by the exception technique. That way > do_set_config() is called by the main thread itself, so it knows the > main thread isn't using those structures. Thanks. The USBCV test has tight timing requirement. Once Set-Config request is sent out, USBCV sends out Get-Config request to get the config value immediately. At that time, gadget driver has not yet done the handle_exception. So Get-Config request returns old config value, and USBCV declares the test failed. Please see the log below. Is there any way to speed up the handle_exception or to ask the USBCV host to not send out Get-Config immediately? I have set the NAK and stall the endpoint 0 after receiving Set-Config request, however, Get-Config request is still sent out by USBCV host immediately. g_file_storage gadget: ep0-setup, length 8: 00000000: 00 09 00 00 00 00 00 00 g_file_storage gadget: set configuration NAK and stall endpoint g_file_storage gadget: ep0-setup, length 8: 00000000: 80 08 00 00 00 00 01 00 g_file_storage gadget: get configuration ept0 in queue len 0x1, buffer 0xc1289800 ep0_complete g_file_storage gadget: ep0-in, length 1: 00000000: 01 after kagen2_ep_queue kagen2_ep_queue 31 512 31 [kagen2_ep_queue] 43425355 89d40868 g_file_storage gadget: bulk-out, length 31: 00000000: 55 53 42 43 68 08 d4 89 00 00 00 00 00 00 0a 35 00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 g_file_storage gadget: SCSI command: SYNCHRONIZE CACHE; Dc=10, Dn=0; Hc=10, Hn=0 attention condition g_file_storage gadget: after calling do_scsi_command handle_exception begin handle_exception wait until handle_exception old_state 4 g_file_storage gadget: reset config g_file_storage gadget: reset interface FSG_STATE_CONFIG_CHANGE 52 53 0 g_file_storage gadget: in handle_exception loop g_file_storage gadget: in fsg->running loop g_file_storage gadget: in fsg->running loop thanks, victor -- 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