Lines Matching full:bmc

307  * accessing those.  If those change on a BMC, a new BMC is allocated.
311 struct list_head intfs; /* Interfaces on this BMC. */
326 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,
461 * interface is used by being looked up through the BMC
467 struct bmc_device *bmc; member
545 * The event receiver for my BMC, only really used at panic
619 * This mutex keeps us from adding the same BMC twice.
2384 msg->msg.data, msg->msg.data_len, &intf->bmc->fetch_id); in bmc_device_id_handler()
2388 intf->bmc->cc = msg->msg.data[0]; in bmc_device_id_handler()
2389 intf->bmc->dyn_id_set = 0; in bmc_device_id_handler()
2396 intf->bmc->dyn_id_set = 1; in bmc_device_id_handler()
2431 static int __get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc) in __get_device_id() argument
2439 bmc->cc = 0; in __get_device_id()
2440 bmc->dyn_id_set = 2; in __get_device_id()
2446 wait_event(intf->waitq, bmc->dyn_id_set != 2); in __get_device_id()
2448 if (!bmc->dyn_id_set) { in __get_device_id()
2449 if ((bmc->cc == IPMI_DEVICE_IN_FW_UPDATE_ERR in __get_device_id()
2450 || bmc->cc == IPMI_DEVICE_IN_INIT_ERR in __get_device_id()
2451 || bmc->cc == IPMI_NOT_IN_MY_STATE_ERR) in __get_device_id()
2455 "BMC returned 0x%2.2x, retry get bmc device id\n", in __get_device_id()
2456 bmc->cc); in __get_device_id()
2473 * Fetch the device id for the bmc/interface. You must pass in either
2474 * bmc or intf, this code will get the other one. If the data has
2481 static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc, in __bmc_get_device_id() argument
2490 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2492 if (list_empty(&bmc->intfs)) { in __bmc_get_device_id()
2493 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2496 intf = list_first_entry(&bmc->intfs, struct ipmi_smi, in __bmc_get_device_id()
2499 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2501 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2502 if (intf != list_first_entry(&bmc->intfs, struct ipmi_smi, in __bmc_get_device_id()
2510 bmc = intf->bmc; in __bmc_get_device_id()
2511 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2517 (bmc->dyn_id_set && time_is_after_jiffies(bmc->dyn_id_expiry))) in __bmc_get_device_id()
2520 prev_guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2523 prev_dyn_id_set = bmc->dyn_id_set; in __bmc_get_device_id()
2524 rv = __get_device_id(intf, bmc); in __bmc_get_device_id()
2530 * not change on a BMC. If it does we have to do some dancing. in __bmc_get_device_id()
2533 || (!prev_guid_set && bmc->dyn_guid_set) in __bmc_get_device_id()
2534 || (!prev_dyn_id_set && bmc->dyn_id_set) in __bmc_get_device_id()
2535 || (prev_guid_set && bmc->dyn_guid_set in __bmc_get_device_id()
2536 && !guid_equal(&bmc->guid, &bmc->fetch_guid)) in __bmc_get_device_id()
2537 || bmc->id.device_id != bmc->fetch_id.device_id in __bmc_get_device_id()
2538 || bmc->id.manufacturer_id != bmc->fetch_id.manufacturer_id in __bmc_get_device_id()
2539 || bmc->id.product_id != bmc->fetch_id.product_id) { in __bmc_get_device_id()
2540 struct ipmi_device_id id = bmc->fetch_id; in __bmc_get_device_id()
2541 int guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2544 guid = bmc->fetch_guid; in __bmc_get_device_id()
2545 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2548 /* Fill in the temporary BMC for good measure. */ in __bmc_get_device_id()
2549 intf->bmc->id = id; in __bmc_get_device_id()
2550 intf->bmc->dyn_guid_set = guid_set; in __bmc_get_device_id()
2551 intf->bmc->guid = guid; in __bmc_get_device_id()
2562 * the next interface for the BMC. in __bmc_get_device_id()
2565 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2569 /* We have a new BMC, set it up. */ in __bmc_get_device_id()
2570 bmc = intf->bmc; in __bmc_get_device_id()
2571 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2573 } else if (memcmp(&bmc->fetch_id, &bmc->id, sizeof(bmc->id))) in __bmc_get_device_id()
2575 __scan_channels(intf, &bmc->fetch_id); in __bmc_get_device_id()
2577 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY; in __bmc_get_device_id()
2582 bmc->dyn_id_set = prev_dyn_id_set; in __bmc_get_device_id()
2585 bmc->id = bmc->fetch_id; in __bmc_get_device_id()
2586 if (bmc->dyn_guid_set) in __bmc_get_device_id()
2587 bmc->guid = bmc->fetch_guid; in __bmc_get_device_id()
2593 bmc->dyn_guid_set = prev_guid_set; in __bmc_get_device_id()
2598 *id = bmc->id; in __bmc_get_device_id()
2601 *guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2603 if (guid && bmc->dyn_guid_set) in __bmc_get_device_id()
2604 *guid = bmc->guid; in __bmc_get_device_id()
2607 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2614 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc, in bmc_get_device_id() argument
2618 return __bmc_get_device_id(intf, bmc, id, guid_set, guid, -1); in bmc_get_device_id()
2625 struct bmc_device *bmc = to_bmc_device(dev); in device_id_show() local
2629 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in device_id_show()
2641 struct bmc_device *bmc = to_bmc_device(dev); in provides_device_sdrs_show() local
2645 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in provides_device_sdrs_show()
2656 struct bmc_device *bmc = to_bmc_device(dev); in revision_show() local
2660 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in revision_show()
2672 struct bmc_device *bmc = to_bmc_device(dev); in firmware_revision_show() local
2676 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in firmware_revision_show()
2689 struct bmc_device *bmc = to_bmc_device(dev); in ipmi_version_show() local
2693 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in ipmi_version_show()
2707 struct bmc_device *bmc = to_bmc_device(dev); in add_dev_support_show() local
2711 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in add_dev_support_show()
2724 struct bmc_device *bmc = to_bmc_device(dev); in manufacturer_id_show() local
2728 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in manufacturer_id_show()
2740 struct bmc_device *bmc = to_bmc_device(dev); in product_id_show() local
2744 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in product_id_show()
2756 struct bmc_device *bmc = to_bmc_device(dev); in aux_firmware_rev_show() local
2760 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in aux_firmware_rev_show()
2775 struct bmc_device *bmc = to_bmc_device(dev); in guid_show() local
2780 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, &guid); in guid_show()
2808 struct bmc_device *bmc = to_bmc_device(dev); in bmc_dev_attr_is_visible() local
2815 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in bmc_dev_attr_is_visible()
2821 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, NULL); in bmc_dev_attr_is_visible()
2844 struct bmc_device *bmc; in __find_bmc_guid() local
2850 bmc = to_bmc_device(dev); in __find_bmc_guid()
2851 rv = bmc->dyn_guid_set && guid_equal(&bmc->guid, guid); in __find_bmc_guid()
2853 rv = kref_get_unless_zero(&bmc->usecount); in __find_bmc_guid()
2858 * Returns with the bmc's usecount incremented, if it is non-NULL.
2864 struct bmc_device *bmc = NULL; in ipmi_find_bmc_guid() local
2868 bmc = to_bmc_device(dev); in ipmi_find_bmc_guid()
2871 return bmc; in ipmi_find_bmc_guid()
2882 struct bmc_device *bmc; in __find_bmc_prod_dev_id() local
2888 bmc = to_bmc_device(dev); in __find_bmc_prod_dev_id()
2889 rv = (bmc->id.product_id == cid->product_id in __find_bmc_prod_dev_id()
2890 && bmc->id.device_id == cid->device_id); in __find_bmc_prod_dev_id()
2892 rv = kref_get_unless_zero(&bmc->usecount); in __find_bmc_prod_dev_id()
2897 * Returns with the bmc's usecount incremented, if it is non-NULL.
2908 struct bmc_device *bmc = NULL; in ipmi_find_bmc_prod_dev_id() local
2912 bmc = to_bmc_device(dev); in ipmi_find_bmc_prod_dev_id()
2915 return bmc; in ipmi_find_bmc_prod_dev_id()
2928 struct bmc_device *bmc = container_of(work, struct bmc_device, in cleanup_bmc_work() local
2930 int id = bmc->pdev.id; /* Unregister overwrites id */ in cleanup_bmc_work()
2932 platform_device_unregister(&bmc->pdev); in cleanup_bmc_work()
2939 struct bmc_device *bmc = container_of(ref, struct bmc_device, usecount); in cleanup_bmc_device() local
2946 schedule_work(&bmc->remove_work); in cleanup_bmc_device()
2954 struct bmc_device *bmc = intf->bmc; in __ipmi_bmc_unregister() local
2959 sysfs_remove_link(&intf->si_dev->kobj, "bmc"); in __ipmi_bmc_unregister()
2960 sysfs_remove_link(&bmc->pdev.dev.kobj, intf->my_dev_name); in __ipmi_bmc_unregister()
2964 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_unregister()
2966 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_unregister()
2967 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_unregister()
2968 kref_put(&bmc->usecount, cleanup_bmc_device); in __ipmi_bmc_unregister()
2987 struct bmc_device *bmc; in __ipmi_bmc_register() local
3001 * representing the interfaced BMC already in __ipmi_bmc_register()
3013 * otherwise register the new BMC device in __ipmi_bmc_register()
3016 bmc = old_bmc; in __ipmi_bmc_register()
3019 * the BMC find functions. in __ipmi_bmc_register()
3021 intf->bmc = old_bmc; in __ipmi_bmc_register()
3022 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3023 list_add_tail(&intf->bmc_link, &bmc->intfs); in __ipmi_bmc_register()
3024 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3027 "interfacing existing BMC (man_id: 0x%6.6x, prod_id: 0x%4.4x, dev_id: 0x%2.2x)\n", in __ipmi_bmc_register()
3028 bmc->id.manufacturer_id, in __ipmi_bmc_register()
3029 bmc->id.product_id, in __ipmi_bmc_register()
3030 bmc->id.device_id); in __ipmi_bmc_register()
3032 bmc = kzalloc(sizeof(*bmc), GFP_KERNEL); in __ipmi_bmc_register()
3033 if (!bmc) { in __ipmi_bmc_register()
3037 INIT_LIST_HEAD(&bmc->intfs); in __ipmi_bmc_register()
3038 mutex_init(&bmc->dyn_mutex); in __ipmi_bmc_register()
3039 INIT_WORK(&bmc->remove_work, cleanup_bmc_work); in __ipmi_bmc_register()
3041 bmc->id = *id; in __ipmi_bmc_register()
3042 bmc->dyn_id_set = 1; in __ipmi_bmc_register()
3043 bmc->dyn_guid_set = guid_set; in __ipmi_bmc_register()
3044 bmc->guid = *guid; in __ipmi_bmc_register()
3045 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY; in __ipmi_bmc_register()
3047 bmc->pdev.name = "ipmi_bmc"; in __ipmi_bmc_register()
3051 kfree(bmc); in __ipmi_bmc_register()
3055 bmc->pdev.dev.driver = &ipmidriver.driver; in __ipmi_bmc_register()
3056 bmc->pdev.id = rv; in __ipmi_bmc_register()
3057 bmc->pdev.dev.release = release_bmc_device; in __ipmi_bmc_register()
3058 bmc->pdev.dev.type = &bmc_device_type; in __ipmi_bmc_register()
3059 kref_init(&bmc->usecount); in __ipmi_bmc_register()
3061 intf->bmc = bmc; in __ipmi_bmc_register()
3062 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3063 list_add_tail(&intf->bmc_link, &bmc->intfs); in __ipmi_bmc_register()
3064 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3066 rv = platform_device_register(&bmc->pdev); in __ipmi_bmc_register()
3069 "Unable to register bmc device: %d\n", in __ipmi_bmc_register()
3075 "Found new BMC (man_id: 0x%6.6x, prod_id: 0x%4.4x, dev_id: 0x%2.2x)\n", in __ipmi_bmc_register()
3076 bmc->id.manufacturer_id, in __ipmi_bmc_register()
3077 bmc->id.product_id, in __ipmi_bmc_register()
3078 bmc->id.device_id); in __ipmi_bmc_register()
3082 * create symlink from system interface device to bmc device in __ipmi_bmc_register()
3085 rv = sysfs_create_link(&intf->si_dev->kobj, &bmc->pdev.dev.kobj, "bmc"); in __ipmi_bmc_register()
3087 dev_err(intf->si_dev, "Unable to create bmc symlink: %d\n", rv); in __ipmi_bmc_register()
3096 dev_err(intf->si_dev, "Unable to allocate link from BMC: %d\n", in __ipmi_bmc_register()
3101 rv = sysfs_create_link(&bmc->pdev.dev.kobj, &intf->si_dev->kobj, in __ipmi_bmc_register()
3104 dev_err(intf->si_dev, "Unable to create symlink to bmc: %d\n", in __ipmi_bmc_register()
3123 sysfs_remove_link(&intf->si_dev->kobj, "bmc"); in __ipmi_bmc_register()
3126 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3128 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3129 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_register()
3130 kref_put(&bmc->usecount, cleanup_bmc_device); in __ipmi_bmc_register()
3134 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3136 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3137 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_register()
3138 put_device(&bmc->pdev.dev); in __ipmi_bmc_register()
3172 struct bmc_device *bmc = intf->bmc; in guid_handler() local
3181 /* Error from getting the GUID, the BMC doesn't have one. */ in guid_handler()
3182 bmc->dyn_guid_set = 0; in guid_handler()
3187 bmc->dyn_guid_set = 0; in guid_handler()
3189 …"The GUID response from the BMC was too short, it was %d but should have been %d. Assuming GUID i… in guid_handler()
3194 import_guid(&bmc->fetch_guid, msg->msg.data + 1); in guid_handler()
3200 bmc->dyn_guid_set = 1; in guid_handler()
3208 struct bmc_device *bmc = intf->bmc; in __get_guid() local
3210 bmc->dyn_guid_set = 2; in __get_guid()
3215 bmc->dyn_guid_set = 0; in __get_guid()
3217 wait_event(intf->waitq, bmc->dyn_guid_set != 2); in __get_guid()
3428 intf->bmc = &intf->tmp_bmc; in ipmi_add_smi()
3429 INIT_LIST_HEAD(&intf->bmc->intfs); in ipmi_add_smi()
3430 mutex_init(&intf->bmc->dyn_mutex); in ipmi_add_smi()
4288 "BMC returned too small a message for netfn %x cmd %x, got %d bytes\n", in handle_one_recv_msg()
4303 "BMC returned incorrect response, expected netfn %x cmd %x, got netfn %x cmd %x\n", in handle_one_recv_msg()
4421 /* It's a response from the local BMC. */ in handle_one_recv_msg()