From owner-freebsd-hackers Thu Apr 18 12:35:58 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from arjun.niksun.com (gwnew.niksun.com [63.148.27.34]) by hub.freebsd.org (Postfix) with ESMTP id 3A3BD37B400 for ; Thu, 18 Apr 2002 12:35:39 -0700 (PDT) Received: from niksun.com (daemon.niksun.com [10.0.10.10]) by arjun.niksun.com (8.9.3/8.9.3) with ESMTP id PAA74954; Thu, 18 Apr 2002 15:35:38 -0400 (EDT) (envelope-from jkim@niksun.com) Message-ID: <3CBF2008.6090009@niksun.com> Date: Thu, 18 Apr 2002 15:35:36 -0400 From: Jung-uk Kim User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:0.9.9) Gecko/20020312 X-Accept-Language: ko, en-us MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Cc: jkim@niksun.com Subject: Floppy device driver problem (with patch) Content-Type: multipart/mixed; boundary="------------010401080706050603080500" Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG This is a multi-part message in MIME format. --------------010401080706050603080500 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit We've got a brand new Compaq ProLiant DL380 G2 machine but floppy drive wasn't working at all with FreeBSD 4.x. I found that there was a PR: http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/21397 I got the following error messages: Apr 16 16:57:48 /kernel: fdc0: direction bit not set Apr 16 16:57:48 /kernel: fdc0: cmd 3 failed at out byte 1 of 3 Apr 16 16:57:48 /kernel: fdc0: direction bit not set Apr 16 16:57:48 /kernel: fdc0: cmd 13 failed at out byte 1 of 4 Apr 16 16:57:48 /kernel: fdc0: Re-enable FIFO failed Apr 16 16:57:50 /kernel: fdc0: direction bit not set Apr 16 16:57:50 /kernel: fdc0: cmd 8 failed at out byte 1 of 1 Apr 16 16:57:50 /kernel: fdc0: sense intr err reading stat reg 0 ------ >8 ------------ >8 ------------ >8 ------------ >8 ------------ >8 ------------ >8 ------ Apr 16 16:58:10 /kernel: fdc0: direction bit not set Apr 16 16:58:10 /kernel: fdc0: cmd 8 failed at out byte 1 of 1 Apr 16 16:58:10 /kernel: fdc0: sense intr err reading stat reg 0 Apr 16 16:58:10 /kernel: fdc0: direction bit not set Apr 16 16:58:10 /kernel: fdc0: cmd 7 failed at out byte 1 of 2 Apr 16 16:58:10 /kernel: fdc0: direction bit not set Apr 16 16:58:10 /kernel: fdc0: cmd 3 failed at out byte 1 of 3 Apr 16 16:58:10 /kernel: fdc0: direction bit not set Apr 16 16:58:10 /kernel: fdc0: cmd 13 failed at out byte 1 of 4 Apr 16 16:58:10 /kernel: fdc0: too many errors, not logging any more I read src/sys/isa/fd.c and found out it was an ancient bug. Here is a patch against 4.5-STABLE. Please note that 5.0-CURRENT has the same problem. I will post the patch soon. JK --------------010401080706050603080500 Content-Type: text/plain; name="fd.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fd.diff" --- sys/isa/fd.c.old Fri Apr 5 07:37:04 2002 +++ sys/isa/fd.c Tue Apr 16 19:59:03 2002 @@ -424,13 +424,15 @@ return fdc_err(fdc, "Enable FIFO failed\n"); /* If command is invalid, return */ - j = 100000; + j = FDSTS_TIMEOUT; while ((i = fdsts_rd(fdc) & (NE7_DIO | NE7_RQM)) - != NE7_RQM && j-- > 0) + != NE7_RQM && j-- > 0) { if (i == (NE7_DIO | NE7_RQM)) { fdc_reset(fdc); return FD_FAILED; } + DELAY(1); + } if (j<0 || fd_cmd(fdc, 3, 0, (fifo_threshold - 1) & 0xf, 0, 0) < 0) { @@ -1296,11 +1298,13 @@ int in_fdc(struct fdc_data *fdc) { - int i, j = 100000; + int i, j = FDSTS_TIMEOUT; while ((i = fdsts_rd(fdc) & (NE7_DIO|NE7_RQM)) - != (NE7_DIO|NE7_RQM) && j-- > 0) + != (NE7_DIO|NE7_RQM) && j-- > 0) { if (i == NE7_RQM) return fdc_err(fdc, "ready for output in input\n"); + DELAY(1); + } if (j <= 0) return fdc_err(fdc, bootverbose? "input ready timeout\n": 0); #ifdef FDC_DEBUG @@ -1318,11 +1322,13 @@ static int fd_in(struct fdc_data *fdc, int *ptr) { - int i, j = 100000; + int i, j = FDSTS_TIMEOUT; while ((i = fdsts_rd(fdc) & (NE7_DIO|NE7_RQM)) - != (NE7_DIO|NE7_RQM) && j-- > 0) + != (NE7_DIO|NE7_RQM) && j-- > 0) { if (i == NE7_RQM) return fdc_err(fdc, "ready for output in input\n"); + DELAY(1); + } if (j <= 0) return fdc_err(fdc, bootverbose? "input ready timeout\n": 0); #ifdef FDC_DEBUG @@ -1344,13 +1350,15 @@ int i; /* Check that the direction bit is set */ - i = 100000; - while ((fdsts_rd(fdc) & NE7_DIO) && i-- > 0); + i = FDSTS_TIMEOUT; + while ((fdsts_rd(fdc) & NE7_DIO) && i-- > 0) + DELAY(1); if (i <= 0) return fdc_err(fdc, "direction bit not set\n"); /* Check that the floppy controller is ready for a command */ - i = 100000; - while ((fdsts_rd(fdc) & NE7_RQM) == 0 && i-- > 0); + i = FDSTS_TIMEOUT; + while ((fdsts_rd(fdc) & NE7_RQM) == 0 && i-- > 0) + DELAY(1); if (i <= 0) return fdc_err(fdc, bootverbose? "output ready timeout\n": 0); --- sys/isa/fdreg.h.old Thu Jan 6 02:13:54 2000 +++ sys/isa/fdreg.h Tue Apr 16 19:54:28 2002 @@ -72,3 +72,4 @@ #define FDI_DCHG 0x80 /* diskette has been changed */ /* requires drive and motor being selected */ /* is cleared by any step pulse to drive */ +#define FDSTS_TIMEOUT 200 /* fdsts_rd() timeout */ --------------010401080706050603080500-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message