Lines Matching full:subsys

146 static void nvme_put_subsystem(struct nvme_subsystem *subsys);
668 ida_free(&head->subsys->ns_ida, head->instance); in nvme_free_ns_head()
670 nvme_put_subsystem(head->subsys); in nvme_free_ns_head()
1216 mutex_lock(&ctrl->subsys->lock); in nvme_passthru_start()
1217 nvme_mpath_start_freeze(ctrl->subsys); in nvme_passthru_start()
1218 nvme_mpath_wait_freeze(ctrl->subsys); in nvme_passthru_start()
1231 nvme_mpath_unfreeze(ctrl->subsys); in nvme_passthru_end()
1232 mutex_unlock(&ctrl->subsys->lock); in nvme_passthru_end()
2045 atomic_bs = (1 + ns->ctrl->subsys->awupf) * bs; in nvme_update_disk_info()
2850 static void nvme_init_subnqn(struct nvme_subsystem *subsys, struct nvme_ctrl *ctrl, in nvme_init_subnqn() argument
2859 strscpy(subsys->subnqn, id->subnqn, NVMF_NQN_SIZE); in nvme_init_subnqn()
2872 off = snprintf(subsys->subnqn, NVMF_NQN_SIZE, in nvme_init_subnqn()
2875 memcpy(subsys->subnqn + off, id->sn, sizeof(id->sn)); in nvme_init_subnqn()
2877 memcpy(subsys->subnqn + off, id->mn, sizeof(id->mn)); in nvme_init_subnqn()
2879 memset(subsys->subnqn + off, 0, sizeof(subsys->subnqn) - off); in nvme_init_subnqn()
2884 struct nvme_subsystem *subsys = in nvme_release_subsystem() local
2887 if (subsys->instance >= 0) in nvme_release_subsystem()
2888 ida_free(&nvme_instance_ida, subsys->instance); in nvme_release_subsystem()
2889 kfree(subsys); in nvme_release_subsystem()
2894 struct nvme_subsystem *subsys = in nvme_destroy_subsystem() local
2898 list_del(&subsys->entry); in nvme_destroy_subsystem()
2901 ida_destroy(&subsys->ns_ida); in nvme_destroy_subsystem()
2902 device_del(&subsys->dev); in nvme_destroy_subsystem()
2903 put_device(&subsys->dev); in nvme_destroy_subsystem()
2906 static void nvme_put_subsystem(struct nvme_subsystem *subsys) in nvme_put_subsystem() argument
2908 kref_put(&subsys->ref, nvme_destroy_subsystem); in nvme_put_subsystem()
2913 struct nvme_subsystem *subsys; in __nvme_find_get_subsystem() local
2928 list_for_each_entry(subsys, &nvme_subsystems, entry) { in __nvme_find_get_subsystem()
2929 if (strcmp(subsys->subnqn, subsysnqn)) in __nvme_find_get_subsystem()
2931 if (!kref_get_unless_zero(&subsys->ref)) in __nvme_find_get_subsystem()
2933 return subsys; in __nvme_find_get_subsystem()
2944 static bool nvme_validate_cntlid(struct nvme_subsystem *subsys, in nvme_validate_cntlid() argument
2951 list_for_each_entry(tmp, &subsys->ctrls, subsys_entry) { in nvme_validate_cntlid()
2957 "Duplicate cntlid %u with %s, subsys %s, rejecting\n", in nvme_validate_cntlid()
2959 subsys->subnqn); in nvme_validate_cntlid()
2977 struct nvme_subsystem *subsys, *found; in nvme_init_subsystem() local
2980 subsys = kzalloc(sizeof(*subsys), GFP_KERNEL); in nvme_init_subsystem()
2981 if (!subsys) in nvme_init_subsystem()
2984 subsys->instance = -1; in nvme_init_subsystem()
2985 mutex_init(&subsys->lock); in nvme_init_subsystem()
2986 kref_init(&subsys->ref); in nvme_init_subsystem()
2987 INIT_LIST_HEAD(&subsys->ctrls); in nvme_init_subsystem()
2988 INIT_LIST_HEAD(&subsys->nsheads); in nvme_init_subsystem()
2989 nvme_init_subnqn(subsys, ctrl, id); in nvme_init_subsystem()
2990 memcpy(subsys->serial, id->sn, sizeof(subsys->serial)); in nvme_init_subsystem()
2991 memcpy(subsys->model, id->mn, sizeof(subsys->model)); in nvme_init_subsystem()
2992 subsys->vendor_id = le16_to_cpu(id->vid); in nvme_init_subsystem()
2993 subsys->cmic = id->cmic; in nvme_init_subsystem()
2997 !strcmp(subsys->subnqn, NVME_DISC_SUBSYS_NAME)) in nvme_init_subsystem()
2998 subsys->subtype = NVME_NQN_DISC; in nvme_init_subsystem()
3000 subsys->subtype = NVME_NQN_NVME; in nvme_init_subsystem()
3002 if (nvme_discovery_ctrl(ctrl) && subsys->subtype != NVME_NQN_DISC) { in nvme_init_subsystem()
3005 subsys->subnqn); in nvme_init_subsystem()
3006 kfree(subsys); in nvme_init_subsystem()
3009 subsys->awupf = le16_to_cpu(id->awupf); in nvme_init_subsystem()
3010 nvme_mpath_default_iopolicy(subsys); in nvme_init_subsystem()
3012 subsys->dev.class = &nvme_subsys_class; in nvme_init_subsystem()
3013 subsys->dev.release = nvme_release_subsystem; in nvme_init_subsystem()
3014 subsys->dev.groups = nvme_subsys_attrs_groups; in nvme_init_subsystem()
3015 dev_set_name(&subsys->dev, "nvme-subsys%d", ctrl->instance); in nvme_init_subsystem()
3016 device_initialize(&subsys->dev); in nvme_init_subsystem()
3019 found = __nvme_find_get_subsystem(subsys->subnqn); in nvme_init_subsystem()
3021 put_device(&subsys->dev); in nvme_init_subsystem()
3022 subsys = found; in nvme_init_subsystem()
3024 if (!nvme_validate_cntlid(subsys, ctrl, id)) { in nvme_init_subsystem()
3029 ret = device_add(&subsys->dev); in nvme_init_subsystem()
3033 put_device(&subsys->dev); in nvme_init_subsystem()
3036 ida_init(&subsys->ns_ida); in nvme_init_subsystem()
3037 list_add_tail(&subsys->entry, &nvme_subsystems); in nvme_init_subsystem()
3040 ret = sysfs_create_link(&subsys->dev.kobj, &ctrl->device->kobj, in nvme_init_subsystem()
3049 subsys->instance = ctrl->instance; in nvme_init_subsystem()
3050 ctrl->subsys = subsys; in nvme_init_subsystem()
3051 list_add_tail(&ctrl->subsys_entry, &subsys->ctrls); in nvme_init_subsystem()
3056 nvme_put_subsystem(subsys); in nvme_init_subsystem()
3134 if (ctrl->subsys->subtype != NVME_NQN_NVME || in nvme_init_non_mdts_limits()
3301 memcpy(ctrl->subsys->firmware_rev, id->fr, in nvme_init_identify()
3302 sizeof(ctrl->subsys->firmware_rev)); in nvme_init_identify()
3505 lockdep_assert_held(&ctrl->subsys->lock); in nvme_find_ns_head()
3507 list_for_each_entry(h, &ctrl->subsys->nsheads, entry) { in nvme_find_ns_head()
3522 static int nvme_subsys_check_duplicate_ids(struct nvme_subsystem *subsys, in nvme_subsys_check_duplicate_ids() argument
3530 lockdep_assert_held(&subsys->lock); in nvme_subsys_check_duplicate_ids()
3532 list_for_each_entry(h, &subsys->nsheads, entry) { in nvme_subsys_check_duplicate_ids()
3627 ret = ida_alloc_min(&ctrl->subsys->ns_ida, 1, GFP_KERNEL); in nvme_alloc_ns_head()
3635 head->subsys = ctrl->subsys; in nvme_alloc_ns_head()
3654 list_add_tail(&head->entry, &ctrl->subsys->nsheads); in nvme_alloc_ns_head()
3656 kref_get(&ctrl->subsys->ref); in nvme_alloc_ns_head()
3662 ida_free(&ctrl->subsys->ns_ida, head->instance); in nvme_alloc_ns_head()
3703 ret = nvme_global_check_duplicate_ids(ctrl->subsys, &info->ids); in nvme_init_ns_head()
3723 ((ns->ctrl->subsys->cmic & NVME_CTRL_CMIC_MULTI_CTRL) && in nvme_init_ns_head()
3741 mutex_lock(&ctrl->subsys->lock); in nvme_init_ns_head()
3744 ret = nvme_subsys_check_duplicate_ids(ctrl->subsys, &info->ids); in nvme_init_ns_head()
3782 mutex_unlock(&ctrl->subsys->lock); in nvme_init_ns_head()
3788 mutex_unlock(&ctrl->subsys->lock); in nvme_init_ns_head()
3873 sprintf(disk->disk_name, "nvme%dc%dn%d", ctrl->subsys->instance, in nvme_alloc_ns()
3877 sprintf(disk->disk_name, "nvme%dn%d", ctrl->subsys->instance, in nvme_alloc_ns()
3926 mutex_lock(&ctrl->subsys->lock); in nvme_alloc_ns()
3930 mutex_unlock(&ctrl->subsys->lock); in nvme_alloc_ns()
3959 mutex_lock(&ns->ctrl->subsys->lock); in nvme_ns_remove()
3965 mutex_unlock(&ns->ctrl->subsys->lock); in nvme_ns_remove()
4403 memcpy(ctrl->subsys->firmware_rev, &log->frs[cur_fw_slot - 1], in nvme_get_fw_slot_info()
4404 sizeof(ctrl->subsys->firmware_rev)); in nvme_get_fw_slot_info()
4732 struct nvme_subsystem *subsys = ctrl->subsys; in nvme_free_ctrl() local
4734 if (!subsys || ctrl->instance != subsys->instance) in nvme_free_ctrl()
4744 if (subsys) { in nvme_free_ctrl()
4747 sysfs_remove_link(&subsys->dev.kobj, dev_name(ctrl->device)); in nvme_free_ctrl()
4753 if (subsys) in nvme_free_ctrl()
4754 nvme_put_subsystem(subsys); in nvme_free_ctrl()