LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-22-2010, 05:10 AM   #1
archanac07
LQ Newbie
 
Registered: Jan 2010
Posts: 26

Rep: Reputation: 15
Unhappy 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
=======================
 
Old 01-22-2010, 05:20 AM   #2
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Would you mind showing the code you are writing ?
 
Old 01-22-2010, 05:31 AM   #3
archanac07
LQ Newbie
 
Registered: Jan 2010
Posts: 26

Original Poster
Rep: Reputation: 15
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
 
Old 01-22-2010, 05:36 AM   #4
archanac07
LQ Newbie
 
Registered: Jan 2010
Posts: 26

Original Poster
Rep: Reputation: 15
Question 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
 
Old 01-22-2010, 07:28 AM   #5
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
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
 
Old 01-22-2010, 11:23 AM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
I have merged two closely related threads.

Please do not keep starting new threads for the same basic question---thank you.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Serial driver problem on reading data from device archieval Programming 2 07-22-2008 11:42 PM
Error reading block "x" (Attempt to read block from....... pvandyk2005 Slackware 6 07-06-2008 05:25 AM
Fortran type conversion error in block data jhwilliams Programming 1 06-26-2008 10:09 AM
Error reading block ... resulted in short read shadowrise Linux - Hardware 1 12-29-2006 08:15 AM
depmod: error reading ELF section data Commish66 Mandriva 1 02-12-2004 12:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration