Lines Matching refs:hp
147 static void mdesc_handle_init(struct mdesc_handle *hp, in mdesc_handle_init() argument
151 BUG_ON(((unsigned long)&hp->mdesc) & (16UL - 1)); in mdesc_handle_init()
153 memset(hp, 0, handle_size); in mdesc_handle_init()
154 INIT_LIST_HEAD(&hp->list); in mdesc_handle_init()
155 hp->self_base = base; in mdesc_handle_init()
156 atomic_set(&hp->refcnt, 1); in mdesc_handle_init()
157 hp->handle_size = handle_size; in mdesc_handle_init()
163 struct mdesc_handle *hp; in mdesc_memblock_alloc() local
173 hp = NULL; in mdesc_memblock_alloc()
175 hp = __va(paddr); in mdesc_memblock_alloc()
176 mdesc_handle_init(hp, handle_size, hp); in mdesc_memblock_alloc()
178 return hp; in mdesc_memblock_alloc()
181 static void __init mdesc_memblock_free(struct mdesc_handle *hp) in mdesc_memblock_free() argument
186 BUG_ON(atomic_read(&hp->refcnt) != 0); in mdesc_memblock_free()
187 BUG_ON(!list_empty(&hp->list)); in mdesc_memblock_free()
189 alloc_size = PAGE_ALIGN(hp->handle_size); in mdesc_memblock_free()
190 start = __pa(hp); in mdesc_memblock_free()
202 struct mdesc_handle *hp; in mdesc_kmalloc() local
215 hp = (struct mdesc_handle *) addr; in mdesc_kmalloc()
217 mdesc_handle_init(hp, handle_size, base); in mdesc_kmalloc()
219 return hp; in mdesc_kmalloc()
222 static void mdesc_kfree(struct mdesc_handle *hp) in mdesc_kfree() argument
224 BUG_ON(atomic_read(&hp->refcnt) != 0); in mdesc_kfree()
225 BUG_ON(!list_empty(&hp->list)); in mdesc_kfree()
227 kfree(hp->self_base); in mdesc_kfree()
238 struct mdesc_handle *hp = mops->alloc(mdesc_size); in mdesc_alloc() local
240 if (hp) in mdesc_alloc()
241 hp->mops = mops; in mdesc_alloc()
243 return hp; in mdesc_alloc()
246 static void mdesc_free(struct mdesc_handle *hp) in mdesc_free() argument
248 hp->mops->free(hp); in mdesc_free()
257 struct mdesc_handle *hp; in mdesc_grab() local
261 hp = cur_mdesc; in mdesc_grab()
262 if (hp) in mdesc_grab()
263 atomic_inc(&hp->refcnt); in mdesc_grab()
266 return hp; in mdesc_grab()
270 void mdesc_release(struct mdesc_handle *hp) in mdesc_release() argument
275 if (atomic_dec_and_test(&hp->refcnt)) { in mdesc_release()
276 list_del_init(&hp->list); in mdesc_release()
277 hp->mops->free(hp); in mdesc_release()
317 static const u64 *parent_cfg_handle(struct mdesc_handle *hp, u64 node) in parent_cfg_handle() argument
323 mdesc_for_each_arc(a, hp, node, MDESC_ARC_TYPE_BACK) { in parent_cfg_handle()
326 target = mdesc_arc_target(hp, a); in parent_cfg_handle()
327 id = mdesc_get_property(hp, target, in parent_cfg_handle()
502 struct mdesc_handle *hp, *orig_hp; in mdesc_update() local
509 hp = mdesc_alloc(len, &kmalloc_mdesc_memops); in mdesc_update()
510 if (!hp) { in mdesc_update()
515 status = sun4v_mach_desc(__pa(&hp->mdesc), len, &real_len); in mdesc_update()
519 atomic_dec(&hp->refcnt); in mdesc_update()
520 mdesc_free(hp); in mdesc_update()
526 cur_mdesc = hp; in mdesc_update()
529 mdesc_notify_clients(orig_hp, hp); in mdesc_update()
542 u64 mdesc_get_node(struct mdesc_handle *hp, const char *node_name, in mdesc_get_node() argument
552 if (hp == NULL || node_name == NULL || node_info == NULL) in mdesc_get_node()
565 mdesc_for_each_node_by_name(hp, hp_node, node_name) { in mdesc_get_node()
566 rv = get_info_func(hp, hp_node, &hp_node_info); in mdesc_get_node()
582 int mdesc_get_node_info(struct mdesc_handle *hp, u64 node, in mdesc_get_node_info() argument
588 if (hp == NULL || node == MDESC_NODE_NULL || in mdesc_get_node_info()
601 rv = get_info_func(hp, node, node_info); in mdesc_get_node_info()
627 u64 mdesc_node_by_name(struct mdesc_handle *hp, in mdesc_node_by_name() argument
630 struct mdesc_elem *ep = node_block(&hp->mdesc); in mdesc_node_by_name()
631 const char *names = name_block(&hp->mdesc); in mdesc_node_by_name()
632 u64 last_node = hp->mdesc.node_sz / 16; in mdesc_node_by_name()
656 const void *mdesc_get_property(struct mdesc_handle *hp, u64 node, in mdesc_get_property() argument
659 const char *names = name_block(&hp->mdesc); in mdesc_get_property()
660 u64 last_node = hp->mdesc.node_sz / 16; in mdesc_get_property()
661 void *data = data_block(&hp->mdesc); in mdesc_get_property()
667 ep = node_block(&hp->mdesc) + node; in mdesc_get_property()
702 u64 mdesc_next_arc(struct mdesc_handle *hp, u64 from, const char *arc_type) in mdesc_next_arc() argument
704 struct mdesc_elem *ep, *base = node_block(&hp->mdesc); in mdesc_next_arc()
705 const char *names = name_block(&hp->mdesc); in mdesc_next_arc()
706 u64 last_node = hp->mdesc.node_sz / 16; in mdesc_next_arc()
728 u64 mdesc_arc_target(struct mdesc_handle *hp, u64 arc) in mdesc_arc_target() argument
730 struct mdesc_elem *ep, *base = node_block(&hp->mdesc); in mdesc_arc_target()
738 const char *mdesc_node_name(struct mdesc_handle *hp, u64 node) in mdesc_node_name() argument
740 struct mdesc_elem *ep, *base = node_block(&hp->mdesc); in mdesc_node_name()
741 const char *names = name_block(&hp->mdesc); in mdesc_node_name()
742 u64 last_node = hp->mdesc.node_sz / 16; in mdesc_node_name()
759 struct mdesc_handle *hp = mdesc_grab(); in report_platform_properties() local
760 u64 pn = mdesc_node_by_name(hp, MDESC_NODE_NULL, "platform"); in report_platform_properties()
769 s = mdesc_get_property(hp, pn, "banner-name", NULL); in report_platform_properties()
771 s = mdesc_get_property(hp, pn, "name", NULL); in report_platform_properties()
774 v = mdesc_get_property(hp, pn, "hostid", NULL); in report_platform_properties()
777 v = mdesc_get_property(hp, pn, "serial#", NULL); in report_platform_properties()
780 v = mdesc_get_property(hp, pn, "stick-frequency", NULL); in report_platform_properties()
782 v = mdesc_get_property(hp, pn, "mac-address", NULL); in report_platform_properties()
785 v = mdesc_get_property(hp, pn, "watchdog-resolution", NULL); in report_platform_properties()
788 v = mdesc_get_property(hp, pn, "watchdog-max-timeout", NULL); in report_platform_properties()
791 v = mdesc_get_property(hp, pn, "max-cpus", NULL); in report_platform_properties()
813 mdesc_release(hp); in report_platform_properties()
816 static void fill_in_one_cache(cpuinfo_sparc *c, struct mdesc_handle *hp, u64 mp) in fill_in_one_cache() argument
818 const u64 *level = mdesc_get_property(hp, mp, "level", NULL); in fill_in_one_cache()
819 const u64 *size = mdesc_get_property(hp, mp, "size", NULL); in fill_in_one_cache()
820 const u64 *line_size = mdesc_get_property(hp, mp, "line-size", NULL); in fill_in_one_cache()
824 type = mdesc_get_property(hp, mp, "type", &type_len); in fill_in_one_cache()
849 mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_FWD) { in fill_in_one_cache()
850 u64 target = mdesc_arc_target(hp, a); in fill_in_one_cache()
851 const char *name = mdesc_node_name(hp, target); in fill_in_one_cache()
854 fill_in_one_cache(c, hp, target); in fill_in_one_cache()
859 static void find_back_node_value(struct mdesc_handle *hp, u64 node, in find_back_node_value() argument
870 mdesc_for_each_arc(arc, hp, node, MDESC_ARC_TYPE_BACK) { in find_back_node_value()
871 u64 n = mdesc_arc_target(hp, arc); in find_back_node_value()
872 const char *name = mdesc_node_name(hp, n); in find_back_node_value()
875 (*func)(hp, n, val); in find_back_node_value()
877 find_back_node_value(hp, n, srch_val, func, val, depth-1); in find_back_node_value()
881 static void __mark_core_id(struct mdesc_handle *hp, u64 node, in __mark_core_id() argument
884 const u64 *id = mdesc_get_property(hp, node, "id", NULL); in __mark_core_id()
890 static void __mark_max_cache_id(struct mdesc_handle *hp, u64 node, in __mark_max_cache_id() argument
893 const u64 *id = mdesc_get_property(hp, node, "id", NULL); in __mark_max_cache_id()
906 static void mark_core_ids(struct mdesc_handle *hp, u64 mp, in mark_core_ids() argument
909 find_back_node_value(hp, mp, "cpu", __mark_core_id, core_id, 10); in mark_core_ids()
912 static void mark_max_cache_ids(struct mdesc_handle *hp, u64 mp, in mark_max_cache_ids() argument
915 find_back_node_value(hp, mp, "cpu", __mark_max_cache_id, in mark_max_cache_ids()
919 static void set_core_ids(struct mdesc_handle *hp) in set_core_ids() argument
929 mdesc_for_each_node_by_name(hp, mp, "cache") { in set_core_ids()
934 level = mdesc_get_property(hp, mp, "level", NULL); in set_core_ids()
938 type = mdesc_get_property(hp, mp, "type", &len); in set_core_ids()
942 mark_core_ids(hp, mp, idx); in set_core_ids()
947 static int set_max_cache_ids_by_cache(struct mdesc_handle *hp, int level) in set_max_cache_ids_by_cache() argument
957 mdesc_for_each_node_by_name(hp, mp, "cache") { in set_max_cache_ids_by_cache()
960 cur_lvl = mdesc_get_property(hp, mp, "level", NULL); in set_max_cache_ids_by_cache()
963 mark_max_cache_ids(hp, mp, idx); in set_max_cache_ids_by_cache()
970 static void set_sock_ids_by_socket(struct mdesc_handle *hp, u64 mp) in set_sock_ids_by_socket() argument
974 mdesc_for_each_node_by_name(hp, mp, "socket") { in set_sock_ids_by_socket()
977 mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_FWD) { in set_sock_ids_by_socket()
978 u64 t = mdesc_arc_target(hp, a); in set_sock_ids_by_socket()
982 name = mdesc_node_name(hp, t); in set_sock_ids_by_socket()
986 id = mdesc_get_property(hp, t, "id", NULL); in set_sock_ids_by_socket()
994 static void set_sock_ids(struct mdesc_handle *hp) in set_sock_ids() argument
1002 if (!set_max_cache_ids_by_cache(hp, 3)) in set_sock_ids()
1003 set_max_cache_ids_by_cache(hp, 2); in set_sock_ids()
1006 mp = mdesc_node_by_name(hp, MDESC_NODE_NULL, "sockets"); in set_sock_ids()
1008 set_sock_ids_by_socket(hp, mp); in set_sock_ids()
1011 static void mark_proc_ids(struct mdesc_handle *hp, u64 mp, int proc_id) in mark_proc_ids() argument
1015 mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_BACK) { in mark_proc_ids()
1016 u64 t = mdesc_arc_target(hp, a); in mark_proc_ids()
1020 name = mdesc_node_name(hp, t); in mark_proc_ids()
1024 id = mdesc_get_property(hp, t, "id", NULL); in mark_proc_ids()
1030 static void __set_proc_ids(struct mdesc_handle *hp, const char *exec_unit_name) in __set_proc_ids() argument
1036 mdesc_for_each_node_by_name(hp, mp, exec_unit_name) { in __set_proc_ids()
1040 type = mdesc_get_property(hp, mp, "type", &len); in __set_proc_ids()
1045 mark_proc_ids(hp, mp, idx); in __set_proc_ids()
1050 static void set_proc_ids(struct mdesc_handle *hp) in set_proc_ids() argument
1052 __set_proc_ids(hp, "exec_unit"); in set_proc_ids()
1053 __set_proc_ids(hp, "exec-unit"); in set_proc_ids()
1078 static void get_mondo_data(struct mdesc_handle *hp, u64 mp, in get_mondo_data() argument
1084 val = mdesc_get_property(hp, mp, "q-cpu-mondo-#bits", NULL); in get_mondo_data()
1087 val = mdesc_get_property(hp, mp, "q-dev-mondo-#bits", NULL); in get_mondo_data()
1090 val = mdesc_get_property(hp, mp, "q-resumable-#bits", NULL); in get_mondo_data()
1093 val = mdesc_get_property(hp, mp, "q-nonresumable-#bits", NULL); in get_mondo_data()
1107 struct mdesc_handle *hp = mdesc_grab(); in mdesc_iterate_over_cpus() local
1111 mdesc_for_each_node_by_name(hp, mp, "cpu") { in mdesc_iterate_over_cpus()
1112 const u64 *id = mdesc_get_property(hp, mp, "id", NULL); in mdesc_iterate_over_cpus()
1126 ret = func(hp, mp, cpuid, arg); in mdesc_iterate_over_cpus()
1131 mdesc_release(hp); in mdesc_iterate_over_cpus()
1135 static void *record_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid, in record_one_cpu() argument
1154 static void * __init check_one_pgsz(struct mdesc_handle *hp, u64 mp, int cpuid, void *arg) in check_one_pgsz() argument
1156 const u64 *pgsz_prop = mdesc_get_property(hp, mp, "mmu-page-size-list", NULL); in check_one_pgsz()
1178 static void *fill_in_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid, in fill_in_one_cpu() argument
1181 const u64 *cfreq = mdesc_get_property(hp, mp, "clock-frequency", NULL); in fill_in_one_cpu()
1200 get_mondo_data(hp, mp, tb); in fill_in_one_cpu()
1202 mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_FWD) { in fill_in_one_cpu()
1203 u64 j, t = mdesc_arc_target(hp, a); in fill_in_one_cpu()
1206 t_name = mdesc_node_name(hp, t); in fill_in_one_cpu()
1208 fill_in_one_cache(c, hp, t); in fill_in_one_cpu()
1212 mdesc_for_each_arc(j, hp, t, MDESC_ARC_TYPE_FWD) { in fill_in_one_cpu()
1213 u64 n = mdesc_arc_target(hp, j); in fill_in_one_cpu()
1216 n_name = mdesc_node_name(hp, n); in fill_in_one_cpu()
1218 fill_in_one_cache(c, hp, n); in fill_in_one_cpu()
1230 struct mdesc_handle *hp; in mdesc_fill_in_cpu_data() local
1234 hp = mdesc_grab(); in mdesc_fill_in_cpu_data()
1236 set_core_ids(hp); in mdesc_fill_in_cpu_data()
1237 set_proc_ids(hp); in mdesc_fill_in_cpu_data()
1238 set_sock_ids(hp); in mdesc_fill_in_cpu_data()
1240 mdesc_release(hp); in mdesc_fill_in_cpu_data()
1252 struct mdesc_handle *hp = mdesc_grab(); in mdesc_open() local
1254 if (!hp) in mdesc_open()
1257 file->private_data = hp; in mdesc_open()
1265 struct mdesc_handle *hp = file->private_data; in mdesc_read() local
1269 if (*offp >= hp->handle_size) in mdesc_read()
1272 bytes_left = hp->handle_size - *offp; in mdesc_read()
1276 mdesc = (unsigned char *)&hp->mdesc; in mdesc_read()
1288 struct mdesc_handle *hp = file->private_data; in mdesc_llseek() local
1290 return no_seek_end_llseek_size(file, offset, whence, hp->handle_size); in mdesc_llseek()
1325 struct mdesc_handle *hp; in sun4v_mdesc_init() local
1332 hp = mdesc_alloc(len, &memblock_mdesc_ops); in sun4v_mdesc_init()
1333 if (hp == NULL) { in sun4v_mdesc_init()
1338 status = sun4v_mach_desc(__pa(&hp->mdesc), len, &real_len); in sun4v_mdesc_init()
1343 mdesc_free(hp); in sun4v_mdesc_init()
1347 cur_mdesc = hp; in sun4v_mdesc_init()