Lines Matching full:bmc
309 * accessing those. If those change on a BMC, a new BMC is allocated.
313 struct list_head intfs; /* Interfaces on this BMC. */
328 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,
463 * interface is used by being looked up through the BMC
469 struct bmc_device *bmc; member
547 * The event receiver for my BMC, only really used at panic
621 * This mutex keeps us from adding the same BMC twice.
2386 msg->msg.data, msg->msg.data_len, &intf->bmc->fetch_id); in bmc_device_id_handler()
2390 intf->bmc->cc = msg->msg.data[0]; in bmc_device_id_handler()
2391 intf->bmc->dyn_id_set = 0; in bmc_device_id_handler()
2398 intf->bmc->dyn_id_set = 1; in bmc_device_id_handler()
2433 static int __get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc) in __get_device_id() argument
2441 bmc->cc = 0; in __get_device_id()
2442 bmc->dyn_id_set = 2; in __get_device_id()
2448 wait_event(intf->waitq, bmc->dyn_id_set != 2); in __get_device_id()
2450 if (!bmc->dyn_id_set) { in __get_device_id()
2451 if ((bmc->cc == IPMI_DEVICE_IN_FW_UPDATE_ERR in __get_device_id()
2452 || bmc->cc == IPMI_DEVICE_IN_INIT_ERR in __get_device_id()
2453 || bmc->cc == IPMI_NOT_IN_MY_STATE_ERR) in __get_device_id()
2457 "BMC returned 0x%2.2x, retry get bmc device id\n", in __get_device_id()
2458 bmc->cc); in __get_device_id()
2475 * Fetch the device id for the bmc/interface. You must pass in either
2476 * bmc or intf, this code will get the other one. If the data has
2483 static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc, in __bmc_get_device_id() argument
2492 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2494 if (list_empty(&bmc->intfs)) { in __bmc_get_device_id()
2495 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2498 intf = list_first_entry(&bmc->intfs, struct ipmi_smi, in __bmc_get_device_id()
2501 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2503 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2504 if (intf != list_first_entry(&bmc->intfs, struct ipmi_smi, in __bmc_get_device_id()
2512 bmc = intf->bmc; in __bmc_get_device_id()
2513 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2519 (bmc->dyn_id_set && time_is_after_jiffies(bmc->dyn_id_expiry))) in __bmc_get_device_id()
2522 prev_guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2525 prev_dyn_id_set = bmc->dyn_id_set; in __bmc_get_device_id()
2526 rv = __get_device_id(intf, bmc); in __bmc_get_device_id()
2532 * not change on a BMC. If it does we have to do some dancing. in __bmc_get_device_id()
2535 || (!prev_guid_set && bmc->dyn_guid_set) in __bmc_get_device_id()
2536 || (!prev_dyn_id_set && bmc->dyn_id_set) in __bmc_get_device_id()
2537 || (prev_guid_set && bmc->dyn_guid_set in __bmc_get_device_id()
2538 && !guid_equal(&bmc->guid, &bmc->fetch_guid)) in __bmc_get_device_id()
2539 || bmc->id.device_id != bmc->fetch_id.device_id in __bmc_get_device_id()
2540 || bmc->id.manufacturer_id != bmc->fetch_id.manufacturer_id in __bmc_get_device_id()
2541 || bmc->id.product_id != bmc->fetch_id.product_id) { in __bmc_get_device_id()
2542 struct ipmi_device_id id = bmc->fetch_id; in __bmc_get_device_id()
2543 int guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2546 guid = bmc->fetch_guid; in __bmc_get_device_id()
2547 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2550 /* Fill in the temporary BMC for good measure. */ in __bmc_get_device_id()
2551 intf->bmc->id = id; in __bmc_get_device_id()
2552 intf->bmc->dyn_guid_set = guid_set; in __bmc_get_device_id()
2553 intf->bmc->guid = guid; in __bmc_get_device_id()
2564 * the next interface for the BMC. in __bmc_get_device_id()
2567 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2571 /* We have a new BMC, set it up. */ in __bmc_get_device_id()
2572 bmc = intf->bmc; in __bmc_get_device_id()
2573 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2575 } else if (memcmp(&bmc->fetch_id, &bmc->id, sizeof(bmc->id))) in __bmc_get_device_id()
2577 __scan_channels(intf, &bmc->fetch_id); in __bmc_get_device_id()
2579 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY; in __bmc_get_device_id()
2584 bmc->dyn_id_set = prev_dyn_id_set; in __bmc_get_device_id()
2587 bmc->id = bmc->fetch_id; in __bmc_get_device_id()
2588 if (bmc->dyn_guid_set) in __bmc_get_device_id()
2589 bmc->guid = bmc->fetch_guid; in __bmc_get_device_id()
2595 bmc->dyn_guid_set = prev_guid_set; in __bmc_get_device_id()
2600 *id = bmc->id; in __bmc_get_device_id()
2603 *guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2605 if (guid && bmc->dyn_guid_set) in __bmc_get_device_id()
2606 *guid = bmc->guid; in __bmc_get_device_id()
2609 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2616 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc, in bmc_get_device_id() argument
2620 return __bmc_get_device_id(intf, bmc, id, guid_set, guid, -1); in bmc_get_device_id()
2627 struct bmc_device *bmc = to_bmc_device(dev); in device_id_show() local
2631 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in device_id_show()
2643 struct bmc_device *bmc = to_bmc_device(dev); in provides_device_sdrs_show() local
2647 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in provides_device_sdrs_show()
2658 struct bmc_device *bmc = to_bmc_device(dev); in revision_show() local
2662 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in revision_show()
2674 struct bmc_device *bmc = to_bmc_device(dev); in firmware_revision_show() local
2678 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in firmware_revision_show()
2691 struct bmc_device *bmc = to_bmc_device(dev); in ipmi_version_show() local
2695 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in ipmi_version_show()
2709 struct bmc_device *bmc = to_bmc_device(dev); in add_dev_support_show() local
2713 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in add_dev_support_show()
2726 struct bmc_device *bmc = to_bmc_device(dev); in manufacturer_id_show() local
2730 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in manufacturer_id_show()
2742 struct bmc_device *bmc = to_bmc_device(dev); in product_id_show() local
2746 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in product_id_show()
2758 struct bmc_device *bmc = to_bmc_device(dev); in aux_firmware_rev_show() local
2762 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in aux_firmware_rev_show()
2777 struct bmc_device *bmc = to_bmc_device(dev); in guid_show() local
2782 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, &guid); in guid_show()
2810 struct bmc_device *bmc = to_bmc_device(dev); in bmc_dev_attr_is_visible() local
2817 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in bmc_dev_attr_is_visible()
2823 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, NULL); in bmc_dev_attr_is_visible()
2846 struct bmc_device *bmc; in __find_bmc_guid() local
2852 bmc = to_bmc_device(dev); in __find_bmc_guid()
2853 rv = bmc->dyn_guid_set && guid_equal(&bmc->guid, guid); in __find_bmc_guid()
2855 rv = kref_get_unless_zero(&bmc->usecount); in __find_bmc_guid()
2860 * Returns with the bmc's usecount incremented, if it is non-NULL.
2866 struct bmc_device *bmc = NULL; in ipmi_find_bmc_guid() local
2870 bmc = to_bmc_device(dev); in ipmi_find_bmc_guid()
2873 return bmc; in ipmi_find_bmc_guid()
2884 struct bmc_device *bmc; in __find_bmc_prod_dev_id() local
2890 bmc = to_bmc_device(dev); in __find_bmc_prod_dev_id()
2891 rv = (bmc->id.product_id == cid->product_id in __find_bmc_prod_dev_id()
2892 && bmc->id.device_id == cid->device_id); in __find_bmc_prod_dev_id()
2894 rv = kref_get_unless_zero(&bmc->usecount); in __find_bmc_prod_dev_id()
2899 * Returns with the bmc's usecount incremented, if it is non-NULL.
2910 struct bmc_device *bmc = NULL; in ipmi_find_bmc_prod_dev_id() local
2914 bmc = to_bmc_device(dev); in ipmi_find_bmc_prod_dev_id()
2917 return bmc; in ipmi_find_bmc_prod_dev_id()
2930 struct bmc_device *bmc = container_of(work, struct bmc_device, in cleanup_bmc_work() local
2932 int id = bmc->pdev.id; /* Unregister overwrites id */ in cleanup_bmc_work()
2934 platform_device_unregister(&bmc->pdev); in cleanup_bmc_work()
2941 struct bmc_device *bmc = container_of(ref, struct bmc_device, usecount); in cleanup_bmc_device() local
2948 queue_work(remove_work_wq, &bmc->remove_work); in cleanup_bmc_device()
2956 struct bmc_device *bmc = intf->bmc; in __ipmi_bmc_unregister() local
2961 sysfs_remove_link(&intf->si_dev->kobj, "bmc"); in __ipmi_bmc_unregister()
2962 sysfs_remove_link(&bmc->pdev.dev.kobj, intf->my_dev_name); in __ipmi_bmc_unregister()
2966 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_unregister()
2968 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_unregister()
2969 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_unregister()
2970 kref_put(&bmc->usecount, cleanup_bmc_device); in __ipmi_bmc_unregister()
2989 struct bmc_device *bmc; in __ipmi_bmc_register() local
3003 * representing the interfaced BMC already in __ipmi_bmc_register()
3015 * otherwise register the new BMC device in __ipmi_bmc_register()
3018 bmc = old_bmc; in __ipmi_bmc_register()
3021 * the BMC find functions. in __ipmi_bmc_register()
3023 intf->bmc = old_bmc; in __ipmi_bmc_register()
3024 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3025 list_add_tail(&intf->bmc_link, &bmc->intfs); in __ipmi_bmc_register()
3026 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3029 "interfacing existing BMC (man_id: 0x%6.6x, prod_id: 0x%4.4x, dev_id: 0x%2.2x)\n", in __ipmi_bmc_register()
3030 bmc->id.manufacturer_id, in __ipmi_bmc_register()
3031 bmc->id.product_id, in __ipmi_bmc_register()
3032 bmc->id.device_id); in __ipmi_bmc_register()
3034 bmc = kzalloc(sizeof(*bmc), GFP_KERNEL); in __ipmi_bmc_register()
3035 if (!bmc) { in __ipmi_bmc_register()
3039 INIT_LIST_HEAD(&bmc->intfs); in __ipmi_bmc_register()
3040 mutex_init(&bmc->dyn_mutex); in __ipmi_bmc_register()
3041 INIT_WORK(&bmc->remove_work, cleanup_bmc_work); in __ipmi_bmc_register()
3043 bmc->id = *id; in __ipmi_bmc_register()
3044 bmc->dyn_id_set = 1; in __ipmi_bmc_register()
3045 bmc->dyn_guid_set = guid_set; in __ipmi_bmc_register()
3046 bmc->guid = *guid; in __ipmi_bmc_register()
3047 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY; in __ipmi_bmc_register()
3049 bmc->pdev.name = "ipmi_bmc"; in __ipmi_bmc_register()
3053 kfree(bmc); in __ipmi_bmc_register()
3057 bmc->pdev.dev.driver = &ipmidriver.driver; in __ipmi_bmc_register()
3058 bmc->pdev.id = rv; in __ipmi_bmc_register()
3059 bmc->pdev.dev.release = release_bmc_device; in __ipmi_bmc_register()
3060 bmc->pdev.dev.type = &bmc_device_type; in __ipmi_bmc_register()
3061 kref_init(&bmc->usecount); in __ipmi_bmc_register()
3063 intf->bmc = bmc; in __ipmi_bmc_register()
3064 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3065 list_add_tail(&intf->bmc_link, &bmc->intfs); in __ipmi_bmc_register()
3066 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3068 rv = platform_device_register(&bmc->pdev); in __ipmi_bmc_register()
3071 "Unable to register bmc device: %d\n", in __ipmi_bmc_register()
3077 "Found new BMC (man_id: 0x%6.6x, prod_id: 0x%4.4x, dev_id: 0x%2.2x)\n", in __ipmi_bmc_register()
3078 bmc->id.manufacturer_id, in __ipmi_bmc_register()
3079 bmc->id.product_id, in __ipmi_bmc_register()
3080 bmc->id.device_id); in __ipmi_bmc_register()
3084 * create symlink from system interface device to bmc device in __ipmi_bmc_register()
3087 rv = sysfs_create_link(&intf->si_dev->kobj, &bmc->pdev.dev.kobj, "bmc"); in __ipmi_bmc_register()
3089 dev_err(intf->si_dev, "Unable to create bmc symlink: %d\n", rv); in __ipmi_bmc_register()
3098 dev_err(intf->si_dev, "Unable to allocate link from BMC: %d\n", in __ipmi_bmc_register()
3103 rv = sysfs_create_link(&bmc->pdev.dev.kobj, &intf->si_dev->kobj, in __ipmi_bmc_register()
3106 dev_err(intf->si_dev, "Unable to create symlink to bmc: %d\n", in __ipmi_bmc_register()
3125 sysfs_remove_link(&intf->si_dev->kobj, "bmc"); in __ipmi_bmc_register()
3128 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3130 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3131 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_register()
3132 kref_put(&bmc->usecount, cleanup_bmc_device); in __ipmi_bmc_register()
3136 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3138 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3139 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_register()
3140 put_device(&bmc->pdev.dev); in __ipmi_bmc_register()
3174 struct bmc_device *bmc = intf->bmc; in guid_handler() local
3183 /* Error from getting the GUID, the BMC doesn't have one. */ in guid_handler()
3184 bmc->dyn_guid_set = 0; in guid_handler()
3189 bmc->dyn_guid_set = 0; in guid_handler()
3191 …"The GUID response from the BMC was too short, it was %d but should have been %d. Assuming GUID i… in guid_handler()
3196 import_guid(&bmc->fetch_guid, msg->msg.data + 1); in guid_handler()
3202 bmc->dyn_guid_set = 1; in guid_handler()
3210 struct bmc_device *bmc = intf->bmc; in __get_guid() local
3212 bmc->dyn_guid_set = 2; in __get_guid()
3217 bmc->dyn_guid_set = 0; in __get_guid()
3219 wait_event(intf->waitq, bmc->dyn_guid_set != 2); in __get_guid()
3430 intf->bmc = &intf->tmp_bmc; in ipmi_add_smi()
3431 INIT_LIST_HEAD(&intf->bmc->intfs); in ipmi_add_smi()
3432 mutex_init(&intf->bmc->dyn_mutex); in ipmi_add_smi()
4290 "BMC returned too small a message for netfn %x cmd %x, got %d bytes\n", in handle_one_recv_msg()
4305 "BMC returned incorrect response, expected netfn %x cmd %x, got netfn %x cmd %x\n", in handle_one_recv_msg()
4423 /* It's a response from the local BMC. */ in handle_one_recv_msg()