linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Chandru <chandru@in.ibm.com>
To: linuxppc-dev@ozlabs.org
Subject: Re: [RFC][PATCH] powerpc: add usable-memory property to drconf memory
Date: Fri, 13 Jun 2008 16:42:17 +0530	[thread overview]
Message-ID: <200806131642.17532.chandru@in.ibm.com> (raw)
In-Reply-To: <200806131451.39467.chandru@in.ibm.com>

On Friday 13 June 2008 14:51:39 Chandru wrote:
> kexec-tools in user space collects rtas, crash , tce region ranges
> from /proc/device-tree/ and passes them as linux,usable-memory properties
> to second/kdump kernel in the device tree buffer. With drconf memory in
> power6 machines, we need a similar method to preserve those regions in the
> kdump kernel.  This patch adopts a method to append the number 'n' from
> n'th lmb entry in ibm,dynamic-memory as a string to "linux,usable-memory"
> string , so as to distinguish each usable-memory region and it's size. 
> Another place that needs similar change but not included in this patch is
> in
> arch/powerpc/mm/numa.c.

The previous patch had  two missing lines. Hence sending it again. Sorry about 
this  :(.

Signed-off-by: Chandru S <chandru@in.ibm.com>
---


--- arch/powerpc/kernel/prom.c.orig	2008-06-13 11:42:45.000000000 +0530
+++ arch/powerpc/kernel/prom.c	2008-06-13 16:21:04.000000000 +0530
@@ -884,20 +884,22 @@ static u64 __init dt_mem_next_cell(int s
  */
 static int __init early_init_dt_scan_drconf_memory(unsigned long node)
 {
-	cell_t *dm, *ls;
-	unsigned long l, n, flags;
+	cell_t *dm, *ls, *udm, *reg, *endp;
+	unsigned long l, n, un, flags;
 	u64 base, size, lmb_size;
+	char buf[64], t[8];
 
 	ls = (cell_t *)of_get_flat_dt_prop(node, "ibm,lmb-size", &l);
 	if (ls == NULL || l < dt_root_size_cells * sizeof(cell_t))
 		return 0;
 	lmb_size = dt_mem_next_cell(dt_root_size_cells, &ls);
 
-	dm = (cell_t *)of_get_flat_dt_prop(node, "ibm,dynamic-memory", &l);
+	udm = dm = (cell_t *)of_get_flat_dt_prop(node,
+						"ibm,dynamic-memory", &l);
 	if (dm == NULL || l < sizeof(cell_t))
 		return 0;
 
-	n = *dm++;	/* number of entries */
+	un = n = *dm++;	/* number of entries */
 	if (l < (n * (dt_root_addr_cells + 4) + 1) * sizeof(cell_t))
 		return 0;
 
@@ -919,6 +921,41 @@ static int __init early_init_dt_scan_drc
 		}
 		lmb_add(base, size);
 	}
+
+	/* Scan usable-memory properties */
+	for (; un != 0; --un) {
+		base = dt_mem_next_cell(dt_root_addr_cells, &udm);
+		flags = dm[3];
+		udm += 4;
+		if ((flags & 0x80) || !(flags & 0x8))
+			continue;
+		strcpy(buf, "linux,usable-memory");
+		sprintf(t, "%d", (int)un);
+		strcat(buf, t);
+		reg = (cell_t *)of_get_flat_dt_prop(node,
+					(const char *)buf, &l);
+		if (reg == NULL)
+			continue;
+		/* remove the previously added lmb */
+		lmb_remove(base, (base+lmb_size));
+		endp = reg + (l / sizeof(cell_t));
+		while ((endp - reg) >= (dt_root_addr_cells +
+						dt_root_size_cells)) {
+
+			base = dt_mem_next_cell(dt_root_addr_cells, &reg);
+			size = dt_mem_next_cell(dt_root_size_cells, &reg);
+
+			if (size == 0)
+				continue;
+			if (iommu_is_off) {
+				if (base >= 0x80000000ul)
+					continue;
+				if ((base + size) > 0x80000000ul)
+					size = 0x80000000ul - base;
+			}
+			lmb_add(base, size);
+		}
+	}
 	lmb_dump_all();
 	return 0;
 }

      reply	other threads:[~2008-06-13 11:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-13  9:21 [RFC][PATCH] powerpc: add usable-memory property to drconf memory Chandru
2008-06-13 11:12 ` Chandru [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200806131642.17532.chandru@in.ibm.com \
    --to=chandru@in.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).