Lines Matching full:hp

148 static void mdesc_handle_init(struct mdesc_handle *hp,  in mdesc_handle_init()  argument
152 BUG_ON(((unsigned long)&hp->mdesc) & (16UL - 1)); in mdesc_handle_init()
154 memset(hp, 0, handle_size); in mdesc_handle_init()
155 INIT_LIST_HEAD(&hp->list); in mdesc_handle_init()
156 hp->self_base = base; in mdesc_handle_init()
157 refcount_set(&hp->refcnt, 1); in mdesc_handle_init()
158 hp->handle_size = handle_size; in mdesc_handle_init()
164 struct mdesc_handle *hp; in mdesc_memblock_alloc() local
174 hp = NULL; in mdesc_memblock_alloc()
176 hp = __va(paddr); in mdesc_memblock_alloc()
177 mdesc_handle_init(hp, handle_size, hp); in mdesc_memblock_alloc()
179 return hp; in mdesc_memblock_alloc()
182 static void __init mdesc_memblock_free(struct mdesc_handle *hp) in mdesc_memblock_free() argument
187 BUG_ON(refcount_read(&hp->refcnt) != 0); in mdesc_memblock_free()
188 BUG_ON(!list_empty(&hp->list)); in mdesc_memblock_free()
190 alloc_size = PAGE_ALIGN(hp->handle_size); in mdesc_memblock_free()
191 start = __pa(hp); in mdesc_memblock_free()
203 struct mdesc_handle *hp; in mdesc_kmalloc() local
216 hp = (struct mdesc_handle *) addr; in mdesc_kmalloc()
218 mdesc_handle_init(hp, handle_size, base); in mdesc_kmalloc()
220 return hp; in mdesc_kmalloc()
223 static void mdesc_kfree(struct mdesc_handle *hp) in mdesc_kfree() argument
225 BUG_ON(refcount_read(&hp->refcnt) != 0); in mdesc_kfree()
226 BUG_ON(!list_empty(&hp->list)); in mdesc_kfree()
228 kfree(hp->self_base); in mdesc_kfree()
239 struct mdesc_handle *hp = mops->alloc(mdesc_size); in mdesc_alloc() local
241 if (hp) in mdesc_alloc()
242 hp->mops = mops; in mdesc_alloc()
244 return hp; in mdesc_alloc()
247 static void mdesc_free(struct mdesc_handle *hp) in mdesc_free() argument
249 hp->mops->free(hp); in mdesc_free()
258 struct mdesc_handle *hp; in mdesc_grab() local
262 hp = cur_mdesc; in mdesc_grab()
263 if (hp) in mdesc_grab()
264 refcount_inc(&hp->refcnt); in mdesc_grab()
267 return hp; in mdesc_grab()
271 void mdesc_release(struct mdesc_handle *hp) in mdesc_release() argument
276 if (refcount_dec_and_test(&hp->refcnt)) { in mdesc_release()
277 list_del_init(&hp->list); in mdesc_release()
278 hp->mops->free(hp); in mdesc_release()
318 static const u64 *parent_cfg_handle(struct mdesc_handle *hp, u64 node) in parent_cfg_handle() argument
324 mdesc_for_each_arc(a, hp, node, MDESC_ARC_TYPE_BACK) { in parent_cfg_handle()
327 target = mdesc_arc_target(hp, a); in parent_cfg_handle()
328 id = mdesc_get_property(hp, target, in parent_cfg_handle()
503 struct mdesc_handle *hp, *orig_hp; in mdesc_update() local
510 hp = mdesc_alloc(len, &kmalloc_mdesc_memops); in mdesc_update()
511 if (!hp) { in mdesc_update()
516 status = sun4v_mach_desc(__pa(&hp->mdesc), len, &real_len); in mdesc_update()
520 refcount_dec(&hp->refcnt); in mdesc_update()
521 mdesc_free(hp); in mdesc_update()
527 cur_mdesc = hp; in mdesc_update()
530 mdesc_notify_clients(orig_hp, hp); in mdesc_update()
543 u64 mdesc_get_node(struct mdesc_handle *hp, const char *node_name, in mdesc_get_node() argument
553 if (hp == NULL || node_name == NULL || node_info == NULL) in mdesc_get_node()
566 mdesc_for_each_node_by_name(hp, hp_node, node_name) { in mdesc_get_node()
567 rv = get_info_func(hp, hp_node, &hp_node_info); in mdesc_get_node()
583 int mdesc_get_node_info(struct mdesc_handle *hp, u64 node, in mdesc_get_node_info() argument
589 if (hp == NULL || node == MDESC_NODE_NULL || in mdesc_get_node_info()
602 rv = get_info_func(hp, node, node_info); in mdesc_get_node_info()
628 u64 mdesc_node_by_name(struct mdesc_handle *hp, in mdesc_node_by_name() argument
631 struct mdesc_elem *ep = node_block(&hp->mdesc); in mdesc_node_by_name()
632 const char *names = name_block(&hp->mdesc); in mdesc_node_by_name()
633 u64 last_node = hp->mdesc.node_sz / 16; in mdesc_node_by_name()
657 const void *mdesc_get_property(struct mdesc_handle *hp, u64 node, in mdesc_get_property() argument
660 const char *names = name_block(&hp->mdesc); in mdesc_get_property()
661 u64 last_node = hp->mdesc.node_sz / 16; in mdesc_get_property()
662 void *data = data_block(&hp->mdesc); in mdesc_get_property()
668 ep = node_block(&hp->mdesc) + node; in mdesc_get_property()
703 u64 mdesc_next_arc(struct mdesc_handle *hp, u64 from, const char *arc_type) in mdesc_next_arc() argument
705 struct mdesc_elem *ep, *base = node_block(&hp->mdesc); in mdesc_next_arc()
706 const char *names = name_block(&hp->mdesc); in mdesc_next_arc()
707 u64 last_node = hp->mdesc.node_sz / 16; in mdesc_next_arc()
729 u64 mdesc_arc_target(struct mdesc_handle *hp, u64 arc) in mdesc_arc_target() argument
731 struct mdesc_elem *ep, *base = node_block(&hp->mdesc); in mdesc_arc_target()
739 const char *mdesc_node_name(struct mdesc_handle *hp, u64 node) in mdesc_node_name() argument
741 struct mdesc_elem *ep, *base = node_block(&hp->mdesc); in mdesc_node_name()
742 const char *names = name_block(&hp->mdesc); in mdesc_node_name()
743 u64 last_node = hp->mdesc.node_sz / 16; in mdesc_node_name()
760 struct mdesc_handle *hp = mdesc_grab(); in report_platform_properties() local
761 u64 pn = mdesc_node_by_name(hp, MDESC_NODE_NULL, "platform"); in report_platform_properties()
770 s = mdesc_get_property(hp, pn, "banner-name", NULL); in report_platform_properties()
772 s = mdesc_get_property(hp, pn, "name", NULL); in report_platform_properties()
775 v = mdesc_get_property(hp, pn, "hostid", NULL); in report_platform_properties()
778 v = mdesc_get_property(hp, pn, "serial#", NULL); in report_platform_properties()
781 v = mdesc_get_property(hp, pn, "stick-frequency", NULL); in report_platform_properties()
783 v = mdesc_get_property(hp, pn, "mac-address", NULL); in report_platform_properties()
786 v = mdesc_get_property(hp, pn, "watchdog-resolution", NULL); in report_platform_properties()
789 v = mdesc_get_property(hp, pn, "watchdog-max-timeout", NULL); in report_platform_properties()
792 v = mdesc_get_property(hp, pn, "max-cpus", NULL); in report_platform_properties()
814 mdesc_release(hp); in report_platform_properties()
817 static void fill_in_one_cache(cpuinfo_sparc *c, struct mdesc_handle *hp, u64 mp) in fill_in_one_cache() argument
819 const u64 *level = mdesc_get_property(hp, mp, "level", NULL); in fill_in_one_cache()
820 const u64 *size = mdesc_get_property(hp, mp, "size", NULL); in fill_in_one_cache()
821 const u64 *line_size = mdesc_get_property(hp, mp, "line-size", NULL); in fill_in_one_cache()
825 type = mdesc_get_property(hp, mp, "type", &type_len); in fill_in_one_cache()
850 mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_FWD) { in fill_in_one_cache()
851 u64 target = mdesc_arc_target(hp, a); in fill_in_one_cache()
852 const char *name = mdesc_node_name(hp, target); in fill_in_one_cache()
855 fill_in_one_cache(c, hp, target); in fill_in_one_cache()
860 static void find_back_node_value(struct mdesc_handle *hp, u64 node, in find_back_node_value() argument
871 mdesc_for_each_arc(arc, hp, node, MDESC_ARC_TYPE_BACK) { in find_back_node_value()
872 u64 n = mdesc_arc_target(hp, arc); in find_back_node_value()
873 const char *name = mdesc_node_name(hp, n); in find_back_node_value()
876 (*func)(hp, n, val); in find_back_node_value()
878 find_back_node_value(hp, n, srch_val, func, val, depth-1); in find_back_node_value()
882 static void __mark_core_id(struct mdesc_handle *hp, u64 node, in __mark_core_id() argument
885 const u64 *id = mdesc_get_property(hp, node, "id", NULL); in __mark_core_id()
891 static void __mark_max_cache_id(struct mdesc_handle *hp, u64 node, in __mark_max_cache_id() argument
894 const u64 *id = mdesc_get_property(hp, node, "id", NULL); in __mark_max_cache_id()
907 static void mark_core_ids(struct mdesc_handle *hp, u64 mp, in mark_core_ids() argument
910 find_back_node_value(hp, mp, "cpu", __mark_core_id, core_id, 10); in mark_core_ids()
913 static void mark_max_cache_ids(struct mdesc_handle *hp, u64 mp, in mark_max_cache_ids() argument
916 find_back_node_value(hp, mp, "cpu", __mark_max_cache_id, in mark_max_cache_ids()
920 static void set_core_ids(struct mdesc_handle *hp) in set_core_ids() argument
930 mdesc_for_each_node_by_name(hp, mp, "cache") { in set_core_ids()
935 level = mdesc_get_property(hp, mp, "level", NULL); in set_core_ids()
939 type = mdesc_get_property(hp, mp, "type", &len); in set_core_ids()
943 mark_core_ids(hp, mp, idx); in set_core_ids()
948 static int set_max_cache_ids_by_cache(struct mdesc_handle *hp, int level) in set_max_cache_ids_by_cache() argument
958 mdesc_for_each_node_by_name(hp, mp, "cache") { in set_max_cache_ids_by_cache()
961 cur_lvl = mdesc_get_property(hp, mp, "level", NULL); in set_max_cache_ids_by_cache()
964 mark_max_cache_ids(hp, mp, idx); in set_max_cache_ids_by_cache()
971 static void set_sock_ids_by_socket(struct mdesc_handle *hp, u64 mp) in set_sock_ids_by_socket() argument
975 mdesc_for_each_node_by_name(hp, mp, "socket") { in set_sock_ids_by_socket()
978 mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_FWD) { in set_sock_ids_by_socket()
979 u64 t = mdesc_arc_target(hp, a); in set_sock_ids_by_socket()
983 name = mdesc_node_name(hp, t); in set_sock_ids_by_socket()
987 id = mdesc_get_property(hp, t, "id", NULL); in set_sock_ids_by_socket()
995 static void set_sock_ids(struct mdesc_handle *hp) in set_sock_ids() argument
1003 if (!set_max_cache_ids_by_cache(hp, 3)) in set_sock_ids()
1004 set_max_cache_ids_by_cache(hp, 2); in set_sock_ids()
1007 mp = mdesc_node_by_name(hp, MDESC_NODE_NULL, "sockets"); in set_sock_ids()
1009 set_sock_ids_by_socket(hp, mp); in set_sock_ids()
1012 static void mark_proc_ids(struct mdesc_handle *hp, u64 mp, int proc_id) in mark_proc_ids() argument
1016 mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_BACK) { in mark_proc_ids()
1017 u64 t = mdesc_arc_target(hp, a); in mark_proc_ids()
1021 name = mdesc_node_name(hp, t); in mark_proc_ids()
1025 id = mdesc_get_property(hp, t, "id", NULL); in mark_proc_ids()
1031 static void __set_proc_ids(struct mdesc_handle *hp, const char *exec_unit_name) in __set_proc_ids() argument
1037 mdesc_for_each_node_by_name(hp, mp, exec_unit_name) { in __set_proc_ids()
1041 type = mdesc_get_property(hp, mp, "type", &len); in __set_proc_ids()
1046 mark_proc_ids(hp, mp, idx); in __set_proc_ids()
1051 static void set_proc_ids(struct mdesc_handle *hp) in set_proc_ids() argument
1053 __set_proc_ids(hp, "exec_unit"); in set_proc_ids()
1054 __set_proc_ids(hp, "exec-unit"); in set_proc_ids()
1079 static void get_mondo_data(struct mdesc_handle *hp, u64 mp, in get_mondo_data() argument
1085 val = mdesc_get_property(hp, mp, "q-cpu-mondo-#bits", NULL); in get_mondo_data()
1088 val = mdesc_get_property(hp, mp, "q-dev-mondo-#bits", NULL); in get_mondo_data()
1091 val = mdesc_get_property(hp, mp, "q-resumable-#bits", NULL); in get_mondo_data()
1094 val = mdesc_get_property(hp, mp, "q-nonresumable-#bits", NULL); in get_mondo_data()
1108 struct mdesc_handle *hp = mdesc_grab(); in mdesc_iterate_over_cpus() local
1112 mdesc_for_each_node_by_name(hp, mp, "cpu") { in mdesc_iterate_over_cpus()
1113 const u64 *id = mdesc_get_property(hp, mp, "id", NULL); in mdesc_iterate_over_cpus()
1127 ret = func(hp, mp, cpuid, arg); in mdesc_iterate_over_cpus()
1132 mdesc_release(hp); in mdesc_iterate_over_cpus()
1136 static void *record_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid, in record_one_cpu() argument
1155 static void * __init check_one_pgsz(struct mdesc_handle *hp, u64 mp, int cpuid, void *arg) in check_one_pgsz() argument
1157 const u64 *pgsz_prop = mdesc_get_property(hp, mp, "mmu-page-size-list", NULL); in check_one_pgsz()
1179 static void *fill_in_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid, in fill_in_one_cpu() argument
1182 const u64 *cfreq = mdesc_get_property(hp, mp, "clock-frequency", NULL); in fill_in_one_cpu()
1201 get_mondo_data(hp, mp, tb); in fill_in_one_cpu()
1203 mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_FWD) { in fill_in_one_cpu()
1204 u64 j, t = mdesc_arc_target(hp, a); in fill_in_one_cpu()
1207 t_name = mdesc_node_name(hp, t); in fill_in_one_cpu()
1209 fill_in_one_cache(c, hp, t); in fill_in_one_cpu()
1213 mdesc_for_each_arc(j, hp, t, MDESC_ARC_TYPE_FWD) { in fill_in_one_cpu()
1214 u64 n = mdesc_arc_target(hp, j); in fill_in_one_cpu()
1217 n_name = mdesc_node_name(hp, n); in fill_in_one_cpu()
1219 fill_in_one_cache(c, hp, n); in fill_in_one_cpu()
1231 struct mdesc_handle *hp; in mdesc_fill_in_cpu_data() local
1235 hp = mdesc_grab(); in mdesc_fill_in_cpu_data()
1237 set_core_ids(hp); in mdesc_fill_in_cpu_data()
1238 set_proc_ids(hp); in mdesc_fill_in_cpu_data()
1239 set_sock_ids(hp); in mdesc_fill_in_cpu_data()
1241 mdesc_release(hp); in mdesc_fill_in_cpu_data()
1253 struct mdesc_handle *hp = mdesc_grab(); in mdesc_open() local
1255 if (!hp) in mdesc_open()
1258 file->private_data = hp; in mdesc_open()
1266 struct mdesc_handle *hp = file->private_data; in mdesc_read() local
1270 if (*offp >= hp->handle_size) in mdesc_read()
1273 bytes_left = hp->handle_size - *offp; in mdesc_read()
1277 mdesc = (unsigned char *)&hp->mdesc; in mdesc_read()
1289 struct mdesc_handle *hp = file->private_data; in mdesc_llseek() local
1291 return no_seek_end_llseek_size(file, offset, whence, hp->handle_size); in mdesc_llseek()
1326 struct mdesc_handle *hp; in sun4v_mdesc_init() local
1333 hp = mdesc_alloc(len, &memblock_mdesc_ops); in sun4v_mdesc_init()
1334 if (hp == NULL) { in sun4v_mdesc_init()
1339 status = sun4v_mach_desc(__pa(&hp->mdesc), len, &real_len); in sun4v_mdesc_init()
1344 mdesc_free(hp); in sun4v_mdesc_init()
1348 cur_mdesc = hp; in sun4v_mdesc_init()