Mercurial > illumos > illumos-gate
changeset 6902:5b004da8de91
6694939 LDoms cpu DR leaves picl tree out of sync.
author | mb158278 |
---|---|
date | Wed, 18 Jun 2008 11:59:22 -0700 |
parents | 307e592cef33 |
children | f4d957afe700 |
files | usr/src/cmd/picl/plugins/sun4v/mdesc/cpu_prop_update.c usr/src/cmd/picl/plugins/sun4v/mdesc/dr.c usr/src/cmd/picl/plugins/sun4v/mdesc/mdescplugin.c |
diffstat | 3 files changed, 117 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/picl/plugins/sun4v/mdesc/cpu_prop_update.c Wed Jun 18 08:22:31 2008 -0700 +++ b/usr/src/cmd/picl/plugins/sun4v/mdesc/cpu_prop_update.c Wed Jun 18 11:59:22 2008 -0700 @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -204,6 +204,74 @@ } } +static void +add_clock_frequency(picl_nodehdl_t pnode, mde_cookie_t mnode) +{ + uint64_t uint64_value; + uint32_t uint32_value; + + if (md_get_prop_val(mdp, mnode, "clock-frequency", + &uint64_value)) { + return; + } + uint32_value = (uint32_t)(uint64_value & UINT32_MAX); + add_md_prop(pnode, sizeof (uint32_value), "clock-frequency", + &uint32_value, PICL_PTYPE_UNSIGNED_INT); +} + +/* + * Return the number of strings in the buffer + */ +static int +get_string_count(char *strdat, int length) +{ + int count; + char *lastnull; + char *nullptr; + + count = 1; + for (lastnull = &strdat[length - 1], nullptr = strchr(strdat, '\0'); + nullptr != lastnull; nullptr = strchr(nullptr + 1, '\0')) + count++; + + return (count); +} + +static void +add_compatible(picl_nodehdl_t pnode, mde_cookie_t mnode) +{ + char *compat; + int len; + int count; + void add_string_list_prop(picl_nodehdl_t, char *, char *, + unsigned int); + + if (prop_exists(pnode, "compatible")) + return; + if (md_get_prop_data(mdp, mnode, "compatible", (uint8_t **)&compat, + &len)) { + return; + } + if (compat[0] == '\0' || compat[len - 1] != '\0') + return; + count = get_string_count(compat, len); + if (count == 1) { + add_md_prop(pnode, len, "compatible", compat, + PICL_PTYPE_CHARSTRING); + return; + } + (void) add_string_list_prop(pnode, "compatible", compat, count); +} + +static void +add_device_type(picl_nodehdl_t pnode) +{ + char *device_type = "cpu"; + + add_md_prop(pnode, strlen(device_type) + 1, "device_type", device_type, + PICL_PTYPE_CHARSTRING); +} + int add_cpu_prop(picl_nodehdl_t node, void *args) { @@ -278,6 +346,12 @@ add_md_prop(node, sizeof (int_value), OBP_PROP_PORTID, &int_value, PICL_PTYPE_INT); + add_clock_frequency(node, cpulistp[x]); + + add_compatible(node, cpulistp[x]); + + add_device_type(node); + /* get caches for CPU */ ncaches = md_scan_dag(mdp, cpulistp[x], md_find_name(mdp, "cache"),
--- a/usr/src/cmd/picl/plugins/sun4v/mdesc/dr.c Wed Jun 18 08:22:31 2008 -0700 +++ b/usr/src/cmd/picl/plugins/sun4v/mdesc/dr.c Wed Jun 18 11:59:22 2008 -0700 @@ -20,7 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -43,7 +43,7 @@ * This function is identical to the one in the picldevtree plugin. * Unfortunately we can't just reuse that code. */ -static int +int add_string_list_prop(picl_nodehdl_t nodeh, char *name, char *strlist, unsigned int nrows) { @@ -164,7 +164,7 @@ for (di_prop = di_prop_next(di_node, DI_PROP_NIL); di_prop != DI_PROP_NIL; - di_prop = di_prop_next(di_node, di_prop)) { + di_prop = di_prop_next(di_node, di_prop)) { di_val = di_prop_name(di_prop); di_ptype = di_prop_type(di_prop); @@ -248,6 +248,36 @@ } /* + * add OBP_REG property to picl cpu node if it's not already there. + */ +static void +add_reg_prop(picl_nodehdl_t pn, di_node_t dn) +{ + int reg_prop[SUN4V_CPU_REGSIZE]; + int status; + int dlen; + int *pdata; + ptree_propinfo_t propinfo; + + status = ptree_get_propval_by_name(pn, OBP_REG, reg_prop, + sizeof (reg_prop)); + if (status == PICL_SUCCESS) { + return; + } + dlen = di_prom_prop_lookup_ints(ph, dn, OBP_REG, &pdata); + if (dlen < 0) { + return; + } + status = ptree_init_propinfo(&propinfo, PTREE_PROPINFO_VERSION, + PICL_PTYPE_BYTEARRAY, PICL_READ, dlen * sizeof (int), OBP_REG, + NULL, NULL); + if (status != PICL_SUCCESS) { + return; + } + (void) ptree_create_and_add_prop(pn, &propinfo, pdata, NULL); +} + +/* * Create a picl node of type cpu and fill it. * properties are filled from both the device tree and the * Machine description. @@ -267,6 +297,7 @@ return (err); add_devinfo_props(anodeh, dn); + add_reg_prop(anodeh, dn); (void) add_cpu_prop(anodeh, NULL); return (err);
--- a/usr/src/cmd/picl/plugins/sun4v/mdesc/mdescplugin.c Wed Jun 18 08:22:31 2008 -0700 +++ b/usr/src/cmd/picl/plugins/sun4v/mdesc/mdescplugin.c Wed Jun 18 11:59:22 2008 -0700 @@ -20,7 +20,7 @@ */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -271,6 +271,13 @@ if (mdp == NULL) return; + /* + * update the cpu configuration in case the snapshot cache used by the + * devtree plugin is out of date. + */ + (void) update_devices(OBP_CPU, DEV_ADD); + (void) update_devices(OBP_CPU, DEV_REMOVE); + rootnode = md_root_node(mdp); /*