aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/netlogic
diff options
context:
space:
mode:
authorJayachandran C <jchandra@broadcom.com>2015-01-07 06:28:33 -0500
committerRalf Baechle <ralf@linux-mips.org>2015-04-01 11:21:52 -0400
commitb3b73ae62ca82744c92c1c2d49381add26d0a8bd (patch)
treed0549c052e82468cce62a13899fc69011cebb12e /arch/mips/netlogic
parentddba6833bbc5d0e1ed264ada2c00927c9f7cc11f (diff)
MIPS: Netlogic: Update function to read DRAM BARs
Change name of xlp_get_dram_map to nlm_get_dram_map to be consistent with the rest of the functions in the file. Pass the the size of the array 'dram_map' to the function, and ensure that it does not write past the end of the array. Signed-off-by: Jayachandran C <jchandra@broadcom.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/8892/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/netlogic')
-rw-r--r--arch/mips/netlogic/xlp/nlm_hal.c12
-rw-r--r--arch/mips/netlogic/xlp/setup.c2
2 files changed, 8 insertions, 6 deletions
diff --git a/arch/mips/netlogic/xlp/nlm_hal.c b/arch/mips/netlogic/xlp/nlm_hal.c
index b80d893da9ad..c6c31e3c0949 100644
--- a/arch/mips/netlogic/xlp/nlm_hal.c
+++ b/arch/mips/netlogic/xlp/nlm_hal.c
@@ -449,19 +449,21 @@ unsigned int nlm_get_cpu_frequency(void)
449 449
450/* 450/*
451 * Fills upto 8 pairs of entries containing the DRAM map of a node 451 * Fills upto 8 pairs of entries containing the DRAM map of a node
452 * if n < 0, get dram map for all nodes 452 * if node < 0, get dram map for all nodes
453 */ 453 */
454int xlp_get_dram_map(int n, uint64_t *dram_map) 454int nlm_get_dram_map(int node, uint64_t *dram_map, int nentries)
455{ 455{
456 uint64_t bridgebase, base, lim; 456 uint64_t bridgebase, base, lim;
457 uint32_t val; 457 uint32_t val;
458 unsigned int barreg, limreg, xlatreg; 458 unsigned int barreg, limreg, xlatreg;
459 int i, node, rv; 459 int i, n, rv;
460 460
461 /* Look only at mapping on Node 0, we don't handle crazy configs */ 461 /* Look only at mapping on Node 0, we don't handle crazy configs */
462 bridgebase = nlm_get_bridge_regbase(0); 462 bridgebase = nlm_get_bridge_regbase(0);
463 rv = 0; 463 rv = 0;
464 for (i = 0; i < 8; i++) { 464 for (i = 0; i < 8; i++) {
465 if (rv + 1 >= nentries)
466 break;
465 if (cpu_is_xlp9xx()) { 467 if (cpu_is_xlp9xx()) {
466 barreg = BRIDGE_9XX_DRAM_BAR(i); 468 barreg = BRIDGE_9XX_DRAM_BAR(i);
467 limreg = BRIDGE_9XX_DRAM_LIMIT(i); 469 limreg = BRIDGE_9XX_DRAM_LIMIT(i);
@@ -471,10 +473,10 @@ int xlp_get_dram_map(int n, uint64_t *dram_map)
471 limreg = BRIDGE_DRAM_LIMIT(i); 473 limreg = BRIDGE_DRAM_LIMIT(i);
472 xlatreg = BRIDGE_DRAM_NODE_TRANSLN(i); 474 xlatreg = BRIDGE_DRAM_NODE_TRANSLN(i);
473 } 475 }
474 if (n >= 0) { 476 if (node >= 0) {
475 /* node specified, get node mapping of BAR */ 477 /* node specified, get node mapping of BAR */
476 val = nlm_read_bridge_reg(bridgebase, xlatreg); 478 val = nlm_read_bridge_reg(bridgebase, xlatreg);
477 node = (val >> 1) & 0x3; 479 n = (val >> 1) & 0x3;
478 if (n != node) 480 if (n != node)
479 continue; 481 continue;
480 } 482 }
diff --git a/arch/mips/netlogic/xlp/setup.c b/arch/mips/netlogic/xlp/setup.c
index 27113a17f18d..f743fd9da323 100644
--- a/arch/mips/netlogic/xlp/setup.c
+++ b/arch/mips/netlogic/xlp/setup.c
@@ -81,7 +81,7 @@ static void __init xlp_init_mem_from_bars(void)
81 uint64_t map[16]; 81 uint64_t map[16];
82 int i, n; 82 int i, n;
83 83
84 n = xlp_get_dram_map(-1, map); /* -1: info for all nodes */ 84 n = nlm_get_dram_map(-1, map, ARRAY_SIZE(map)); /* -1 : all nodes */
85 for (i = 0; i < n; i += 2) { 85 for (i = 0; i < n; i += 2) {
86 /* exclude 0x1000_0000-0x2000_0000, u-boot device */ 86 /* exclude 0x1000_0000-0x2000_0000, u-boot device */
87 if (map[i] <= 0x10000000 && map[i+1] > 0x10000000) 87 if (map[i] <= 0x10000000 && map[i+1] > 0x10000000)