Re: Not enough memory when entering CLI

Stefan Hajnoczi <[email protected]> Sun, 18 Oct 2009 15:31:01 +0100
Newsgroups gmane.network.etherboot.user
Message-ID <[email protected]>
On Sat, Oct 17, 2009 at 12:52 PM, Itay Gazit <[email protected]> wrote:
> on some machines, when trying to enter CLI the drivers get stuck or even
> reboot the machine.

How much RAM do these machines have?

> How can we ensure the memory region reported by the BIOS are large enough to
> fit Mellanox devices?
> How can we ensure that umalloc command will fail when we ask for memory
> region which is out of range?

Do you get a clean error when running with the patch below?

(Build with "make DEBUG=mtnic bin/mtnic.usb" to see the debug output.)

Stefan

diff --git a/src/drivers/net/mtnic.c b/src/drivers/net/mtnic.c
index d7ee8d2..7b58698 100644
--- a/src/drivers/net/mtnic.c
+++ b/src/drivers/net/mtnic.c
@@ -544,6 +544,7 @@ out:
 static int
 mtnic_map_cmd(struct mtnic *mtnic, u16 op, struct mtnic_pages pages)
 {
+	userptr_t ubuf;
 	unsigned int j;
 	u32 addr;
 	unsigned int len;
@@ -553,8 +554,15 @@ mtnic_map_cmd(struct mtnic *mtnic, u16 op, struct
mtnic_pages pages)

 	memset(page_arr, 0, PAGE_SIZE);

+	ubuf = umalloc(PAGE_SIZE * (pages.num + 1));
+	if (ubuf == UNULL) {
+		DBG("MTNIC %p umalloc of 0x%x bytes failed\n",
+		    mtnic, PAGE_SIZE * (pages.num + 1));
+		return -ENOMEM;
+	}
+
 	len = PAGE_SIZE * pages.num;
-	pages.buf = (u32 *)umalloc(PAGE_SIZE * (pages.num + 1));
+	pages.buf = (u32 *)ubuf;
 	addr = PAGE_SIZE + ((virt_to_bus(pages.buf) & 0xfffff000) + PAGE_SIZE);
 	DBG("Mapping pages: size: %x address: %p\n", pages.num, pages.buf);

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference