diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2007-07-27 14:33:18 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2007-07-31 16:35:25 -0400 |
commit | 41790e04e6656fa1aef205ad9a76ab4edbb5f14a (patch) | |
tree | fce609dc3c6426e4418ce69926b549dd8db2bcd3 /arch/mips/kernel/vpe.c | |
parent | 07cc0c9e65d3e262f871ea357dd77b41950b1ca5 (diff) |
[MIPS] RP: Pass number of TCs available to RP program in $2.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel/vpe.c')
-rw-r--r-- | arch/mips/kernel/vpe.c | 82 |
1 files changed, 73 insertions, 9 deletions
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c index c726c47cd2c3..1323cb6d058d 100644 --- a/arch/mips/kernel/vpe.c +++ b/arch/mips/kernel/vpe.c | |||
@@ -64,6 +64,10 @@ typedef void *vpe_handle; | |||
64 | /* If this is set, the section belongs in the init part of the module */ | 64 | /* If this is set, the section belongs in the init part of the module */ |
65 | #define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1)) | 65 | #define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1)) |
66 | 66 | ||
67 | /* | ||
68 | * The number of TCs and VPEs physically available on the core | ||
69 | */ | ||
70 | static int hw_tcs, hw_vpes; | ||
67 | static char module_name[] = "vpe"; | 71 | static char module_name[] = "vpe"; |
68 | static int major; | 72 | static int major; |
69 | static const int minor = 1; /* fixed for now */ | 73 | static const int minor = 1; /* fixed for now */ |
@@ -126,6 +130,8 @@ struct vpe { | |||
126 | 130 | ||
127 | /* the list of who wants to know when something major happens */ | 131 | /* the list of who wants to know when something major happens */ |
128 | struct list_head notify; | 132 | struct list_head notify; |
133 | |||
134 | unsigned int ntcs; | ||
129 | }; | 135 | }; |
130 | 136 | ||
131 | struct tc { | 137 | struct tc { |
@@ -738,6 +744,7 @@ static int vpe_run(struct vpe * v) | |||
738 | * here... Or set $a3 to zero and define DFLT_STACK_SIZE and | 744 | * here... Or set $a3 to zero and define DFLT_STACK_SIZE and |
739 | * DFLT_HEAP_SIZE when you compile your program | 745 | * DFLT_HEAP_SIZE when you compile your program |
740 | */ | 746 | */ |
747 | mttgpr(6, v->ntcs); | ||
741 | mttgpr(7, physical_memsize); | 748 | mttgpr(7, physical_memsize); |
742 | 749 | ||
743 | /* set up VPE1 */ | 750 | /* set up VPE1 */ |
@@ -1333,16 +1340,60 @@ static void kspd_sp_exit( int sp_id) | |||
1333 | } | 1340 | } |
1334 | #endif | 1341 | #endif |
1335 | 1342 | ||
1336 | static struct device *vpe_dev; | 1343 | static ssize_t show_ntcs(struct class_device *cd, char *buf) |
1344 | { | ||
1345 | struct vpe *vpe = get_vpe(tclimit); | ||
1346 | |||
1347 | return sprintf(buf, "%d\n", vpe->ntcs); | ||
1348 | } | ||
1349 | |||
1350 | static ssize_t store_ntcs(struct class_device *dev, const char *buf, size_t len) | ||
1351 | { | ||
1352 | struct vpe *vpe = get_vpe(tclimit); | ||
1353 | unsigned long new; | ||
1354 | char *endp; | ||
1355 | |||
1356 | new = simple_strtoul(buf, &endp, 0); | ||
1357 | if (endp == buf) | ||
1358 | goto out_einval; | ||
1359 | |||
1360 | if (new == 0 || new > (hw_tcs - tclimit)) | ||
1361 | goto out_einval; | ||
1362 | |||
1363 | vpe->ntcs = new; | ||
1364 | |||
1365 | return len; | ||
1366 | |||
1367 | out_einval: | ||
1368 | return -EINVAL;; | ||
1369 | } | ||
1370 | |||
1371 | static struct class_device_attribute vpe_class_attributes[] = { | ||
1372 | __ATTR(ntcs, S_IRUGO | S_IWUSR, show_ntcs, store_ntcs), | ||
1373 | {} | ||
1374 | }; | ||
1375 | |||
1376 | static void vpe_class_device_release(struct class_device *cd) | ||
1377 | { | ||
1378 | kfree(cd); | ||
1379 | } | ||
1380 | |||
1381 | struct class vpe_class = { | ||
1382 | .name = "vpe", | ||
1383 | .owner = THIS_MODULE, | ||
1384 | .release = vpe_class_device_release, | ||
1385 | .class_dev_attrs = vpe_class_attributes, | ||
1386 | }; | ||
1387 | |||
1388 | struct class_device vpe_device; | ||
1337 | 1389 | ||
1338 | static int __init vpe_module_init(void) | 1390 | static int __init vpe_module_init(void) |
1339 | { | 1391 | { |
1340 | unsigned int mtflags, vpflags; | 1392 | unsigned int mtflags, vpflags; |
1341 | int hw_tcs, hw_vpes, tc, err = 0; | ||
1342 | unsigned long flags, val; | 1393 | unsigned long flags, val; |
1343 | struct vpe *v = NULL; | 1394 | struct vpe *v = NULL; |
1344 | struct device *dev; | ||
1345 | struct tc *t; | 1395 | struct tc *t; |
1396 | int tc, err; | ||
1346 | 1397 | ||
1347 | if (!cpu_has_mipsmt) { | 1398 | if (!cpu_has_mipsmt) { |
1348 | printk("VPE loader: not a MIPS MT capable processor\n"); | 1399 | printk("VPE loader: not a MIPS MT capable processor\n"); |
@@ -1371,13 +1422,22 @@ static int __init vpe_module_init(void) | |||
1371 | return major; | 1422 | return major; |
1372 | } | 1423 | } |
1373 | 1424 | ||
1374 | dev = device_create(mt_class, NULL, MKDEV(major, minor), | 1425 | err = class_register(&vpe_class); |
1375 | "vpe%d", minor); | 1426 | if (err) { |
1376 | if (IS_ERR(dev)) { | 1427 | printk(KERN_ERR "vpe_class registration failed\n"); |
1377 | err = PTR_ERR(dev); | ||
1378 | goto out_chrdev; | 1428 | goto out_chrdev; |
1379 | } | 1429 | } |
1380 | vpe_dev = dev; | 1430 | |
1431 | class_device_initialize(&vpe_device); | ||
1432 | vpe_device.class = &vpe_class, | ||
1433 | vpe_device.parent = NULL, | ||
1434 | strlcpy(vpe_device.class_id, "vpe1", BUS_ID_SIZE); | ||
1435 | vpe_device.devt = MKDEV(major, minor); | ||
1436 | err = class_device_add(&vpe_device); | ||
1437 | if (err) { | ||
1438 | printk(KERN_ERR "Adding vpe_device failed\n"); | ||
1439 | goto out_class; | ||
1440 | } | ||
1381 | 1441 | ||
1382 | local_irq_save(flags); | 1442 | local_irq_save(flags); |
1383 | mtflags = dmt(); | 1443 | mtflags = dmt(); |
@@ -1422,6 +1482,8 @@ static int __init vpe_module_init(void) | |||
1422 | goto out_reenable; | 1482 | goto out_reenable; |
1423 | } | 1483 | } |
1424 | 1484 | ||
1485 | v->ntcs = hw_tcs - tclimit; | ||
1486 | |||
1425 | /* add the tc to the list of this vpe's tc's. */ | 1487 | /* add the tc to the list of this vpe's tc's. */ |
1426 | list_add(&t->tc, &v->tc); | 1488 | list_add(&t->tc, &v->tc); |
1427 | 1489 | ||
@@ -1497,6 +1559,8 @@ out_reenable: | |||
1497 | #endif | 1559 | #endif |
1498 | return 0; | 1560 | return 0; |
1499 | 1561 | ||
1562 | out_class: | ||
1563 | class_unregister(&vpe_class); | ||
1500 | out_chrdev: | 1564 | out_chrdev: |
1501 | unregister_chrdev(major, module_name); | 1565 | unregister_chrdev(major, module_name); |
1502 | 1566 | ||
@@ -1514,7 +1578,7 @@ static void __exit vpe_module_exit(void) | |||
1514 | } | 1578 | } |
1515 | } | 1579 | } |
1516 | 1580 | ||
1517 | device_destroy(mt_class, MKDEV(major, minor)); | 1581 | class_device_del(&vpe_device); |
1518 | unregister_chrdev(major, module_name); | 1582 | unregister_chrdev(major, module_name); |
1519 | } | 1583 | } |
1520 | 1584 | ||