Skip to content

Commit c0de00b

Browse files
Thomas Bogendoerferpaulburton
authored andcommitted
MIPS: SGI-IP22/28: Use PROM for memory detection
EARLY_PRINTK uses ArcWrite (via prom_putchar) on IP22/28, which needs to not mess up PROMs data structures. ARC PROM gives out a list of memory chunks, which are used and which are free. This fixes the problem of not working early printk. By using XKPHYS spaces more than 256MB memory on Indigo2 R4k machines is working now, too. Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de> Signed-off-by: Paul Burton <paul.burton@mips.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: James Hogan <jhogan@kernel.org> Cc: linux-mips@vger.kernel.org Cc: linux-kernel@vger.kernel.org
1 parent 931e1bf commit c0de00b

5 files changed

Lines changed: 34 additions & 79 deletions

File tree

‎arch/mips/Kconfig‎

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ config RALINK
634634

635635
config SGI_IP22
636636
bool "SGI IP22 (Indy/Indigo2)"
637+
select ARC_MEMORY
637638
select ARC_PROMLIB
638639
select FW_ARC
639640
select FW_ARC32
@@ -658,14 +659,7 @@ config SGI_IP22
658659
select SWAP_IO_SPACE
659660
select SYS_HAS_CPU_R4X00
660661
select SYS_HAS_CPU_R5000
661-
#
662-
# Disable EARLY_PRINTK for now since it leads to overwritten prom
663-
# memory during early boot on some machines.
664-
#
665-
# See http://www.linux-mips.org/cgi-bin/mesg.cgi?a=linux-mips&i=20091119164009.GA15038%40deprecation.cyrius.com
666-
# for a more details discussion
667-
#
668-
# select SYS_HAS_EARLY_PRINTK
662+
select SYS_HAS_EARLY_PRINTK
669663
select SYS_SUPPORTS_32BIT_KERNEL
670664
select SYS_SUPPORTS_64BIT_KERNEL
671665
select SYS_SUPPORTS_BIG_ENDIAN
@@ -703,6 +697,7 @@ config SGI_IP27
703697

704698
config SGI_IP28
705699
bool "SGI IP28 (Indigo2 R10k)"
700+
select ARC_MEMORY
706701
select ARC_PROMLIB
707702
select FW_ARC
708703
select FW_ARC64
@@ -725,14 +720,7 @@ config SGI_IP28
725720
select SGI_HAS_ZILOG
726721
select SWAP_IO_SPACE
727722
select SYS_HAS_CPU_R10000
728-
#
729-
# Disable EARLY_PRINTK for now since it leads to overwritten prom
730-
# memory during early boot on some machines.
731-
#
732-
# See http://www.linux-mips.org/cgi-bin/mesg.cgi?a=linux-mips&i=20091119164009.GA15038%40deprecation.cyrius.com
733-
# for a more details discussion
734-
#
735-
# select SYS_HAS_EARLY_PRINTK
723+
select SYS_HAS_EARLY_PRINTK
736724
select SYS_SUPPORTS_64BIT_KERNEL
737725
select SYS_SUPPORTS_BIG_ENDIAN
738726
select MIPS_L1_CACHE_SHIFT_7

‎arch/mips/fw/arc/memory.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ void __init prom_meminit(void)
158158
}
159159
}
160160

161+
void __weak __init prom_cleanup(void)
162+
{
163+
}
164+
161165
void __init prom_free_prom_memory(void)
162166
{
163167
int i;
@@ -169,4 +173,9 @@ void __init prom_free_prom_memory(void)
169173
free_init_pages("prom memory",
170174
prom_mem_base[i], prom_mem_base[i] + prom_mem_size[i]);
171175
}
176+
/*
177+
* at this point it isn't safe to call PROM functions
178+
* give platforms a way to do PROM cleanups
179+
*/
180+
prom_cleanup();
172181
}

‎arch/mips/include/asm/bootinfo.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ extern void detect_memory_region(phys_addr_t start, phys_addr_t sz_min, phys_ad
9999

100100
extern void prom_init(void);
101101
extern void prom_free_prom_memory(void);
102+
extern void prom_cleanup(void);
102103

103104
extern void free_init_pages(const char *what,
104105
unsigned long begin, unsigned long end);

‎arch/mips/include/asm/mach-ip22/spaces.h‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@
1212

1313
#define PHYS_OFFSET _AC(0x08000000, UL)
1414

15-
#ifdef CONFIG_64BIT
16-
17-
#define CAC_BASE 0xffffffff80000000
18-
#define IO_BASE 0xffffffffa0000000
19-
#define UNCAC_BASE 0xffffffffa0000000
20-
#define MAP_BASE 0xc000000000000000
21-
22-
#endif /* CONFIG_64BIT */
23-
2415
#include <asm/mach-generic/spaces.h>
2516

2617
#endif /* __ASM_MACH_IP22_SPACES_H */

‎arch/mips/sgi-ip22/ip22-mc.c‎

Lines changed: 20 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/init.h>
1212
#include <linux/export.h>
1313
#include <linux/kernel.h>
14+
#include <linux/memblock.h>
1415
#include <linux/spinlock.h>
1516

1617
#include <asm/io.h>
@@ -40,70 +41,36 @@ static inline unsigned int get_bank_config(int bank)
4041
return bank % 2 ? res & 0xffff : res >> 16;
4142
}
4243

43-
struct mem {
44-
unsigned long addr;
45-
unsigned long size;
46-
};
47-
44+
#if defined(CONFIG_SGI_IP28) || defined(CONFIG_32BIT)
45+
static void __init probe_memory(void)
46+
{
47+
/* prom detects all usable memory */
48+
}
49+
#else
4850
/*
49-
* Detect installed memory, do some sanity checks and notify kernel about it
51+
* Detect installed memory, which PROM misses
5052
*/
5153
static void __init probe_memory(void)
5254
{
53-
int i, j, found, cnt = 0;
54-
struct mem bank[4];
55-
struct mem space[2] = {{SGIMC_SEG0_BADDR, 0}, {SGIMC_SEG1_BADDR, 0}};
55+
unsigned long addr, size;
56+
int i;
5657

5758
printk(KERN_INFO "MC: Probing memory configuration:\n");
58-
for (i = 0; i < ARRAY_SIZE(bank); i++) {
59+
for (i = 0; i < 4; i++) {
5960
unsigned int tmp = get_bank_config(i);
6061
if (!(tmp & SGIMC_MCONFIG_BVALID))
6162
continue;
6263

63-
bank[cnt].size = get_bank_size(tmp);
64-
bank[cnt].addr = get_bank_addr(tmp);
64+
size = get_bank_size(tmp);
65+
addr = get_bank_addr(tmp);
6566
printk(KERN_INFO " bank%d: %3ldM @ %08lx\n",
66-
i, bank[cnt].size / 1024 / 1024, bank[cnt].addr);
67-
cnt++;
68-
}
67+
i, size / 1024 / 1024, addr);
6968

70-
/* And you thought bubble sort is dead algorithm... */
71-
do {
72-
unsigned long addr, size;
73-
74-
found = 0;
75-
for (i = 1; i < cnt; i++)
76-
if (bank[i-1].addr > bank[i].addr) {
77-
addr = bank[i].addr;
78-
size = bank[i].size;
79-
bank[i].addr = bank[i-1].addr;
80-
bank[i].size = bank[i-1].size;
81-
bank[i-1].addr = addr;
82-
bank[i-1].size = size;
83-
found = 1;
84-
}
85-
} while (found);
86-
87-
/* Figure out how are memory banks mapped into spaces */
88-
for (i = 0; i < cnt; i++) {
89-
found = 0;
90-
for (j = 0; j < ARRAY_SIZE(space) && !found; j++)
91-
if (space[j].addr + space[j].size == bank[i].addr) {
92-
space[j].size += bank[i].size;
93-
found = 1;
94-
}
95-
/* There is either hole or overlapping memory */
96-
if (!found)
97-
printk(KERN_CRIT "MC: Memory configuration mismatch "
98-
"(%08lx), expect Bus Error soon\n",
99-
bank[i].addr);
69+
if (addr >= SGIMC_SEG1_BADDR)
70+
memblock_add(addr, size);
10071
}
101-
102-
for (i = 0; i < ARRAY_SIZE(space); i++)
103-
if (space[i].size)
104-
add_memory_region(space[i].addr, space[i].size,
105-
BOOT_MEM_RAM);
10672
}
73+
#endif
10774

10875
void __init sgimc_init(void)
10976
{
@@ -205,10 +172,9 @@ void __init sgimc_init(void)
205172
probe_memory();
206173
}
207174

208-
void __init prom_meminit(void) {}
209-
void __init prom_free_prom_memory(void)
210-
{
211175
#ifdef CONFIG_SGI_IP28
176+
void __init prom_cleanup(void)
177+
{
212178
u32 mconfig1;
213179
unsigned long flags;
214180
spinlock_t lock;
@@ -233,5 +199,5 @@ void __init prom_free_prom_memory(void)
233199
sgimc->mconfig1 = mconfig1;
234200
iob();
235201
spin_unlock_irqrestore(&lock, flags);
236-
#endif
237202
}
203+
#endif

0 commit comments

Comments
 (0)