From 2c7dd71738c79e0e7dbd6fe230aa85ac11356be2 Mon Sep 17 00:00:00 2001 From: Hadar Hen Zion Date: Tue, 11 Mar 2014 17:44:51 +0200 Subject: [PATCH] mlx4_core: Fix resource tracker memory leak after Reset Flow In case of non-responsive device mlx4_ACCESS_MEM fails and the driver can't read qp_detach mailbox, which includes all the rule information. Since the driver doesn't get the rules attributes form the qp_detach mailbox the master fails to detach his rules form the resource tracker during driver unload sequence when the device in in internal_error state. Calling rem_slave_qp will remove those rules and the qps they are attached to unconditionally. Signed-off-by: Hadar Hen Zion (Ported from Mellanox OFED 2.4) Signed-off-by: Mukesh Kacker --- drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c index eaefc8a16bdc..b25e12a1d417 100644 --- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c @@ -293,6 +293,7 @@ static const char *resource_str(enum mlx4_resource rt) } static void rem_slave_vlans(struct mlx4_dev *dev, int slave); +static void rem_slave_qps(struct mlx4_dev *dev, int slave); static inline int mlx4_grant_resource(struct mlx4_dev *dev, int slave, enum mlx4_resource res_type, int count, int port) @@ -632,6 +633,15 @@ void mlx4_free_resource_tracker(struct mlx4_dev *dev, mlx4_reset_roce_gids(dev, i); mutex_lock(&priv->mfunc.master.res_tracker.slave_list[i].mutex); rem_slave_vlans(dev, i); + /* Free master's qps in case of 'Reset Flow'. + * When the device is non-responsive the master is + * unable to read steering rules mailboxes and + * therefore can't delete those rules and the qp they are + * attached to from the resource tracker. + * Calling rem_slave_qp removes those resources + * unconditionally. + */ + rem_slave_qps(dev, i); mutex_unlock(&priv->mfunc.master.res_tracker.slave_list[i].mutex); } -- 2.50.1