From eugen@grosbein.pp.ru  Sat Sep 30 04:58:20 2006
Return-Path: <eugen@grosbein.pp.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 0F40E16A415
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 30 Sep 2006 04:58:20 +0000 (UTC)
	(envelope-from eugen@grosbein.pp.ru)
Received: from grosbein.pp.ru (grgw.svzserv.kemerovo.su [213.184.64.166])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 0744843D55
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 30 Sep 2006 04:58:17 +0000 (GMT)
	(envelope-from eugen@grosbein.pp.ru)
Received: from grosbein.pp.ru (localhost [127.0.0.1])
	by grosbein.pp.ru (8.13.8/8.13.8) with ESMTP id k8U4wFKN000976
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 30 Sep 2006 12:58:15 +0800 (KRAST)
	(envelope-from eugen@grosbein.pp.ru)
Received: (from eugen@localhost)
	by grosbein.pp.ru (8.13.8/8.13.8/Submit) id k8U4wEFk000975;
	Sat, 30 Sep 2006 12:58:14 +0800 (KRAST)
	(envelope-from eugen)
Message-Id: <200609300458.k8U4wEFk000975@grosbein.pp.ru>
Date: Sat, 30 Sep 2006 12:58:14 +0800 (KRAST)
From: Eugene Grosbein <eugen@grosbein.pp.ru>
Reply-To: Eugene Grosbein <eugen@grosbein.pp.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: fdc(4) does not work
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         103841
>Category:       kern
>Synopsis:       [fdc] [patch] fdc(4) does not work (regression)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    jkim
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Sep 30 05:00:35 GMT 2006
>Closed-Date:    Sat Sep 15 13:14:26 GMT 2007
>Last-Modified:  Sat Sep 15 13:14:26 GMT 2007
>Originator:     Eugene Grosbein
>Release:        FreeBSD 6.2-PRERELEASE i386
>Organization:
Svyaz-Service JSC
>Environment:
System: FreeBSD grosbein.pp.ru 6.2-PRERELEASE FreeBSD 6.2-PRERELEASE #11: Sat Sep 30 11:46:06 KRAST 2006 eu@grosbein.pp.ru:/mnt/home/obj/usr/local/src/sys/DADV i386
	Intel D975XBX motherboard, "standard" FDD 1.44

>Description:
	I have a dual-boot machine, FreeBSD 6.2-PRERELEASE/Windows XP Sp2.
	FDD work fine with Windows XP, it formats, writes and reads
	floppy disks normally. It does not work with FreeBSD at all.

	To obtain meaningful debug info I made 'debug.fdc.debugflags'
	loader tunable with the following patch:

--- fdc.c.orig	Sat Sep 30 12:18:40 2006
+++ fdc.c	Sat Sep 30 11:45:51 2006
@@ -268,6 +268,7 @@
 	"FIFO threshold setting");
 
 static int debugflags = 0;
+TUNABLE_INT("debug.fdc.debugflags", &debugflags);
 SYSCTL_INT(_debug_fdc, OID_AUTO, debugflags, CTLFLAG_RW, &debugflags, 0,
 	"Debug flags");
 
	Please commit this :-)

	Now details:

	1. fdc(4) driver makes 65 second delay during last stage of
	kernel initialization just before GEOM adds ATA drives,
	if FDD has no floppy disk inserted.

	Without fdc enabled there is no delay.
	I've used verbose boot and debug.fdc.debugflags=255 to see
	what happens:

fdc0: <floppy drive controller> port 0x3f0-0x3f5,0x3f0 irq 6 drq 2 on acpi0
fdc0: ic_type 90 part_id 80
fdc0: [MPSAFE]
fdc0: [FAST]
 00 00 00 00 af 10 12 80 57 00
fd0: <1440-KB 3.5" drive> on fdc0 drive 0
New disk in probe
Got disk in probe
op 40 bn 0 siz 0 ptr 0xe391eb2c retry 0
  -> 40 1 0 fe
status 40 01 00 fe ff 01
[unknown][UNKNOWN()]
Retry line 1123
Too many retries (EIO)
op 40 bn 0 siz 0 ptr 0xe391eb2c retry 0
  -> 40 1 0 fe
status 40 01 00 fe ff 01
[unknown][UNKNOWN()]
Retry line 1123
Too many retries (EIO)
fd0: autoselection failed
op 1 bn 0 siz 512 ptr 0xc5177800 retry 0
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177800 retry 1
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177800 retry 2
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177800 retry 3
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177800 retry 4
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177800 retry 5
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177800 retry 6
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177800 retry 7
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177800 retry 8
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177800 retry 9
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
Too many retries (EIO)
retries: 10
op 1 bn 1 siz 512 ptr 0xc5177600 retry 0
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
op 1 bn 1 siz 512 ptr 0xc5177600 retry 1
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
op 1 bn 1 siz 512 ptr 0xc5177600 retry 2
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
op 1 bn 1 siz 512 ptr 0xc5177600 retry 3
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
op 1 bn 1 siz 512 ptr 0xc5177600 retry 4
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
op 1 bn 1 siz 512 ptr 0xc5177600 retry 5
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
op 1 bn 1 siz 512 ptr 0xc5177600 retry 6
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
op 1 bn 1 siz 512 ptr 0xc5177600 retry 7
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
op 1 bn 1 siz 512 ptr 0xc5177600 retry 8
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
op 1 bn 1 siz 512 ptr 0xc5177600 retry 9
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
Too many retries (EIO)
retries: 10
op 1 bn 0 siz 512 ptr 0xc5177400 retry 0
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177400 retry 1
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177400 retry 2
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177400 retry 3
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177400 retry 4
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177400 retry 5
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177400 retry 6
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177400 retry 7
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177400 retry 8
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177400 retry 9
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
Too many retries (EIO)
retries: 10
GEOM: new disk ad4
GEOM: new disk ad6
GEOM: new disk cd0
Trying to mount root from ufs:/dev/ad4s4a
start_init: trying /sbin/init
gif0: bpf attached
tun0: bpf attached
em0: Link is Down
em0: Link is up 100 Mbps Full Duplex
em0: link state changed to UP
ng_pppoe[3]: session in wrong state

	2. fdc(4) driver makes 12 second delay during last stage of
	kernel initialization just before GEOM adds ATA drives,
	if FDD has good FAT-formatted floppy disk inserted.

fdc0: <floppy drive controller> port 0x3f0-0x3f5,0x3f0 irq 6 drq 2 on acpi0
fdc0: ic_type 90 part_id 80
fdc0: [MPSAFE]
fdc0: [FAST]
 00 00 00 00 af 10 12 80 57 00
fd0: <1440-KB 3.5" drive> on fdc0 drive 0
New disk in probe
Got disk in probe
op 40 bn 0 siz 0 ptr 0xe391eb2c retry 0
  -> 40 1 0 fe
status 40 01 00 fe ff 01
[unknown][UNKNOWN()]
Retry line 1123
Too many retries (EIO)
op 40 bn 0 siz 0 ptr 0xe391eb2c retry 0
  -> 40 1 0 fe
status 40 01 00 fe ff 01
[unknown][UNKNOWN()]
Retry line 1123
Too many retries (EIO)
fd0: autoselection failed
op 1 bn 0 siz 512 ptr 0xc5177800 retry 0
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177800 retry 1
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177800 retry 2
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177800 retry 3
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177800 retry 4
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177800 retry 5
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177800 retry 6
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177800 retry 7
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177800 retry 8
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177800 retry 9
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
Too many retries (EIO)
retries: 10
op 1 bn 1 siz 512 ptr 0xc5177600 retry 0
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
op 1 bn 1 siz 512 ptr 0xc5177600 retry 1
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
op 1 bn 1 siz 512 ptr 0xc5177600 retry 2
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
op 1 bn 1 siz 512 ptr 0xc5177600 retry 3
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
op 1 bn 1 siz 512 ptr 0xc5177600 retry 4
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
op 1 bn 1 siz 512 ptr 0xc5177600 retry 5
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
op 1 bn 1 siz 512 ptr 0xc5177600 retry 6
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
op 1 bn 1 siz 512 ptr 0xc5177600 retry 7
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
op 1 bn 1 siz 512 ptr 0xc5177600 retry 8
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
op 1 bn 1 siz 512 ptr 0xc5177600 retry 9
  -> 40 1 0 0
status 40 01 00 00 00 02
fd0[READ(offset=512, length=512)]
Retry line 1123
Too many retries (EIO)
retries: 10
op 1 bn 0 siz 512 ptr 0xc5177400 retry 0
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177400 retry 1
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177400 retry 2
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177400 retry 3
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177400 retry 4
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177400 retry 5
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177400 retry 6
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177400 retry 7
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177400 retry 8
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
op 1 bn 0 siz 512 ptr 0xc5177400 retry 9
  -> 40 1 0 0
status 40 01 00 00 00 01
fd0[READ(offset=0, length=512)]
Retry line 1123
Too many retries (EIO)
retries: 10
GEOM: new disk ad4
GEOM: new disk ad6
GEOM: new disk cd0
Trying to mount root from ufs:/dev/ad4s4a
start_init: trying /sbin/init

	3. In both cases, any userland read operation with /dev/fd0
	fails with EIO, as well as attempt to format disk with fdformat.

	4. I've tried to manually merge revision 1.311 of fdc.c,
	this eliminates delays during boot. But drive still does not work.

>How-To-Repeat:

	I'd like to see how to NOT repeat this.
	
>Fix:

	Unknown.
>Release-Note:
>Audit-Trail:

From: Eugene Grosbein <eugen@www.svzserv.kemerovo.su>
To: bug-followup@freebsd.org
Cc: jhb@freebsd.org, jkim@freebsd.org
Subject: Re: kern/103841: fdc(4) does not work
Date: Thu, 5 Oct 2006 13:54:56 +0800

 Hi!
 
 Forget to note that FDD works fine in FreeBSD 4.11
 that is installed here too. More, there is very strange effect:
 
 1. I boot FreeBSD 4.11 and make sure FDD works (mount FAT floppy, ls etc.)
 2. Warm reboot to FreeBSD 6.2-PRE and see that FDD became to work there too,
 it detects 1.44 floppy in drive at boot time, it reads all its contents
 to image with dd, it successfully formats floppy with fdformat
 and writes image back to the floppy with dd then mounts floppy Ok.
 2. Warm reboot 6.2-PRE again and FDD does not work again.
 
 This is 100% reproduceable.
 
 I did not try this machine's floppy with more early 6.x version.
 
 Eugene Grosbein

From: Eugene Grosbein <eugen@www.svzserv.kemerovo.su>
To: Robert Watson <rwatson@freebsd.org>
Cc: FreeBSD Stable <freebsd-stable@freebsd.org>, bug-followup@freebsd.org
Subject: Re: kern/103841: [fdc] fdc(4) does not work (regression)
Date: Fri, 6 Oct 2006 00:48:21 +0800

 On Thu, Oct 05, 2006 at 10:48:52PM +0800, Eugene Grosbein wrote:
 
 > > >It's definetely a regression from 4.11-STABLE that runs fine on this 
 > > >system with ACPI fully enabled 
 > 
 > Hmm, I was wrong about 4.11 using ACPI - it does not use it here really,
 > it uses "good old" APM.
 > 
 > > It would be interesting to know how 4.x probes the hardware vs. how it 
 > > apperas in the 6.x dmesg.
 > 
 > 4.11-STABLE:
 > 
 > fdc0: <NEC 72065B or clone> at port 0x3f0-0x3f5,0x3f7 irq 6 drq 2 on isa0
 > fdc0: FIFO enabled, 8 bytes threshold
 > fd0: <1440-KB 3.5" drive> on fdc0 drive 0
 > 
 > 6.2-PRERELEASE:
 > 
 > fdc0: <floppy drive controller> port 0x3f0-0x3f5,0x3f0 irq 6 drq 2 on acpi0
 > fdc0: [FAST]
 > fd0: <1440-KB 3.5" drive> on fdc0 drive 0
 
 I managed to know that fdc_initial_reset() in sys/dev/fdc/fdc.c
 probes my fdc controller as "Enhanced floppy controller" (ic_type==0x90) vs.
 4.x's "NEC close". BTW, does in possible to obtain fdc's probe result vs.
 fdc_acpi's result without addition of call to
 "fdc_print_child(device_get_parent(dev), dev);" to fdc_initial_reset()?
 
 I've forced sys/dev/fdc/fdc.c to probe my controller as "NEC clone"
 by moving "case 0x90:" upwards to "case 0x80" in this function
 but that does not help, no change in behavour was observed.
 
 Eugene Grosbein

From: Eugene Grosbein <eugen@www.svzserv.kemerovo.su>
To: Robert Watson <rwatson@freebsd.org>
Cc: FreeBSD Stable <freebsd-stable@freebsd.org>, bug-followup@freebsd.org
Subject: Re: kern/103841: [fdc] fdc(4) does not work (regression)
Date: Fri, 6 Oct 2006 03:05:09 +0800

 I've tried 5.4-RELEASE and 6.0-RELEASE.
 
 5.4-RELEASE works OK. 6.0-RELEASE does not work the same way as 6.2-PRE.
 
 Eugene Grosbein

From: Eugene Grosbein <eugen@kuzbass.ru>
To: Robert Watson <rwatson@freebsd.org>
Cc: FreeBSD Stable <freebsd-stable@freebsd.org>, re@freebsd.org,
        bug-followup@freebsd.org
Subject: Re: kern/103841: [fdc] fdc(4) does not work (regression)
Date: Fri, 6 Oct 2006 04:19:07 +0800

 I've backported fdc(4) from CURRENT to RELENG_6 and it now works all right,
 it reads, it formats, it writes.
 
 Please perform MFC and then close this PR :-)
 
 Eugene Grosbein

From: Dmitry Pryanishnikov <dmitry@atlantis.dp.ua>
To: Eugene Grosbein <eugen@www.svzserv.kemerovo.su>
Cc: Robert Watson <rwatson@freebsd.org>,
        FreeBSD Stable <freebsd-stable@freebsd.org>, bug-followup@freebsd.org
Subject: Re: kern/103841: [fdc] fdc(4) does not work (regression)
Date: Fri, 6 Oct 2006 00:00:15 +0300 (EEST)

 Hello!
 
    The problem is clearly an I/O port resource misdetection:
 
 On Fri, 6 Oct 2006, Eugene Grosbein wrote:
 >> 4.11-STABLE:
 >>
 >> fdc0: <NEC 72065B or clone> at port 0x3f0-0x3f5,0x3f7 irq 6 drq 2 on isa0
 ---------------------------------------^^^^^^^^^^^^^^^^^
 
   OK.
 
 >> 6.2-PRERELEASE:
 >>
 >> fdc0: <floppy drive controller> port 0x3f0-0x3f5,0x3f0 irq 6 drq 2 on acpi0
 ----------------------------------------^^^^^^^^^^^^^^^^^
 
   Bad (no 0x3f7, 0x3f0 gets listed twice).
 
 Sincerely, Dmitry
 -- 
 Atlantis ISP, System Administrator
 e-mail:  dmitry@atlantis.dp.ua
 nic-hdl: LYNX-RIPE

From: Eugene Grosbein <eugen@kuzbass.ru>
To: Dmitry Pryanishnikov <dmitry@atlantis.dp.ua>
Cc: Robert Watson <rwatson@freebsd.org>,
        FreeBSD Stable <freebsd-stable@freebsd.org>, bug-followup@freebsd.org
Subject: Re: kern/103841: [fdc] fdc(4) does not work (regression)
Date: Fri, 6 Oct 2006 05:11:22 +0800

 On Fri, Oct 06, 2006 at 12:00:15AM +0300, Dmitry Pryanishnikov wrote:
 
 >   The problem is clearly an I/O port resource misdetection:
 > On Fri, 6 Oct 2006, Eugene Grosbein wrote:
 > >>4.11-STABLE:
 > >>fdc0: <NEC 72065B or clone> at port 0x3f0-0x3f5,0x3f7 irq 6 drq 2 on isa0
 > ---------------------------------------^^^^^^^^^^^^^^^^^
 >  OK.
 > >>6.2-PRERELEASE:
 > >>fdc0: <floppy drive controller> port 0x3f0-0x3f5,0x3f0 irq 6 drq 2 on 
 > >>acpi0
 > ----------------------------------------^^^^^^^^^^^^^^^^^
 >  Bad (no 0x3f7, 0x3f0 gets listed twice).
 
 Recent revisions of fdc(4) do not use control register at port 0x3f7.
 
 CURRENT's version works fine and still probes controller this way,
 without 0x3f7. You can get background info from commint logs for fdc.c
 
 Eugene Grosbein

From: Dmitry Pryanishnikov <dmitry@atlantis.dp.ua>
To: Eugene Grosbein <eugen@kuzbass.ru>
Cc: FreeBSD Stable <freebsd-stable@freebsd.org>,
        Robert Watson <rwatson@freebsd.org>, bug-followup@freebsd.org
Subject: Re: kern/103841: [fdc] fdc(4) does not work (regression)
Date: Fri, 6 Oct 2006 00:41:32 +0300 (EEST)

 Hello!
 
 On Fri, 6 Oct 2006, Eugene Grosbein wrote:
 >>>> fdc0: <floppy drive controller> port 0x3f0-0x3f5,0x3f0 irq 6 drq 2 on
 >>>> acpi0
 >> ----------------------------------------^^^^^^^^^^^^^^^^^
 >>  Bad (no 0x3f7, 0x3f0 gets listed twice).
 >
 > Recent revisions of fdc(4) do not use control register at port 0x3f7.
 
   Are you sure? I see the following in /sys/dev/fdc/fdc.c (CURRENT version):
 
 #define   FDCTL   7       /* Control Register (W) */
 
 static void
 fdctl_wr(struct fdc_data *fdc, u_int8_t v)
 {
          fdregwr(fdc, FDCTL, v);
 }
 
 Well, in CURRENT it _may not_ be used if you've got the "Enhanced"
 floppy controller:
 
          if (fdc->fdct == FDC_ENHANCED)
                  fddsr_wr(fdc, fd->ft->trans);
          else
                  fdctl_wr(fdc, fd->ft->trans);
 
 while in RELENG_6 it's always
 
  	fdctl_wr(fdc, fd->ft->trans);
 
 That's why version from CURRENT works for you despite the absence of 0x3f7
 resource. But it's incorrect to say that "Recent revisions of fdc(4) do not 
 use control register at port 0x3f7" - actually they do for non-FDC_ENHANCED 
 case.
 
 Sincerely, Dmitry
 -- 
 Atlantis ISP, System Administrator
 e-mail:  dmitry@atlantis.dp.ua
 nic-hdl: LYNX-RIPE

Adding to audit trail from misfiled PR kern/104046:

Date: Fri, 6 Oct 2006 17:56:37 +0800
From: Eugene Grosbein <eugen@kuzbass.ru>

 > You have bad ACPI DSDT.  Try newer BIOS if there's any.
 
 I've just upgraded BIOS to lastest available at support.intel.com
 for my motherboard (I was wrong thinking I run latest, there were more fresh).
 
 No change in behaviour of fdc(4) in RELENG_6 and in HEAD, they still
 probe fdc0 the same way, STABLE's driver still does not work
 and CURRENT's works fine.
 
 Eugene Grosbein

From: Jung-uk Kim <jkim@FreeBSD.org>
To: bug-followup@FreeBSD.org, eugen@grosbein.pp.ru
Cc:  
Subject: Re: kern/103841: [fdc] fdc(4) does not work (regression)
Date: Fri, 6 Oct 2006 15:49:07 -0400

 Your problem is in the ACPI BIOS.  Please do:
 
 	acpidump -d -t > acpidump.asl
 
 and send me the acpidump.asl.
 
 Jung-uk Kim

From: Andrey Zadorozhny <zandyg@hotbox.ru>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: kern/103841: [fdc] fdc(4) does not work (regression)
Date: Thu, 25 Jan 2007 10:57:38 +0500

 I have FreeBSD 6.2 Release  installed on a Intel D945GNT motherboard. 
 The boot process pauses right at this point:
  SMP: AP CPU #1 Launched!
 Several minutes nothing. Then the boot process resumes normally. 
 Disabling the floppy controller in the BIOS makes the boot delay go away.
 
 Applying the patch from Eugene Grosbein resolved my problem.
 

From: Eugene Grosbein <eugen@grosbein.pp.ru>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: kern/103841: [fdc] fdc(4) does not work (regression)
Date: Fri, 26 Jan 2007 19:55:51 +0700

 Hi!
 
 The patch mentioned by Andrey Zadorozhny follows.
 This is just a backport of some commits from 7.0-CURRENT
 to RELENG_6. Requested acpidump.asl was sent to Jung-uk Kim
 some time ago and now I put latest version here:
 
 http://www.grosbein.pp.ru/acpidump.asl.bz2
 It corresponds to D975XBD Standard BIOS version 1474 of
 December 20, 2006.
 
 --- sys/dev/fdc/fdc.c.orig	Sat Sep 30 12:18:40 2006
 +++ sys/dev/fdc/fdc.c	Fri Oct  6 04:09:31 2006
 @@ -191,6 +191,7 @@
  #define	FDO_MOEN3	0x80	/*  motor enable drive 3 */
  
  #define	FDSTS	4	/* NEC 765 Main Status Register (R) */
 +#define FDDSR	4	/* Data Rate Select Register (W) */
  #define	FDDATA	5	/* NEC 765 Data Register (R/W) */
  #define	FDCTL	7	/* Control Register (W) */
  
 @@ -344,6 +345,13 @@
  }
  
  static void
 +fddsr_wr(struct fdc_data *fdc, u_int8_t v)
 +{
 +
 +	fdregwr(fdc, FDDSR, v);
 +}
 +
 +static void
  fddata_wr(struct fdc_data *fdc, u_int8_t v)
  {
  
 @@ -494,11 +502,16 @@
  {
  	int i, r[10];
  
 -	/* Try a reset, keep motor on */
 -	fdout_wr(fdc, fdc->fdout & ~(FDO_FRST|FDO_FDMAEN));
 -	DELAY(100);
 -	/* enable FDC, but defer interrupts a moment */
 -	fdout_wr(fdc, fdc->fdout & ~FDO_FDMAEN);
 +	if (fdc->fdct == FDC_ENHANCED) {
 +		/* Try a software reset, default precomp, and 500 kb/s */
 +		fddsr_wr(fdc, 0x80);
 +	} else {
 +		/* Try a hardware reset, keep motor on */
 +		fdout_wr(fdc, fdc->fdout & ~(FDO_FRST|FDO_FDMAEN));
 +		DELAY(100);
 +		/* enable FDC, but defer interrupts a moment */
 +		fdout_wr(fdc, fdc->fdout & ~FDO_FDMAEN);
 +	}
  	DELAY(100);
  	fdout_wr(fdc, fdc->fdout);
  
 @@ -519,7 +532,7 @@
  			    " CONFIGURE failed in reset\n");
  		if (debugflags & 1) {
  			if (fdc_cmd(fdc, 1,
 -			    0x0e,			/* DUMPREG */
 +			    0x0e,
  			    10, &r[0], &r[1], &r[2], &r[3], &r[4],
  			    &r[5], &r[6], &r[7], &r[8], &r[9]))
  				device_printf(fdc->fdc_dev,
 @@ -745,6 +758,9 @@
  		(fdc->retry >= retries || (fd->options & FDOPT_NORETRY))) {
  		if ((debugflags & 4))
  			printf("Too many retries (EIO)\n");
 +		mtx_lock(&fdc->fdc_mtx);
 +		fd->flags |= FD_EMPTY;
 +		mtx_unlock(&fdc->fdc_mtx);
  		return (fdc_biodone(fdc, EIO));
  	}
  
 @@ -804,7 +820,10 @@
  
  	/* Select drive, setup params */
  	fd_select(fd);
 -	fdctl_wr(fdc, fd->ft->trans);
 +	if (fdc->fdct == FDC_ENHANCED)
 +		fddsr_wr(fdc, fd->ft->trans);
 +	else
 +		fdctl_wr(fdc, fd->ft->trans);
  
  	if (bp->bio_cmd & BIO_PROBE) {
  
 --- sys/dev/fdc/fdc_acpi.c.orig	Thu Oct  5 23:42:29 2006
 +++ sys/dev/fdc/fdc_acpi.c	Fri Oct  6 03:53:51 2006
 @@ -98,7 +98,6 @@
  	device_t bus;
  	int error, fde_count, i;
  	ACPI_OBJECT *obj, *pkg;
 -	ACPI_HANDLE h;
  	uint32_t fde[ACPI_FDC_MAXDEVS];
  
  	/* Get our softc and use the same accessor as ISA. */
 @@ -107,7 +106,6 @@
  
  	/* Initialize variables and get a temporary buffer for _FDE. */
  	error = ENXIO;
 -	h = acpi_get_handle(dev);
  	buf.Length = ACPI_FDC_BUFLEN;
  	buf.Pointer = malloc(buf.Length, M_TEMP, M_NOWAIT | M_ZERO);
  	if (buf.Pointer == NULL)

Adding to audit trail from misfiled PR kern/113553:

Date: Mon, 11 Jun 2007 14:14:36 +0800
From: Eugene Grosbein <eugen@www.svzserv.kemerovo.su>

 Hi!
 
 This is still the problem for recent 6.2-STABLE and BIOS version 1479,
 and the patch in the Audit-Trail still solves it.
 
 Eugene Grosbein

From: Alex Bakhtin <bakhtin@amt.ru>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/103841: [fdc] [patch] fdc(4) does not work (regression)
Date: Thu, 13 Sep 2007 17:19:52 +0400

 Hi.
 
         I have the similar problem on PIII based Compaq DL-320 rackmount
 chassis. There is a great delay (several minutes) on boot time after hard
 disk detection (and also 25 second delay when manually loading any GEOM
 class ) and there are two ways to prevent this - disable floppy disk
 controller or apply this patch. RELENG_6 from 12-sep-2007 is still
 affected.
 
 -- 
 Best regards, Alex Bakhtin, CCIE #8439
 AMT Group, Cisco Systems Gold Partner, http://www.amt.ru

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/103841: commit references a PR
Date: Fri, 14 Sep 2007 23:44:17 +0000 (UTC)

 jkim        2007-09-14 23:44:11 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_6)
     sys/dev/fdc          fdc.c 
     sys/dev/ic           nec765.h 
     sys/pc98/cbus        fdc.c 
   Log:
   MFC:    sys/dev/fdc/fdc.c       1.310-1.313
           sys/dev/ic/nec765.h     1.12, 1.13
           sys/dev/pc98/fdc.c      1.167
   
   - Enhanced floppy controllers have Data Rate Select Register (DSR) at 0x3f4.
   Use it to reset controller and to select data rate.  According to Intel
   80277AA datasheet, software reset behaves the same as DOR reset except
   that it is self clearing.  National Semiconductor PC8477B datasheet says
   the same.  As a side effect, we no longer use Configuration Control
   Register (CCR) at 0x3f7 for these controllers, which is often missing
   in modern hardware.
   - Assume floppy disk is not inserted when we have exhausted retries.  This
   significantly reduces booting time when there is broken floppy disk drive,
   controller, cable, BIOS, etc.
   When the floppy controller interface is correctly implemented, disk change
   signal (DSKCHG) is reflected in the Digital Input Register (DIR) at 0x3f7.
   However, there are many cases that the signal is unusable.  Moreover, some
   BIOS does not reserve the port at all.  In those cases, the register may not
   function.
   - Fix style nits.
   
   PR:     kern/103841
   
   Revision   Changes    Path
   1.307.2.4  +27 -8     src/sys/dev/fdc/fdc.c
   1.11.8.1   +29 -23    src/sys/dev/ic/nec765.h
   1.160.2.4  +2 -2      src/sys/pc98/cbus/fdc.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
Responsible-Changed-From-To: freebsd-bugs->jkim 
Responsible-Changed-By: jkim 
Responsible-Changed-When: Fri Sep 14 23:55:17 UTC 2007 
Responsible-Changed-Why:  
Grab. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=103841 
State-Changed-From-To: open->feedback 
State-Changed-By: jkim 
State-Changed-When: Fri Sep 14 23:55:50 UTC 2007 
State-Changed-Why:  
I just MFC'd the relevant changes to RELENG_6. 
Please let me know if it doesn't work. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=103841 

From: Eugene Grosbein <eugen@grosbein.pp.ru>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/103841: [fdc] [patch] fdc(4) does not work (regression)
Date: Sat, 15 Sep 2007 14:57:10 +0800

 On Fri, Sep 14, 2007 at 11:57:50PM +0000, jkim@FreeBSD.org wrote:
 
 > I just MFC'd the relevant changes to RELENG_6.
 > Please let me know if it doesn'twork.
 > 
 > http://www.freebsd.org/cgi/query-pr.cgi?pr=103841
 
 It works, thank you very much!
 
 Eugene
State-Changed-From-To: feedback->closed 
State-Changed-By: jkim 
State-Changed-When: Sat Sep 15 13:13:22 UTC 2007 
State-Changed-Why:  
Feedback received.  Thanks! 

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