Lines Matching full:hp

149 static void mdesc_handle_init(struct mdesc_handle *hp,  in mdesc_handle_init()  argument
153 BUG_ON(((unsigned long)&hp->mdesc) & (16UL - 1)); in mdesc_handle_init()
155 memset(hp, 0, handle_size); in mdesc_handle_init()
156 INIT_LIST_HEAD(&hp->list); in mdesc_handle_init()
157 hp->self_base = base; in mdesc_handle_init()
158 refcount_set(&hp->refcnt, 1); in mdesc_handle_init()
159 hp->handle_size = handle_size; in mdesc_handle_init()
165 struct mdesc_handle *hp; in mdesc_memblock_alloc() local
175 hp = NULL; in mdesc_memblock_alloc()
177 hp = __va(paddr); in mdesc_memblock_alloc()
178 mdesc_handle_init(hp, handle_size, hp); in mdesc_memblock_alloc()
180 return hp; in mdesc_memblock_alloc()
183 static void __init mdesc_memblock_free(struct mdesc_handle *hp) in mdesc_memblock_free() argument
188 BUG_ON(refcount_read(&hp->refcnt) != 0); in mdesc_memblock_free()
189 BUG_ON(!list_empty(&hp->list)); in mdesc_memblock_free()
191 alloc_size = PAGE_ALIGN(hp->handle_size); in mdesc_memblock_free()
192 start = __pa(hp); in mdesc_memblock_free()
204 struct mdesc_handle *hp; in mdesc_kmalloc() local
217 hp = (struct mdesc_handle *) addr; in mdesc_kmalloc()
219 mdesc_handle_init(hp, handle_size, base); in mdesc_kmalloc()
221 return hp; in mdesc_kmalloc()
224 static void mdesc_kfree(struct mdesc_handle *hp) in mdesc_kfree() argument
226 BUG_ON(refcount_read(&hp->refcnt) != 0); in mdesc_kfree()
227 BUG_ON(!list_empty(&hp->list)); in mdesc_kfree()
229 kfree(hp->self_base); in mdesc_kfree()
240 struct mdesc_handle *hp = mops->alloc(mdesc_size); in mdesc_alloc() local
242 if (hp) in mdesc_alloc()
243 hp->mops = mops; in mdesc_alloc()
245 return hp; in mdesc_alloc()
248 static void mdesc_free(struct mdesc_handle *hp) in mdesc_free() argument
250 hp->mops->free(hp); in mdesc_free()
259 struct mdesc_handle *hp; in mdesc_grab() local
263 hp = cur_mdesc; in mdesc_grab()
264 if (hp) in mdesc_grab()
265 refcount_inc(&hp->refcnt); in mdesc_grab()
268 return hp; in mdesc_grab()
272 void mdesc_release(struct mdesc_handle *hp) in mdesc_release() argument
277 if (refcount_dec_and_test(&hp->refcnt)) { in mdesc_release()
278 list_del_init(&hp->list); in mdesc_release()
279 hp->mops->free(hp); in mdesc_release()
319 static const u64 *parent_cfg_handle(struct mdesc_handle *hp, u64 node) in parent_cfg_handle() argument
325 mdesc_for_each_arc(a, hp, node, MDESC_ARC_TYPE_BACK) { in parent_cfg_handle()
328 target = mdesc_arc_target(hp, a); in parent_cfg_handle()
329 id = mdesc_get_property(hp, target, in parent_cfg_handle()
504 struct mdesc_handle *hp, *orig_hp; in mdesc_update() local
511 hp = mdesc_alloc(len, &kmalloc_mdesc_memops); in mdesc_update()
512 if (!hp) { in mdesc_update()
517 status = sun4v_mach_desc(__pa(&hp->mdesc), len, &real_len); in mdesc_update()
521 refcount_dec(&hp->refcnt); in mdesc_update()
522 mdesc_free(hp); in mdesc_update()
528 cur_mdesc = hp; in mdesc_update()
531 mdesc_notify_clients(orig_hp, hp); in mdesc_update()
544 u64 mdesc_get_node(struct mdesc_handle *hp, const char *node_name, in mdesc_get_node() argument
554 if (hp == NULL || node_name == NULL || node_info == NULL) in mdesc_get_node()
567 mdesc_for_each_node_by_name(hp, hp_node, node_name) { in mdesc_get_node()
568 rv = get_info_func(hp, hp_node, &hp_node_info); in mdesc_get_node()
584 int mdesc_get_node_info(struct mdesc_handle *hp, u64 node, in mdesc_get_node_info() argument
590 if (hp == NULL || node == MDESC_NODE_NULL || in mdesc_get_node_info()
603 rv = get_info_func(hp, node, node_info); in mdesc_get_node_info()
629 u64 mdesc_node_by_name(struct mdesc_handle *hp, in mdesc_node_by_name() argument
632 struct mdesc_elem *ep = node_block(&hp->mdesc); in mdesc_node_by_name()
633 const char *names = name_block(&hp->mdesc); in mdesc_node_by_name()
634 u64 last_node = hp->mdesc.node_sz / 16; in mdesc_node_by_name()
658 const void *mdesc_get_property(struct mdesc_handle *hp, u64 node, in mdesc_get_property() argument
661 const char *names = name_block(&hp->mdesc); in mdesc_get_property()
662 u64 last_node = hp->mdesc.node_sz / 16; in mdesc_get_property()
663 void *data = data_block(&hp->mdesc); in mdesc_get_property()
669 ep = node_block(&hp->mdesc) + node; in mdesc_get_property()
704 u64 mdesc_next_arc(struct mdesc_handle *hp, u64 from, const char *arc_type) in mdesc_next_arc() argument
706 struct mdesc_elem *ep, *base = node_block(&hp->mdesc); in mdesc_next_arc()
707 const char *names = name_block(&hp->mdesc); in mdesc_next_arc()
708 u64 last_node = hp->mdesc.node_sz / 16; in mdesc_next_arc()
730 u64 mdesc_arc_target(struct mdesc_handle *hp, u64 arc) in mdesc_arc_target() argument
732 struct mdesc_elem *ep, *base = node_block(&hp->mdesc); in mdesc_arc_target()
740 const char *mdesc_node_name(struct mdesc_handle *hp, u64 node) in mdesc_node_name() argument
742 struct mdesc_elem *ep, *base = node_block(&hp->mdesc); in mdesc_node_name()
743 const char *names = name_block(&hp->mdesc); in mdesc_node_name()
744 u64 last_node = hp->mdesc.node_sz / 16; in mdesc_node_name()
761 struct mdesc_handle *hp = mdesc_grab(); in report_platform_properties() local
762 u64 pn = mdesc_node_by_name(hp, MDESC_NODE_NULL, "platform"); in report_platform_properties()
771 s = mdesc_get_property(hp, pn, "banner-name", NULL); in report_platform_properties()
773 s = mdesc_get_property(hp, pn, "name", NULL); in report_platform_properties()
776 v = mdesc_get_property(hp, pn, "hostid", NULL); in report_platform_properties()
779 v = mdesc_get_property(hp, pn, "serial#", NULL); in report_platform_properties()
782 v = mdesc_get_property(hp, pn, "stick-frequency", NULL); in report_platform_properties()
784 v = mdesc_get_property(hp, pn, "mac-address", NULL); in report_platform_properties()
787 v = mdesc_get_property(hp, pn, "watchdog-resolution", NULL); in report_platform_properties()
790 v = mdesc_get_property(hp, pn, "watchdog-max-timeout", NULL); in report_platform_properties()
793 v = mdesc_get_property(hp, pn, "max-cpus", NULL); in report_platform_properties()
815 mdesc_release(hp); in report_platform_properties()
818 static void fill_in_one_cache(cpuinfo_sparc *c, struct mdesc_handle *hp, u64 mp) in fill_in_one_cache() argument
820 const u64 *level = mdesc_get_property(hp, mp, "level", NULL); in fill_in_one_cache()
821 const u64 *size = mdesc_get_property(hp, mp, "size", NULL); in fill_in_one_cache()
822 const u64 *line_size = mdesc_get_property(hp, mp, "line-size", NULL); in fill_in_one_cache()
826 type = mdesc_get_property(hp, mp, "type", &type_len); in fill_in_one_cache()
851 mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_FWD) { in fill_in_one_cache()
852 u64 target = mdesc_arc_target(hp, a); in fill_in_one_cache()
853 const char *name = mdesc_node_name(hp, target); in fill_in_one_cache()
856 fill_in_one_cache(c, hp, target); in fill_in_one_cache()
861 static void find_back_node_value(struct mdesc_handle *hp, u64 node, in find_back_node_value() argument
872 mdesc_for_each_arc(arc, hp, node, MDESC_ARC_TYPE_BACK) { in find_back_node_value()
873 u64 n = mdesc_arc_target(hp, arc); in find_back_node_value()
874 const char *name = mdesc_node_name(hp, n); in find_back_node_value()
877 (*func)(hp, n, val); in find_back_node_value()
879 find_back_node_value(hp, n, srch_val, func, val, depth-1); in find_back_node_value()
883 static void __mark_core_id(struct mdesc_handle *hp, u64 node, in __mark_core_id() argument
886 const u64 *id = mdesc_get_property(hp, node, "id", NULL); in __mark_core_id()
892 static void __mark_max_cache_id(struct mdesc_handle *hp, u64 node, in __mark_max_cache_id() argument
895 const u64 *id = mdesc_get_property(hp, node, "id", NULL); in __mark_max_cache_id()
908 static void mark_core_ids(struct mdesc_handle *hp, u64 mp, in mark_core_ids() argument
911 find_back_node_value(hp, mp, "cpu", __mark_core_id, core_id, 10); in mark_core_ids()
914 static void mark_max_cache_ids(struct mdesc_handle *hp, u64 mp, in mark_max_cache_ids() argument
917 find_back_node_value(hp, mp, "cpu", __mark_max_cache_id, in mark_max_cache_ids()
921 static void set_core_ids(struct mdesc_handle *hp) in set_core_ids() argument
931 mdesc_for_each_node_by_name(hp, mp, "cache") { in set_core_ids()
936 level = mdesc_get_property(hp, mp, "level", NULL); in set_core_ids()
940 type = mdesc_get_property(hp, mp, "type", &len); in set_core_ids()
944 mark_core_ids(hp, mp, idx); in set_core_ids()
949 static int set_max_cache_ids_by_cache(struct mdesc_handle *hp, int level) in set_max_cache_ids_by_cache() argument
959 mdesc_for_each_node_by_name(hp, mp, "cache") { in set_max_cache_ids_by_cache()
962 cur_lvl = mdesc_get_property(hp, mp, "level", NULL); in set_max_cache_ids_by_cache()
965 mark_max_cache_ids(hp, mp, idx); in set_max_cache_ids_by_cache()
972 static void set_sock_ids_by_socket(struct mdesc_handle *hp, u64 mp) in set_sock_ids_by_socket() argument
976 mdesc_for_each_node_by_name(hp, mp, "socket") { in set_sock_ids_by_socket()
979 mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_FWD) { in set_sock_ids_by_socket()
980 u64 t = mdesc_arc_target(hp, a); in set_sock_ids_by_socket()
984 name = mdesc_node_name(hp, t); in set_sock_ids_by_socket()
988 id = mdesc_get_property(hp, t, "id", NULL); in set_sock_ids_by_socket()
996 static void set_sock_ids(struct mdesc_handle *hp) in set_sock_ids() argument
1004 if (!set_max_cache_ids_by_cache(hp, 3)) in set_sock_ids()
1005 set_max_cache_ids_by_cache(hp, 2); in set_sock_ids()
1008 mp = mdesc_node_by_name(hp, MDESC_NODE_NULL, "sockets"); in set_sock_ids()
1010 set_sock_ids_by_socket(hp, mp); in set_sock_ids()
1013 static void mark_proc_ids(struct mdesc_handle *hp, u64 mp, int proc_id) in mark_proc_ids() argument
1017 mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_BACK) { in mark_proc_ids()
1018 u64 t = mdesc_arc_target(hp, a); in mark_proc_ids()
1022 name = mdesc_node_name(hp, t); in mark_proc_ids()
1026 id = mdesc_get_property(hp, t, "id", NULL); in mark_proc_ids()
1032 static void __set_proc_ids(struct mdesc_handle *hp, const char *exec_unit_name) in __set_proc_ids() argument
1038 mdesc_for_each_node_by_name(hp, mp, exec_unit_name) { in __set_proc_ids()
1042 type = mdesc_get_property(hp, mp, "type", &len); in __set_proc_ids()
1047 mark_proc_ids(hp, mp, idx); in __set_proc_ids()
1052 static void set_proc_ids(struct mdesc_handle *hp) in set_proc_ids() argument
1054 __set_proc_ids(hp, "exec_unit"); in set_proc_ids()
1055 __set_proc_ids(hp, "exec-unit"); in set_proc_ids()
1080 static void get_mondo_data(struct mdesc_handle *hp, u64 mp, in get_mondo_data() argument
1086 val = mdesc_get_property(hp, mp, "q-cpu-mondo-#bits", NULL); in get_mondo_data()
1089 val = mdesc_get_property(hp, mp, "q-dev-mondo-#bits", NULL); in get_mondo_data()
1092 val = mdesc_get_property(hp, mp, "q-resumable-#bits", NULL); in get_mondo_data()
1095 val = mdesc_get_property(hp, mp, "q-nonresumable-#bits", NULL); in get_mondo_data()
1109 struct mdesc_handle *hp = mdesc_grab(); in mdesc_iterate_over_cpus() local
1113 mdesc_for_each_node_by_name(hp, mp, "cpu") { in mdesc_iterate_over_cpus()
1114 const u64 *id = mdesc_get_property(hp, mp, "id", NULL); in mdesc_iterate_over_cpus()
1128 ret = func(hp, mp, cpuid, arg); in mdesc_iterate_over_cpus()
1133 mdesc_release(hp); in mdesc_iterate_over_cpus()
1137 static void *record_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid, in record_one_cpu() argument
1156 static void * __init check_one_pgsz(struct mdesc_handle *hp, u64 mp, int cpuid, void *arg) in check_one_pgsz() argument
1158 const u64 *pgsz_prop = mdesc_get_property(hp, mp, "mmu-page-size-list", NULL); in check_one_pgsz()
1180 static void *fill_in_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid, in fill_in_one_cpu() argument
1183 const u64 *cfreq = mdesc_get_property(hp, mp, "clock-frequency", NULL); in fill_in_one_cpu()
1202 get_mondo_data(hp, mp, tb); in fill_in_one_cpu()
1204 mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_FWD) { in fill_in_one_cpu()
1205 u64 j, t = mdesc_arc_target(hp, a); in fill_in_one_cpu()
1208 t_name = mdesc_node_name(hp, t); in fill_in_one_cpu()
1210 fill_in_one_cache(c, hp, t); in fill_in_one_cpu()
1214 mdesc_for_each_arc(j, hp, t, MDESC_ARC_TYPE_FWD) { in fill_in_one_cpu()
1215 u64 n = mdesc_arc_target(hp, j); in fill_in_one_cpu()
1218 n_name = mdesc_node_name(hp, n); in fill_in_one_cpu()
1220 fill_in_one_cache(c, hp, n); in fill_in_one_cpu()
1232 struct mdesc_handle *hp; in mdesc_fill_in_cpu_data() local
1236 hp = mdesc_grab(); in mdesc_fill_in_cpu_data()
1238 set_core_ids(hp); in mdesc_fill_in_cpu_data()
1239 set_proc_ids(hp); in mdesc_fill_in_cpu_data()
1240 set_sock_ids(hp); in mdesc_fill_in_cpu_data()
1242 mdesc_release(hp); in mdesc_fill_in_cpu_data()
1254 struct mdesc_handle *hp = mdesc_grab(); in mdesc_open() local
1256 if (!hp) in mdesc_open()
1259 file->private_data = hp; in mdesc_open()
1267 struct mdesc_handle *hp = file->private_data; in mdesc_read() local
1271 if (*offp >= hp->handle_size) in mdesc_read()
1274 bytes_left = hp->handle_size - *offp; in mdesc_read()
1278 mdesc = (unsigned char *)&hp->mdesc; in mdesc_read()
1290 struct mdesc_handle *hp = file->private_data; in mdesc_llseek() local
1292 return no_seek_end_llseek_size(file, offset, whence, hp->handle_size); in mdesc_llseek()
1327 struct mdesc_handle *hp; in sun4v_mdesc_init() local
1334 hp = mdesc_alloc(len, &memblock_mdesc_ops); in sun4v_mdesc_init()
1335 if (hp == NULL) { in sun4v_mdesc_init()
1340 status = sun4v_mach_desc(__pa(&hp->mdesc), len, &real_len); in sun4v_mdesc_init()
1345 mdesc_free(hp); in sun4v_mdesc_init()
1349 cur_mdesc = hp; in sun4v_mdesc_init()