@@ -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
{
@@ -604,8 +618,20 @@ int mlx5_core_create_rq_tracked(struct mlx5_ib_dev *dev, u32 *in, int inlen,
604
618
int mlx5_core_destroy_rq_tracked (struct mlx5_ib_dev * dev ,
605
619
struct mlx5_core_qp * rq )
606
620
{
621
+ int ret ;
622
+
623
+ /* The rq destruction can be called again in case it fails, hence we
624
+ * mark the common resource as invalid and only once FW destruction
625
+ * is completed successfully we actually destroy the resources.
626
+ */
627
+ modify_resource_common_state (dev , rq , true);
628
+ ret = destroy_rq_tracked (dev , rq -> qpn , rq -> uid );
629
+ if (ret ) {
630
+ modify_resource_common_state (dev , rq , false);
631
+ return ret ;
632
+ }
607
633
destroy_resource_common (dev , rq );
608
- return destroy_rq_tracked ( dev , rq -> qpn , rq -> uid ) ;
634
+ return 0 ;
609
635
}
610
636
611
637
static void destroy_sq_tracked (struct mlx5_ib_dev * dev , u32 sqn , u16 uid )
0 commit comments