[sane-devel] SCSI problems with a DMC

abel deuring a.deuring@satzbau-gmbh.de
Tue, 29 Oct 2002 18:14:33 +0100


Andrew Kuchling wrote:
> 
> I'm using the sane-dmc backend to read from Polaroid DMC cameras
> attached to several different machines.  Recently one camera can no
> longer produce images; scanimage just dies with a "Error during device
> I/O", and I don't think anything on the machine has changed recently
> to trigger this.  It fails identically with both the Debian-packaged
> SANE 1.0.1 and a freshly compiled SANE 1.0.9.
> 
> The last lines of the SCSI debug log are:
> 
> [sanei_debug] Setting debug level of sanei_scsi to 255.
> [sanei_scsi] sanei_scsi_open: SG driver version: 20139
> [sanei_scsi] sanei_scsi_open_extended: using 131072 bytes as SCSI buffer
> [sanei_scsi] trying to enable low level command queueing
> [sanei_scsi] sanei_scsi_open: Host adapter queue depth: 3
> [sanei_scsi] sanei_scsi_open: SG driver can change buffer size at run time
> [sanei_scsi] sanei_scsi_open: low level command queueing enabled
> [sanei_scsi] scsi_req_enter: entered 0x4012c008
> [sanei_scsi] sanei_scsi.issue: 0x4012c008
> [sanei_scsi] scsi_req_enter: queue_used: 1, queue_max: 3
> [sanei_scsi] sanei_scsi_req_wait: waiting for 0x4012c008
> [sanei_scsi] sanei_scsi.issue: 0x4012c008
> [sanei_scsi] sanei_scsi_req_wait: read 36 bytes
> [sanei_scsi] sanei_scsi_req_wait: SCSI command complained: Success
> [sanei_scsi] sense buffer: 70 00 04 00 00 00 00 0a 00 00 00 00 80 00 00 00
> [sanei_scsi] target status: 00 host status: 00 driver status: 00
> 
> (Full SCSI log at http://www.mems-exchange.org/misc/files/scsi-log)
> 
> The SCSI error is being caught by the code around line 2085 of
> sanei_scsi.c, in sanei_scsi_req_wait().  The conditional is:
> 
>              /* check for errors, but let the sense_handler decide.... */
>               if ( (req->sgdata.cdb.hdr.result != 0) ||
>                   ((req->sgdata.cdb.hdr.sense_buffer[0] & 0x7f) != 0))
> 
> hdr.result is zero, so it's the second condition that's true; the
> first byte of the sense buffer is 0x70.  What does this mean?  And
> does it provide a clue to the problem?

Sounds like a bug in sanei_scsi.c . Try

              if ( (req->sgdata.cdb.hdr.result != 0) ||
                  ((req->sgdata.cdb.hdr.sense_buffer[0] & 0x7f) != 0)
                   && (req->sgdata.cdb.hdr.driver_status & DRIVER_SENSE)
                  )

(This won't work with _really_ old SG drivers -- a proper fix would
require another #ifdef HAVE_SG_TARGET_STATUS. I think)

I am not sure, if this will really fix your problem though: The sense
buffer looks, hmm, "reasonable" -- but the driver status claims that no
sense data is available. I don't know, why the Linux SCSI drivers return
valid looking sense data but do not signal this in driver_status...

Abel