]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - arch/mips/kernel/vpe-cmp.c
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
6 * Copyright (C) 2004, 2005 MIPS Technologies, Inc. All rights reserved.
7 * Copyright (C) 2013 Imagination Technologies Ltd.
9 #include <linux/kernel.h>
10 #include <linux/device.h>
12 #include <linux/slab.h>
13 #include <linux/export.h>
19 void cleanup_tc(struct tc
*tc
)
24 static ssize_t
store_kill(struct device
*dev
, struct device_attribute
*attr
,
25 const char *buf
, size_t len
)
27 struct vpe
*vpe
= get_vpe(aprp_cpu_index());
28 struct vpe_notifications
*notifier
;
30 list_for_each_entry(notifier
, &vpe
->notify
, list
)
31 notifier
->stop(aprp_cpu_index());
33 release_progmem(vpe
->load_addr
);
34 vpe
->state
= VPE_STATE_UNUSED
;
38 static DEVICE_ATTR(kill
, S_IWUSR
, NULL
, store_kill
);
40 static ssize_t
ntcs_show(struct device
*cd
, struct device_attribute
*attr
,
43 struct vpe
*vpe
= get_vpe(aprp_cpu_index());
45 return sprintf(buf
, "%d\n", vpe
->ntcs
);
48 static ssize_t
ntcs_store(struct device
*dev
, struct device_attribute
*attr
,
49 const char *buf
, size_t len
)
51 struct vpe
*vpe
= get_vpe(aprp_cpu_index());
55 ret
= kstrtoul(buf
, 0, &new);
59 /* APRP can only reserve one TC in a VPE and no more. */
67 static DEVICE_ATTR_RW(ntcs
);
69 static struct attribute
*vpe_attrs
[] = {
74 ATTRIBUTE_GROUPS(vpe
);
76 static void vpe_device_release(struct device
*cd
)
81 static struct class vpe_class
= {
84 .dev_release
= vpe_device_release
,
85 .dev_groups
= vpe_groups
,
88 static struct device vpe_device
;
90 int __init
vpe_module_init(void)
96 if (!cpu_has_mipsmt
) {
97 pr_warn("VPE loader: not a MIPS MT capable processor\n");
101 if (num_possible_cpus() - aprp_cpu_index() < 1) {
102 pr_warn("No VPEs reserved for AP/SP, not initialize VPE loader\n"
103 "Pass maxcpus=<n> argument as kernel argument\n");
107 major
= register_chrdev(0, VPE_MODULE_NAME
, &vpe_fops
);
109 pr_warn("VPE loader: unable to register character device\n");
113 err
= class_register(&vpe_class
);
115 pr_err("vpe_class registration failed\n");
119 device_initialize(&vpe_device
);
120 vpe_device
.class = &vpe_class
,
121 vpe_device
.parent
= NULL
,
122 dev_set_name(&vpe_device
, "vpe_sp");
123 vpe_device
.devt
= MKDEV(major
, VPE_MODULE_MINOR
);
124 err
= device_add(&vpe_device
);
126 pr_err("Adding vpe_device failed\n");
130 t
= alloc_tc(aprp_cpu_index());
132 pr_warn("VPE: unable to allocate TC\n");
138 v
= alloc_vpe(aprp_cpu_index());
140 pr_warn("VPE: unable to allocate VPE\n");
148 /* add the tc to the list of this vpe's tc's. */
149 list_add(&t
->tc
, &v
->tc
);
152 t
->pvpe
= v
; /* set the parent vpe */
157 device_del(&vpe_device
);
160 class_unregister(&vpe_class
);
163 unregister_chrdev(major
, VPE_MODULE_NAME
);
168 void __exit
vpe_module_exit(void)
172 device_del(&vpe_device
);
173 class_unregister(&vpe_class
);
174 unregister_chrdev(major
, VPE_MODULE_NAME
);
176 /* No locking needed here */
177 list_for_each_entry_safe(v
, n
, &vpecontrol
.vpe_list
, list
)
178 if (v
->state
!= VPE_STATE_UNUSED
)