From 2b29b35e30ed6cd137394ac8c1f59b8cf2268021 Mon Sep 17 00:00:00 2001 From: Abel Deuring Date: Tue, 10 Apr 2001 22:38:01 +0000 Subject: [PATCH] sanei_scsi.c: Fixed a buf in the rror handling for the Linux SG driver v3.x; disabled direct IO by default --- README.linux | 20 +++++++++++++++----- sanei/sanei_scsi.c | 13 +++++++++++-- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/README.linux b/README.linux index ca48c17ab..ad1020551 100644 --- a/README.linux +++ b/README.linux @@ -33,12 +33,12 @@ device mustek:/dev/scanner' is a Mustek ScanExpress 12000SP flatbed scanner If this doesn't work you may have to add the right SCSI generic device name to the configuration file. This should be documented in the man page for -your backend. To find out about the right SCSI device use sane-find-scanner: +your backend. To find out about the right SCSI device use tools/find-scanner: -# sane-find-scanner -sane-find-scanner: found scanner "SCANNER 2.02" at device /dev/scanner -sane-find-scanner: found scanner "SCANNER 2.02" at device /dev/sg0 -sane-find-scanner: found scanner "SCANNER 2.02" at device /dev/sga +# tools/find-scanner +find-scanner: found scanner "SCANNER 2.02" at device /dev/scanner +find-scanner: found scanner "SCANNER 2.02" at device /dev/sg0 +find-scanner: found scanner "SCANNER 2.02" at device /dev/sga It may help to set a soft link /dev/scanner to the respective device. @@ -60,6 +60,16 @@ idescsi: SANE. If your scanner isn't found or you encounter segmentation faults try to disable idescsi. +Direct IO: Recent versions of the Linux SG driver for the 2.4 kernels support + direct IO, i.e., the SCSI adapter's DMA chip copies data directly to/from + user memory. Direct IO reduces memory usage and it may give better + throughput for very fast scanners, but it can lead to access conflicts, + if a backend uses shared memory. Sane does not use direct IO by default, + if you want to use it, run + + configure --enable-directio=yes + + Other Information ================= diff --git a/sanei/sanei_scsi.c b/sanei/sanei_scsi.c index 25abbf79a..131ff3dd8 100644 --- a/sanei/sanei_scsi.c +++ b/sanei/sanei_scsi.c @@ -1693,7 +1693,6 @@ issue (struct req *req) } } ); - IF_DBG(if (DBG_LEVEL >= 255) system("cat /proc/scsi/sg/debug 1>&2");) #ifdef SG_IO } else @@ -1916,7 +1915,16 @@ sanei_scsi_req_enter2 (int fd, req->sgdata.sg3.hdr.sbp = &(req->sgdata.sg3.sense_buffer[0]); /* 10 minutes should be ok even for slow scanners */ req->sgdata.sg3.hdr.timeout = 1000 * 60 * 10; +#ifdef ENABLE_DIRECTIO + /* for the adventurous: If direct IO is used, + the kernel locks the buffer. This can lead to conflicts, + if a backend uses shared memory. + OTOH, direct IO may be faster, and it reduces memory usage + */ req->sgdata.sg3.hdr.flags = SG_FLAG_DIRECT_IO; +#else + req->sgdata.sg3.hdr.flags = 0; +#endif req->sgdata.sg3.hdr.pack_id = pack_id++; req->sgdata.sg3.hdr.usr_ptr = 0; } @@ -1982,6 +1990,7 @@ sanei_scsi_req_wait (void *id) } else { + IF_DBG(if (DBG_LEVEL >= 255) system("cat /proc/scsi/sg/debug 1>&2");) ATOMIC (nread = read (req->fd, &req->sgdata.sg3.hdr, sizeof(Sg_io_hdr)); req->done = 1); } @@ -2073,7 +2082,7 @@ sanei_scsi_req_wait (void *id) else { /* check for errors, but let the sense_handler decide.... */ - if ( (req->sgdata.sg3.hdr.info && SG_INFO_CHECK != 0) + if ( ((req->sgdata.sg3.hdr.info & SG_INFO_CHECK) != 0) || (req->sgdata.sg3.hdr.sb_len_wr > 0 && ((req->sgdata.sg3.sense_buffer[0] & 0x7f) != 0))) {