Commit acd43fe8 authored by David S. Miller's avatar David S. Miller

Merge branch 'mlx4-fixes'

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: default avatarDavid S. Miller <davem@davemloft.net>
parents 27777daa 9d769311
...@@ -406,14 +406,18 @@ static int mlx4_en_vlan_rx_add_vid(struct net_device *dev, ...@@ -406,14 +406,18 @@ static int mlx4_en_vlan_rx_add_vid(struct net_device *dev,
mutex_lock(&mdev->state_lock); mutex_lock(&mdev->state_lock);
if (mdev->device_up && priv->port_up) { if (mdev->device_up && priv->port_up) {
err = mlx4_SET_VLAN_FLTR(mdev->dev, priv); err = mlx4_SET_VLAN_FLTR(mdev->dev, priv);
if (err) if (err) {
en_err(priv, "Failed configuring VLAN filter\n"); 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); err = mlx4_register_vlan(mdev->dev, priv->port, vid, &idx);
mutex_unlock(&mdev->state_lock); 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, static int mlx4_en_vlan_rx_kill_vid(struct net_device *dev,
...@@ -421,7 +425,7 @@ static int mlx4_en_vlan_rx_kill_vid(struct net_device *dev, ...@@ -421,7 +425,7 @@ static int mlx4_en_vlan_rx_kill_vid(struct net_device *dev,
{ {
struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_en_dev *mdev = priv->mdev; struct mlx4_en_dev *mdev = priv->mdev;
int err; int err = 0;
en_dbg(HW, priv, "Killing VID:%d\n", vid); en_dbg(HW, priv, "Killing VID:%d\n", vid);
...@@ -438,7 +442,7 @@ static int mlx4_en_vlan_rx_kill_vid(struct net_device *dev, ...@@ -438,7 +442,7 @@ static int mlx4_en_vlan_rx_kill_vid(struct net_device *dev,
} }
mutex_unlock(&mdev->state_lock); 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) static void mlx4_en_u64_to_mac(unsigned char dst_mac[ETH_ALEN + 2], u64 src_mac)
...@@ -2032,11 +2036,20 @@ int mlx4_en_alloc_resources(struct mlx4_en_priv *priv) ...@@ -2032,11 +2036,20 @@ int mlx4_en_alloc_resources(struct mlx4_en_priv *priv)
return -ENOMEM; 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) void mlx4_en_destroy_netdev(struct net_device *dev)
{ {
struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_en_dev *mdev = priv->mdev; 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); en_dbg(DRV, priv, "Destroying netdev on port:%d\n", priv->port);
...@@ -2044,6 +2057,9 @@ void mlx4_en_destroy_netdev(struct net_device *dev) ...@@ -2044,6 +2057,9 @@ void mlx4_en_destroy_netdev(struct net_device *dev)
if (priv->registered) { if (priv->registered) {
devlink_port_type_clear(mlx4_get_devlink_port(mdev->dev, devlink_port_type_clear(mlx4_get_devlink_port(mdev->dev,
priv->port)); priv->port));
if (shutdown)
mlx4_en_shutdown(dev);
else
unregister_netdev(dev); unregister_netdev(dev);
} }
...@@ -2069,6 +2085,7 @@ void mlx4_en_destroy_netdev(struct net_device *dev) ...@@ -2069,6 +2085,7 @@ void mlx4_en_destroy_netdev(struct net_device *dev)
kfree(priv->tx_ring); kfree(priv->tx_ring);
kfree(priv->tx_cq); kfree(priv->tx_cq);
if (!shutdown)
free_netdev(dev); free_netdev(dev);
} }
......
...@@ -4135,8 +4135,11 @@ static void mlx4_shutdown(struct pci_dev *pdev) ...@@ -4135,8 +4135,11 @@ static void mlx4_shutdown(struct pci_dev *pdev)
mlx4_info(persist->dev, "mlx4_shutdown was called\n"); mlx4_info(persist->dev, "mlx4_shutdown was called\n");
mutex_lock(&persist->interface_state_mutex); 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); mlx4_unload_one(pdev);
}
mutex_unlock(&persist->interface_state_mutex); mutex_unlock(&persist->interface_state_mutex);
} }
......
...@@ -466,6 +466,7 @@ enum { ...@@ -466,6 +466,7 @@ enum {
enum { enum {
MLX4_INTERFACE_STATE_UP = 1 << 0, MLX4_INTERFACE_STATE_UP = 1 << 0,
MLX4_INTERFACE_STATE_DELETION = 1 << 1, 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 | \ #define MSTR_SM_CHANGE_MASK (MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK | \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment