summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmallett <jmallett@FreeBSD.org>2010-12-28 20:11:54 +0000
committerjmallett <jmallett@FreeBSD.org>2010-12-28 20:11:54 +0000
commitd9307a36882c75778990b4beb48298aedd14382c (patch)
tree901b7ec5ba6ecbb3780770176bb73c7a581b6a25
parent99000f187883986c4e077750c360c8cda6efbaa8 (diff)
downloadFreeBSD-src-d9307a36882c75778990b4beb48298aedd14382c.zip
FreeBSD-src-d9307a36882c75778990b4beb48298aedd14382c.tar.gz
When allocating memory from bootmem for the kernel to use, try to leave about
2MB of memory in the bootmem allocator for the SDK to use internally at a later point. It'd be nice if there were some functions we could call before allocating memory to let various facilities reserve some memory, but for now this seems sufficient. Previously some unfortunate systems could give up all (or at least most) of their memory to the kernel from bootmem, and then allocating command queues for packet output and the like would fail later in the boot process (which in turn would lead to crashes even later.) Reported by: kan
-rw-r--r--sys/mips/cavium/octeon_machdep.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/mips/cavium/octeon_machdep.c b/sys/mips/cavium/octeon_machdep.c
index edb92af..43b9669 100644
--- a/sys/mips/cavium/octeon_machdep.c
+++ b/sys/mips/cavium/octeon_machdep.c
@@ -287,6 +287,14 @@ octeon_memory_init(void)
*/
i = 0;
while (i < PHYS_AVAIL_ENTRIES) {
+ /*
+ * If there is less than 2MB of memory available in 128-byte
+ * blocks, do not steal any more memory. We need to leave some
+ * memory for the command queues to be allocated out of.
+ */
+ if (cvmx_bootmem_available_mem(128) < 2 << 20)
+ break;
+
addr = cvmx_bootmem_phy_alloc(1 << 20, phys_end,
~(vm_paddr_t)0, PAGE_SIZE, 0);
if (addr == -1)
OpenPOWER on IntegriCloud