@@ -21,8 +21,10 @@ mlx5_get_rsc(struct mlx5_qp_table *table, u32 rsn)
21
21
spin_lock_irqsave (& table -> lock , flags );
22
22
23
23
common = radix_tree_lookup (& table -> tree , rsn );
24
- if (common )
24
+ if (common && ! common -> invalid )
25
25
refcount_inc (& common -> refcount );
26
+ else
27
+ common = NULL ;
26
28
27
29
spin_unlock_irqrestore (& table -> lock , flags );
28
30
@@ -178,6 +180,18 @@ static int create_resource_common(struct mlx5_ib_dev *dev,
178
180
return 0 ;
179
181
}
180
182
183
+ static void modify_resource_common_state (struct mlx5_ib_dev * dev ,
184
+ struct mlx5_core_qp * qp ,
185
+ bool invalid )
186
+ {
187
+ struct mlx5_qp_table * table = & dev -> qp_table ;
188
+ unsigned long flags ;
189
+
190
+ spin_lock_irqsave (& table -> lock , flags );
191
+ qp -> common .invalid = invalid ;
192
+ spin_unlock_irqrestore (& table -> lock , flags );
193
+ }
194
+
181
195
static void destroy_resource_common (struct mlx5_ib_dev * dev ,
182
196
struct mlx5_core_qp * qp )
183
197
{
@@ -602,8 +616,20 @@ int mlx5_core_create_rq_tracked(struct mlx5_ib_dev *dev, u32 *in, int inlen,
602
616
int mlx5_core_destroy_rq_tracked (struct mlx5_ib_dev * dev ,
603
617
struct mlx5_core_qp * rq )
604
618
{
619
+ int ret ;
620
+
621
+ /* The rq destruction can be called again in case it fails, hence we
622
+ * mark the common resource as invalid and only once FW destruction
623
+ * is completed successfully we actually destroy the resources.
624
+ */
625
+ modify_resource_common_state (dev , rq , true);
626
+ ret = destroy_rq_tracked (dev , rq -> qpn , rq -> uid );
627
+ if (ret ) {
628
+ modify_resource_common_state (dev , rq , false);
629
+ return ret ;
630
+ }
605
631
destroy_resource_common (dev , rq );
606
- return destroy_rq_tracked ( dev , rq -> qpn , rq -> uid ) ;
632
+ return 0 ;
607
633
}
608
634
609
635
static void destroy_sq_tracked (struct mlx5_ib_dev * dev , u32 sqn , u16 uid )
0 commit comments