LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-15-2008, 11:06 AM   #1
oingoboingo
LQ Newbie
 
Registered: Jan 2008
Posts: 3

Rep: Reputation: 0
Angry lk 2.4 SG driver question


I am working on C app that uses the SG driver (SCSI Generic) to access some scsi drives on a QLogic QLA2100 Fiber Channel card. Everything seems to work just fine, I can access the devices and send your standard set of SCSI commands to the devices but I am running in to an issue with FORMAT UNIT and TEST UNIT READY.

Here is the deal, I have issued a FORMAT UNIT command with the IMMED bit set, the command returns immediately and the format begins. Technically I should be able to issue any number of TEST UNIT READY commands to the device and it will return sense data indicating progress, the problem is the the TEST UNIT READY gets stuck in an infinite loop. Not my code but the SG driver itself. I have watched it on a bus analyzer and it never returns form the ioctl() it just loops issues TUR over and over. Even with a timeout of 1000 milliseconds set in the struct it never returns.

Just to make sure I wasn't crazy I used another utility that I found
(or actually a collection) and they got the same result the sg driver hung just issuing the TUR over and over.

I am wondering if there is a bug in the sg driver or if this is by design (if so, its a bad one!).

just a little background, the file descriptor I am opening is "/dev/sg0" and the open flags are O_RDWR | O_NONBLOCK the TUR command issues on its own when the drive is not formatting so I know that what I am doing is *correct* but there is no logical reason that this is behaving this way!
 
Old 01-16-2008, 06:20 AM   #2
oingoboingo
LQ Newbie
 
Registered: Jan 2008
Posts: 3

Original Poster
Rep: Reputation: 0
just a little more background, I am accessing the device using the SG_IO ioctl and the struct I mentioned is sg_io_hdr_t.

Code:
typedef struct sg_io_hdr
{
    int interface_id;           /* [i] 'S' (required) */
    int dxfer_direction;        /* [i] */
    unsigned char cmd_len;      /* [i] */
    unsigned char mx_sb_len;    /* [i] */
    unsigned short iovec_count; /* [i] */
    unsigned int dxfer_len;     /* [i] */
    void * dxferp;              /* [i], [*io] */
    unsigned char * cmdp;       /* [i], [*i]  */
    unsigned char * sbp;        /* [i], [*o]  */
    unsigned int timeout;       /* [i] unit: millisecs */
    unsigned int flags;         /* [i] */
    int pack_id;                /* [i->o] */
    void * usr_ptr;             /* [i->o] */
    unsigned char status;       /* [o] */
    unsigned char masked_status;/* [o] */
    unsigned char msg_status;   /* [o] */
    unsigned char sb_len_wr;    /* [o] */
    unsigned short host_status; /* [o] */
    unsigned short driver_status;/* [o] */
    int resid;                  /* [o] */
    unsigned int duration;      /* [o] */
    unsigned int info;          /* [o] */
} sg_io_hdr_t;  /* 64 bytes long (on i386) */
 
Old 01-16-2008, 12:32 PM   #3
oingoboingo
LQ Newbie
 
Registered: Jan 2008
Posts: 3

Original Poster
Rep: Reputation: 0
well, we upgraded to lk 2.6 CentOS 5 and the problem has dissappeared, it appears that there is a problem with the error processing in the particular version of the sg driver provided with lk 2.4
 
  


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
ati driver question and console question kholdstayr Slackware 2 07-18-2005 03:30 PM
Driver Question megadeth Linux - Software 1 04-18-2005 05:15 PM
driver question zeviddalop Linux - Networking 2 01-21-2005 03:59 PM
RE: Question about driver sektor Linux - Hardware 2 02-10-2004 05:40 PM
Driver Question jhayess Linux - Software 2 11-13-2003 03:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:36 AM.

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