Lines Matching refs:subsys

123 static void nvme_put_subsystem(struct nvme_subsystem *subsys);
630 ida_free(&head->subsys->ns_ida, head->instance); in nvme_free_ns_head()
632 nvme_put_subsystem(head->subsys); in nvme_free_ns_head()
1119 mutex_lock(&ctrl->subsys->lock); in nvme_passthru_start()
1120 nvme_mpath_start_freeze(ctrl->subsys); in nvme_passthru_start()
1121 nvme_mpath_wait_freeze(ctrl->subsys); in nvme_passthru_start()
1134 nvme_mpath_unfreeze(ctrl->subsys); in nvme_passthru_end()
1135 mutex_unlock(&ctrl->subsys->lock); in nvme_passthru_end()
1918 atomic_bs = (1 + ns->ctrl->subsys->awupf) * bs; in nvme_update_disk_info()
2643 static void nvme_init_subnqn(struct nvme_subsystem *subsys, struct nvme_ctrl *ctrl, in nvme_init_subnqn() argument
2652 strscpy(subsys->subnqn, id->subnqn, NVMF_NQN_SIZE); in nvme_init_subnqn()
2665 off = snprintf(subsys->subnqn, NVMF_NQN_SIZE, in nvme_init_subnqn()
2668 memcpy(subsys->subnqn + off, id->sn, sizeof(id->sn)); in nvme_init_subnqn()
2670 memcpy(subsys->subnqn + off, id->mn, sizeof(id->mn)); in nvme_init_subnqn()
2672 memset(subsys->subnqn + off, 0, sizeof(subsys->subnqn) - off); in nvme_init_subnqn()
2677 struct nvme_subsystem *subsys = in nvme_release_subsystem() local
2680 if (subsys->instance >= 0) in nvme_release_subsystem()
2681 ida_free(&nvme_instance_ida, subsys->instance); in nvme_release_subsystem()
2682 kfree(subsys); in nvme_release_subsystem()
2687 struct nvme_subsystem *subsys = in nvme_destroy_subsystem() local
2691 list_del(&subsys->entry); in nvme_destroy_subsystem()
2694 ida_destroy(&subsys->ns_ida); in nvme_destroy_subsystem()
2695 device_del(&subsys->dev); in nvme_destroy_subsystem()
2696 put_device(&subsys->dev); in nvme_destroy_subsystem()
2699 static void nvme_put_subsystem(struct nvme_subsystem *subsys) in nvme_put_subsystem() argument
2701 kref_put(&subsys->ref, nvme_destroy_subsystem); in nvme_put_subsystem()
2706 struct nvme_subsystem *subsys; in __nvme_find_get_subsystem() local
2721 list_for_each_entry(subsys, &nvme_subsystems, entry) { in __nvme_find_get_subsystem()
2722 if (strcmp(subsys->subnqn, subsysnqn)) in __nvme_find_get_subsystem()
2724 if (!kref_get_unless_zero(&subsys->ref)) in __nvme_find_get_subsystem()
2726 return subsys; in __nvme_find_get_subsystem()
2737 static bool nvme_validate_cntlid(struct nvme_subsystem *subsys, in nvme_validate_cntlid() argument
2744 list_for_each_entry(tmp, &subsys->ctrls, subsys_entry) { in nvme_validate_cntlid()
2752 subsys->subnqn); in nvme_validate_cntlid()
2770 struct nvme_subsystem *subsys, *found; in nvme_init_subsystem() local
2773 subsys = kzalloc(sizeof(*subsys), GFP_KERNEL); in nvme_init_subsystem()
2774 if (!subsys) in nvme_init_subsystem()
2777 subsys->instance = -1; in nvme_init_subsystem()
2778 mutex_init(&subsys->lock); in nvme_init_subsystem()
2779 kref_init(&subsys->ref); in nvme_init_subsystem()
2780 INIT_LIST_HEAD(&subsys->ctrls); in nvme_init_subsystem()
2781 INIT_LIST_HEAD(&subsys->nsheads); in nvme_init_subsystem()
2782 nvme_init_subnqn(subsys, ctrl, id); in nvme_init_subsystem()
2783 memcpy(subsys->serial, id->sn, sizeof(subsys->serial)); in nvme_init_subsystem()
2784 memcpy(subsys->model, id->mn, sizeof(subsys->model)); in nvme_init_subsystem()
2785 subsys->vendor_id = le16_to_cpu(id->vid); in nvme_init_subsystem()
2786 subsys->cmic = id->cmic; in nvme_init_subsystem()
2790 !strcmp(subsys->subnqn, NVME_DISC_SUBSYS_NAME)) in nvme_init_subsystem()
2791 subsys->subtype = NVME_NQN_DISC; in nvme_init_subsystem()
2793 subsys->subtype = NVME_NQN_NVME; in nvme_init_subsystem()
2795 if (nvme_discovery_ctrl(ctrl) && subsys->subtype != NVME_NQN_DISC) { in nvme_init_subsystem()
2798 subsys->subnqn); in nvme_init_subsystem()
2799 kfree(subsys); in nvme_init_subsystem()
2802 subsys->awupf = le16_to_cpu(id->awupf); in nvme_init_subsystem()
2803 nvme_mpath_default_iopolicy(subsys); in nvme_init_subsystem()
2805 subsys->dev.class = nvme_subsys_class; in nvme_init_subsystem()
2806 subsys->dev.release = nvme_release_subsystem; in nvme_init_subsystem()
2807 subsys->dev.groups = nvme_subsys_attrs_groups; in nvme_init_subsystem()
2808 dev_set_name(&subsys->dev, "nvme-subsys%d", ctrl->instance); in nvme_init_subsystem()
2809 device_initialize(&subsys->dev); in nvme_init_subsystem()
2812 found = __nvme_find_get_subsystem(subsys->subnqn); in nvme_init_subsystem()
2814 put_device(&subsys->dev); in nvme_init_subsystem()
2815 subsys = found; in nvme_init_subsystem()
2817 if (!nvme_validate_cntlid(subsys, ctrl, id)) { in nvme_init_subsystem()
2822 ret = device_add(&subsys->dev); in nvme_init_subsystem()
2826 put_device(&subsys->dev); in nvme_init_subsystem()
2829 ida_init(&subsys->ns_ida); in nvme_init_subsystem()
2830 list_add_tail(&subsys->entry, &nvme_subsystems); in nvme_init_subsystem()
2833 ret = sysfs_create_link(&subsys->dev.kobj, &ctrl->device->kobj, in nvme_init_subsystem()
2842 subsys->instance = ctrl->instance; in nvme_init_subsystem()
2843 ctrl->subsys = subsys; in nvme_init_subsystem()
2844 list_add_tail(&ctrl->subsys_entry, &subsys->ctrls); in nvme_init_subsystem()
2849 nvme_put_subsystem(subsys); in nvme_init_subsystem()
2935 if (ctrl->subsys->subtype != NVME_NQN_NVME || in nvme_init_non_mdts_limits()
3061 memcpy(ctrl->subsys->firmware_rev, id->fr, in nvme_init_identify()
3062 sizeof(ctrl->subsys->firmware_rev)); in nvme_init_identify()
3274 lockdep_assert_held(&ctrl->subsys->lock); in nvme_find_ns_head()
3276 list_for_each_entry(h, &ctrl->subsys->nsheads, entry) { in nvme_find_ns_head()
3291 static int nvme_subsys_check_duplicate_ids(struct nvme_subsystem *subsys, in nvme_subsys_check_duplicate_ids() argument
3299 lockdep_assert_held(&subsys->lock); in nvme_subsys_check_duplicate_ids()
3301 list_for_each_entry(h, &subsys->nsheads, entry) { in nvme_subsys_check_duplicate_ids()
3396 ret = ida_alloc_min(&ctrl->subsys->ns_ida, 1, GFP_KERNEL); in nvme_alloc_ns_head()
3404 head->subsys = ctrl->subsys; in nvme_alloc_ns_head()
3421 list_add_tail(&head->entry, &ctrl->subsys->nsheads); in nvme_alloc_ns_head()
3423 kref_get(&ctrl->subsys->ref); in nvme_alloc_ns_head()
3429 ida_free(&ctrl->subsys->ns_ida, head->instance); in nvme_alloc_ns_head()
3470 ret = nvme_global_check_duplicate_ids(ctrl->subsys, &info->ids); in nvme_init_ns_head()
3490 ((ns->ctrl->subsys->cmic & NVME_CTRL_CMIC_MULTI_CTRL) && in nvme_init_ns_head()
3508 mutex_lock(&ctrl->subsys->lock); in nvme_init_ns_head()
3511 ret = nvme_subsys_check_duplicate_ids(ctrl->subsys, &info->ids); in nvme_init_ns_head()
3549 mutex_unlock(&ctrl->subsys->lock); in nvme_init_ns_head()
3555 mutex_unlock(&ctrl->subsys->lock); in nvme_init_ns_head()
3640 sprintf(disk->disk_name, "nvme%dc%dn%d", ctrl->subsys->instance, in nvme_alloc_ns()
3644 sprintf(disk->disk_name, "nvme%dn%d", ctrl->subsys->instance, in nvme_alloc_ns()
3684 mutex_lock(&ctrl->subsys->lock); in nvme_alloc_ns()
3688 mutex_unlock(&ctrl->subsys->lock); in nvme_alloc_ns()
3717 mutex_lock(&ns->ctrl->subsys->lock); in nvme_ns_remove()
3723 mutex_unlock(&ns->ctrl->subsys->lock); in nvme_ns_remove()
4429 struct nvme_subsystem *subsys = ctrl->subsys; in nvme_free_ctrl() local
4431 if (!subsys || ctrl->instance != subsys->instance) in nvme_free_ctrl()
4441 if (subsys) { in nvme_free_ctrl()
4444 sysfs_remove_link(&subsys->dev.kobj, dev_name(ctrl->device)); in nvme_free_ctrl()
4450 if (subsys) in nvme_free_ctrl()
4451 nvme_put_subsystem(subsys); in nvme_free_ctrl()