Skip to content

Commit b8503b2

Browse files
committed
Merge tag 'mips-fixes_6.7_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux
Pull MIPS fixes from Thomas Bogendoerfer: - Fixes for broken Loongson firmware - Fix lockdep splat - Fix FPU states when creating kernel threads * tag 'mips-fixes_6.7_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux: MIPS: kernel: Clear FPU states when setting up kernel threads MIPS: Loongson64: Handle more memory types passed from firmware MIPS: Loongson64: Enable DMA noncoherent support MIPS: Loongson64: Reserve vgabios memory on boot mips/smp: Call rcutree_report_cpu_starting() earlier
2 parents 9d3bc45 + a58a173 commit b8503b2

File tree

6 files changed

+64
-33
lines changed

6 files changed

+64
-33
lines changed

arch/mips/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ config MACH_LOONGSON2EF
460460

461461
config MACH_LOONGSON64
462462
bool "Loongson 64-bit family of machines"
463+
select ARCH_DMA_DEFAULT_COHERENT
463464
select ARCH_SPARSEMEM_ENABLE
464465
select ARCH_MIGHT_HAVE_PC_PARPORT
465466
select ARCH_MIGHT_HAVE_PC_SERIO
@@ -1251,6 +1252,7 @@ config CPU_LOONGSON64
12511252
select CPU_SUPPORTS_MSA
12521253
select CPU_DIEI_BROKEN if !LOONGSON3_ENHANCEMENT
12531254
select CPU_MIPSR2_IRQ_VI
1255+
select DMA_NONCOHERENT
12541256
select WEAK_ORDERING
12551257
select WEAK_REORDERING_BEYOND_LLSC
12561258
select MIPS_ASID_BITS_VARIABLE

arch/mips/include/asm/mach-loongson64/boot_param.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
#define ADAPTER_ROM 8
1515
#define ACPI_TABLE 9
1616
#define SMBIOS_TABLE 10
17-
#define MAX_MEMORY_TYPE 11
17+
#define UMA_VIDEO_RAM 11
18+
#define VUMA_VIDEO_RAM 12
19+
#define MAX_MEMORY_TYPE 13
20+
21+
#define MEM_SIZE_IS_IN_BYTES (1 << 31)
1822

1923
#define LOONGSON3_BOOT_MEM_MAP_MAX 128
2024
struct efi_memory_map_loongson {
@@ -117,7 +121,8 @@ struct irq_source_routing_table {
117121
u64 pci_io_start_addr;
118122
u64 pci_io_end_addr;
119123
u64 pci_config_addr;
120-
u32 dma_mask_bits;
124+
u16 dma_mask_bits;
125+
u16 dma_noncoherent;
121126
} __packed;
122127

123128
struct interface_info {

arch/mips/kernel/process.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,19 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
121121
/* Put the stack after the struct pt_regs. */
122122
childksp = (unsigned long) childregs;
123123
p->thread.cp0_status = (read_c0_status() & ~(ST0_CU2|ST0_CU1)) | ST0_KERNEL_CUMASK;
124+
125+
/*
126+
* New tasks lose permission to use the fpu. This accelerates context
127+
* switching for most programs since they don't use the fpu.
128+
*/
129+
clear_tsk_thread_flag(p, TIF_USEDFPU);
130+
clear_tsk_thread_flag(p, TIF_USEDMSA);
131+
clear_tsk_thread_flag(p, TIF_MSA_CTX_LIVE);
132+
133+
#ifdef CONFIG_MIPS_MT_FPAFF
134+
clear_tsk_thread_flag(p, TIF_FPUBOUND);
135+
#endif /* CONFIG_MIPS_MT_FPAFF */
136+
124137
if (unlikely(args->fn)) {
125138
/* kernel thread */
126139
unsigned long status = p->thread.cp0_status;
@@ -149,20 +162,8 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
149162
p->thread.reg29 = (unsigned long) childregs;
150163
p->thread.reg31 = (unsigned long) ret_from_fork;
151164

152-
/*
153-
* New tasks lose permission to use the fpu. This accelerates context
154-
* switching for most programs since they don't use the fpu.
155-
*/
156165
childregs->cp0_status &= ~(ST0_CU2|ST0_CU1);
157166

158-
clear_tsk_thread_flag(p, TIF_USEDFPU);
159-
clear_tsk_thread_flag(p, TIF_USEDMSA);
160-
clear_tsk_thread_flag(p, TIF_MSA_CTX_LIVE);
161-
162-
#ifdef CONFIG_MIPS_MT_FPAFF
163-
clear_tsk_thread_flag(p, TIF_FPUBOUND);
164-
#endif /* CONFIG_MIPS_MT_FPAFF */
165-
166167
#ifdef CONFIG_MIPS_FP_SUPPORT
167168
atomic_set(&p->thread.bd_emu_frame, BD_EMUFRAME_NONE);
168169
#endif

arch/mips/kernel/smp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,11 @@ early_initcall(mips_smp_ipi_init);
351351
*/
352352
asmlinkage void start_secondary(void)
353353
{
354-
unsigned int cpu;
354+
unsigned int cpu = raw_smp_processor_id();
355355

356356
cpu_probe();
357357
per_cpu_trap_init(false);
358+
rcutree_report_cpu_starting(cpu);
358359
mips_clockevent_init();
359360
mp_ops->init_secondary();
360361
cpu_report();
@@ -366,7 +367,6 @@ asmlinkage void start_secondary(void)
366367
*/
367368

368369
calibrate_delay();
369-
cpu = smp_processor_id();
370370
cpu_data[cpu].udelay_val = loops_per_jiffy;
371371

372372
set_cpu_sibling_map(cpu);

arch/mips/loongson64/env.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* Copyright (C) 2009 Lemote Inc.
1414
* Author: Wu Zhangjin, [email protected]
1515
*/
16+
17+
#include <linux/dma-map-ops.h>
1618
#include <linux/export.h>
1719
#include <linux/pci_ids.h>
1820
#include <asm/bootinfo.h>
@@ -147,8 +149,14 @@ void __init prom_lefi_init_env(void)
147149

148150
loongson_sysconf.dma_mask_bits = eirq_source->dma_mask_bits;
149151
if (loongson_sysconf.dma_mask_bits < 32 ||
150-
loongson_sysconf.dma_mask_bits > 64)
152+
loongson_sysconf.dma_mask_bits > 64) {
151153
loongson_sysconf.dma_mask_bits = 32;
154+
dma_default_coherent = true;
155+
} else {
156+
dma_default_coherent = !eirq_source->dma_noncoherent;
157+
}
158+
159+
pr_info("Firmware: Coherent DMA: %s\n", dma_default_coherent ? "on" : "off");
152160

153161
loongson_sysconf.restart_addr = boot_p->reset_system.ResetWarm;
154162
loongson_sysconf.poweroff_addr = boot_p->reset_system.Shutdown;

arch/mips/loongson64/init.c

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ void virtual_early_config(void)
4949
void __init szmem(unsigned int node)
5050
{
5151
u32 i, mem_type;
52-
static unsigned long num_physpages;
53-
u64 node_id, node_psize, start_pfn, end_pfn, mem_start, mem_size;
52+
phys_addr_t node_id, mem_start, mem_size;
5453

5554
/* Otherwise come from DTB */
5655
if (loongson_sysconf.fw_interface != LOONGSON_LEFI)
@@ -64,30 +63,46 @@ void __init szmem(unsigned int node)
6463

6564
mem_type = loongson_memmap->map[i].mem_type;
6665
mem_size = loongson_memmap->map[i].mem_size;
67-
mem_start = loongson_memmap->map[i].mem_start;
66+
67+
/* Memory size comes in MB if MEM_SIZE_IS_IN_BYTES not set */
68+
if (mem_size & MEM_SIZE_IS_IN_BYTES)
69+
mem_size &= ~MEM_SIZE_IS_IN_BYTES;
70+
else
71+
mem_size = mem_size << 20;
72+
73+
mem_start = (node_id << 44) | loongson_memmap->map[i].mem_start;
6874

6975
switch (mem_type) {
7076
case SYSTEM_RAM_LOW:
7177
case SYSTEM_RAM_HIGH:
72-
start_pfn = ((node_id << 44) + mem_start) >> PAGE_SHIFT;
73-
node_psize = (mem_size << 20) >> PAGE_SHIFT;
74-
end_pfn = start_pfn + node_psize;
75-
num_physpages += node_psize;
76-
pr_info("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx MB\n",
77-
(u32)node_id, mem_type, mem_start, mem_size);
78-
pr_info(" start_pfn:0x%llx, end_pfn:0x%llx, num_physpages:0x%lx\n",
79-
start_pfn, end_pfn, num_physpages);
80-
memblock_add_node(PFN_PHYS(start_pfn),
81-
PFN_PHYS(node_psize), node,
78+
case UMA_VIDEO_RAM:
79+
pr_info("Node %d, mem_type:%d\t[%pa], %pa bytes usable\n",
80+
(u32)node_id, mem_type, &mem_start, &mem_size);
81+
memblock_add_node(mem_start, mem_size, node,
8282
MEMBLOCK_NONE);
8383
break;
8484
case SYSTEM_RAM_RESERVED:
85-
pr_info("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx MB\n",
86-
(u32)node_id, mem_type, mem_start, mem_size);
87-
memblock_reserve(((node_id << 44) + mem_start), mem_size << 20);
85+
case VIDEO_ROM:
86+
case ADAPTER_ROM:
87+
case ACPI_TABLE:
88+
case SMBIOS_TABLE:
89+
pr_info("Node %d, mem_type:%d\t[%pa], %pa bytes reserved\n",
90+
(u32)node_id, mem_type, &mem_start, &mem_size);
91+
memblock_reserve(mem_start, mem_size);
92+
break;
93+
/* We should not reserve VUMA_VIDEO_RAM as it overlaps with MMIO */
94+
case VUMA_VIDEO_RAM:
95+
default:
96+
pr_info("Node %d, mem_type:%d\t[%pa], %pa bytes unhandled\n",
97+
(u32)node_id, mem_type, &mem_start, &mem_size);
8898
break;
8999
}
90100
}
101+
102+
/* Reserve vgabios if it comes from firmware */
103+
if (loongson_sysconf.vgabios_addr)
104+
memblock_reserve(virt_to_phys((void *)loongson_sysconf.vgabios_addr),
105+
SZ_256K);
91106
}
92107

93108
#ifndef CONFIG_NUMA

0 commit comments

Comments
 (0)