@@ -30,8 +30,10 @@ nvkm_object_search(struct nvkm_client *client, u64 handle,
30
30
const struct nvkm_object_func * func )
31
31
{
32
32
struct nvkm_object * object ;
33
+ unsigned long flags ;
33
34
34
35
if (handle ) {
36
+ spin_lock_irqsave (& client -> obj_lock , flags );
35
37
struct rb_node * node = client -> objroot .rb_node ;
36
38
while (node ) {
37
39
object = rb_entry (node , typeof (* object ), node );
@@ -40,9 +42,12 @@ nvkm_object_search(struct nvkm_client *client, u64 handle,
40
42
else
41
43
if (handle > object -> object )
42
44
node = node -> rb_right ;
43
- else
45
+ else {
46
+ spin_unlock_irqrestore (& client -> obj_lock , flags );
44
47
goto done ;
48
+ }
45
49
}
50
+ spin_unlock_irqrestore (& client -> obj_lock , flags );
46
51
return ERR_PTR (- ENOENT );
47
52
} else {
48
53
object = & client -> object ;
@@ -57,30 +62,39 @@ nvkm_object_search(struct nvkm_client *client, u64 handle,
57
62
void
58
63
nvkm_object_remove (struct nvkm_object * object )
59
64
{
65
+ unsigned long flags ;
66
+
67
+ spin_lock_irqsave (& object -> client -> obj_lock , flags );
60
68
if (!RB_EMPTY_NODE (& object -> node ))
61
69
rb_erase (& object -> node , & object -> client -> objroot );
70
+ spin_unlock_irqrestore (& object -> client -> obj_lock , flags );
62
71
}
63
72
64
73
bool
65
74
nvkm_object_insert (struct nvkm_object * object )
66
75
{
67
- struct rb_node * * ptr = & object -> client -> objroot . rb_node ;
76
+ struct rb_node * * ptr ;
68
77
struct rb_node * parent = NULL ;
78
+ unsigned long flags ;
69
79
80
+ spin_lock_irqsave (& object -> client -> obj_lock , flags );
81
+ ptr = & object -> client -> objroot .rb_node ;
70
82
while (* ptr ) {
71
83
struct nvkm_object * this = rb_entry (* ptr , typeof (* this ), node );
72
84
parent = * ptr ;
73
- if (object -> object < this -> object )
85
+ if (object -> object < this -> object ) {
74
86
ptr = & parent -> rb_left ;
75
- else
76
- if (object -> object > this -> object )
87
+ } else if (object -> object > this -> object ) {
77
88
ptr = & parent -> rb_right ;
78
- else
89
+ } else {
90
+ spin_unlock_irqrestore (& object -> client -> obj_lock , flags );
79
91
return false;
92
+ }
80
93
}
81
94
82
95
rb_link_node (& object -> node , parent , ptr );
83
96
rb_insert_color (& object -> node , & object -> client -> objroot );
97
+ spin_unlock_irqrestore (& object -> client -> obj_lock , flags );
84
98
return true;
85
99
}
86
100
0 commit comments