[sane-devel] Re: Sane on Ultra Sparc

abel deuring a.deuring@satzbau-gmbh.de
Fri, 10 Jan 2003 10:41:45 +0100

T. Ribbrock wrote:
> On Wed, Jan 08, 2003 at 12:23:44AM +0100, abel deuring wrote:
>>Dr. Ing. Dieter Jurzitza wrote:
> [Problem with Mustek Scanner on UltraSparc/Linux]
>>[sanei_scsi] sanei_scsi.issue: 0x70260008
>>dev_max(currently)=11 max_active_device=6 (origin 1)
>> scsi_dma_free_sectors=2192 sg_pool_secs_aval=320 def_reserved_size=32768
>> >>> device=sg5 scsi1 chan=0 id=2 lun=0   em=0 sg_tablesize=127 excl=1
>>   FD(1): timeout=60000ms bufflen=131072 (res)sgat=4 low_dma=0
>>   cmd_q=1 f_packid=0 k_orphan=0 closed=0
>>     No requests active
>>[sanei_scsi] sanei_scsi.issue: bad write (errno=22) Invalid argument -1
>>errno 22 is EINVAL; this error is returned by the SG driver for version 
>>3 SG headers, if the header size passed by the caller (i.e., 
>>sanei_scai.c, functions sanei_scsi_req_enter and issue) in a write() or 
>>read() call does not match the size expected by the SG driver.
> [...]
> Sorry to barge in here, but as it happens I've been stumped by the
> very same problem, so I thought I'd add some data:


More opinions / suggestions / reports are always welcome ;)

> I've seen it happen on two different configurations (both times with a
> Mustek 600 II CD Scanner):
> Box 1: Sun UltraSparc 5/400, no-name Symbios 53c810 SCSI card, no SCSI
>        disks, Aurora Sparc Linux 0.42 w/ kernel 2.4.20, sane-backends
>        1.0.7 (as comes with Aurora 0.42) and 1.0.9 (test build from
>        the tarball)
> Box 2: Sun UltraSparc 1/140, on-board esd SCSI controller, two SCSI
>        disks, Aurora Sparc Linux 0.42 w/ kernel 2.4.18, sane 1.0.7 and
>        1.0.9.
> I'll include the output from
> SANE_DEBUG_SANEI_SCSI=255 sane-find-scanner -vv > logfile 2>&1
> for the latter config at the end.
> Note: I built only sane-backends-1.0.9 and used this command to build:
> CFLAGS="-g -O -Wall" ./configure --disable-shared
> (given in the README to use if you want to debug).
> I can confirm the errno=22 and it occurs in the write on line 1744
> (sane 1.0.9) in sane_scsi.c - not knowing sane very well, I had to use
> ddd to get there... ;-)
> I've used the very same scanner with Aurora 0.4, sane 1.0.7 and
> kernel 2.4.18 on a SparcStation 20 SMP and with Aurora 0.32, sane 1.0.7,
> kernel 2.4.18 on a SparcStation 5/170 without any problems, so my
> guess would indeed be that we're talking about a 32bit<->64bit issue,
> especially, as the SparcStations are using the same SCSI controller
> (esd) as the UltraSparc 1.
> Unfortunately, I'm not knowledgable enought to solve this myself... I
> can, however, offer to run tests on my box, if that's of any help.
> It would be great if this was solvable... The U5 is a good bit faster
> than the SS20... ;-)

The SS20 is as 32 bit machine, so this looks indeed like a 32/64 bit 

But is there really no way to compile Sane as a 64 bit program on an 

Another option could be to define a "64 bit version" of struct sg_io_hdr 
in sanei_scsi.c and to use this struct for SG driver write calls. I am 
not sure though, if it is simply possible to convert 32 bit pointers to 
64 bit pointers by filling in leading zeros. Would be good to know a bit 
more, how 32 bit programs are run on the 64 bit platform.