diff options
| author | Deng-Cheng Zhu <dengcheng.zhu@imgtec.com> | 2014-01-01 10:26:46 -0500 |
|---|---|---|
| committer | Ralf Baechle <ralf@linux-mips.org> | 2014-01-22 14:19:02 -0500 |
| commit | 2c973ef0cc3f981bfb137c3e42e08de5e8f1cc18 (patch) | |
| tree | 8f15ba20262f53e7465348db0581f16befb130db /arch/mips/kernel | |
| parent | 17a1d523aa5826dec25f2362e1630be365167bda (diff) | |
MIPS: APRP: Split RTLX support into separate files.
Split the RTLX functionality in preparation for adding support for CMP
platforms. Common functions remain in the original file and a new file
contains code specific to platforms that do not have a CMP.
Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
Patchwork: http://patchwork.linux-mips.org/patch/6093/
Reviewed-by: John Crispin <blogic@openwrt.org>
Diffstat (limited to 'arch/mips/kernel')
| -rw-r--r-- | arch/mips/kernel/Makefile | 1 | ||||
| -rw-r--r-- | arch/mips/kernel/rtlx-mt.c | 148 | ||||
| -rw-r--r-- | arch/mips/kernel/rtlx.c | 142 |
3 files changed, 159 insertions, 132 deletions
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile index e5a73568aa56..3de44d89a046 100644 --- a/arch/mips/kernel/Makefile +++ b/arch/mips/kernel/Makefile | |||
| @@ -59,6 +59,7 @@ obj-$(CONFIG_MIPS_VPE_LOADER) += vpe.o | |||
| 59 | obj-$(CONFIG_MIPS_VPE_LOADER_CMP) += vpe-cmp.o | 59 | obj-$(CONFIG_MIPS_VPE_LOADER_CMP) += vpe-cmp.o |
| 60 | obj-$(CONFIG_MIPS_VPE_LOADER_MT) += vpe-mt.o | 60 | obj-$(CONFIG_MIPS_VPE_LOADER_MT) += vpe-mt.o |
| 61 | obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o | 61 | obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o |
| 62 | obj-$(CONFIG_MIPS_VPE_APSP_API_MT) += rtlx-mt.o | ||
| 62 | 63 | ||
| 63 | obj-$(CONFIG_I8259) += i8259.o | 64 | obj-$(CONFIG_I8259) += i8259.o |
| 64 | obj-$(CONFIG_IRQ_CPU) += irq_cpu.o | 65 | obj-$(CONFIG_IRQ_CPU) += irq_cpu.o |
diff --git a/arch/mips/kernel/rtlx-mt.c b/arch/mips/kernel/rtlx-mt.c new file mode 100644 index 000000000000..91d61ba422b4 --- /dev/null +++ b/arch/mips/kernel/rtlx-mt.c | |||
| @@ -0,0 +1,148 @@ | |||
| 1 | /* | ||
| 2 | * This file is subject to the terms and conditions of the GNU General Public | ||
| 3 | * License. See the file "COPYING" in the main directory of this archive | ||
| 4 | * for more details. | ||
| 5 | * | ||
| 6 | * Copyright (C) 2005 MIPS Technologies, Inc. All rights reserved. | ||
| 7 | * Copyright (C) 2013 Imagination Technologies Ltd. | ||
| 8 | */ | ||
| 9 | #include <linux/device.h> | ||
| 10 | #include <linux/fs.h> | ||
| 11 | #include <linux/err.h> | ||
| 12 | #include <linux/wait.h> | ||
| 13 | #include <linux/sched.h> | ||
| 14 | #include <linux/interrupt.h> | ||
| 15 | #include <linux/irq.h> | ||
| 16 | |||
| 17 | #include <asm/mips_mt.h> | ||
| 18 | #include <asm/vpe.h> | ||
| 19 | #include <asm/rtlx.h> | ||
| 20 | |||
| 21 | static int major; | ||
| 22 | |||
| 23 | static void rtlx_dispatch(void) | ||
| 24 | { | ||
| 25 | if (read_c0_cause() & read_c0_status() & C_SW0) | ||
| 26 | do_IRQ(MIPS_CPU_IRQ_BASE + MIPS_CPU_RTLX_IRQ); | ||
| 27 | } | ||
| 28 | |||
| 29 | /* | ||
| 30 | * Interrupt handler may be called before rtlx_init has otherwise had | ||
| 31 | * a chance to run. | ||
| 32 | */ | ||
| 33 | static irqreturn_t rtlx_interrupt(int irq, void *dev_id) | ||
| 34 | { | ||
| 35 | unsigned int vpeflags; | ||
| 36 | unsigned long flags; | ||
| 37 | int i; | ||
| 38 | |||
| 39 | /* Ought not to be strictly necessary for SMTC builds */ | ||
| 40 | local_irq_save(flags); | ||
| 41 | vpeflags = dvpe(); | ||
| 42 | set_c0_status(0x100 << MIPS_CPU_RTLX_IRQ); | ||
| 43 | irq_enable_hazard(); | ||
| 44 | evpe(vpeflags); | ||
| 45 | local_irq_restore(flags); | ||
| 46 | |||
| 47 | for (i = 0; i < RTLX_CHANNELS; i++) { | ||
| 48 | wake_up(&channel_wqs[i].lx_queue); | ||
| 49 | wake_up(&channel_wqs[i].rt_queue); | ||
| 50 | } | ||
| 51 | |||
| 52 | return IRQ_HANDLED; | ||
| 53 | } | ||
| 54 | |||
| 55 | static struct irqaction rtlx_irq = { | ||
| 56 | .handler = rtlx_interrupt, | ||
| 57 | .name = "RTLX", | ||
| 58 | }; | ||
| 59 | |||
| 60 | static int rtlx_irq_num = MIPS_CPU_IRQ_BASE + MIPS_CPU_RTLX_IRQ; | ||
| 61 | |||
| 62 | void _interrupt_sp(void) | ||
| 63 | { | ||
| 64 | unsigned long flags; | ||
| 65 | |||
| 66 | local_irq_save(flags); | ||
| 67 | dvpe(); | ||
| 68 | settc(1); | ||
| 69 | write_vpe_c0_cause(read_vpe_c0_cause() | C_SW0); | ||
| 70 | evpe(EVPE_ENABLE); | ||
| 71 | local_irq_restore(flags); | ||
| 72 | } | ||
| 73 | |||
| 74 | int __init rtlx_module_init(void) | ||
| 75 | { | ||
| 76 | struct device *dev; | ||
| 77 | int i, err; | ||
| 78 | |||
| 79 | if (!cpu_has_mipsmt) { | ||
| 80 | pr_warn("VPE loader: not a MIPS MT capable processor\n"); | ||
| 81 | return -ENODEV; | ||
| 82 | } | ||
| 83 | |||
| 84 | if (aprp_cpu_index() == 0) { | ||
| 85 | pr_warn("No TCs reserved for AP/SP, not initializing RTLX.\n" | ||
| 86 | "Pass maxtcs=<n> argument as kernel argument\n"); | ||
| 87 | |||
| 88 | return -ENODEV; | ||
| 89 | } | ||
| 90 | |||
| 91 | major = register_chrdev(0, RTLX_MODULE_NAME, &rtlx_fops); | ||
| 92 | if (major < 0) { | ||
| 93 | pr_err("rtlx_module_init: unable to register device\n"); | ||
| 94 | return major; | ||
| 95 | } | ||
| 96 | |||
| 97 | /* initialise the wait queues */ | ||
| 98 | for (i = 0; i < RTLX_CHANNELS; i++) { | ||
| 99 | init_waitqueue_head(&channel_wqs[i].rt_queue); | ||
| 100 | init_waitqueue_head(&channel_wqs[i].lx_queue); | ||
| 101 | atomic_set(&channel_wqs[i].in_open, 0); | ||
| 102 | mutex_init(&channel_wqs[i].mutex); | ||
| 103 | |||
| 104 | dev = device_create(mt_class, NULL, MKDEV(major, i), NULL, | ||
| 105 | "%s%d", RTLX_MODULE_NAME, i); | ||
| 106 | if (IS_ERR(dev)) { | ||
| 107 | err = PTR_ERR(dev); | ||
| 108 | goto out_chrdev; | ||
| 109 | } | ||
| 110 | } | ||
| 111 | |||
| 112 | /* set up notifiers */ | ||
| 113 | rtlx_notify.start = rtlx_starting; | ||
| 114 | rtlx_notify.stop = rtlx_stopping; | ||
| 115 | vpe_notify(aprp_cpu_index(), &rtlx_notify); | ||
| 116 | |||
| 117 | if (cpu_has_vint) { | ||
| 118 | aprp_hook = rtlx_dispatch; | ||
| 119 | } else { | ||
| 120 | pr_err("APRP RTLX init on non-vectored-interrupt processor\n"); | ||
| 121 | err = -ENODEV; | ||
| 122 | goto out_class; | ||
| 123 | } | ||
| 124 | |||
| 125 | rtlx_irq.dev_id = rtlx; | ||
| 126 | err = setup_irq(rtlx_irq_num, &rtlx_irq); | ||
| 127 | if (err) | ||
| 128 | goto out_class; | ||
| 129 | |||
| 130 | return 0; | ||
| 131 | |||
| 132 | out_class: | ||
| 133 | for (i = 0; i < RTLX_CHANNELS; i++) | ||
| 134 | device_destroy(mt_class, MKDEV(major, i)); | ||
| 135 | out_chrdev: | ||
| 136 | unregister_chrdev(major, RTLX_MODULE_NAME); | ||
| 137 | |||
| 138 | return err; | ||
| 139 | } | ||
| 140 | |||
| 141 | void __exit rtlx_module_exit(void) | ||
| 142 | { | ||
| 143 | int i; | ||
| 144 | |||
| 145 | for (i = 0; i < RTLX_CHANNELS; i++) | ||
| 146 | device_destroy(mt_class, MKDEV(major, i)); | ||
| 147 | unregister_chrdev(major, RTLX_MODULE_NAME); | ||
| 148 | } | ||
diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c index 2c12ea1668d1..59db407d0499 100644 --- a/arch/mips/kernel/rtlx.c +++ b/arch/mips/kernel/rtlx.c | |||
| @@ -42,52 +42,12 @@ | |||
| 42 | #include <asm/rtlx.h> | 42 | #include <asm/rtlx.h> |
| 43 | #include <asm/setup.h> | 43 | #include <asm/setup.h> |
| 44 | 44 | ||
| 45 | static struct rtlx_info *rtlx; | ||
| 46 | static int major; | ||
| 47 | static char module_name[] = "rtlx"; | ||
| 48 | |||
| 49 | static struct chan_waitqueues { | ||
| 50 | wait_queue_head_t rt_queue; | ||
| 51 | wait_queue_head_t lx_queue; | ||
| 52 | atomic_t in_open; | ||
| 53 | struct mutex mutex; | ||
| 54 | } channel_wqs[RTLX_CHANNELS]; | ||
| 55 | |||
| 56 | static struct vpe_notifications notify; | ||
| 57 | static int sp_stopping; | 45 | static int sp_stopping; |
| 58 | 46 | struct rtlx_info *rtlx; | |
| 59 | extern void *vpe_get_shared(int index); | 47 | struct chan_waitqueues channel_wqs[RTLX_CHANNELS]; |
| 60 | 48 | struct vpe_notifications rtlx_notify; | |
| 61 | static void rtlx_dispatch(void) | 49 | void (*aprp_hook)(void) = NULL; |
| 62 | { | 50 | EXPORT_SYMBOL(aprp_hook); |
| 63 | do_IRQ(MIPS_CPU_IRQ_BASE + MIPS_CPU_RTLX_IRQ); | ||
| 64 | } | ||
| 65 | |||
| 66 | |||
| 67 | /* Interrupt handler may be called before rtlx_init has otherwise had | ||
| 68 | a chance to run. | ||
| 69 | */ | ||
| 70 | static irqreturn_t rtlx_interrupt(int irq, void *dev_id) | ||
| 71 | { | ||
| 72 | unsigned int vpeflags; | ||
| 73 | unsigned long flags; | ||
| 74 | int i; | ||
| 75 | |||
| 76 | /* Ought not to be strictly necessary for SMTC builds */ | ||
| 77 | local_irq_save(flags); | ||
| 78 | vpeflags = dvpe(); | ||
| 79 | set_c0_status(0x100 << MIPS_CPU_RTLX_IRQ); | ||
| 80 | irq_enable_hazard(); | ||
| 81 | evpe(vpeflags); | ||
| 82 | local_irq_restore(flags); | ||
| 83 | |||
| 84 | for (i = 0; i < RTLX_CHANNELS; i++) { | ||
| 85 | wake_up(&channel_wqs[i].lx_queue); | ||
| 86 | wake_up(&channel_wqs[i].rt_queue); | ||
| 87 | } | ||
| 88 | |||
| 89 | return IRQ_HANDLED; | ||
| 90 | } | ||
| 91 | 51 | ||
| 92 | static void __used dump_rtlx(void) | 52 | static void __used dump_rtlx(void) |
| 93 | { | 53 | { |
| @@ -127,7 +87,7 @@ static int rtlx_init(struct rtlx_info *rtlxi) | |||
| 127 | } | 87 | } |
| 128 | 88 | ||
| 129 | /* notifications */ | 89 | /* notifications */ |
| 130 | static void starting(int vpe) | 90 | void rtlx_starting(int vpe) |
| 131 | { | 91 | { |
| 132 | int i; | 92 | int i; |
| 133 | sp_stopping = 0; | 93 | sp_stopping = 0; |
| @@ -140,7 +100,7 @@ static void starting(int vpe) | |||
| 140 | wake_up_interruptible(&channel_wqs[i].lx_queue); | 100 | wake_up_interruptible(&channel_wqs[i].lx_queue); |
| 141 | } | 101 | } |
| 142 | 102 | ||
| 143 | static void stopping(int vpe) | 103 | void rtlx_stopping(int vpe) |
| 144 | { | 104 | { |
| 145 | int i; | 105 | int i; |
| 146 | 106 | ||
| @@ -384,6 +344,8 @@ out: | |||
| 384 | smp_wmb(); | 344 | smp_wmb(); |
| 385 | mutex_unlock(&channel_wqs[index].mutex); | 345 | mutex_unlock(&channel_wqs[index].mutex); |
| 386 | 346 | ||
| 347 | _interrupt_sp(); | ||
| 348 | |||
| 387 | return count; | 349 | return count; |
| 388 | } | 350 | } |
| 389 | 351 | ||
| @@ -454,7 +416,7 @@ static ssize_t file_write(struct file *file, const char __user * buffer, | |||
| 454 | return rtlx_write(minor, buffer, count); | 416 | return rtlx_write(minor, buffer, count); |
| 455 | } | 417 | } |
| 456 | 418 | ||
| 457 | static const struct file_operations rtlx_fops = { | 419 | const struct file_operations rtlx_fops = { |
| 458 | .owner = THIS_MODULE, | 420 | .owner = THIS_MODULE, |
| 459 | .open = file_open, | 421 | .open = file_open, |
| 460 | .release = file_release, | 422 | .release = file_release, |
| @@ -464,90 +426,6 @@ static const struct file_operations rtlx_fops = { | |||
| 464 | .llseek = noop_llseek, | 426 | .llseek = noop_llseek, |
| 465 | }; | 427 | }; |
| 466 | 428 | ||
| 467 | static struct irqaction rtlx_irq = { | ||
| 468 | .handler = rtlx_interrupt, | ||
| 469 | .name = "RTLX", | ||
| 470 | }; | ||
| 471 | |||
| 472 | static int rtlx_irq_num = MIPS_CPU_IRQ_BASE + MIPS_CPU_RTLX_IRQ; | ||
| 473 | |||
| 474 | static char register_chrdev_failed[] __initdata = | ||
| 475 | KERN_ERR "rtlx_module_init: unable to register device\n"; | ||
| 476 | |||
| 477 | static int __init rtlx_module_init(void) | ||
| 478 | { | ||
| 479 | struct device *dev; | ||
| 480 | int i, err; | ||
| 481 | |||
| 482 | if (!cpu_has_mipsmt) { | ||
| 483 | printk("VPE loader: not a MIPS MT capable processor\n"); | ||
| 484 | return -ENODEV; | ||
| 485 | } | ||
| 486 | |||
| 487 | if (tclimit == 0) { | ||
| 488 | printk(KERN_WARNING "No TCs reserved for AP/SP, not " | ||
| 489 | "initializing RTLX.\nPass maxtcs=<n> argument as kernel " | ||
| 490 | "argument\n"); | ||
| 491 | |||
| 492 | return -ENODEV; | ||
| 493 | } | ||
| 494 | |||
| 495 | major = register_chrdev(0, module_name, &rtlx_fops); | ||
| 496 | if (major < 0) { | ||
| 497 | printk(register_chrdev_failed); | ||
| 498 | return major; | ||
| 499 | } | ||
| 500 | |||
| 501 | /* initialise the wait queues */ | ||
| 502 | for (i = 0; i < RTLX_CHANNELS; i++) { | ||
| 503 | init_waitqueue_head(&channel_wqs[i].rt_queue); | ||
| 504 | init_waitqueue_head(&channel_wqs[i].lx_queue); | ||
| 505 | atomic_set(&channel_wqs[i].in_open, 0); | ||
| 506 | mutex_init(&channel_wqs[i].mutex); | ||
| 507 | |||
| 508 | dev = device_create(mt_class, NULL, MKDEV(major, i), NULL, | ||
| 509 | "%s%d", module_name, i); | ||
| 510 | if (IS_ERR(dev)) { | ||
| 511 | err = PTR_ERR(dev); | ||
| 512 | goto out_chrdev; | ||
| 513 | } | ||
| 514 | } | ||
| 515 | |||
| 516 | /* set up notifiers */ | ||
| 517 | notify.start = starting; | ||
| 518 | notify.stop = stopping; | ||
| 519 | vpe_notify(tclimit, ¬ify); | ||
| 520 | |||
| 521 | if (cpu_has_vint) | ||
| 522 | set_vi_handler(MIPS_CPU_RTLX_IRQ, rtlx_dispatch); | ||
| 523 | else { | ||
| 524 | pr_err("APRP RTLX init on non-vectored-interrupt processor\n"); | ||
| 525 | err = -ENODEV; | ||
| 526 | goto out_chrdev; | ||
| 527 | } | ||
| 528 | |||
| 529 | rtlx_irq.dev_id = rtlx; | ||
| 530 | setup_irq(rtlx_irq_num, &rtlx_irq); | ||
| 531 | |||
| 532 | return 0; | ||
| 533 | |||
| 534 | out_chrdev: | ||
| 535 | for (i = 0; i < RTLX_CHANNELS; i++) | ||
| 536 | device_destroy(mt_class, MKDEV(major, i)); | ||
| 537 | |||
| 538 | return err; | ||
| 539 | } | ||
| 540 | |||
| 541 | static void __exit rtlx_module_exit(void) | ||
| 542 | { | ||
| 543 | int i; | ||
| 544 | |||
| 545 | for (i = 0; i < RTLX_CHANNELS; i++) | ||
| 546 | device_destroy(mt_class, MKDEV(major, i)); | ||
| 547 | |||
| 548 | unregister_chrdev(major, module_name); | ||
| 549 | } | ||
| 550 | |||
| 551 | module_init(rtlx_module_init); | 429 | module_init(rtlx_module_init); |
| 552 | module_exit(rtlx_module_exit); | 430 | module_exit(rtlx_module_exit); |
| 553 | 431 | ||
