Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Loongson64: Switch to SYNC_R4K

Nowadays SYNC_R4K is performing better than Loongson64's
custom sync mechanism.

Switch to SYNC_R4K to improve performance and reduce code
duplication.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Jiaxun Yang and committed by
Thomas Bogendoerfer
fa165f91 bb2d6350

+3 -34
+1
arch/mips/Kconfig
··· 478 478 select BOARD_SCACHE 479 479 select CSRC_R4K 480 480 select CEVT_R4K 481 + select SYNC_R4K 481 482 select FORCE_PCI 482 483 select ISA 483 484 select I8259
-1
arch/mips/include/asm/smp.h
··· 50 50 #define SMP_CALL_FUNCTION 0x2 51 51 /* Octeon - Tell another core to flush its icache */ 52 52 #define SMP_ICACHE_FLUSH 0x4 53 - #define SMP_ASK_C0COUNT 0x8 54 53 55 54 /* Mask of CPUs which are currently definitely operating coherently */ 56 55 extern cpumask_t cpu_coherent_mask;
+2 -33
arch/mips/loongson64/smp.c
··· 33 33 static void __iomem *ipi_status0_regs[16]; 34 34 static void __iomem *ipi_en0_regs[16]; 35 35 static void __iomem *ipi_mailbox_buf[16]; 36 - static uint32_t core0_c0count[NR_CPUS]; 37 36 38 37 static u32 (*ipi_read_clear)(int cpu); 39 38 static void (*ipi_write_action)(int cpu, u32 action); ··· 381 382 ipi_write_action(cpu_logical_map(i), (u32)action); 382 383 } 383 384 384 - 385 385 static irqreturn_t loongson3_ipi_interrupt(int irq, void *dev_id) 386 386 { 387 - int i, cpu = smp_processor_id(); 388 - unsigned int action, c0count; 387 + int cpu = smp_processor_id(); 388 + unsigned int action; 389 389 390 390 action = ipi_read_clear(cpu); 391 391 ··· 397 399 irq_exit(); 398 400 } 399 401 400 - if (action & SMP_ASK_C0COUNT) { 401 - BUG_ON(cpu != 0); 402 - c0count = read_c0_count(); 403 - c0count = c0count ? c0count : 1; 404 - for (i = 1; i < nr_cpu_ids; i++) 405 - core0_c0count[i] = c0count; 406 - nudge_writes(); /* Let others see the result ASAP */ 407 - } 408 - 409 402 return IRQ_HANDLED; 410 403 } 411 404 412 - #define MAX_LOOPS 800 413 405 /* 414 406 * SMP init and finish on secondary CPUs 415 407 */ 416 408 static void loongson3_init_secondary(void) 417 409 { 418 - int i; 419 - uint32_t initcount; 420 410 unsigned int cpu = smp_processor_id(); 421 411 unsigned int imask = STATUSF_IP7 | STATUSF_IP6 | 422 412 STATUSF_IP3 | STATUSF_IP2; ··· 418 432 cpu_logical_map(cpu) % loongson_sysconf.cores_per_package); 419 433 cpu_data[cpu].package = 420 434 cpu_logical_map(cpu) / loongson_sysconf.cores_per_package; 421 - 422 - i = 0; 423 - core0_c0count[cpu] = 0; 424 - loongson3_send_ipi_single(0, SMP_ASK_C0COUNT); 425 - while (!core0_c0count[cpu]) { 426 - i++; 427 - cpu_relax(); 428 - } 429 - 430 - if (i > MAX_LOOPS) 431 - i = MAX_LOOPS; 432 - if (cpu_data[cpu].package) 433 - initcount = core0_c0count[cpu] + i; 434 - else /* Local access is faster for loops */ 435 - initcount = core0_c0count[cpu] + i/2; 436 - 437 - write_c0_count(initcount); 438 435 } 439 436 440 437 static void loongson3_smp_finish(void)