Lines Matching full:bmc
295 * accessing those. If those change on a BMC, a new BMC is allocated.
299 struct list_head intfs; /* Interfaces on this BMC. */
314 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,
449 * interface is used by being looked up through the BMC
455 struct bmc_device *bmc; member
533 * The event receiver for my BMC, only really used at panic
607 * This mutex keeps us from adding the same BMC twice.
2373 msg->msg.data, msg->msg.data_len, &intf->bmc->fetch_id); in bmc_device_id_handler()
2377 intf->bmc->cc = msg->msg.data[0]; in bmc_device_id_handler()
2378 intf->bmc->dyn_id_set = 0; in bmc_device_id_handler()
2385 intf->bmc->dyn_id_set = 1; in bmc_device_id_handler()
2420 static int __get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc) in __get_device_id() argument
2428 bmc->cc = 0; in __get_device_id()
2429 bmc->dyn_id_set = 2; in __get_device_id()
2435 wait_event(intf->waitq, bmc->dyn_id_set != 2); in __get_device_id()
2437 if (!bmc->dyn_id_set) { in __get_device_id()
2438 if (bmc->cc != IPMI_CC_NO_ERROR && in __get_device_id()
2442 "BMC returned 0x%2.2x, retry get bmc device id\n", in __get_device_id()
2443 bmc->cc); in __get_device_id()
2460 * Fetch the device id for the bmc/interface. You must pass in either
2461 * bmc or intf, this code will get the other one. If the data has
2468 static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc, in __bmc_get_device_id() argument
2477 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2479 if (list_empty(&bmc->intfs)) { in __bmc_get_device_id()
2480 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2483 intf = list_first_entry(&bmc->intfs, struct ipmi_smi, in __bmc_get_device_id()
2486 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2488 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2489 if (intf != list_first_entry(&bmc->intfs, struct ipmi_smi, in __bmc_get_device_id()
2497 bmc = intf->bmc; in __bmc_get_device_id()
2498 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2504 (bmc->dyn_id_set && time_is_after_jiffies(bmc->dyn_id_expiry))) in __bmc_get_device_id()
2507 prev_guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2510 prev_dyn_id_set = bmc->dyn_id_set; in __bmc_get_device_id()
2511 rv = __get_device_id(intf, bmc); in __bmc_get_device_id()
2517 * not change on a BMC. If it does we have to do some dancing. in __bmc_get_device_id()
2520 || (!prev_guid_set && bmc->dyn_guid_set) in __bmc_get_device_id()
2521 || (!prev_dyn_id_set && bmc->dyn_id_set) in __bmc_get_device_id()
2522 || (prev_guid_set && bmc->dyn_guid_set in __bmc_get_device_id()
2523 && !guid_equal(&bmc->guid, &bmc->fetch_guid)) in __bmc_get_device_id()
2524 || bmc->id.device_id != bmc->fetch_id.device_id in __bmc_get_device_id()
2525 || bmc->id.manufacturer_id != bmc->fetch_id.manufacturer_id in __bmc_get_device_id()
2526 || bmc->id.product_id != bmc->fetch_id.product_id) { in __bmc_get_device_id()
2527 struct ipmi_device_id id = bmc->fetch_id; in __bmc_get_device_id()
2528 int guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2531 guid = bmc->fetch_guid; in __bmc_get_device_id()
2532 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2535 /* Fill in the temporary BMC for good measure. */ in __bmc_get_device_id()
2536 intf->bmc->id = id; in __bmc_get_device_id()
2537 intf->bmc->dyn_guid_set = guid_set; in __bmc_get_device_id()
2538 intf->bmc->guid = guid; in __bmc_get_device_id()
2549 * the next interface for the BMC. in __bmc_get_device_id()
2552 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2556 /* We have a new BMC, set it up. */ in __bmc_get_device_id()
2557 bmc = intf->bmc; in __bmc_get_device_id()
2558 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2560 } else if (memcmp(&bmc->fetch_id, &bmc->id, sizeof(bmc->id))) in __bmc_get_device_id()
2562 __scan_channels(intf, &bmc->fetch_id); in __bmc_get_device_id()
2564 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY; in __bmc_get_device_id()
2569 bmc->dyn_id_set = prev_dyn_id_set; in __bmc_get_device_id()
2572 bmc->id = bmc->fetch_id; in __bmc_get_device_id()
2573 if (bmc->dyn_guid_set) in __bmc_get_device_id()
2574 bmc->guid = bmc->fetch_guid; in __bmc_get_device_id()
2580 bmc->dyn_guid_set = prev_guid_set; in __bmc_get_device_id()
2585 *id = bmc->id; in __bmc_get_device_id()
2588 *guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2590 if (guid && bmc->dyn_guid_set) in __bmc_get_device_id()
2591 *guid = bmc->guid; in __bmc_get_device_id()
2594 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2601 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc, in bmc_get_device_id() argument
2605 return __bmc_get_device_id(intf, bmc, id, guid_set, guid, -1); in bmc_get_device_id()
2612 struct bmc_device *bmc = to_bmc_device(dev); in device_id_show() local
2616 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in device_id_show()
2628 struct bmc_device *bmc = to_bmc_device(dev); in provides_device_sdrs_show() local
2632 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in provides_device_sdrs_show()
2643 struct bmc_device *bmc = to_bmc_device(dev); in revision_show() local
2647 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in revision_show()
2659 struct bmc_device *bmc = to_bmc_device(dev); in firmware_revision_show() local
2663 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in firmware_revision_show()
2676 struct bmc_device *bmc = to_bmc_device(dev); in ipmi_version_show() local
2680 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in ipmi_version_show()
2694 struct bmc_device *bmc = to_bmc_device(dev); in add_dev_support_show() local
2698 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in add_dev_support_show()
2711 struct bmc_device *bmc = to_bmc_device(dev); in manufacturer_id_show() local
2715 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in manufacturer_id_show()
2727 struct bmc_device *bmc = to_bmc_device(dev); in product_id_show() local
2731 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in product_id_show()
2743 struct bmc_device *bmc = to_bmc_device(dev); in aux_firmware_rev_show() local
2747 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in aux_firmware_rev_show()
2762 struct bmc_device *bmc = to_bmc_device(dev); in guid_show() local
2767 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, &guid); in guid_show()
2795 struct bmc_device *bmc = to_bmc_device(dev); in bmc_dev_attr_is_visible() local
2802 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in bmc_dev_attr_is_visible()
2808 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, NULL); in bmc_dev_attr_is_visible()
2831 struct bmc_device *bmc; in __find_bmc_guid() local
2837 bmc = to_bmc_device(dev); in __find_bmc_guid()
2838 rv = bmc->dyn_guid_set && guid_equal(&bmc->guid, guid); in __find_bmc_guid()
2840 rv = kref_get_unless_zero(&bmc->usecount); in __find_bmc_guid()
2845 * Returns with the bmc's usecount incremented, if it is non-NULL.
2851 struct bmc_device *bmc = NULL; in ipmi_find_bmc_guid() local
2855 bmc = to_bmc_device(dev); in ipmi_find_bmc_guid()
2858 return bmc; in ipmi_find_bmc_guid()
2869 struct bmc_device *bmc; in __find_bmc_prod_dev_id() local
2875 bmc = to_bmc_device(dev); in __find_bmc_prod_dev_id()
2876 rv = (bmc->id.product_id == cid->product_id in __find_bmc_prod_dev_id()
2877 && bmc->id.device_id == cid->device_id); in __find_bmc_prod_dev_id()
2879 rv = kref_get_unless_zero(&bmc->usecount); in __find_bmc_prod_dev_id()
2884 * Returns with the bmc's usecount incremented, if it is non-NULL.
2895 struct bmc_device *bmc = NULL; in ipmi_find_bmc_prod_dev_id() local
2899 bmc = to_bmc_device(dev); in ipmi_find_bmc_prod_dev_id()
2902 return bmc; in ipmi_find_bmc_prod_dev_id()
2915 struct bmc_device *bmc = container_of(work, struct bmc_device, in cleanup_bmc_work() local
2917 int id = bmc->pdev.id; /* Unregister overwrites id */ in cleanup_bmc_work()
2919 platform_device_unregister(&bmc->pdev); in cleanup_bmc_work()
2926 struct bmc_device *bmc = container_of(ref, struct bmc_device, usecount); in cleanup_bmc_device() local
2933 schedule_work(&bmc->remove_work); in cleanup_bmc_device()
2941 struct bmc_device *bmc = intf->bmc; in __ipmi_bmc_unregister() local
2946 sysfs_remove_link(&intf->si_dev->kobj, "bmc"); in __ipmi_bmc_unregister()
2947 sysfs_remove_link(&bmc->pdev.dev.kobj, intf->my_dev_name); in __ipmi_bmc_unregister()
2951 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_unregister()
2953 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_unregister()
2954 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_unregister()
2955 kref_put(&bmc->usecount, cleanup_bmc_device); in __ipmi_bmc_unregister()
2974 struct bmc_device *bmc; in __ipmi_bmc_register() local
2988 * representing the interfaced BMC already in __ipmi_bmc_register()
3000 * otherwise register the new BMC device in __ipmi_bmc_register()
3003 bmc = old_bmc; in __ipmi_bmc_register()
3006 * the BMC find functions. in __ipmi_bmc_register()
3008 intf->bmc = old_bmc; in __ipmi_bmc_register()
3009 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3010 list_add_tail(&intf->bmc_link, &bmc->intfs); in __ipmi_bmc_register()
3011 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3014 "interfacing existing BMC (man_id: 0x%6.6x, prod_id: 0x%4.4x, dev_id: 0x%2.2x)\n", in __ipmi_bmc_register()
3015 bmc->id.manufacturer_id, in __ipmi_bmc_register()
3016 bmc->id.product_id, in __ipmi_bmc_register()
3017 bmc->id.device_id); in __ipmi_bmc_register()
3019 bmc = kzalloc(sizeof(*bmc), GFP_KERNEL); in __ipmi_bmc_register()
3020 if (!bmc) { in __ipmi_bmc_register()
3024 INIT_LIST_HEAD(&bmc->intfs); in __ipmi_bmc_register()
3025 mutex_init(&bmc->dyn_mutex); in __ipmi_bmc_register()
3026 INIT_WORK(&bmc->remove_work, cleanup_bmc_work); in __ipmi_bmc_register()
3028 bmc->id = *id; in __ipmi_bmc_register()
3029 bmc->dyn_id_set = 1; in __ipmi_bmc_register()
3030 bmc->dyn_guid_set = guid_set; in __ipmi_bmc_register()
3031 bmc->guid = *guid; in __ipmi_bmc_register()
3032 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY; in __ipmi_bmc_register()
3034 bmc->pdev.name = "ipmi_bmc"; in __ipmi_bmc_register()
3038 kfree(bmc); in __ipmi_bmc_register()
3042 bmc->pdev.dev.driver = &ipmidriver.driver; in __ipmi_bmc_register()
3043 bmc->pdev.id = rv; in __ipmi_bmc_register()
3044 bmc->pdev.dev.release = release_bmc_device; in __ipmi_bmc_register()
3045 bmc->pdev.dev.type = &bmc_device_type; in __ipmi_bmc_register()
3046 kref_init(&bmc->usecount); in __ipmi_bmc_register()
3048 intf->bmc = bmc; in __ipmi_bmc_register()
3049 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3050 list_add_tail(&intf->bmc_link, &bmc->intfs); in __ipmi_bmc_register()
3051 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3053 rv = platform_device_register(&bmc->pdev); in __ipmi_bmc_register()
3056 "Unable to register bmc device: %d\n", in __ipmi_bmc_register()
3062 "Found new BMC (man_id: 0x%6.6x, prod_id: 0x%4.4x, dev_id: 0x%2.2x)\n", in __ipmi_bmc_register()
3063 bmc->id.manufacturer_id, in __ipmi_bmc_register()
3064 bmc->id.product_id, in __ipmi_bmc_register()
3065 bmc->id.device_id); in __ipmi_bmc_register()
3069 * create symlink from system interface device to bmc device in __ipmi_bmc_register()
3072 rv = sysfs_create_link(&intf->si_dev->kobj, &bmc->pdev.dev.kobj, "bmc"); in __ipmi_bmc_register()
3074 dev_err(intf->si_dev, "Unable to create bmc symlink: %d\n", rv); in __ipmi_bmc_register()
3083 dev_err(intf->si_dev, "Unable to allocate link from BMC: %d\n", in __ipmi_bmc_register()
3088 rv = sysfs_create_link(&bmc->pdev.dev.kobj, &intf->si_dev->kobj, in __ipmi_bmc_register()
3091 dev_err(intf->si_dev, "Unable to create symlink to bmc: %d\n", in __ipmi_bmc_register()
3110 sysfs_remove_link(&intf->si_dev->kobj, "bmc"); in __ipmi_bmc_register()
3113 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3115 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3116 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_register()
3117 kref_put(&bmc->usecount, cleanup_bmc_device); in __ipmi_bmc_register()
3121 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3123 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3124 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_register()
3125 put_device(&bmc->pdev.dev); in __ipmi_bmc_register()
3159 struct bmc_device *bmc = intf->bmc; in guid_handler() local
3168 /* Error from getting the GUID, the BMC doesn't have one. */ in guid_handler()
3169 bmc->dyn_guid_set = 0; in guid_handler()
3174 bmc->dyn_guid_set = 0; in guid_handler()
3176 …"The GUID response from the BMC was too short, it was %d but should have been %d. Assuming GUID i… in guid_handler()
3181 import_guid(&bmc->fetch_guid, msg->msg.data + 1); in guid_handler()
3187 bmc->dyn_guid_set = 1; in guid_handler()
3195 struct bmc_device *bmc = intf->bmc; in __get_guid() local
3197 bmc->dyn_guid_set = 2; in __get_guid()
3202 bmc->dyn_guid_set = 0; in __get_guid()
3204 wait_event(intf->waitq, bmc->dyn_guid_set != 2); in __get_guid()
3415 intf->bmc = &intf->tmp_bmc; in ipmi_add_smi()
3416 INIT_LIST_HEAD(&intf->bmc->intfs); in ipmi_add_smi()
3417 mutex_init(&intf->bmc->dyn_mutex); in ipmi_add_smi()
4275 "BMC returned too small a message for netfn %x cmd %x, got %d bytes\n", in handle_one_recv_msg()
4290 "BMC returned incorrect response, expected netfn %x cmd %x, got netfn %x cmd %x\n", in handle_one_recv_msg()
4408 /* It's a response from the local BMC. */ in handle_one_recv_msg()