diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-26 14:48:42 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-26 14:48:42 -0400 |
| commit | aba16dc5cf9318b4e0fe92f8261779cd9f1d2d77 (patch) | |
| tree | 1f53d2cee40e82efe6a727208307af475327af9a /drivers | |
| parent | c4726e774ed27680c418e138234dfd2b8e1e89ac (diff) | |
| parent | 1df895190233fcc30d46beca4550bcafb7b959a6 (diff) | |
Merge branch 'ida-4.19' of git://git.infradead.org/users/willy/linux-dax
Pull IDA updates from Matthew Wilcox:
"A better IDA API:
id = ida_alloc(ida, GFP_xxx);
ida_free(ida, id);
rather than the cumbersome ida_simple_get(), ida_simple_remove().
The new IDA API is similar to ida_simple_get() but better named. The
internal restructuring of the IDA code removes the bitmap
preallocation nonsense.
I hope the net -200 lines of code is convincing"
* 'ida-4.19' of git://git.infradead.org/users/willy/linux-dax: (29 commits)
ida: Change ida_get_new_above to return the id
ida: Remove old API
test_ida: check_ida_destroy and check_ida_alloc
test_ida: Convert check_ida_conv to new API
test_ida: Move ida_check_max
test_ida: Move ida_check_leaf
idr-test: Convert ida_check_nomem to new API
ida: Start new test_ida module
target/iscsi: Allocate session IDs from an IDA
iscsi target: fix session creation failure handling
drm/vmwgfx: Convert to new IDA API
dmaengine: Convert to new IDA API
ppc: Convert vas ID allocation to new IDA API
media: Convert entity ID allocation to new IDA API
ppc: Convert mmu context allocation to new IDA API
Convert net_namespace to new IDA API
cb710: Convert to new IDA API
rsxx: Convert to new IDA API
osd: Convert to new IDA API
sd: Convert to new IDA API
...
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/block/mtip32xx/mtip32xx.c | 29 | ||||
| -rw-r--r-- | drivers/block/rsxx/core.c | 21 | ||||
| -rw-r--r-- | drivers/dma/dmaengine.c | 23 | ||||
| -rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 41 | ||||
| -rw-r--r-- | drivers/media/media-device.c | 16 | ||||
| -rw-r--r-- | drivers/misc/cb710/core.c | 23 | ||||
| -rw-r--r-- | drivers/scsi/osd/osd_uld.c | 22 | ||||
| -rw-r--r-- | drivers/scsi/sd.c | 21 | ||||
| -rw-r--r-- | drivers/target/iscsi/iscsi_target.c | 10 | ||||
| -rw-r--r-- | drivers/target/iscsi/iscsi_target.h | 4 | ||||
| -rw-r--r-- | drivers/target/iscsi/iscsi_target_login.c | 41 |
11 files changed, 72 insertions, 179 deletions
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c index db253cd5b32a..d0666f5ce003 100644 --- a/drivers/block/mtip32xx/mtip32xx.c +++ b/drivers/block/mtip32xx/mtip32xx.c | |||
| @@ -118,7 +118,6 @@ static struct dentry *dfs_device_status; | |||
| 118 | 118 | ||
| 119 | static u32 cpu_use[NR_CPUS]; | 119 | static u32 cpu_use[NR_CPUS]; |
| 120 | 120 | ||
| 121 | static DEFINE_SPINLOCK(rssd_index_lock); | ||
| 122 | static DEFINE_IDA(rssd_index_ida); | 121 | static DEFINE_IDA(rssd_index_ida); |
| 123 | 122 | ||
| 124 | static int mtip_block_initialize(struct driver_data *dd); | 123 | static int mtip_block_initialize(struct driver_data *dd); |
| @@ -3767,20 +3766,10 @@ static int mtip_block_initialize(struct driver_data *dd) | |||
| 3767 | goto alloc_disk_error; | 3766 | goto alloc_disk_error; |
| 3768 | } | 3767 | } |
| 3769 | 3768 | ||
| 3770 | /* Generate the disk name, implemented same as in sd.c */ | 3769 | rv = ida_alloc(&rssd_index_ida, GFP_KERNEL); |
| 3771 | do { | 3770 | if (rv < 0) |
| 3772 | if (!ida_pre_get(&rssd_index_ida, GFP_KERNEL)) { | ||
| 3773 | rv = -ENOMEM; | ||
| 3774 | goto ida_get_error; | ||
| 3775 | } | ||
| 3776 | |||
| 3777 | spin_lock(&rssd_index_lock); | ||
| 3778 | rv = ida_get_new(&rssd_index_ida, &index); | ||
| 3779 | spin_unlock(&rssd_index_lock); | ||
| 3780 | } while (rv == -EAGAIN); | ||
| 3781 | |||
| 3782 | if (rv) | ||
| 3783 | goto ida_get_error; | 3771 | goto ida_get_error; |
| 3772 | index = rv; | ||
| 3784 | 3773 | ||
| 3785 | rv = rssd_disk_name_format("rssd", | 3774 | rv = rssd_disk_name_format("rssd", |
| 3786 | index, | 3775 | index, |
| @@ -3922,9 +3911,7 @@ block_queue_alloc_init_error: | |||
| 3922 | block_queue_alloc_tag_error: | 3911 | block_queue_alloc_tag_error: |
| 3923 | mtip_hw_debugfs_exit(dd); | 3912 | mtip_hw_debugfs_exit(dd); |
| 3924 | disk_index_error: | 3913 | disk_index_error: |
| 3925 | spin_lock(&rssd_index_lock); | 3914 | ida_free(&rssd_index_ida, index); |
| 3926 | ida_remove(&rssd_index_ida, index); | ||
| 3927 | spin_unlock(&rssd_index_lock); | ||
| 3928 | 3915 | ||
| 3929 | ida_get_error: | 3916 | ida_get_error: |
| 3930 | put_disk(dd->disk); | 3917 | put_disk(dd->disk); |
| @@ -4012,9 +3999,7 @@ static int mtip_block_remove(struct driver_data *dd) | |||
| 4012 | } | 3999 | } |
| 4013 | dd->disk = NULL; | 4000 | dd->disk = NULL; |
| 4014 | 4001 | ||
| 4015 | spin_lock(&rssd_index_lock); | 4002 | ida_free(&rssd_index_ida, dd->index); |
| 4016 | ida_remove(&rssd_index_ida, dd->index); | ||
| 4017 | spin_unlock(&rssd_index_lock); | ||
| 4018 | 4003 | ||
| 4019 | /* De-initialize the protocol layer. */ | 4004 | /* De-initialize the protocol layer. */ |
| 4020 | mtip_hw_exit(dd); | 4005 | mtip_hw_exit(dd); |
| @@ -4054,9 +4039,7 @@ static int mtip_block_shutdown(struct driver_data *dd) | |||
| 4054 | dd->queue = NULL; | 4039 | dd->queue = NULL; |
| 4055 | } | 4040 | } |
| 4056 | 4041 | ||
| 4057 | spin_lock(&rssd_index_lock); | 4042 | ida_free(&rssd_index_ida, dd->index); |
| 4058 | ida_remove(&rssd_index_ida, dd->index); | ||
| 4059 | spin_unlock(&rssd_index_lock); | ||
| 4060 | return 0; | 4043 | return 0; |
| 4061 | } | 4044 | } |
| 4062 | 4045 | ||
diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c index b7d71914a32a..f2c631ce793c 100644 --- a/drivers/block/rsxx/core.c +++ b/drivers/block/rsxx/core.c | |||
| @@ -58,7 +58,6 @@ MODULE_PARM_DESC(sync_start, "On by Default: Driver load will not complete " | |||
| 58 | "until the card startup has completed."); | 58 | "until the card startup has completed."); |
| 59 | 59 | ||
| 60 | static DEFINE_IDA(rsxx_disk_ida); | 60 | static DEFINE_IDA(rsxx_disk_ida); |
| 61 | static DEFINE_SPINLOCK(rsxx_ida_lock); | ||
| 62 | 61 | ||
| 63 | /* --------------------Debugfs Setup ------------------- */ | 62 | /* --------------------Debugfs Setup ------------------- */ |
| 64 | 63 | ||
| @@ -771,19 +770,10 @@ static int rsxx_pci_probe(struct pci_dev *dev, | |||
| 771 | card->dev = dev; | 770 | card->dev = dev; |
| 772 | pci_set_drvdata(dev, card); | 771 | pci_set_drvdata(dev, card); |
| 773 | 772 | ||
| 774 | do { | 773 | st = ida_alloc(&rsxx_disk_ida, GFP_KERNEL); |
| 775 | if (!ida_pre_get(&rsxx_disk_ida, GFP_KERNEL)) { | 774 | if (st < 0) |
| 776 | st = -ENOMEM; | ||
| 777 | goto failed_ida_get; | ||
| 778 | } | ||
| 779 | |||
| 780 | spin_lock(&rsxx_ida_lock); | ||
| 781 | st = ida_get_new(&rsxx_disk_ida, &card->disk_id); | ||
| 782 | spin_unlock(&rsxx_ida_lock); | ||
| 783 | } while (st == -EAGAIN); | ||
| 784 | |||
| 785 | if (st) | ||
| 786 | goto failed_ida_get; | 775 | goto failed_ida_get; |
| 776 | card->disk_id = st; | ||
| 787 | 777 | ||
| 788 | st = pci_enable_device(dev); | 778 | st = pci_enable_device(dev); |
| 789 | if (st) | 779 | if (st) |
| @@ -985,9 +975,7 @@ failed_request_regions: | |||
| 985 | failed_dma_mask: | 975 | failed_dma_mask: |
| 986 | pci_disable_device(dev); | 976 | pci_disable_device(dev); |
| 987 | failed_enable: | 977 | failed_enable: |
| 988 | spin_lock(&rsxx_ida_lock); | 978 | ida_free(&rsxx_disk_ida, card->disk_id); |
| 989 | ida_remove(&rsxx_disk_ida, card->disk_id); | ||
| 990 | spin_unlock(&rsxx_ida_lock); | ||
| 991 | failed_ida_get: | 979 | failed_ida_get: |
| 992 | kfree(card); | 980 | kfree(card); |
| 993 | 981 | ||
| @@ -1050,6 +1038,7 @@ static void rsxx_pci_remove(struct pci_dev *dev) | |||
| 1050 | pci_disable_device(dev); | 1038 | pci_disable_device(dev); |
| 1051 | pci_release_regions(dev); | 1039 | pci_release_regions(dev); |
| 1052 | 1040 | ||
| 1041 | ida_free(&rsxx_disk_ida, card->disk_id); | ||
| 1053 | kfree(card); | 1042 | kfree(card); |
| 1054 | } | 1043 | } |
| 1055 | 1044 | ||
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 272bed6c8ba7..f1a441ab395d 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c | |||
| @@ -161,9 +161,7 @@ static void chan_dev_release(struct device *dev) | |||
| 161 | 161 | ||
| 162 | chan_dev = container_of(dev, typeof(*chan_dev), device); | 162 | chan_dev = container_of(dev, typeof(*chan_dev), device); |
| 163 | if (atomic_dec_and_test(chan_dev->idr_ref)) { | 163 | if (atomic_dec_and_test(chan_dev->idr_ref)) { |
| 164 | mutex_lock(&dma_list_mutex); | 164 | ida_free(&dma_ida, chan_dev->dev_id); |
| 165 | ida_remove(&dma_ida, chan_dev->dev_id); | ||
| 166 | mutex_unlock(&dma_list_mutex); | ||
| 167 | kfree(chan_dev->idr_ref); | 165 | kfree(chan_dev->idr_ref); |
| 168 | } | 166 | } |
| 169 | kfree(chan_dev); | 167 | kfree(chan_dev); |
| @@ -898,17 +896,12 @@ static bool device_has_all_tx_types(struct dma_device *device) | |||
| 898 | 896 | ||
| 899 | static int get_dma_id(struct dma_device *device) | 897 | static int get_dma_id(struct dma_device *device) |
| 900 | { | 898 | { |
| 901 | int rc; | 899 | int rc = ida_alloc(&dma_ida, GFP_KERNEL); |
| 902 | |||
| 903 | do { | ||
| 904 | if (!ida_pre_get(&dma_ida, GFP_KERNEL)) | ||
| 905 | return -ENOMEM; | ||
| 906 | mutex_lock(&dma_list_mutex); | ||
| 907 | rc = ida_get_new(&dma_ida, &device->dev_id); | ||
| 908 | mutex_unlock(&dma_list_mutex); | ||
| 909 | } while (rc == -EAGAIN); | ||
| 910 | 900 | ||
| 911 | return rc; | 901 | if (rc < 0) |
| 902 | return rc; | ||
| 903 | device->dev_id = rc; | ||
| 904 | return 0; | ||
| 912 | } | 905 | } |
| 913 | 906 | ||
| 914 | /** | 907 | /** |
| @@ -1092,9 +1085,7 @@ int dma_async_device_register(struct dma_device *device) | |||
| 1092 | err_out: | 1085 | err_out: |
| 1093 | /* if we never registered a channel just release the idr */ | 1086 | /* if we never registered a channel just release the idr */ |
| 1094 | if (atomic_read(idr_ref) == 0) { | 1087 | if (atomic_read(idr_ref) == 0) { |
| 1095 | mutex_lock(&dma_list_mutex); | 1088 | ida_free(&dma_ida, device->dev_id); |
| 1096 | ida_remove(&dma_ida, device->dev_id); | ||
| 1097 | mutex_unlock(&dma_list_mutex); | ||
| 1098 | kfree(idr_ref); | 1089 | kfree(idr_ref); |
| 1099 | return rc; | 1090 | return rc; |
| 1100 | } | 1091 | } |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c index ddb1e9365a3e..b93c558dd86e 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | |||
| @@ -51,51 +51,34 @@ static int vmw_gmrid_man_get_node(struct ttm_mem_type_manager *man, | |||
| 51 | { | 51 | { |
| 52 | struct vmwgfx_gmrid_man *gman = | 52 | struct vmwgfx_gmrid_man *gman = |
| 53 | (struct vmwgfx_gmrid_man *)man->priv; | 53 | (struct vmwgfx_gmrid_man *)man->priv; |
| 54 | int ret = 0; | ||
| 55 | int id; | 54 | int id; |
| 56 | 55 | ||
| 57 | mem->mm_node = NULL; | 56 | mem->mm_node = NULL; |
| 58 | 57 | ||
| 58 | id = ida_alloc_max(&gman->gmr_ida, gman->max_gmr_ids - 1, GFP_KERNEL); | ||
| 59 | if (id < 0) | ||
| 60 | return id; | ||
| 61 | |||
| 59 | spin_lock(&gman->lock); | 62 | spin_lock(&gman->lock); |
| 60 | 63 | ||
| 61 | if (gman->max_gmr_pages > 0) { | 64 | if (gman->max_gmr_pages > 0) { |
| 62 | gman->used_gmr_pages += bo->num_pages; | 65 | gman->used_gmr_pages += bo->num_pages; |
| 63 | if (unlikely(gman->used_gmr_pages > gman->max_gmr_pages)) | 66 | if (unlikely(gman->used_gmr_pages > gman->max_gmr_pages)) |
| 64 | goto out_err_locked; | 67 | goto nospace; |
| 65 | } | 68 | } |
| 66 | 69 | ||
| 67 | do { | 70 | mem->mm_node = gman; |
| 68 | spin_unlock(&gman->lock); | 71 | mem->start = id; |
| 69 | if (unlikely(ida_pre_get(&gman->gmr_ida, GFP_KERNEL) == 0)) { | 72 | mem->num_pages = bo->num_pages; |
| 70 | ret = -ENOMEM; | ||
| 71 | goto out_err; | ||
| 72 | } | ||
| 73 | spin_lock(&gman->lock); | ||
| 74 | |||
| 75 | ret = ida_get_new(&gman->gmr_ida, &id); | ||
| 76 | if (unlikely(ret == 0 && id >= gman->max_gmr_ids)) { | ||
| 77 | ida_remove(&gman->gmr_ida, id); | ||
| 78 | ret = 0; | ||
| 79 | goto out_err_locked; | ||
| 80 | } | ||
| 81 | } while (ret == -EAGAIN); | ||
| 82 | |||
| 83 | if (likely(ret == 0)) { | ||
| 84 | mem->mm_node = gman; | ||
| 85 | mem->start = id; | ||
| 86 | mem->num_pages = bo->num_pages; | ||
| 87 | } else | ||
| 88 | goto out_err_locked; | ||
| 89 | 73 | ||
| 90 | spin_unlock(&gman->lock); | 74 | spin_unlock(&gman->lock); |
| 91 | return 0; | 75 | return 0; |
| 92 | 76 | ||
| 93 | out_err: | 77 | nospace: |
| 94 | spin_lock(&gman->lock); | ||
| 95 | out_err_locked: | ||
| 96 | gman->used_gmr_pages -= bo->num_pages; | 78 | gman->used_gmr_pages -= bo->num_pages; |
| 97 | spin_unlock(&gman->lock); | 79 | spin_unlock(&gman->lock); |
| 98 | return ret; | 80 | ida_free(&gman->gmr_ida, id); |
| 81 | return 0; | ||
| 99 | } | 82 | } |
| 100 | 83 | ||
| 101 | static void vmw_gmrid_man_put_node(struct ttm_mem_type_manager *man, | 84 | static void vmw_gmrid_man_put_node(struct ttm_mem_type_manager *man, |
| @@ -105,8 +88,8 @@ static void vmw_gmrid_man_put_node(struct ttm_mem_type_manager *man, | |||
| 105 | (struct vmwgfx_gmrid_man *)man->priv; | 88 | (struct vmwgfx_gmrid_man *)man->priv; |
| 106 | 89 | ||
| 107 | if (mem->mm_node) { | 90 | if (mem->mm_node) { |
| 91 | ida_free(&gman->gmr_ida, mem->start); | ||
| 108 | spin_lock(&gman->lock); | 92 | spin_lock(&gman->lock); |
| 109 | ida_remove(&gman->gmr_ida, mem->start); | ||
| 110 | gman->used_gmr_pages -= mem->num_pages; | 93 | gman->used_gmr_pages -= mem->num_pages; |
| 111 | spin_unlock(&gman->lock); | 94 | spin_unlock(&gman->lock); |
| 112 | mem->mm_node = NULL; | 95 | mem->mm_node = NULL; |
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index fcdf3d5dc4b6..3bae24b15eaa 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c | |||
| @@ -585,18 +585,12 @@ int __must_check media_device_register_entity(struct media_device *mdev, | |||
| 585 | entity->num_links = 0; | 585 | entity->num_links = 0; |
| 586 | entity->num_backlinks = 0; | 586 | entity->num_backlinks = 0; |
| 587 | 587 | ||
| 588 | if (!ida_pre_get(&mdev->entity_internal_idx, GFP_KERNEL)) | 588 | ret = ida_alloc_min(&mdev->entity_internal_idx, 1, GFP_KERNEL); |
| 589 | return -ENOMEM; | 589 | if (ret < 0) |
| 590 | |||
| 591 | mutex_lock(&mdev->graph_mutex); | ||
| 592 | |||
| 593 | ret = ida_get_new_above(&mdev->entity_internal_idx, 1, | ||
| 594 | &entity->internal_idx); | ||
| 595 | if (ret < 0) { | ||
| 596 | mutex_unlock(&mdev->graph_mutex); | ||
| 597 | return ret; | 590 | return ret; |
| 598 | } | 591 | entity->internal_idx = ret; |
| 599 | 592 | ||
| 593 | mutex_lock(&mdev->graph_mutex); | ||
| 600 | mdev->entity_internal_idx_max = | 594 | mdev->entity_internal_idx_max = |
| 601 | max(mdev->entity_internal_idx_max, entity->internal_idx); | 595 | max(mdev->entity_internal_idx_max, entity->internal_idx); |
| 602 | 596 | ||
| @@ -642,7 +636,7 @@ static void __media_device_unregister_entity(struct media_entity *entity) | |||
| 642 | struct media_interface *intf; | 636 | struct media_interface *intf; |
| 643 | unsigned int i; | 637 | unsigned int i; |
| 644 | 638 | ||
| 645 | ida_simple_remove(&mdev->entity_internal_idx, entity->internal_idx); | 639 | ida_free(&mdev->entity_internal_idx, entity->internal_idx); |
| 646 | 640 | ||
| 647 | /* Remove all interface links pointing to this entity */ | 641 | /* Remove all interface links pointing to this entity */ |
| 648 | list_for_each_entry(intf, &mdev->interfaces, graph_obj.list) { | 642 | list_for_each_entry(intf, &mdev->interfaces, graph_obj.list) { |
diff --git a/drivers/misc/cb710/core.c b/drivers/misc/cb710/core.c index 4d4acf763b65..2c43fd09d602 100644 --- a/drivers/misc/cb710/core.c +++ b/drivers/misc/cb710/core.c | |||
| @@ -16,7 +16,6 @@ | |||
| 16 | #include <linux/gfp.h> | 16 | #include <linux/gfp.h> |
| 17 | 17 | ||
| 18 | static DEFINE_IDA(cb710_ida); | 18 | static DEFINE_IDA(cb710_ida); |
| 19 | static DEFINE_SPINLOCK(cb710_ida_lock); | ||
| 20 | 19 | ||
| 21 | void cb710_pci_update_config_reg(struct pci_dev *pdev, | 20 | void cb710_pci_update_config_reg(struct pci_dev *pdev, |
| 22 | int reg, uint32_t mask, uint32_t xor) | 21 | int reg, uint32_t mask, uint32_t xor) |
| @@ -205,7 +204,6 @@ static int cb710_probe(struct pci_dev *pdev, | |||
| 205 | const struct pci_device_id *ent) | 204 | const struct pci_device_id *ent) |
| 206 | { | 205 | { |
| 207 | struct cb710_chip *chip; | 206 | struct cb710_chip *chip; |
| 208 | unsigned long flags; | ||
| 209 | u32 val; | 207 | u32 val; |
| 210 | int err; | 208 | int err; |
| 211 | int n = 0; | 209 | int n = 0; |
| @@ -256,18 +254,10 @@ static int cb710_probe(struct pci_dev *pdev, | |||
| 256 | if (err) | 254 | if (err) |
| 257 | return err; | 255 | return err; |
| 258 | 256 | ||
| 259 | do { | 257 | err = ida_alloc(&cb710_ida, GFP_KERNEL); |
| 260 | if (!ida_pre_get(&cb710_ida, GFP_KERNEL)) | 258 | if (err < 0) |
| 261 | return -ENOMEM; | 259 | return err; |
| 262 | 260 | chip->platform_id = err; | |
| 263 | spin_lock_irqsave(&cb710_ida_lock, flags); | ||
| 264 | err = ida_get_new(&cb710_ida, &chip->platform_id); | ||
| 265 | spin_unlock_irqrestore(&cb710_ida_lock, flags); | ||
| 266 | |||
| 267 | if (err && err != -EAGAIN) | ||
| 268 | return err; | ||
| 269 | } while (err); | ||
| 270 | |||
| 271 | 261 | ||
| 272 | dev_info(&pdev->dev, "id %d, IO 0x%p, IRQ %d\n", | 262 | dev_info(&pdev->dev, "id %d, IO 0x%p, IRQ %d\n", |
| 273 | chip->platform_id, chip->iobase, pdev->irq); | 263 | chip->platform_id, chip->iobase, pdev->irq); |
| @@ -308,7 +298,6 @@ unreg_mmc: | |||
| 308 | static void cb710_remove_one(struct pci_dev *pdev) | 298 | static void cb710_remove_one(struct pci_dev *pdev) |
| 309 | { | 299 | { |
| 310 | struct cb710_chip *chip = pci_get_drvdata(pdev); | 300 | struct cb710_chip *chip = pci_get_drvdata(pdev); |
| 311 | unsigned long flags; | ||
| 312 | 301 | ||
| 313 | cb710_unregister_slot(chip, CB710_SLOT_SM); | 302 | cb710_unregister_slot(chip, CB710_SLOT_SM); |
| 314 | cb710_unregister_slot(chip, CB710_SLOT_MS); | 303 | cb710_unregister_slot(chip, CB710_SLOT_MS); |
| @@ -317,9 +306,7 @@ static void cb710_remove_one(struct pci_dev *pdev) | |||
| 317 | BUG_ON(atomic_read(&chip->slot_refs_count) != 0); | 306 | BUG_ON(atomic_read(&chip->slot_refs_count) != 0); |
| 318 | #endif | 307 | #endif |
| 319 | 308 | ||
| 320 | spin_lock_irqsave(&cb710_ida_lock, flags); | 309 | ida_free(&cb710_ida, chip->platform_id); |
| 321 | ida_remove(&cb710_ida, chip->platform_id); | ||
| 322 | spin_unlock_irqrestore(&cb710_ida_lock, flags); | ||
| 323 | } | 310 | } |
| 324 | 311 | ||
| 325 | static const struct pci_device_id cb710_pci_tbl[] = { | 312 | static const struct pci_device_id cb710_pci_tbl[] = { |
diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c index 0e56f1eb05dc..eaf36ccf58db 100644 --- a/drivers/scsi/osd/osd_uld.c +++ b/drivers/scsi/osd/osd_uld.c | |||
| @@ -423,19 +423,11 @@ static int osd_probe(struct device *dev) | |||
| 423 | if (scsi_device->type != TYPE_OSD) | 423 | if (scsi_device->type != TYPE_OSD) |
| 424 | return -ENODEV; | 424 | return -ENODEV; |
| 425 | 425 | ||
| 426 | do { | 426 | minor = ida_alloc_max(&osd_minor_ida, SCSI_OSD_MAX_MINOR, GFP_KERNEL); |
| 427 | if (!ida_pre_get(&osd_minor_ida, GFP_KERNEL)) | 427 | if (minor == -ENOSPC) |
| 428 | return -ENODEV; | 428 | return -EBUSY; |
| 429 | 429 | if (minor < 0) | |
| 430 | error = ida_get_new(&osd_minor_ida, &minor); | 430 | return -ENODEV; |
| 431 | } while (error == -EAGAIN); | ||
| 432 | |||
| 433 | if (error) | ||
| 434 | return error; | ||
| 435 | if (minor >= SCSI_OSD_MAX_MINOR) { | ||
| 436 | error = -EBUSY; | ||
| 437 | goto err_retract_minor; | ||
| 438 | } | ||
| 439 | 431 | ||
| 440 | error = -ENOMEM; | 432 | error = -ENOMEM; |
| 441 | oud = kzalloc(sizeof(*oud), GFP_KERNEL); | 433 | oud = kzalloc(sizeof(*oud), GFP_KERNEL); |
| @@ -499,7 +491,7 @@ static int osd_probe(struct device *dev) | |||
| 499 | err_free_osd: | 491 | err_free_osd: |
| 500 | put_device(&oud->class_dev); | 492 | put_device(&oud->class_dev); |
| 501 | err_retract_minor: | 493 | err_retract_minor: |
| 502 | ida_remove(&osd_minor_ida, minor); | 494 | ida_free(&osd_minor_ida, minor); |
| 503 | return error; | 495 | return error; |
| 504 | } | 496 | } |
| 505 | 497 | ||
| @@ -514,7 +506,7 @@ static int osd_remove(struct device *dev) | |||
| 514 | } | 506 | } |
| 515 | 507 | ||
| 516 | cdev_device_del(&oud->cdev, &oud->class_dev); | 508 | cdev_device_del(&oud->cdev, &oud->class_dev); |
| 517 | ida_remove(&osd_minor_ida, oud->minor); | 509 | ida_free(&osd_minor_ida, oud->minor); |
| 518 | put_device(&oud->class_dev); | 510 | put_device(&oud->class_dev); |
| 519 | 511 | ||
| 520 | return 0; | 512 | return 0; |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index a58cee7a85f2..b79b366a94f7 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
| @@ -123,7 +123,6 @@ static void scsi_disk_release(struct device *cdev); | |||
| 123 | static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *); | 123 | static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *); |
| 124 | static void sd_print_result(const struct scsi_disk *, const char *, int); | 124 | static void sd_print_result(const struct scsi_disk *, const char *, int); |
| 125 | 125 | ||
| 126 | static DEFINE_SPINLOCK(sd_index_lock); | ||
| 127 | static DEFINE_IDA(sd_index_ida); | 126 | static DEFINE_IDA(sd_index_ida); |
| 128 | 127 | ||
| 129 | /* This semaphore is used to mediate the 0->1 reference get in the | 128 | /* This semaphore is used to mediate the 0->1 reference get in the |
| @@ -3340,16 +3339,8 @@ static int sd_probe(struct device *dev) | |||
| 3340 | if (!gd) | 3339 | if (!gd) |
| 3341 | goto out_free; | 3340 | goto out_free; |
| 3342 | 3341 | ||
| 3343 | do { | 3342 | index = ida_alloc(&sd_index_ida, GFP_KERNEL); |
| 3344 | if (!ida_pre_get(&sd_index_ida, GFP_KERNEL)) | 3343 | if (index < 0) { |
| 3345 | goto out_put; | ||
| 3346 | |||
| 3347 | spin_lock(&sd_index_lock); | ||
| 3348 | error = ida_get_new(&sd_index_ida, &index); | ||
| 3349 | spin_unlock(&sd_index_lock); | ||
| 3350 | } while (error == -EAGAIN); | ||
| 3351 | |||
| 3352 | if (error) { | ||
| 3353 | sdev_printk(KERN_WARNING, sdp, "sd_probe: memory exhausted.\n"); | 3344 | sdev_printk(KERN_WARNING, sdp, "sd_probe: memory exhausted.\n"); |
| 3354 | goto out_put; | 3345 | goto out_put; |
| 3355 | } | 3346 | } |
| @@ -3393,9 +3384,7 @@ static int sd_probe(struct device *dev) | |||
| 3393 | return 0; | 3384 | return 0; |
| 3394 | 3385 | ||
| 3395 | out_free_index: | 3386 | out_free_index: |
| 3396 | spin_lock(&sd_index_lock); | 3387 | ida_free(&sd_index_ida, index); |
| 3397 | ida_remove(&sd_index_ida, index); | ||
| 3398 | spin_unlock(&sd_index_lock); | ||
| 3399 | out_put: | 3388 | out_put: |
| 3400 | put_disk(gd); | 3389 | put_disk(gd); |
| 3401 | out_free: | 3390 | out_free: |
| @@ -3460,9 +3449,7 @@ static void scsi_disk_release(struct device *dev) | |||
| 3460 | struct scsi_disk *sdkp = to_scsi_disk(dev); | 3449 | struct scsi_disk *sdkp = to_scsi_disk(dev); |
| 3461 | struct gendisk *disk = sdkp->disk; | 3450 | struct gendisk *disk = sdkp->disk; |
| 3462 | 3451 | ||
| 3463 | spin_lock(&sd_index_lock); | 3452 | ida_free(&sd_index_ida, sdkp->index); |
| 3464 | ida_remove(&sd_index_ida, sdkp->index); | ||
| 3465 | spin_unlock(&sd_index_lock); | ||
| 3466 | 3453 | ||
| 3467 | disk->private_data = NULL; | 3454 | disk->private_data = NULL; |
| 3468 | put_disk(disk); | 3455 | put_disk(disk); |
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 8e223799347a..94bad43c41ff 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c | |||
| @@ -57,9 +57,8 @@ static DEFINE_SPINLOCK(tiqn_lock); | |||
| 57 | static DEFINE_MUTEX(np_lock); | 57 | static DEFINE_MUTEX(np_lock); |
| 58 | 58 | ||
| 59 | static struct idr tiqn_idr; | 59 | static struct idr tiqn_idr; |
| 60 | struct idr sess_idr; | 60 | DEFINE_IDA(sess_ida); |
| 61 | struct mutex auth_id_lock; | 61 | struct mutex auth_id_lock; |
| 62 | spinlock_t sess_idr_lock; | ||
| 63 | 62 | ||
| 64 | struct iscsit_global *iscsit_global; | 63 | struct iscsit_global *iscsit_global; |
| 65 | 64 | ||
| @@ -700,9 +699,7 @@ static int __init iscsi_target_init_module(void) | |||
| 700 | 699 | ||
| 701 | spin_lock_init(&iscsit_global->ts_bitmap_lock); | 700 | spin_lock_init(&iscsit_global->ts_bitmap_lock); |
| 702 | mutex_init(&auth_id_lock); | 701 | mutex_init(&auth_id_lock); |
| 703 | spin_lock_init(&sess_idr_lock); | ||
| 704 | idr_init(&tiqn_idr); | 702 | idr_init(&tiqn_idr); |
| 705 | idr_init(&sess_idr); | ||
| 706 | 703 | ||
| 707 | ret = target_register_template(&iscsi_ops); | 704 | ret = target_register_template(&iscsi_ops); |
| 708 | if (ret) | 705 | if (ret) |
| @@ -4375,10 +4372,7 @@ int iscsit_close_session(struct iscsi_session *sess) | |||
| 4375 | pr_debug("Decremented number of active iSCSI Sessions on" | 4372 | pr_debug("Decremented number of active iSCSI Sessions on" |
| 4376 | " iSCSI TPG: %hu to %u\n", tpg->tpgt, tpg->nsessions); | 4373 | " iSCSI TPG: %hu to %u\n", tpg->tpgt, tpg->nsessions); |
| 4377 | 4374 | ||
| 4378 | spin_lock(&sess_idr_lock); | 4375 | ida_free(&sess_ida, sess->session_index); |
| 4379 | idr_remove(&sess_idr, sess->session_index); | ||
| 4380 | spin_unlock(&sess_idr_lock); | ||
| 4381 | |||
| 4382 | kfree(sess->sess_ops); | 4376 | kfree(sess->sess_ops); |
| 4383 | sess->sess_ops = NULL; | 4377 | sess->sess_ops = NULL; |
| 4384 | spin_unlock_bh(&se_tpg->session_lock); | 4378 | spin_unlock_bh(&se_tpg->session_lock); |
diff --git a/drivers/target/iscsi/iscsi_target.h b/drivers/target/iscsi/iscsi_target.h index 42de1843aa40..48bac0acf8c7 100644 --- a/drivers/target/iscsi/iscsi_target.h +++ b/drivers/target/iscsi/iscsi_target.h | |||
| @@ -55,9 +55,7 @@ extern struct kmem_cache *lio_ooo_cache; | |||
| 55 | extern struct kmem_cache *lio_qr_cache; | 55 | extern struct kmem_cache *lio_qr_cache; |
| 56 | extern struct kmem_cache *lio_r2t_cache; | 56 | extern struct kmem_cache *lio_r2t_cache; |
| 57 | 57 | ||
| 58 | extern struct idr sess_idr; | 58 | extern struct ida sess_ida; |
| 59 | extern struct mutex auth_id_lock; | 59 | extern struct mutex auth_id_lock; |
| 60 | extern spinlock_t sess_idr_lock; | ||
| 61 | |||
| 62 | 60 | ||
| 63 | #endif /*** ISCSI_TARGET_H ***/ | 61 | #endif /*** ISCSI_TARGET_H ***/ |
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index 923b1a9fc3dc..9e74f8bc2963 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c | |||
| @@ -336,22 +336,15 @@ static int iscsi_login_zero_tsih_s1( | |||
| 336 | timer_setup(&sess->time2retain_timer, | 336 | timer_setup(&sess->time2retain_timer, |
| 337 | iscsit_handle_time2retain_timeout, 0); | 337 | iscsit_handle_time2retain_timeout, 0); |
| 338 | 338 | ||
| 339 | idr_preload(GFP_KERNEL); | 339 | ret = ida_alloc(&sess_ida, GFP_KERNEL); |
| 340 | spin_lock_bh(&sess_idr_lock); | ||
| 341 | ret = idr_alloc(&sess_idr, NULL, 0, 0, GFP_NOWAIT); | ||
| 342 | if (ret >= 0) | ||
| 343 | sess->session_index = ret; | ||
| 344 | spin_unlock_bh(&sess_idr_lock); | ||
| 345 | idr_preload_end(); | ||
| 346 | |||
| 347 | if (ret < 0) { | 340 | if (ret < 0) { |
| 348 | pr_err("idr_alloc() for sess_idr failed\n"); | 341 | pr_err("Session ID allocation failed %d\n", ret); |
| 349 | iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, | 342 | iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, |
| 350 | ISCSI_LOGIN_STATUS_NO_RESOURCES); | 343 | ISCSI_LOGIN_STATUS_NO_RESOURCES); |
| 351 | kfree(sess); | 344 | goto free_sess; |
| 352 | return -ENOMEM; | ||
| 353 | } | 345 | } |
| 354 | 346 | ||
| 347 | sess->session_index = ret; | ||
| 355 | sess->creation_time = get_jiffies_64(); | 348 | sess->creation_time = get_jiffies_64(); |
| 356 | /* | 349 | /* |
| 357 | * The FFP CmdSN window values will be allocated from the TPG's | 350 | * The FFP CmdSN window values will be allocated from the TPG's |
| @@ -365,20 +358,26 @@ static int iscsi_login_zero_tsih_s1( | |||
| 365 | ISCSI_LOGIN_STATUS_NO_RESOURCES); | 358 | ISCSI_LOGIN_STATUS_NO_RESOURCES); |
| 366 | pr_err("Unable to allocate memory for" | 359 | pr_err("Unable to allocate memory for" |
| 367 | " struct iscsi_sess_ops.\n"); | 360 | " struct iscsi_sess_ops.\n"); |
| 368 | kfree(sess); | 361 | goto free_id; |
| 369 | return -ENOMEM; | ||
| 370 | } | 362 | } |
| 371 | 363 | ||
| 372 | sess->se_sess = transport_alloc_session(TARGET_PROT_NORMAL); | 364 | sess->se_sess = transport_alloc_session(TARGET_PROT_NORMAL); |
| 373 | if (IS_ERR(sess->se_sess)) { | 365 | if (IS_ERR(sess->se_sess)) { |
| 374 | iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, | 366 | iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, |
| 375 | ISCSI_LOGIN_STATUS_NO_RESOURCES); | 367 | ISCSI_LOGIN_STATUS_NO_RESOURCES); |
| 376 | kfree(sess->sess_ops); | 368 | goto free_ops; |
| 377 | kfree(sess); | ||
| 378 | return -ENOMEM; | ||
| 379 | } | 369 | } |
| 380 | 370 | ||
| 381 | return 0; | 371 | return 0; |
| 372 | |||
| 373 | free_ops: | ||
| 374 | kfree(sess->sess_ops); | ||
| 375 | free_id: | ||
| 376 | ida_free(&sess_ida, sess->session_index); | ||
| 377 | free_sess: | ||
| 378 | kfree(sess); | ||
| 379 | conn->sess = NULL; | ||
| 380 | return -ENOMEM; | ||
| 382 | } | 381 | } |
| 383 | 382 | ||
| 384 | static int iscsi_login_zero_tsih_s2( | 383 | static int iscsi_login_zero_tsih_s2( |
| @@ -1161,13 +1160,9 @@ void iscsi_target_login_sess_out(struct iscsi_conn *conn, | |||
| 1161 | ISCSI_LOGIN_STATUS_INIT_ERR); | 1160 | ISCSI_LOGIN_STATUS_INIT_ERR); |
| 1162 | if (!zero_tsih || !conn->sess) | 1161 | if (!zero_tsih || !conn->sess) |
| 1163 | goto old_sess_out; | 1162 | goto old_sess_out; |
| 1164 | if (conn->sess->se_sess) | 1163 | |
| 1165 | transport_free_session(conn->sess->se_sess); | 1164 | transport_free_session(conn->sess->se_sess); |
| 1166 | if (conn->sess->session_index != 0) { | 1165 | ida_free(&sess_ida, conn->sess->session_index); |
| 1167 | spin_lock_bh(&sess_idr_lock); | ||
| 1168 | idr_remove(&sess_idr, conn->sess->session_index); | ||
| 1169 | spin_unlock_bh(&sess_idr_lock); | ||
| 1170 | } | ||
| 1171 | kfree(conn->sess->sess_ops); | 1166 | kfree(conn->sess->sess_ops); |
| 1172 | kfree(conn->sess); | 1167 | kfree(conn->sess); |
| 1173 | conn->sess = NULL; | 1168 | conn->sess = NULL; |
