Skip to content

Commit c2a65d3

Browse files
committed
Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus
Pull MIPS fixes from Ralf Baechle: "Three issues fixed accross the field: - Some functions that were recently outlined as part of a preemption fix were causing problems with function tracing. - The recently merged in-kernel MPI library uses very outdated headers that contain MIPS-specific code which won't build on with gcc 4.4 or newer. - The MIPS non-NUMA memory initialization was making only a very half-baked attempt at merging adjacent memory ranges. This kept the code simple enough but is now causing issues with kexec." * 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus: MPI: Fix compilation on MIPS with GCC 4.4 and newer MIPS: Fix crash that occurs when function tracing is enabled MIPS: Merge overlapping bootmem ranges
2 parents 194d983 + a3cea98 commit c2a65d3

File tree

3 files changed

+41
-12
lines changed

3 files changed

+41
-12
lines changed

arch/mips/kernel/setup.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static struct resource data_resource = { .name = "Kernel data", };
7979
void __init add_memory_region(phys_t start, phys_t size, long type)
8080
{
8181
int x = boot_mem_map.nr_map;
82-
struct boot_mem_map_entry *prev = boot_mem_map.map + x - 1;
82+
int i;
8383

8484
/* Sanity check */
8585
if (start + size < start) {
@@ -88,15 +88,29 @@ void __init add_memory_region(phys_t start, phys_t size, long type)
8888
}
8989

9090
/*
91-
* Try to merge with previous entry if any. This is far less than
92-
* perfect but is sufficient for most real world cases.
91+
* Try to merge with existing entry, if any.
9392
*/
94-
if (x && prev->addr + prev->size == start && prev->type == type) {
95-
prev->size += size;
93+
for (i = 0; i < boot_mem_map.nr_map; i++) {
94+
struct boot_mem_map_entry *entry = boot_mem_map.map + i;
95+
unsigned long top;
96+
97+
if (entry->type != type)
98+
continue;
99+
100+
if (start + size < entry->addr)
101+
continue; /* no overlap */
102+
103+
if (entry->addr + entry->size < start)
104+
continue; /* no overlap */
105+
106+
top = max(entry->addr + entry->size, start + size);
107+
entry->addr = min(entry->addr, start);
108+
entry->size = top - entry->addr;
109+
96110
return;
97111
}
98112

99-
if (x == BOOT_MEM_MAP_MAX) {
113+
if (boot_mem_map.nr_map == BOOT_MEM_MAP_MAX) {
100114
pr_err("Ooops! Too many entries in the memory map!\n");
101115
return;
102116
}

arch/mips/lib/mips-atomic.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ __asm__(
5656
" .set pop \n"
5757
" .endm \n");
5858

59-
void arch_local_irq_disable(void)
59+
notrace void arch_local_irq_disable(void)
6060
{
6161
preempt_disable();
6262
__asm__ __volatile__(
@@ -93,7 +93,7 @@ __asm__(
9393
" .set pop \n"
9494
" .endm \n");
9595

96-
unsigned long arch_local_irq_save(void)
96+
notrace unsigned long arch_local_irq_save(void)
9797
{
9898
unsigned long flags;
9999
preempt_disable();
@@ -135,7 +135,7 @@ __asm__(
135135
" .set pop \n"
136136
" .endm \n");
137137

138-
void arch_local_irq_restore(unsigned long flags)
138+
notrace void arch_local_irq_restore(unsigned long flags)
139139
{
140140
unsigned long __tmp1;
141141

@@ -159,7 +159,7 @@ void arch_local_irq_restore(unsigned long flags)
159159
EXPORT_SYMBOL(arch_local_irq_restore);
160160

161161

162-
void __arch_local_irq_restore(unsigned long flags)
162+
notrace void __arch_local_irq_restore(unsigned long flags)
163163
{
164164
unsigned long __tmp1;
165165

lib/mpi/longlong.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,14 @@ do { \
641641
************** MIPS *****************
642642
***************************************/
643643
#if defined(__mips__) && W_TYPE_SIZE == 32
644-
#if __GNUC__ > 2 || __GNUC_MINOR__ >= 7
644+
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4
645+
#define umul_ppmm(w1, w0, u, v) \
646+
do { \
647+
UDItype __ll = (UDItype)(u) * (v); \
648+
w1 = __ll >> 32; \
649+
w0 = __ll; \
650+
} while (0)
651+
#elif __GNUC__ > 2 || __GNUC_MINOR__ >= 7
645652
#define umul_ppmm(w1, w0, u, v) \
646653
__asm__ ("multu %2,%3" \
647654
: "=l" ((USItype)(w0)), \
@@ -666,7 +673,15 @@ do { \
666673
************** MIPS/64 **************
667674
***************************************/
668675
#if (defined(__mips) && __mips >= 3) && W_TYPE_SIZE == 64
669-
#if __GNUC__ > 2 || __GNUC_MINOR__ >= 7
676+
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4
677+
#define umul_ppmm(w1, w0, u, v) \
678+
do { \
679+
typedef unsigned int __ll_UTItype __attribute__((mode(TI))); \
680+
__ll_UTItype __ll = (__ll_UTItype)(u) * (v); \
681+
w1 = __ll >> 64; \
682+
w0 = __ll; \
683+
} while (0)
684+
#elif __GNUC__ > 2 || __GNUC_MINOR__ >= 7
670685
#define umul_ppmm(w1, w0, u, v) \
671686
__asm__ ("dmultu %2,%3" \
672687
: "=l" ((UDItype)(w0)), \

0 commit comments

Comments
 (0)