mlx4: allow device removal by fixing dma unmap size
authorThadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>
Mon, 6 Feb 2012 08:39:49 +0000 (08:39 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 6 Feb 2012 19:42:28 +0000 (14:42 -0500)
After opening the network interface, Mellanox ConnectX device cannot be
removed by hotplug because it has not properly unmapped all DMA memory.

It happens that mlx4_en_activate_rx_rings overrides the variable that
keeps the size of the memory mapped.

This is fixed by passing to mlx4_en_destroy_rx_ring the same size that is
given to mlx4_en_create_rx_ring.

After applying this patch, hot unplugging the device works after opening
the interface.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
drivers/net/ethernet/mellanox/mlx4/en_rx.c
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h

index 467ae5824875c9009b94527fdeef7ef4d4992d9d..149e60da0a32870aa809d676856c971ee95ebf80 100644 (file)
@@ -892,7 +892,8 @@ void mlx4_en_free_resources(struct mlx4_en_priv *priv)
 
        for (i = 0; i < priv->rx_ring_num; i++) {
                if (priv->rx_ring[i].rx_info)
-                       mlx4_en_destroy_rx_ring(priv, &priv->rx_ring[i]);
+                       mlx4_en_destroy_rx_ring(priv, &priv->rx_ring[i],
+                               priv->prof->rx_ring_size, priv->stride);
                if (priv->rx_cq[i].buf)
                        mlx4_en_destroy_cq(priv, &priv->rx_cq[i]);
        }
index 971d4b6b8dfee21aed00724fd3af8a36fc8f6608..d1c631e8293a929f2c0b7a00c0b1b30695b2167f 100644 (file)
@@ -380,12 +380,12 @@ err_allocator:
 }
 
 void mlx4_en_destroy_rx_ring(struct mlx4_en_priv *priv,
-                            struct mlx4_en_rx_ring *ring)
+                            struct mlx4_en_rx_ring *ring, u32 size, u16 stride)
 {
        struct mlx4_en_dev *mdev = priv->mdev;
 
        mlx4_en_unmap_buffer(&ring->wqres.buf);
-       mlx4_free_hwq_res(mdev->dev, &ring->wqres, ring->buf_size + TXBB_SIZE);
+       mlx4_free_hwq_res(mdev->dev, &ring->wqres, size * stride + TXBB_SIZE);
        vfree(ring->rx_info);
        ring->rx_info = NULL;
 }
index 35f08840813c2b8b679851d8a63271011674b598..d60335f3c473382ea80f4a3f2c1c819a50391c33 100644 (file)
@@ -528,7 +528,8 @@ int mlx4_en_create_rx_ring(struct mlx4_en_priv *priv,
                           struct mlx4_en_rx_ring *ring,
                           u32 size, u16 stride);
 void mlx4_en_destroy_rx_ring(struct mlx4_en_priv *priv,
-                            struct mlx4_en_rx_ring *ring);
+                            struct mlx4_en_rx_ring *ring,
+                            u32 size, u16 stride);
 int mlx4_en_activate_rx_rings(struct mlx4_en_priv *priv);
 void mlx4_en_deactivate_rx_ring(struct mlx4_en_priv *priv,
                                struct mlx4_en_rx_ring *ring);