Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 Dec 2002 03:21:35 +0100 (CET)
From:      Peter Much <pmc@citylink.dinoex.sub.org>
To:        freebsd-scsi@FreeBSD.ORG, freebsd-questions@FreeBSD.ORG
Cc:        sane-devel@www.mostang.com
Subject:   Getting SCSI Scanner to work (with Symbios 53c810a and FreeBSD 4.4)
Message-ID:  <200212010221.gB12LZk02947@disp.oper.dinoex.org>

next in thread | raw e-mail | index | archive | help

Keywords: FreeBSD SANE Scanner Mustek SCSI MFS-6000CX synchronous disable Symbios 53c810a

Just for the records, or: to whom it may concern.

This is what I had to do to get a scsi scanner to work. I post it
here so others having a similar problem may get inspired.

I got some Mustek MFS-6000CX. The SANE docs say this scanner
will not run synchronous scsi transfers and will not disconnect/
reconnect.

The Qlogic 1020 controller does not detect it, but instead it will
hang infinitely at biosboot.

The WD7000 controller will detect it, but either it does not report
it to the host, or the FreeBSD driver does not recognize it. I did 
not check this further, as this ISA controller is rather outdated
(although it likely might be good enough for a scanner).

The Symbios 53c810a will detect the scanner at biosboot as an
asynchronous scsi device, and also FreeBSD detects it as devicetype 
"Scanner" when looking for devices. But it is not possible
to send any scsi command (like tur, inquiry, etc.) to the scanner;
none will be answered. 

Modifying parameters with "camcontrol negotiate" does not help.

The scanner will be lost at "camcontrol rescan" and will never be 
detected again until system reboot.

Each time a scsi command is issued to the scanner, there will be
no answer, but a kernel error message is logged:

/kernel: (probe5:sym0:0:6:0): phase change 6-7 6@07c5bf8c resid=5.

-------------------------------------------------------------------

I investigated the source of the Symbios driver and found out:
It is not possible to switch off synchronous transfer negotiation
for a device. There is a variable named "period" in the source,
and it is set to 25, and it has to do something with synchronous
transfer.
The driver will try to negotiate this value with every device, 
and when it does this to an asynch device, the above error 
"phase change 6-7" will appear. 
This happens with other asynch devices too. But there it does
happen only once, at detection time. Afterwards the "period"
value is changed to 0, and there will be no problems. Obviousely
there is some reaction from the device, and this reaction makes
that the driver changes that value.
And obviousely the Mustek scanner does not provide this expected
reaction, so the 25 value is negotiated again and again before
each scsi command, and then the command does fail due to the "phase
change" error.

So, after figuring this out, the solution is rather simple: we 
need to change the "period" value to 0 on our own initiative.

I did not find a quirk table for generic scsi devices where such
things could be meddled with. (This would have been the nice solution,
making the modification dependent on the scanner's device id string.)

Instead, I did hard-code the scanner's scsi-id via a config file
option. The tradeoff is, if you have more than one Symbios
controller in the machine, then the respective scsi-id on each
bus will have synch transfers disabled. I did not notice any
other tradeoff - I have a disk and two tapes on that bus, and
they work just fine (except for the typical effects of having
a device on the bus that does not disconnect/reconnect).

The disabling of disconnect/reconnect is simple and works as 
documented: "camcontrol negotiate 0:6:0 -D disable", where 6
is the scsi-id of the scanner.

Here is the diff to the Symbios driver, it applies to the source
from RELENG_4_4_0_RELEASE.

*** sys/conf/options.i386.orig	Wed Aug 15 03:23:48 2001
--- sys/conf/options.i386	Thu Nov 28 02:49:01 2002
***************
*** 1,4 ****
! # $FreeBSD: src/sys/conf/options.i386,v 1.132.2.7 2001/08/15 01:23:48 peter Exp $
  
  DISABLE_PSE
  IDE_DELAY
--- 1,4 ----
! # $FreeBSD: $
  
  DISABLE_PSE
  IDE_DELAY
***************
*** 133,138 ****
--- 133,140 ----
  PCVT_SCREENSAVER	opt_pcvt.h
  PCVT_USEKBDSEC		opt_pcvt.h
  PCVT_VT220KEYB		opt_pcvt.h
+ 
+ SYM_MUSTEK_6000CX_ID	opt_sym.h
  
  # voxware options
  GUS_DMA2		opt_sound.h
*** sys/dev/sym/sym_hipd.c.orig	Thu Nov 28 02:50:07 2002
--- sys/dev/sym/sym_hipd.c	Thu Nov 28 02:55:11 2002
***************
*** 55,61 ****
   * SUCH DAMAGE.
   */
  
! /* $FreeBSD: src/sys/dev/sym/sym_hipd.c,v 1.6.2.10 2001/07/08 20:04:04 groudier Exp $ */
  
  #define SYM_DRIVER_NAME	"sym-1.6.5-20000902"
  
--- 55,61 ----
   * SUCH DAMAGE.
   */
  
! /* $FreeBSD: $ */
  
  #define SYM_DRIVER_NAME	"sym-1.6.5-20000902"
  
***************
*** 7836,7841 ****
--- 7836,7849 ----
  	 *  Build a negotiation message if needed.
  	 *  (nego_status is filled by sym_prepare_nego())
  	 */
+ #ifdef SYM_MUSTEK_6000CX_ID
+ 	if (tp->tinfo.current.period  != tp->tinfo.goal.period &&
+ 		ccb_h->target_id == SYM_MUSTEK_6000CX_ID) {
+ 	    printf("Fixing goal period for Mustek 6000CX: %d->%d\n",
+ 	    	tp->tinfo.goal.period, tp->tinfo.current.period);
+ 	    tp->tinfo.goal.period = tp->tinfo.current.period;
+ 	} 
+ #endif
  	cp->nego_status = 0;
  	if (tp->tinfo.current.width   != tp->tinfo.goal.width  ||
  	    tp->tinfo.current.period  != tp->tinfo.goal.period ||

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200212010221.gB12LZk02947>