Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaba16dc

Browse files
committed
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 ...
2 parentsc4726e7 +1df8951 commitaba16dc

File tree

28 files changed

+485
-679
lines changed

28 files changed

+485
-679
lines changed

‎arch/powerpc/mm/mmu_context_book3s64.c‎

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,48 +26,16 @@
2626
#include<asm/mmu_context.h>
2727
#include<asm/pgalloc.h>
2828

29-
staticDEFINE_SPINLOCK(mmu_context_lock);
3029
staticDEFINE_IDA(mmu_context_ida);
3130

3231
staticintalloc_context_id(intmin_id,intmax_id)
3332
{
34-
intindex,err;
35-
36-
again:
37-
if (!ida_pre_get(&mmu_context_ida,GFP_KERNEL))
38-
return-ENOMEM;
39-
40-
spin_lock(&mmu_context_lock);
41-
err=ida_get_new_above(&mmu_context_ida,min_id,&index);
42-
spin_unlock(&mmu_context_lock);
43-
44-
if (err==-EAGAIN)
45-
gotoagain;
46-
elseif (err)
47-
returnerr;
48-
49-
if (index>max_id) {
50-
spin_lock(&mmu_context_lock);
51-
ida_remove(&mmu_context_ida,index);
52-
spin_unlock(&mmu_context_lock);
53-
return-ENOMEM;
54-
}
55-
56-
returnindex;
33+
returnida_alloc_range(&mmu_context_ida,min_id,max_id,GFP_KERNEL);
5734
}
5835

5936
voidhash__reserve_context_id(intid)
6037
{
61-
intrc,result=0;
62-
63-
do {
64-
if (!ida_pre_get(&mmu_context_ida,GFP_KERNEL))
65-
break;
66-
67-
spin_lock(&mmu_context_lock);
68-
rc=ida_get_new_above(&mmu_context_ida,id,&result);
69-
spin_unlock(&mmu_context_lock);
70-
}while (rc==-EAGAIN);
38+
intresult=ida_alloc_range(&mmu_context_ida,id,id,GFP_KERNEL);
7139

7240
WARN(result!=id,"mmu: Failed to reserve context id %d (rc %d)\n",id,result);
7341
}
@@ -172,23 +140,19 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
172140

173141
void__destroy_context(intcontext_id)
174142
{
175-
spin_lock(&mmu_context_lock);
176-
ida_remove(&mmu_context_ida,context_id);
177-
spin_unlock(&mmu_context_lock);
143+
ida_free(&mmu_context_ida,context_id);
178144
}
179145
EXPORT_SYMBOL_GPL(__destroy_context);
180146

181147
staticvoiddestroy_contexts(mm_context_t*ctx)
182148
{
183149
intindex,context_id;
184150

185-
spin_lock(&mmu_context_lock);
186151
for (index=0;index<ARRAY_SIZE(ctx->extended_id);index++) {
187152
context_id=ctx->extended_id[index];
188153
if (context_id)
189-
ida_remove(&mmu_context_ida,context_id);
154+
ida_free(&mmu_context_ida,context_id);
190155
}
191-
spin_unlock(&mmu_context_lock);
192156
}
193157

194158
staticvoidpte_frag_destroy(void*pte_frag)

‎arch/powerpc/platforms/powernv/vas-window.c‎

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -515,35 +515,17 @@ int init_winctx_regs(struct vas_window *window, struct vas_winctx *winctx)
515515
return0;
516516
}
517517

518-
staticDEFINE_SPINLOCK(vas_ida_lock);
519-
520518
staticvoidvas_release_window_id(structida*ida,intwinid)
521519
{
522-
spin_lock(&vas_ida_lock);
523-
ida_remove(ida,winid);
524-
spin_unlock(&vas_ida_lock);
520+
ida_free(ida,winid);
525521
}
526522

527523
staticintvas_assign_window_id(structida*ida)
528524
{
529-
intrc,winid;
530-
531-
do {
532-
rc=ida_pre_get(ida,GFP_KERNEL);
533-
if (!rc)
534-
return-EAGAIN;
535-
536-
spin_lock(&vas_ida_lock);
537-
rc=ida_get_new(ida,&winid);
538-
spin_unlock(&vas_ida_lock);
539-
}while (rc==-EAGAIN);
540-
541-
if (rc)
542-
returnrc;
525+
intwinid=ida_alloc_max(ida,VAS_WINDOWS_PER_CHIP-1,GFP_KERNEL);
543526

544-
if (winid>VAS_WINDOWS_PER_CHIP) {
545-
pr_err("Too many (%d) open windows\n",winid);
546-
vas_release_window_id(ida,winid);
527+
if (winid==-ENOSPC) {
528+
pr_err("Too many (%d) open windows\n",VAS_WINDOWS_PER_CHIP);
547529
return-EAGAIN;
548530
}
549531

‎drivers/block/mtip32xx/mtip32xx.c‎

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ static struct dentry *dfs_device_status;
118118

119119
staticu32cpu_use[NR_CPUS];
120120

121-
staticDEFINE_SPINLOCK(rssd_index_lock);
122121
staticDEFINE_IDA(rssd_index_ida);
123122

124123
staticintmtip_block_initialize(structdriver_data*dd);
@@ -3767,20 +3766,10 @@ static int mtip_block_initialize(struct driver_data *dd)
37673766
gotoalloc_disk_error;
37683767
}
37693768

3770-
/* Generate the disk name, implemented same as in sd.c */
3771-
do {
3772-
if (!ida_pre_get(&rssd_index_ida,GFP_KERNEL)) {
3773-
rv=-ENOMEM;
3774-
gotoida_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)
3769+
rv=ida_alloc(&rssd_index_ida,GFP_KERNEL);
3770+
if (rv<0)
37833771
gotoida_get_error;
3772+
index=rv;
37843773

37853774
rv=rssd_disk_name_format("rssd",
37863775
index,
@@ -3922,9 +3911,7 @@ static int mtip_block_initialize(struct driver_data *dd)
39223911
block_queue_alloc_tag_error:
39233912
mtip_hw_debugfs_exit(dd);
39243913
disk_index_error:
3925-
spin_lock(&rssd_index_lock);
3926-
ida_remove(&rssd_index_ida,index);
3927-
spin_unlock(&rssd_index_lock);
3914+
ida_free(&rssd_index_ida,index);
39283915

39293916
ida_get_error:
39303917
put_disk(dd->disk);
@@ -4012,9 +3999,7 @@ static int mtip_block_remove(struct driver_data *dd)
40123999
}
40134000
dd->disk=NULL;
40144001

4015-
spin_lock(&rssd_index_lock);
4016-
ida_remove(&rssd_index_ida,dd->index);
4017-
spin_unlock(&rssd_index_lock);
4002+
ida_free(&rssd_index_ida,dd->index);
40184003

40194004
/* De-initialize the protocol layer. */
40204005
mtip_hw_exit(dd);
@@ -4054,9 +4039,7 @@ static int mtip_block_shutdown(struct driver_data *dd)
40544039
dd->queue=NULL;
40554040
}
40564041

4057-
spin_lock(&rssd_index_lock);
4058-
ida_remove(&rssd_index_ida,dd->index);
4059-
spin_unlock(&rssd_index_lock);
4042+
ida_free(&rssd_index_ida,dd->index);
40604043
return0;
40614044
}
40624045

‎drivers/block/rsxx/core.c‎

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ MODULE_PARM_DESC(sync_start, "On by Default: Driver load will not complete "
5858
"until the card startup has completed.");
5959

6060
staticDEFINE_IDA(rsxx_disk_ida);
61-
staticDEFINE_SPINLOCK(rsxx_ida_lock);
6261

6362
/* --------------------Debugfs Setup ------------------- */
6463

@@ -771,19 +770,10 @@ static int rsxx_pci_probe(struct pci_dev *dev,
771770
card->dev=dev;
772771
pci_set_drvdata(dev,card);
773772

774-
do {
775-
if (!ida_pre_get(&rsxx_disk_ida,GFP_KERNEL)) {
776-
st=-ENOMEM;
777-
gotofailed_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)
773+
st=ida_alloc(&rsxx_disk_ida,GFP_KERNEL);
774+
if (st<0)
786775
gotofailed_ida_get;
776+
card->disk_id=st;
787777

788778
st=pci_enable_device(dev);
789779
if (st)
@@ -985,9 +975,7 @@ static int rsxx_pci_probe(struct pci_dev *dev,
985975
failed_dma_mask:
986976
pci_disable_device(dev);
987977
failed_enable:
988-
spin_lock(&rsxx_ida_lock);
989-
ida_remove(&rsxx_disk_ida,card->disk_id);
990-
spin_unlock(&rsxx_ida_lock);
978+
ida_free(&rsxx_disk_ida,card->disk_id);
991979
failed_ida_get:
992980
kfree(card);
993981

@@ -1050,6 +1038,7 @@ static void rsxx_pci_remove(struct pci_dev *dev)
10501038
pci_disable_device(dev);
10511039
pci_release_regions(dev);
10521040

1041+
ida_free(&rsxx_disk_ida,card->disk_id);
10531042
kfree(card);
10541043
}
10551044

‎drivers/dma/dmaengine.c‎

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,7 @@ static void chan_dev_release(struct device *dev)
161161

162162
chan_dev=container_of(dev,typeof(*chan_dev),device);
163163
if (atomic_dec_and_test(chan_dev->idr_ref)) {
164-
mutex_lock(&dma_list_mutex);
165-
ida_remove(&dma_ida,chan_dev->dev_id);
166-
mutex_unlock(&dma_list_mutex);
164+
ida_free(&dma_ida,chan_dev->dev_id);
167165
kfree(chan_dev->idr_ref);
168166
}
169167
kfree(chan_dev);
@@ -898,17 +896,12 @@ static bool device_has_all_tx_types(struct dma_device *device)
898896

899897
staticintget_dma_id(structdma_device*device)
900898
{
901-
intrc;
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);
899+
intrc=ida_alloc(&dma_ida,GFP_KERNEL);
910900

911-
returnrc;
901+
if (rc<0)
902+
returnrc;
903+
device->dev_id=rc;
904+
return0;
912905
}
913906

914907
/**
@@ -1092,9 +1085,7 @@ int dma_async_device_register(struct dma_device *device)
10921085
err_out:
10931086
/* if we never registered a channel just release the idr */
10941087
if (atomic_read(idr_ref)==0) {
1095-
mutex_lock(&dma_list_mutex);
1096-
ida_remove(&dma_ida,device->dev_id);
1097-
mutex_unlock(&dma_list_mutex);
1088+
ida_free(&dma_ida,device->dev_id);
10981089
kfree(idr_ref);
10991090
returnrc;
11001091
}

‎drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c‎

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,51 +51,34 @@ static int vmw_gmrid_man_get_node(struct ttm_mem_type_manager *man,
5151
{
5252
structvmwgfx_gmrid_man*gman=
5353
(structvmwgfx_gmrid_man*)man->priv;
54-
intret=0;
5554
intid;
5655

5756
mem->mm_node=NULL;
5857

58+
id=ida_alloc_max(&gman->gmr_ida,gman->max_gmr_ids-1,GFP_KERNEL);
59+
if (id<0)
60+
returnid;
61+
5962
spin_lock(&gman->lock);
6063

6164
if (gman->max_gmr_pages>0) {
6265
gman->used_gmr_pages+=bo->num_pages;
6366
if (unlikely(gman->used_gmr_pages>gman->max_gmr_pages))
64-
gotoout_err_locked;
67+
gotonospace;
6568
}
6669

67-
do {
68-
spin_unlock(&gman->lock);
69-
if (unlikely(ida_pre_get(&gman->gmr_ida,GFP_KERNEL)==0)) {
70-
ret=-ENOMEM;
71-
gotoout_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-
gotoout_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-
gotoout_err_locked;
70+
mem->mm_node=gman;
71+
mem->start=id;
72+
mem->num_pages=bo->num_pages;
8973

9074
spin_unlock(&gman->lock);
9175
return0;
9276

93-
out_err:
94-
spin_lock(&gman->lock);
95-
out_err_locked:
77+
nospace:
9678
gman->used_gmr_pages-=bo->num_pages;
9779
spin_unlock(&gman->lock);
98-
returnret;
80+
ida_free(&gman->gmr_ida,id);
81+
return0;
9982
}
10083

10184
staticvoidvmw_gmrid_man_put_node(structttm_mem_type_manager*man,
@@ -105,8 +88,8 @@ static void vmw_gmrid_man_put_node(struct ttm_mem_type_manager *man,
10588
(structvmwgfx_gmrid_man*)man->priv;
10689

10790
if (mem->mm_node) {
91+
ida_free(&gman->gmr_ida,mem->start);
10892
spin_lock(&gman->lock);
109-
ida_remove(&gman->gmr_ida,mem->start);
11093
gman->used_gmr_pages-=mem->num_pages;
11194
spin_unlock(&gman->lock);
11295
mem->mm_node=NULL;

‎drivers/media/media-device.c‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -585,18 +585,12 @@ int __must_check media_device_register_entity(struct media_device *mdev,
585585
entity->num_links=0;
586586
entity->num_backlinks=0;
587587

588-
if (!ida_pre_get(&mdev->entity_internal_idx,GFP_KERNEL))
589-
return-ENOMEM;
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);
588+
ret=ida_alloc_min(&mdev->entity_internal_idx,1,GFP_KERNEL);
589+
if (ret<0)
597590
returnret;
598-
}
591+
entity->internal_idx=ret;
599592

593+
mutex_lock(&mdev->graph_mutex);
600594
mdev->entity_internal_idx_max=
601595
max(mdev->entity_internal_idx_max,entity->internal_idx);
602596

@@ -642,7 +636,7 @@ static void __media_device_unregister_entity(struct media_entity *entity)
642636
structmedia_interface*intf;
643637
unsignedinti;
644638

645-
ida_simple_remove(&mdev->entity_internal_idx,entity->internal_idx);
639+
ida_free(&mdev->entity_internal_idx,entity->internal_idx);
646640

647641
/* Remove all interface links pointing to this entity */
648642
list_for_each_entry(intf,&mdev->interfaces,graph_obj.list) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp