Lines Matching defs:hp

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