linux block driver error while reading data
hi
i am writing sample block driver while reading data i am getting below error i am not getting what is this error plz help BUG: sleeping function called from invalid context at kernel/sched.c:4684 in_atomic():0, irqs_disabled():1 Pid: 5364, comm: test_buf Not tainted 2.6.27.42 #1 [<c041f1d4>] __might_sleep+0xae/0xb3 [<c063ae43>] wait_for_common+0x1f/0x117 [<c0584bd3>] ? usb_submit_urb+0x1e1/0x1fd [<c063af99>] wait_for_completion_timeout+0xd/0xf [<c05856d5>] usb_start_wait_urb+0x58/0x95 [<c0410280>] ? p4_unreserve+0x1e/0x2c [<c0585800>] usb_bulk_msg+0xee/0xf5 [<c0410280>] ? p4_unreserve+0x1e/0x2c [<f8fc48dd>] test_request+0x1d6/0x268 [test_driver_usb] [<c04ee9e7>] __generic_unplug_device+0x1d/0x20 [<c04eec67>] generic_unplug_device+0x21/0x3a [<c04ed77d>] blk_unplug+0x51/0x58 [<c04ed78f>] blk_backing_dev_unplug+0xb/0xd [<c04a3e65>] block_sync_page+0x32/0x34 [<c0464a6d>] sync_page+0x31/0x3a [<c0464a7e>] sync_page_killable+0x8/0x2e [<c063b10b>] __wait_on_bit_lock+0x34/0x70 [<c0464a76>] ? sync_page_killable+0x0/0x2e [<c04649a7>] __lock_page_killable+0x7b/0x83 [<c043b272>] ? wake_bit_function+0x0/0x43 [<c0466553>] generic_file_aio_read+0x385/0x588 [<c0487242>] do_sync_read+0xab/0xe9 [<c043b23f>] ? autoremove_wake_function+0x0/0x33 [<c04db692>] ? selinux_file_permission+0xff/0x105 [<c04d49be>] ? security_file_permission+0xf/0x11 [<c0487197>] ? do_sync_read+0x0/0xe9 [<c0487bdb>] vfs_read+0x87/0x12b [<c0487d18>] sys_read+0x3b/0x60 [<c0403a2f>] sysenter_do_call+0x12/0x2f [<c0630000>] ? nv_msi_ht_cap_quirk+0xe/0xe5 ======================= |
Would you mind showing the code you are writing ?
|
hi
this my read function which is getting called from request function static ssize_t data_read(struct test_usb *dev, char *buffer, size_t count) { printk("*** SARD: Inside Read Function ***\n"); int retval; int bytes_read; int rcvbulkpipe = usb_rcvbulkpipe(dev->udev, dev->bulk_in_endpointAddr); int timeout = jiffies + (HZ*10); if (!dev->interface) { // disconnect() was called retval = -ENODEV; return retval; } dev->usb_buffer = "Test Application"; printk("usb buffer:= %s\n", dev->usb_buffer); retval = usb_bulk_msg(dev->udev, rcvbulkpipe, dev->usb_buffer, min(strlen(dev->usb_buffer), count), &bytes_read, timeout); info("usbDIO: Read retval: %d, count: %lu, bytes Read: %d", retval, count, bytes_read); if (retval == 0) { if (copy_to_user(buffer, dev->usb_buffer, bytes_read)) retval = -EFAULT; else{ retval = bytes_read; printk("bufer:= %s\n", buffer); printk("usb_buffer:= %s\n", dev->usb_buffer); } } else { if (retval == -ETIMEDOUT) { info("usbDIO: Read timeout"); retval = 0; } } return retval; } //request function static void data_transfer(struct test_usb *dev_t, unsigned long sector, unsigned long nsect, char *buffer, int write) { printk("*** Archana: Inside data_transfer ***\n"); unsigned long offset = sector * blkdev_sect_size; unsigned long nbytes = nsect * blkdev_sect_size; if ((offset + nbytes) > dev_t->buffer_size) { printk (KERN_NOTICE "Beyond-end write (%ld %ld)\n", offset, nbytes); return; } if (write) { data_write(); } else { data_read(dev_t, buffer, nbytes); } } .. when control goes to read function i am getting above mentioned error and it is not reading anything if u know anything plz share |
scsi command for linux block driver
hi
i am writing block deriver for usb device in linux i want to read data from usb device i already opened the handle for the usb device now i need to send scsi command to usb device to make it work but i dont have knowledge about scsi commands and how to use them now i need to know which scsi command i need to pass to the usb device and how can i pass that command to usb device |
Read these links carefully, some other people have faced the same bug
http://www.mail-archive.com/utrace-d.../msg00391.html http://www.mail-archive.com/utrace-d.../msg00392.html |
I have merged two closely related threads.
Please do not keep starting new threads for the same basic question---thank you. |
All times are GMT -5. The time now is 09:34 PM. |