From mburgett@firedraig.awen.com  Sun Jul 12 22:31:19 1998
Received: from firedraig.awen.com (firedraig.awen.com [207.33.155.8])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id WAA13188
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 12 Jul 1998 22:31:18 -0700 (PDT)
          (envelope-from mburgett@firedraig.awen.com)
Received: (from mburgett@localhost)
	by firedraig.awen.com (8.9.1/8.8.8) id WAA00553;
	Sun, 12 Jul 1998 22:32:14 -0700 (PDT)
	(envelope-from mburgett)
Message-Id: <199807130532.WAA00553@firedraig.awen.com>
Date: Sun, 12 Jul 1998 22:32:14 -0700 (PDT)
From: mburgett@awen.com
Reply-To: mburgett@awen.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: PSM detection problem with console switch
X-Send-Pr-Version: 3.2

>Number:         7266
>Category:       i386
>Synopsis:       PSM detection failure with Linksys console switch
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jul 12 22:40:00 PDT 1998
>Closed-Date:    Sat Jul 30 01:09:42 GMT 2005
>Last-Modified:  Sat Jul 30 01:09:42 GMT 2005
>Originator:     Mike Burgett
>Release:        FreeBSD 3.0-980709-SNAP i386
>Organization:
None
>Environment:

Copyright (c) 1992-1998 FreeBSD Inc.
Copyright (c) 1982, 1986, 1989, 1991, 1993
        The Regents of the University of California. All rights reserved.
FreeBSD 3.0-980709-SNAP #3: Sun Jul 12 22:05:38 PDT 1998
    root@firedraig.awen.com:/usr/src/sys/compile/FIREDRAIG
CPU: Pentium Pro (686-class CPU)
  Origin = "GenuineIntel"  Id = 0x617  Stepping=7
  Features=0xfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV>
real memory  = 268435456 (262144K bytes)
avail memory = 258809856 (252744K bytes)
FreeBSD/SMP: Multiprocessor motherboard
 cpu0 (BSP): apic id:  1, version: 0x00040011, at 0xfee00000
 cpu1 (AP):  apic id:  0, version: 0x00040011, at 0xfee00000
 io0 (APIC): apic id:  2, version: 0x00170011, at 0xfec00000

>Description:

 With the Linksys SVIEW04 Console switch inline, PSM is not detected. Turning
 on PSM debugging in the kernel revealed some functions returning PSM_RESEND,
 and with failure code being sent if result != PSM_ACK.  Adding a loop to
 disble_aux_dev allows PSM to correctly detect, though some resends on status
 checks are still returned as errors.

>How-To-Repeat:

  Boot system with Linksys console switch attached, and system screen
  selected or not. With debugging on, a failure should be observed at this
  section of the function psmprobe() (I think, this code fragment occurs in
  psm_reinitialize() as well.)

    if (!enable_aux_dev(sc->kbdc) || !disable_aux_dev(sc->kbdc)) {
        /* MOUSE ERROR */
        restore_controller(sc->kbdc, command_byte);
        if (verbose)
            printf("psm%d: failed to enable the aux device.\n", unit);
        endprobe(0);
    }

  The call to enable_aux_dev returns a good result, but the disable_aux_dev
  returns a PSM_RESEND, which is interpreted as a failure, instead of being
  retried.  With the work-around below, the following can be observed:

psm0: current command byte:0047
psm: ENABLE_DEV return code:00fa
psm: DISABLE_DEV return code:00fe
psm: DISABLE_DEV return code:00fa
psm: SEND_AUX_DEV_STATUS return code:00fa

  indicating that the first disable_aux_dev is still returing the 
  PSM_RESEND, but is succeeding on the second attempt.  I suspect there
  are other places where retry needs to be detected and implemented (I've
  seen PSM_RESEND returned in the send_aux_command() call in 
  get_mouse_status().)

>Fix:

  I did the following as a work around:

original:

static int
disable_aux_dev(KBDC kbdc)
{
    int res;

    res = send_aux_command(kbdc, PSMC_DISABLE_DEV);
    if (verbose >= 2)
        log(LOG_DEBUG, "psm: DISABLE_DEV return code:%04x\n", res);

    return (res == PSM_ACK);
}   

hack:

static int 
disable_aux_dev(KBDC kbdc) 
{
    int res = PSM_RESEND;
    int maxretry = 10; /* don't want to retry forever */

    while ((res == PSM_RESEND) && (maxretry--))  
    {
      res = send_aux_command(kbdc, PSMC_DISABLE_DEV);
      if (verbose >= 2)
        log(LOG_DEBUG, "psm: DISABLE_DEV return code:%04x\n", res);
    }
    return (res == PSM_ACK);
}


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->yokota 
Responsible-Changed-By: yokota 
Responsible-Changed-When: Mon Jul 20 03:59:30 PDT 1998 
Responsible-Changed-Why:  
I will be looking at the code. 

From: Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
To: mburgett@awen.com
Cc: FreeBSD-gnats-submit@freebsd.org, yokota@zodiac.mech.utsunomiya-u.ac.jp
Subject: Re: i386/7266: PSM detection problem with console switch 
Date: Mon, 20 Jul 1998 20:03:32 +0900

 >>Number:         7266
 >>Category:       i386
 >>Synopsis:       PSM detection failure with Linksys console switch
 [...]
 >>Release:        FreeBSD 3.0-980709-SNAP i386
 >>Environment:
 >
 >Copyright (c) 1992-1998 FreeBSD Inc.
 >Copyright (c) 1982, 1986, 1989, 1991, 1993
 >        The Regents of the University of California. All rights reserved.
 >FreeBSD 3.0-980709-SNAP #3: Sun Jul 12 22:05:38 PDT 1998
 >    root@firedraig.awen.com:/usr/src/sys/compile/FIREDRAIG
 >CPU: Pentium Pro (686-class CPU)
 >  Origin = "GenuineIntel"  Id = 0x617  Stepping=7
 >  Features=0xfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMO
 >V>
 >real memory  = 268435456 (262144K bytes)
 >avail memory = 258809856 (252744K bytes)
 >FreeBSD/SMP: Multiprocessor motherboard
 > cpu0 (BSP): apic id:  1, version: 0x00040011, at 0xfee00000
 > cpu1 (AP):  apic id:  0, version: 0x00040011, at 0xfee00000
 > io0 (APIC): apic id:  2, version: 0x00170011, at 0xfec00000
 >
 >>Description:
 >
 > With the Linksys SVIEW04 Console switch inline, PSM is not detected. Turning
 > on PSM debugging in the kernel revealed some functions returning PSM_RESEND,
 > and with failure code being sent if result != PSM_ACK.  Adding a loop to
 > disble_aux_dev allows PSM to correctly detect, though some resends on status
 > checks are still returned as errors.
 
 Do you have the same problem if you don't use the console switch and
 connect your PS/2 mouse directly to the motherboard?
 
 >  The call to enable_aux_dev returns a good result, but the disable_aux_dev
 >  returns a PSM_RESEND, which is interpreted as a failure, instead of being
 >  retried.  With the work-around below, the following can be observed:
 >
 >psm0: current command byte:0047
 >psm: ENABLE_DEV return code:00fa
 >psm: DISABLE_DEV return code:00fe
 >psm: DISABLE_DEV return code:00fa
 >psm: SEND_AUX_DEV_STATUS return code:00fa
 >
 >  indicating that the first disable_aux_dev is still returing the 
 >  PSM_RESEND, but is succeeding on the second attempt.  I suspect there
 >  are other places where retry needs to be detected and implemented (I've
 >  seen PSM_RESEND returned in the send_aux_command() call in 
 >  get_mouse_status().)
 
 The PS/2 mouse sends PSM_RESEND if a wrong command byte or data byte
 has been sent to the mouse (by buggy software or by bad serial
 connection between the mouse and the motherboard) or transmission
 error has been detected on the serial line.
 
 As PSM_DISABLE_DEV IS a valid command byte and your PS/2 mouse does
 respond correctly on the second attempt, I would presume that the
 serial connection between the mouse and the motherboard is somewhat
 shaky (because of the console switch box?).
 
 I have not seen serial connection problems between the mouse and the
 motherboard in the machines around me before...
 
 OK, I will review the I/O code for the PS/2 mouse and try to add retry
 loops...
 
 Kazu
 yokota@freebsd.org
 
State-Changed-From-To: open->feedback 
State-Changed-By: linimon 
State-Changed-When: Thu Aug 26 03:22:24 GMT 2004 
State-Changed-Why:  
Is this still a problem with modern versions of FreeBSD? 


Responsible-Changed-From-To: yokota->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Thu Aug 26 03:22:24 GMT 2004 
Responsible-Changed-Why:  
With bugmeister hat on, reassign from inactive committer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=7266 
State-Changed-From-To: feedback->closed 
State-Changed-By: kris 
State-Changed-When: Sat Jul 30 01:09:35 GMT 2005 
State-Changed-Why:  
Feedback timeout 

http://www.freebsd.org/cgi/query-pr.cgi?pr=7266 
>Unformatted:
