Hi,
>> > That's right. Interrupts can occur at almost any time (on
>> > multiprocessor systems they can occur even when interrupts are disabled
>> > on some of the CPUs).
>>
>> I am confused. I add the spinlock functions to kagen2_ep_queue function.
>>
>> spin_lock_irqsave(&dev->lock, flags);
>> ......
>> spin_unlock_irqrestore(&dev->lock, flags);
>>
>> When kagen2_ep_queue function is called, the error "BUG: scheduling
>> while atomic: swapper/0/0x00000002" occurs. I test the same spinlock
>> functions in other device module. It is ok in other device module.
>
> While the function holds a spinlock, it is not allowed to sleep.
>
> The BUG occurs because kagen2_ep_queue must call some function that can
> sleep. But since you did not provide the rest of the BUG message
> (including the stack trace), I can't tell what function it calls.
The "BUG: scheduling while atomic" is solved. Need to add extra
spinlock functions for req->complete() as below:
spin_unlock(&dev->lock);
req->complete(ep, req);
spin_lock(&dev->lock);
Now, the SCSI_WRITE_10 command is received but the data is not
received. There is disconnect or port reset after SCSI_WRITE_10
command. Please see below:
[start_transfer] 613e2d71 61757463
ept1 out queue len 0x200, buffer 0xc1338000
g_file_storage gadget: bulk-out, length 31:
00000000: 55 53 42 43 f6 00 00 00 00 02 00 00 00 00 0a 2a
00000010: 00 00 00 00 01 00 00 01 00 00 00 00 80 b7 21
EP1 OUT IRQ 0x28
g_file_storage gadget: disconnect or port reset
g_file_storage gadget: SCSI command: WRITE(10); Dc=10, Do=512; Hc=10, Ho=512
[start_transfer] 43425355 f6
ept1 out queue len 0x200, buffer 0xc1338000
g_file_storage gadget: do_scsi_command
unlink (ep1) pio
kagen2_set_halt 1 0
g_file_storage gadget: bulk-out, length 0:
g_file_storage gadget: bulk_out_complete --> 0, 0/512
g_file_storage gadget: reset config
g_file_storage gadget: reset interface
g_file_storage gadget: handle_exception
"g_file_storage gadget: do_scsi_command" is from extra DBG statement
that i added in file_storage.c.
if (do_scsi_command(fsg) || finish_reply(fsg))
{
DBG(fsg, "do_scsi_command\n");
continue;
}
thanks,
victor
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html