Lines Matching full:bmc
311 * accessing those. If those change on a BMC, a new BMC is allocated.
315 struct list_head intfs; /* Interfaces on this BMC. */
330 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,
469 * interface is used by being looked up through the BMC
475 struct bmc_device *bmc; member
553 * The event receiver for my BMC, only really used at panic
627 * This mutex keeps us from adding the same BMC twice.
2502 intf->bmc->dyn_id_set = 0; in bmc_device_id_handler()
2507 msg->msg.data, msg->msg.data_len, &intf->bmc->fetch_id); in bmc_device_id_handler()
2511 intf->bmc->cc = msg->msg.data[0]; in bmc_device_id_handler()
2512 intf->bmc->dyn_id_set = 0; in bmc_device_id_handler()
2519 intf->bmc->dyn_id_set = 1; in bmc_device_id_handler()
2554 static int __get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc) in __get_device_id() argument
2562 bmc->cc = 0; in __get_device_id()
2563 bmc->dyn_id_set = 2; in __get_device_id()
2569 wait_event(intf->waitq, bmc->dyn_id_set != 2); in __get_device_id()
2571 if (!bmc->dyn_id_set) { in __get_device_id()
2572 if (bmc->cc != IPMI_CC_NO_ERROR && in __get_device_id()
2576 "BMC returned 0x%2.2x, retry get bmc device id\n", in __get_device_id()
2577 bmc->cc); in __get_device_id()
2594 * Fetch the device id for the bmc/interface. You must pass in either
2595 * bmc or intf, this code will get the other one. If the data has
2602 static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc, in __bmc_get_device_id() argument
2611 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2613 if (list_empty(&bmc->intfs)) { in __bmc_get_device_id()
2614 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2617 intf = list_first_entry(&bmc->intfs, struct ipmi_smi, in __bmc_get_device_id()
2620 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2622 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2623 if (intf != list_first_entry(&bmc->intfs, struct ipmi_smi, in __bmc_get_device_id()
2631 bmc = intf->bmc; in __bmc_get_device_id()
2632 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2638 (bmc->dyn_id_set && time_is_after_jiffies(bmc->dyn_id_expiry))) in __bmc_get_device_id()
2641 prev_guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2644 prev_dyn_id_set = bmc->dyn_id_set; in __bmc_get_device_id()
2645 rv = __get_device_id(intf, bmc); in __bmc_get_device_id()
2651 * not change on a BMC. If it does we have to do some dancing. in __bmc_get_device_id()
2654 || (!prev_guid_set && bmc->dyn_guid_set) in __bmc_get_device_id()
2655 || (!prev_dyn_id_set && bmc->dyn_id_set) in __bmc_get_device_id()
2656 || (prev_guid_set && bmc->dyn_guid_set in __bmc_get_device_id()
2657 && !guid_equal(&bmc->guid, &bmc->fetch_guid)) in __bmc_get_device_id()
2658 || bmc->id.device_id != bmc->fetch_id.device_id in __bmc_get_device_id()
2659 || bmc->id.manufacturer_id != bmc->fetch_id.manufacturer_id in __bmc_get_device_id()
2660 || bmc->id.product_id != bmc->fetch_id.product_id) { in __bmc_get_device_id()
2661 struct ipmi_device_id id = bmc->fetch_id; in __bmc_get_device_id()
2662 int guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2665 guid = bmc->fetch_guid; in __bmc_get_device_id()
2666 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2669 /* Fill in the temporary BMC for good measure. */ in __bmc_get_device_id()
2670 intf->bmc->id = id; in __bmc_get_device_id()
2671 intf->bmc->dyn_guid_set = guid_set; in __bmc_get_device_id()
2672 intf->bmc->guid = guid; in __bmc_get_device_id()
2683 * the next interface for the BMC. in __bmc_get_device_id()
2686 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2690 /* We have a new BMC, set it up. */ in __bmc_get_device_id()
2691 bmc = intf->bmc; in __bmc_get_device_id()
2692 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2694 } else if (memcmp(&bmc->fetch_id, &bmc->id, sizeof(bmc->id))) in __bmc_get_device_id()
2696 __scan_channels(intf, &bmc->fetch_id); in __bmc_get_device_id()
2698 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY; in __bmc_get_device_id()
2703 bmc->dyn_id_set = prev_dyn_id_set; in __bmc_get_device_id()
2706 bmc->id = bmc->fetch_id; in __bmc_get_device_id()
2707 if (bmc->dyn_guid_set) in __bmc_get_device_id()
2708 bmc->guid = bmc->fetch_guid; in __bmc_get_device_id()
2714 bmc->dyn_guid_set = prev_guid_set; in __bmc_get_device_id()
2719 *id = bmc->id; in __bmc_get_device_id()
2722 *guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2724 if (guid && bmc->dyn_guid_set) in __bmc_get_device_id()
2725 *guid = bmc->guid; in __bmc_get_device_id()
2728 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2735 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc, in bmc_get_device_id() argument
2739 return __bmc_get_device_id(intf, bmc, id, guid_set, guid, -1); in bmc_get_device_id()
2746 struct bmc_device *bmc = to_bmc_device(dev); in device_id_show() local
2750 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in device_id_show()
2762 struct bmc_device *bmc = to_bmc_device(dev); in provides_device_sdrs_show() local
2766 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in provides_device_sdrs_show()
2777 struct bmc_device *bmc = to_bmc_device(dev); in revision_show() local
2781 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in revision_show()
2793 struct bmc_device *bmc = to_bmc_device(dev); in firmware_revision_show() local
2797 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in firmware_revision_show()
2810 struct bmc_device *bmc = to_bmc_device(dev); in ipmi_version_show() local
2814 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in ipmi_version_show()
2828 struct bmc_device *bmc = to_bmc_device(dev); in add_dev_support_show() local
2832 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in add_dev_support_show()
2845 struct bmc_device *bmc = to_bmc_device(dev); in manufacturer_id_show() local
2849 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in manufacturer_id_show()
2861 struct bmc_device *bmc = to_bmc_device(dev); in product_id_show() local
2865 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in product_id_show()
2877 struct bmc_device *bmc = to_bmc_device(dev); in aux_firmware_rev_show() local
2881 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in aux_firmware_rev_show()
2896 struct bmc_device *bmc = to_bmc_device(dev); in guid_show() local
2901 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, &guid); in guid_show()
2929 struct bmc_device *bmc = to_bmc_device(dev); in bmc_dev_attr_is_visible() local
2936 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in bmc_dev_attr_is_visible()
2942 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, NULL); in bmc_dev_attr_is_visible()
2965 struct bmc_device *bmc; in __find_bmc_guid() local
2971 bmc = to_bmc_device(dev); in __find_bmc_guid()
2972 rv = bmc->dyn_guid_set && guid_equal(&bmc->guid, guid); in __find_bmc_guid()
2974 rv = kref_get_unless_zero(&bmc->usecount); in __find_bmc_guid()
2979 * Returns with the bmc's usecount incremented, if it is non-NULL.
2985 struct bmc_device *bmc = NULL; in ipmi_find_bmc_guid() local
2989 bmc = to_bmc_device(dev); in ipmi_find_bmc_guid()
2992 return bmc; in ipmi_find_bmc_guid()
3003 struct bmc_device *bmc; in __find_bmc_prod_dev_id() local
3009 bmc = to_bmc_device(dev); in __find_bmc_prod_dev_id()
3010 rv = (bmc->id.product_id == cid->product_id in __find_bmc_prod_dev_id()
3011 && bmc->id.device_id == cid->device_id); in __find_bmc_prod_dev_id()
3013 rv = kref_get_unless_zero(&bmc->usecount); in __find_bmc_prod_dev_id()
3018 * Returns with the bmc's usecount incremented, if it is non-NULL.
3029 struct bmc_device *bmc = NULL; in ipmi_find_bmc_prod_dev_id() local
3033 bmc = to_bmc_device(dev); in ipmi_find_bmc_prod_dev_id()
3036 return bmc; in ipmi_find_bmc_prod_dev_id()
3049 struct bmc_device *bmc = container_of(work, struct bmc_device, in cleanup_bmc_work() local
3051 int id = bmc->pdev.id; /* Unregister overwrites id */ in cleanup_bmc_work()
3053 platform_device_unregister(&bmc->pdev); in cleanup_bmc_work()
3060 struct bmc_device *bmc = container_of(ref, struct bmc_device, usecount); in cleanup_bmc_device() local
3067 queue_work(remove_work_wq, &bmc->remove_work); in cleanup_bmc_device()
3075 struct bmc_device *bmc = intf->bmc; in __ipmi_bmc_unregister() local
3080 sysfs_remove_link(&intf->si_dev->kobj, "bmc"); in __ipmi_bmc_unregister()
3081 sysfs_remove_link(&bmc->pdev.dev.kobj, intf->my_dev_name); in __ipmi_bmc_unregister()
3085 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_unregister()
3087 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_unregister()
3088 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_unregister()
3089 kref_put(&bmc->usecount, cleanup_bmc_device); in __ipmi_bmc_unregister()
3108 struct bmc_device *bmc; in __ipmi_bmc_register() local
3122 * representing the interfaced BMC already in __ipmi_bmc_register()
3134 * otherwise register the new BMC device in __ipmi_bmc_register()
3137 bmc = old_bmc; in __ipmi_bmc_register()
3140 * the BMC find functions. in __ipmi_bmc_register()
3142 intf->bmc = old_bmc; in __ipmi_bmc_register()
3143 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3144 list_add_tail(&intf->bmc_link, &bmc->intfs); in __ipmi_bmc_register()
3145 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3148 "interfacing existing BMC (man_id: 0x%6.6x, prod_id: 0x%4.4x, dev_id: 0x%2.2x)\n", in __ipmi_bmc_register()
3149 bmc->id.manufacturer_id, in __ipmi_bmc_register()
3150 bmc->id.product_id, in __ipmi_bmc_register()
3151 bmc->id.device_id); in __ipmi_bmc_register()
3153 bmc = kzalloc(sizeof(*bmc), GFP_KERNEL); in __ipmi_bmc_register()
3154 if (!bmc) { in __ipmi_bmc_register()
3158 INIT_LIST_HEAD(&bmc->intfs); in __ipmi_bmc_register()
3159 mutex_init(&bmc->dyn_mutex); in __ipmi_bmc_register()
3160 INIT_WORK(&bmc->remove_work, cleanup_bmc_work); in __ipmi_bmc_register()
3162 bmc->id = *id; in __ipmi_bmc_register()
3163 bmc->dyn_id_set = 1; in __ipmi_bmc_register()
3164 bmc->dyn_guid_set = guid_set; in __ipmi_bmc_register()
3165 bmc->guid = *guid; in __ipmi_bmc_register()
3166 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY; in __ipmi_bmc_register()
3168 bmc->pdev.name = "ipmi_bmc"; in __ipmi_bmc_register()
3172 kfree(bmc); in __ipmi_bmc_register()
3176 bmc->pdev.dev.driver = &ipmidriver.driver; in __ipmi_bmc_register()
3177 bmc->pdev.id = rv; in __ipmi_bmc_register()
3178 bmc->pdev.dev.release = release_bmc_device; in __ipmi_bmc_register()
3179 bmc->pdev.dev.type = &bmc_device_type; in __ipmi_bmc_register()
3180 kref_init(&bmc->usecount); in __ipmi_bmc_register()
3182 intf->bmc = bmc; in __ipmi_bmc_register()
3183 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3184 list_add_tail(&intf->bmc_link, &bmc->intfs); in __ipmi_bmc_register()
3185 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3187 rv = platform_device_register(&bmc->pdev); in __ipmi_bmc_register()
3190 "Unable to register bmc device: %d\n", in __ipmi_bmc_register()
3196 "Found new BMC (man_id: 0x%6.6x, prod_id: 0x%4.4x, dev_id: 0x%2.2x)\n", in __ipmi_bmc_register()
3197 bmc->id.manufacturer_id, in __ipmi_bmc_register()
3198 bmc->id.product_id, in __ipmi_bmc_register()
3199 bmc->id.device_id); in __ipmi_bmc_register()
3203 * create symlink from system interface device to bmc device in __ipmi_bmc_register()
3206 rv = sysfs_create_link(&intf->si_dev->kobj, &bmc->pdev.dev.kobj, "bmc"); in __ipmi_bmc_register()
3208 dev_err(intf->si_dev, "Unable to create bmc symlink: %d\n", rv); in __ipmi_bmc_register()
3217 dev_err(intf->si_dev, "Unable to allocate link from BMC: %d\n", in __ipmi_bmc_register()
3222 rv = sysfs_create_link(&bmc->pdev.dev.kobj, &intf->si_dev->kobj, in __ipmi_bmc_register()
3225 dev_err(intf->si_dev, "Unable to create symlink to bmc: %d\n", in __ipmi_bmc_register()
3244 sysfs_remove_link(&intf->si_dev->kobj, "bmc"); in __ipmi_bmc_register()
3247 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3249 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3250 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_register()
3251 kref_put(&bmc->usecount, cleanup_bmc_device); in __ipmi_bmc_register()
3255 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3257 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3258 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_register()
3259 put_device(&bmc->pdev.dev); in __ipmi_bmc_register()
3293 struct bmc_device *bmc = intf->bmc; in guid_handler() local
3302 /* Error from getting the GUID, the BMC doesn't have one. */ in guid_handler()
3303 bmc->dyn_guid_set = 0; in guid_handler()
3308 bmc->dyn_guid_set = 0; in guid_handler()
3310 …"The GUID response from the BMC was too short, it was %d but should have been %d. Assuming GUID i… in guid_handler()
3315 import_guid(&bmc->fetch_guid, msg->msg.data + 1); in guid_handler()
3321 bmc->dyn_guid_set = 1; in guid_handler()
3329 struct bmc_device *bmc = intf->bmc; in __get_guid() local
3331 bmc->dyn_guid_set = 2; in __get_guid()
3336 bmc->dyn_guid_set = 0; in __get_guid()
3338 wait_event(intf->waitq, bmc->dyn_guid_set != 2); in __get_guid()
3579 intf->bmc = &intf->tmp_bmc; in ipmi_add_smi()
3580 INIT_LIST_HEAD(&intf->bmc->intfs); in ipmi_add_smi()
3581 mutex_init(&intf->bmc->dyn_mutex); in ipmi_add_smi()
4540 "BMC returned too small a message for netfn %x cmd %x, got %d bytes\n", in handle_one_recv_msg()
4618 "BMC returned incorrect response, expected netfn %x cmd %x, got netfn %x cmd %x\n", in handle_one_recv_msg()
4743 /* It's a response from the local BMC. */ in handle_one_recv_msg()