Lines Matching +full:j +full:- +full:to +full:- +full:k

1 // SPDX-License-Identifier: GPL-2.0-or-later
20 #define INVALID_CNODE -1
33 static signed short uv_master_nasid = -1;
59 return -1; in ordinal_to_nasid()
77 return -1; in location_to_bpos()
90 if (!obj->f.fields.this_part && !obj->f.fields.is_shared) in cache_obj_to_cnode()
93 if (location_to_bpos(obj->location, &obj_rack, &obj_slot, &obj_blade)) in cache_obj_to_cnode()
94 return -1; in cache_obj_to_cnode()
102 prev_obj_to_cnode[obj->id] = cnode; in cache_obj_to_cnode()
123 return sysfs_emit(buf, "%s\n", hub_info->name); in hub_name_show()
128 return sysfs_emit(buf, "%s\n", hub_info->location); in hub_location_show()
133 return sysfs_emit(buf, "%d\n", hub_info->f.fields.this_part); in hub_partition_show()
138 return sysfs_emit(buf, "%d\n", hub_info->f.fields.is_shared); in hub_shared_show()
142 int cnode = get_obj_to_cnode(hub_info->id); in hub_nasid_show()
148 return sysfs_emit(buf, "%d\n", get_obj_to_cnode(hub_info->id)); in hub_cnode_show()
192 struct uv_bios_hub_info *bios_hub_info = hub->hub_info; in hub_type_show()
197 if (!entry->show) in hub_type_show()
198 return -EIO; in hub_type_show()
200 return entry->show(bios_hub_info, buf); in hub_type_show()
222 return -ENOMEM; in uv_hubs_init()
229 ret = -ENOMEM; in uv_hubs_init()
235 ret = -ENOMEM; in uv_hubs_init()
241 ret = -EINVAL; in uv_hubs_init()
247 ret = -ENOMEM; in uv_hubs_init()
254 i--; in uv_hubs_init()
255 ret = -ENOMEM; in uv_hubs_init()
259 uv_hubs[i]->hub_info = &hub_buf[i]; in uv_hubs_init()
260 cache_obj_to_cnode(uv_hubs[i]->hub_info); in uv_hubs_init()
262 uv_hubs[i]->kobj.kset = uv_hubs_kset; in uv_hubs_init()
264 ret = kobject_init_and_add(&uv_hubs[i]->kobj, &hub_attr_type, in uv_hubs_init()
268 kobject_uevent(&uv_hubs[i]->kobj, KOBJ_ADD); in uv_hubs_init()
273 for (; i >= 0; i--) in uv_hubs_init()
274 kobject_put(&uv_hubs[i]->kobj); in uv_hubs_init()
291 kobject_put(&uv_hubs[i]->kobj); in uv_hubs_exit()
308 return sysfs_emit(buf, "%d\n", port->conn_id); in uv_port_conn_hub_show()
313 return sysfs_emit(buf, "%d\n", port->conn_port); in uv_port_conn_port_show()
345 struct uv_bios_port_info *port_info = port->port_info; in uv_port_type_show()
350 if (!entry->show) in uv_port_type_show()
351 return -EIO; in uv_port_type_show()
353 return entry->show(port_info, buf); in uv_port_type_show()
369 int j = 0, k = 0, ret, sz; in uv_ports_init() local
373 return -ENOMEM; in uv_ports_init()
375 for (j = 0; j < uv_bios_obj_cnt; j++) { in uv_ports_init()
376 sz = hub_buf[j].ports * sizeof(*port_buf[j]); in uv_ports_init()
377 port_buf[j] = kzalloc(sz, GFP_KERNEL); in uv_ports_init()
378 if (!port_buf[j]) { in uv_ports_init()
379 ret = -ENOMEM; in uv_ports_init()
380 j--; in uv_ports_init()
383 biosr = uv_bios_enum_ports((u64)uv_master_nasid, (u64)hub_buf[j].id, sz, in uv_ports_init()
384 (u64 *)port_buf[j]); in uv_ports_init()
386 ret = -EINVAL; in uv_ports_init()
390 for (j = 0; j < uv_bios_obj_cnt; j++) { in uv_ports_init()
391 uv_hubs[j]->ports = kcalloc(hub_buf[j].ports, in uv_ports_init()
392 sizeof(*uv_hubs[j]->ports), GFP_KERNEL); in uv_ports_init()
393 if (!uv_hubs[j]->ports) { in uv_ports_init()
394 ret = -ENOMEM; in uv_ports_init()
395 j--; in uv_ports_init()
399 for (j = 0; j < uv_bios_obj_cnt; j++) { in uv_ports_init()
400 for (k = 0; k < hub_buf[j].ports; k++) { in uv_ports_init()
401 uv_hubs[j]->ports[k] = kzalloc(sizeof(*uv_hubs[j]->ports[k]), GFP_KERNEL); in uv_ports_init()
402 if (!uv_hubs[j]->ports[k]) { in uv_ports_init()
403 ret = -ENOMEM; in uv_ports_init()
404 k--; in uv_ports_init()
407 uv_hubs[j]->ports[k]->port_info = &port_buf[j][k]; in uv_ports_init()
408 ret = kobject_init_and_add(&uv_hubs[j]->ports[k]->kobj, &uv_port_attr_type, in uv_ports_init()
409 &uv_hubs[j]->kobj, "port_%d", port_buf[j][k].port); in uv_ports_init()
412 kobject_uevent(&uv_hubs[j]->ports[k]->kobj, KOBJ_ADD); in uv_ports_init()
418 for (; j >= 0; j--) { in uv_ports_init()
419 for (; k >= 0; k--) in uv_ports_init()
420 kobject_put(&uv_hubs[j]->ports[k]->kobj); in uv_ports_init()
421 if (j > 0) in uv_ports_init()
422 k = hub_buf[j-1].ports - 1; in uv_ports_init()
424 j = uv_bios_obj_cnt - 1; in uv_ports_init()
426 for (; j >= 0; j--) in uv_ports_init()
427 kfree(uv_hubs[j]->ports); in uv_ports_init()
428 j = uv_bios_obj_cnt - 1; in uv_ports_init()
430 for (; j >= 0; j--) in uv_ports_init()
431 kfree(port_buf[j]); in uv_ports_init()
438 int j, k; in uv_ports_exit() local
440 for (j = 0; j < uv_bios_obj_cnt; j++) { in uv_ports_exit()
441 for (k = hub_buf[j].ports - 1; k >= 0; k--) in uv_ports_exit()
442 kobject_put(&uv_hubs[j]->ports[k]->kobj); in uv_ports_exit()
444 for (j = 0; j < uv_bios_obj_cnt; j++) { in uv_ports_exit()
445 kfree(uv_hubs[j]->ports); in uv_ports_exit()
446 kfree(port_buf[j]); in uv_ports_exit()
464 return sysfs_emit(buf, "%s\n", top_obj->type); in uv_pci_type_show()
469 return sysfs_emit(buf, "%s\n", top_obj->location); in uv_pci_location_show()
474 return sysfs_emit(buf, "%d\n", top_obj->iio_stack); in uv_pci_iio_stack_show()
479 return sysfs_emit(buf, "%s\n", top_obj->ppb_addr); in uv_pci_ppb_addr_show()
484 return sysfs_emit(buf, "%d\n", top_obj->slot); in uv_pci_slot_show()
508 kfree(top_obj->type); in uv_pci_top_release()
509 kfree(top_obj->location); in uv_pci_top_release()
510 kfree(top_obj->ppb_addr); in uv_pci_top_release()
522 if (!entry->show) in pci_top_type_show()
523 return -EIO; in pci_top_type_show()
525 return entry->show(top_obj, buf); in pci_top_type_show()
546 return -EINVAL; in init_pci_top_obj()
548 //Line must match format "pcibus %4x:%2x" to be valid in init_pci_top_obj()
551 return -EINVAL; in init_pci_top_obj()
553 /* Connect pcibus to segment:bus number with '_' in init_pci_top_obj()
554 * to concatenate name tokens. in init_pci_top_obj()
555 * pcibus 0000:00 ... -> pcibus_0000:00 ... in init_pci_top_obj()
560 * to produce kobj name string. in init_pci_top_obj()
564 // Use start to index after name tokens string for remainder of line info. in init_pci_top_obj()
567 top_obj->iio_stack = -1; in init_pci_top_obj()
568 top_obj->slot = -1; in init_pci_top_obj()
579 location, type, &top_obj->iio_stack); in init_pci_top_obj()
581 return -EINVAL; in init_pci_top_obj()
582 top_obj->type = kstrdup(type, GFP_KERNEL); in init_pci_top_obj()
583 if (!top_obj->type) in init_pci_top_obj()
584 return -ENOMEM; in init_pci_top_obj()
585 top_obj->location = kstrdup(location, GFP_KERNEL); in init_pci_top_obj()
586 if (!top_obj->location) { in init_pci_top_obj()
587 kfree(top_obj->type); in init_pci_top_obj()
588 return -ENOMEM; in init_pci_top_obj()
596 type, ppb_addr, &top_obj->slot); in init_pci_top_obj()
598 return -EINVAL; in init_pci_top_obj()
599 top_obj->type = kstrdup(type, GFP_KERNEL); in init_pci_top_obj()
600 if (!top_obj->type) in init_pci_top_obj()
601 return -ENOMEM; in init_pci_top_obj()
602 top_obj->ppb_addr = kstrdup(ppb_addr, GFP_KERNEL); in init_pci_top_obj()
603 if (!top_obj->ppb_addr) { in init_pci_top_obj()
604 kfree(top_obj->type); in init_pci_top_obj()
605 return -ENOMEM; in init_pci_top_obj()
608 return -EINVAL; in init_pci_top_obj()
610 top_obj->kobj.kset = uv_pcibus_kset; in init_pci_top_obj()
612 ret = kobject_init_and_add(&top_obj->kobj, &uv_pci_top_attr_type, NULL, "%s", line); in init_pci_top_obj()
616 if (top_obj->type) { in init_pci_top_obj()
617 ret = sysfs_create_file(&top_obj->kobj, &uv_pci_type_attribute.attr); in init_pci_top_obj()
621 if (top_obj->location) { in init_pci_top_obj()
622 ret = sysfs_create_file(&top_obj->kobj, &uv_pci_location_attribute.attr); in init_pci_top_obj()
626 if (top_obj->iio_stack >= 0) { in init_pci_top_obj()
627 ret = sysfs_create_file(&top_obj->kobj, &uv_pci_iio_stack_attribute.attr); in init_pci_top_obj()
631 if (top_obj->ppb_addr) { in init_pci_top_obj()
632 ret = sysfs_create_file(&top_obj->kobj, &uv_pci_ppb_addr_attribute.attr); in init_pci_top_obj()
636 if (top_obj->slot >= 0) { in init_pci_top_obj()
637 ret = sysfs_create_file(&top_obj->kobj, &uv_pci_slot_attribute.attr); in init_pci_top_obj()
642 kobject_uevent(&top_obj->kobj, KOBJ_ADD); in init_pci_top_obj()
646 kobject_put(&top_obj->kobj); in init_pci_top_obj()
655 int l = 0, k = 0; in pci_topology_init() local
660 return -ENOMEM; in pci_topology_init()
665 ret = -ENOMEM; in pci_topology_init()
681 ret = -ENOMEM; in pci_topology_init()
686 uv_pci_objs[k] = kzalloc(sizeof(*uv_pci_objs[k]), GFP_KERNEL); in pci_topology_init()
687 if (!uv_pci_objs[k]) { in pci_topology_init()
688 ret = -ENOMEM; in pci_topology_init()
691 ret = init_pci_top_obj(uv_pci_objs[k], found); in pci_topology_init()
694 k++; in pci_topology_init()
695 if (k == num_pci_lines) in pci_topology_init()
706 k--; in pci_topology_init()
707 for (; k >= 0; k--) in pci_topology_init()
708 kobject_put(&uv_pci_objs[k]->kobj); in pci_topology_init()
718 int k; in pci_topology_exit() local
720 for (k = 0; k < num_pci_lines; k++) in pci_topology_exit()
721 kobject_put(&uv_pci_objs[k]->kobj); in pci_topology_exit()
795 return -EINVAL; in initial_bios_setup()
799 return -EINVAL; in initial_bios_setup()
803 return -ENOMEM; in initial_bios_setup()
808 return -EINVAL; in initial_bios_setup()
814 return -EINVAL; in initial_bios_setup()
851 return -ENODEV; in uv_sysfs_init()
859 return -EINVAL; in uv_sysfs_init()