Skip to content

Commit

Permalink
Merge branch 'mlx4-fixes'
Browse files Browse the repository at this point in the history
Tariq Toukan says:

====================
mlx4_en fixes for 4.7-rc

This small patchset includes two small fixes for mlx4_en driver.

One allows a clean shutdown even when clients do not release their
netdev reference.
The other adds error return values to the VLAN VID add/kill functions.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jun 22, 2016
2 parents 27777da + 9d76931 commit acd43fe
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
35 changes: 26 additions & 9 deletions drivers/net/ethernet/mellanox/mlx4/en_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,22 +406,26 @@ static int mlx4_en_vlan_rx_add_vid(struct net_device *dev,
mutex_lock(&mdev->state_lock);
if (mdev->device_up && priv->port_up) {
err = mlx4_SET_VLAN_FLTR(mdev->dev, priv);
if (err)
if (err) {
en_err(priv, "Failed configuring VLAN filter\n");
goto out;
}
}
if (mlx4_register_vlan(mdev->dev, priv->port, vid, &idx))
en_dbg(HW, priv, "failed adding vlan %d\n", vid);
mutex_unlock(&mdev->state_lock);
err = mlx4_register_vlan(mdev->dev, priv->port, vid, &idx);
if (err)
en_dbg(HW, priv, "Failed adding vlan %d\n", vid);

return 0;
out:
mutex_unlock(&mdev->state_lock);
return err;
}

static int mlx4_en_vlan_rx_kill_vid(struct net_device *dev,
__be16 proto, u16 vid)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_en_dev *mdev = priv->mdev;
int err;
int err = 0;

en_dbg(HW, priv, "Killing VID:%d\n", vid);

Expand All @@ -438,7 +442,7 @@ static int mlx4_en_vlan_rx_kill_vid(struct net_device *dev,
}
mutex_unlock(&mdev->state_lock);

return 0;
return err;
}

static void mlx4_en_u64_to_mac(unsigned char dst_mac[ETH_ALEN + 2], u64 src_mac)
Expand Down Expand Up @@ -2032,19 +2036,31 @@ int mlx4_en_alloc_resources(struct mlx4_en_priv *priv)
return -ENOMEM;
}

static void mlx4_en_shutdown(struct net_device *dev)
{
rtnl_lock();
netif_device_detach(dev);
mlx4_en_close(dev);
rtnl_unlock();
}

void mlx4_en_destroy_netdev(struct net_device *dev)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_en_dev *mdev = priv->mdev;
bool shutdown = mdev->dev->persist->interface_state &
MLX4_INTERFACE_STATE_SHUTDOWN;

en_dbg(DRV, priv, "Destroying netdev on port:%d\n", priv->port);

/* Unregister device - this will close the port if it was up */
if (priv->registered) {
devlink_port_type_clear(mlx4_get_devlink_port(mdev->dev,
priv->port));
unregister_netdev(dev);
if (shutdown)
mlx4_en_shutdown(dev);
else
unregister_netdev(dev);
}

if (priv->allocated)
Expand All @@ -2069,7 +2085,8 @@ void mlx4_en_destroy_netdev(struct net_device *dev)
kfree(priv->tx_ring);
kfree(priv->tx_cq);

free_netdev(dev);
if (!shutdown)
free_netdev(dev);
}

static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu)
Expand Down
5 changes: 4 additions & 1 deletion drivers/net/ethernet/mellanox/mlx4/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4135,8 +4135,11 @@ static void mlx4_shutdown(struct pci_dev *pdev)

mlx4_info(persist->dev, "mlx4_shutdown was called\n");
mutex_lock(&persist->interface_state_mutex);
if (persist->interface_state & MLX4_INTERFACE_STATE_UP)
if (persist->interface_state & MLX4_INTERFACE_STATE_UP) {
/* Notify mlx4 clients that the kernel is being shut down */
persist->interface_state |= MLX4_INTERFACE_STATE_SHUTDOWN;
mlx4_unload_one(pdev);
}
mutex_unlock(&persist->interface_state_mutex);
}

Expand Down
1 change: 1 addition & 0 deletions include/linux/mlx4/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ enum {
enum {
MLX4_INTERFACE_STATE_UP = 1 << 0,
MLX4_INTERFACE_STATE_DELETION = 1 << 1,
MLX4_INTERFACE_STATE_SHUTDOWN = 1 << 2,
};

#define MSTR_SM_CHANGE_MASK (MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK | \
Expand Down

0 comments on commit acd43fe

Please sign in to comment.