Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 Nov 2000 19:16:31 +0100 (CET)
From:      tegge@trondheim.fast.no
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   i386/22944: isa_dmainit fails on machines with 512MB memory or more
Message-ID:  <200011181816.eAIIGVH00724@not.trondheim.fast.no>

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

>Number:         22944
>Category:       i386
>Synopsis:       isa_dmainit fails on machines with 512MB memory or more
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Nov 18 10:20:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Tor Egge
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
Fast Search & Transfer ASA
>Environment:
System: FreeBSD not.trondheim.fast.no 5.0-CURRENT FreeBSD 5.0-CURRENT #9: Sat Nov 18 18:29:33 CET 2000 root@not.trondheim.fast.no:/usr/src/sys/compile/NOT_SMP i386

>Description:

On machines with lots of memory (>= 512 MB), all of the ISA memory might be
allocated before the device probes has completed.  This causes ISA devices to
fail during DMA buffer allocation:

 isa_probe_children: probing non-PnP devices
 fdc0: <NEC 72065B or clone> at port 0x3f0-0x3f5,0x3f7 irq 6 drq 2 on isa0
 isa_dmainit(2, 1024) failed
 fdc0: FIFO enabled, 8 bytes threshold
 fd0: <1440-KB 3.5" drive> on fdc0 drive 0

The ISA memory has been used by

	kernel text, data, bss
	arrays allocated by vm_page_startup()
	memory allocated via kmem_alloc()
	memory allocated via malloc() with M_ZERO

Printing the number of free ISA memory pages at the end of vm_mem_init() showed
that with 512 MB memory and a standard kernel, only 165 pages were available at
that time.  Later during probing, the floppy driver failed to allocate ISA
memory.

Attempts to access the floppy device causes an instant panic:

not# dd if=/dev/rfd0a of=/dev/null bs=512 count=1
panic: isa_dmastart: bad bounce buffer

syncing disks... 1 1 

>How-To-Repeat:

Use the floppy device on a -current machine with 512 MB or more memory.

>Fix:

Ensure that the largest memory region described by phys_avail[] doesn't
contain the ISA memory.  This increases the number of free ISA pages 
at end of vm_mem_init() from 165 to 2341.

Change vm_add_new_page to alternate between adding to the head and the
tail of the page queues.  This further increases the number of free ISA 
pages at end of vm_mem_init() from 2341 to 2789.

Index: sys/i386/i386/machdep.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/i386/machdep.c,v
retrieving revision 1.420
diff -u -r1.420 machdep.c
--- sys/i386/i386/machdep.c	2000/10/27 11:45:23	1.420
+++ sys/i386/i386/machdep.c	2000/11/18 18:09:15
@@ -120,6 +120,8 @@
 #include <sys/ptrace.h>
 #include <machine/sigframe.h>
 
+#include	"isa.h"
+
 extern void init386 __P((int first));
 extern void dblfault_handler __P((void));
 
@@ -1807,6 +1811,31 @@
 	phys_avail[pa_indx] -= round_page(MSGBUF_SIZE);
 
 	avail_end = phys_avail[pa_indx];
+
+#if NISA > 0
+#define ISA_MEM_END (16 * 1024 * 1024)
+#define ISA_MEM_CONSERVELIM (128 * 1024 * 1024)
+	if (pa_indx + 2 < PHYS_AVAIL_ARRAY_END) {
+		for (i = pa_indx; i >= 1; i -= 2)
+			if (phys_avail[i - 1] < ISA_MEM_END &&
+			    phys_avail[i] > ISA_MEM_CONSERVELIM)
+				break;
+		if (i >= 1) {
+			phys_avail[pa_indx + 4] = 0;
+			phys_avail[pa_indx + 3] = 0;
+			for (i = pa_indx; i >= 1; i-= 2) {
+				phys_avail[i + 2] = phys_avail[i];
+				phys_avail[i + 1] = phys_avail[i -1];
+				if (phys_avail[i - 1] < ISA_MEM_END &&
+				    phys_avail[i] > ISA_MEM_CONSERVELIM) {
+					phys_avail[i + 1] = ISA_MEM_END;
+					phys_avail[i] = ISA_MEM_END;
+					break;
+				}
+			}
+		}
+	}
+#endif
 }
 
 void
@@ -1943,7 +1972,6 @@
 	 */
 	cninit();
 
-#include	"isa.h"
 #if	NISA >0
 	isa_defaultirq();
 #endif
Index: sys/vm/vm_page.c
===================================================================
RCS file: /home/ncvs/src/sys/vm/vm_page.c,v
retrieving revision 1.153
diff -u -r1.153 vm_page.c
--- sys/vm/vm_page.c	2000/07/04 04:32:40	1.153
+++ sys/vm/vm_page.c	2000/11/18 17:29:30
@@ -161,7 +163,10 @@
 	m->flags = 0;
 	m->pc = (pa >> PAGE_SHIFT) & PQ_L2_MASK;
 	m->queue = m->pc + PQ_FREE;
-	TAILQ_INSERT_HEAD(&vm_page_queues[m->queue].pl, m, pageq);
+	if (((pa >> PAGE_SHIFT) & 1) == 0)
+		TAILQ_INSERT_HEAD(&vm_page_queues[m->queue].pl, m, pageq);
+	else
+		TAILQ_INSERT_TAIL(&vm_page_queues[m->queue].pl, m, pageq);
 	vm_page_queues[m->queue].lcnt++;
 	return (m);
 }

>Release-Note:
>Audit-Trail:
>Unformatted:


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




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