@@ -137,22 +137,17 @@ void mlx5_cq_event(struct mlx5_eq *eq, u32 cqn, int event_type)
137137int mlx5_core_create_cq (struct mlx5_core_dev * dev , struct mlx5_core_cq * cq ,
138138 u32 * in , int inlen )
139139{
140+ int eqn = MLX5_GET (cqc , MLX5_ADDR_OF (create_cq_in , in , cq_context ), c_eqn );
141+ u32 dout [MLX5_ST_SZ_DW (destroy_cq_out )];
140142 u32 out [MLX5_ST_SZ_DW (create_cq_out )];
141143 u32 din [MLX5_ST_SZ_DW (destroy_cq_in )];
142- u32 dout [MLX5_ST_SZ_DW (destroy_cq_out )];
143- int eqn = MLX5_GET (cqc , MLX5_ADDR_OF (create_cq_in , in , cq_context ),
144- c_eqn );
145- struct mlx5_eq * eq , * async_eq ;
146- struct mlx5_cq_table * table ;
144+ struct mlx5_eq * eq ;
147145 int err ;
148146
149- async_eq = & dev -> priv .eq_table .async_eq ;
150147 eq = mlx5_eqn2eq (dev , eqn );
151148 if (IS_ERR (eq ))
152149 return PTR_ERR (eq );
153150
154- table = & eq -> cq_table ;
155-
156151 memset (out , 0 , sizeof (out ));
157152 MLX5_SET (create_cq_in , in , opcode , MLX5_CMD_OP_CREATE_CQ );
158153 err = mlx5_cmd_exec (dev , in , inlen , out , sizeof (out ));
@@ -172,18 +167,14 @@ int mlx5_core_create_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq,
172167 INIT_LIST_HEAD (& cq -> tasklet_ctx .list );
173168
174169 /* Add to comp EQ CQ tree to recv comp events */
175- spin_lock_irq (& table -> lock );
176- err = radix_tree_insert (& table -> tree , cq -> cqn , cq );
177- spin_unlock_irq (& table -> lock );
170+ err = mlx5_eq_add_cq (eq , cq );
178171 if (err )
179172 goto err_cmd ;
180173
181- /* Add to async EQ CQ tree to recv Async events */
182- spin_lock_irq (& async_eq -> cq_table .lock );
183- err = radix_tree_insert (& async_eq -> cq_table .tree , cq -> cqn , cq );
184- spin_unlock_irq (& async_eq -> cq_table .lock );
174+ /* Add to async EQ CQ tree to recv async events */
175+ err = mlx5_eq_add_cq (& dev -> priv .eq_table .async_eq , cq );
185176 if (err )
186- goto err_cq_table ;
177+ goto err_cq_add ;
187178
188179 cq -> pid = current -> pid ;
189180 err = mlx5_debug_cq_add (dev , cq );
@@ -195,10 +186,8 @@ int mlx5_core_create_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq,
195186
196187 return 0 ;
197188
198- err_cq_table :
199- spin_lock_irq (& table -> lock );
200- radix_tree_delete (& table -> tree , cq -> cqn );
201- spin_unlock_irq (& table -> lock );
189+ err_cq_add :
190+ mlx5_eq_del_cq (eq , cq );
202191err_cmd :
203192 memset (din , 0 , sizeof (din ));
204193 memset (dout , 0 , sizeof (dout ));
@@ -211,36 +200,17 @@ EXPORT_SYMBOL(mlx5_core_create_cq);
211200
212201int mlx5_core_destroy_cq (struct mlx5_core_dev * dev , struct mlx5_core_cq * cq )
213202{
214- struct mlx5_cq_table * asyn_eq_cq_table = & dev -> priv .eq_table .async_eq .cq_table ;
215- struct mlx5_cq_table * table = & cq -> eq -> cq_table ;
216203 u32 out [MLX5_ST_SZ_DW (destroy_cq_out )] = {0 };
217204 u32 in [MLX5_ST_SZ_DW (destroy_cq_in )] = {0 };
218- struct mlx5_core_cq * tmp ;
219205 int err ;
220206
221- spin_lock_irq (& asyn_eq_cq_table -> lock );
222- tmp = radix_tree_delete (& asyn_eq_cq_table -> tree , cq -> cqn );
223- spin_unlock_irq (& asyn_eq_cq_table -> lock );
224- if (!tmp ) {
225- mlx5_core_warn (dev , "cq 0x%x not found in async eq cq tree\n" , cq -> cqn );
226- return - EINVAL ;
227- }
228- if (tmp != cq ) {
229- mlx5_core_warn (dev , "corruption on cqn 0x%x in async eq cq tree\n" , cq -> cqn );
230- return - EINVAL ;
231- }
207+ err = mlx5_eq_del_cq (& dev -> priv .eq_table .async_eq , cq );
208+ if (err )
209+ return err ;
232210
233- spin_lock_irq (& table -> lock );
234- tmp = radix_tree_delete (& table -> tree , cq -> cqn );
235- spin_unlock_irq (& table -> lock );
236- if (!tmp ) {
237- mlx5_core_warn (dev , "cq 0x%x not found in comp eq cq tree\n" , cq -> cqn );
238- return - EINVAL ;
239- }
240- if (tmp != cq ) {
241- mlx5_core_warn (dev , "corruption on cqn 0x%x in comp eq cq tree\n" , cq -> cqn );
242- return - EINVAL ;
243- }
211+ err = mlx5_eq_del_cq (cq -> eq , cq );
212+ if (err )
213+ return err ;
244214
245215 MLX5_SET (destroy_cq_in , in , opcode , MLX5_CMD_OP_DESTROY_CQ );
246216 MLX5_SET (destroy_cq_in , in , cqn , cq -> cqn );
0 commit comments