aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/mlx4
diff options
context:
space:
mode:
authorEli Cohen <eli@mellanox.co.il>2011-03-22 18:38:48 -0400
committerDavid S. Miller <davem@davemloft.net>2011-03-23 15:24:24 -0400
commit9ace5e0176f165f04537497143506621d33a0139 (patch)
tree4587ba19581862b2de2905f5cf6ea7f610a9d9ae /drivers/net/mlx4
parent42d1e017e2f040c3e3d62b6cfa3a26351a865d04 (diff)
mlx4_core: reserve UARs for userspace consumers
Do not allow a kernel consumer to allocate a UAR to serve for blue flame if the number of available UARs gets below MLX4_NUM_RESERVED_UARS (currently 8). This will allow userspace apps to open a device file and run things like ibv_devinfo. Signed-off-by: Eli Cohen <eli@mellanox.co.il> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/mlx4')
-rw-r--r--drivers/net/mlx4/pd.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/net/mlx4/pd.c b/drivers/net/mlx4/pd.c
index 5210a0f31413..1286b886dcea 100644
--- a/drivers/net/mlx4/pd.c
+++ b/drivers/net/mlx4/pd.c
@@ -39,6 +39,10 @@
39#include "mlx4.h" 39#include "mlx4.h"
40#include "icm.h" 40#include "icm.h"
41 41
42enum {
43 MLX4_NUM_RESERVED_UARS = 8
44};
45
42int mlx4_pd_alloc(struct mlx4_dev *dev, u32 *pdn) 46int mlx4_pd_alloc(struct mlx4_dev *dev, u32 *pdn)
43{ 47{
44 struct mlx4_priv *priv = mlx4_priv(dev); 48 struct mlx4_priv *priv = mlx4_priv(dev);
@@ -104,6 +108,10 @@ int mlx4_bf_alloc(struct mlx4_dev *dev, struct mlx4_bf *bf)
104 if (!list_empty(&priv->bf_list)) 108 if (!list_empty(&priv->bf_list))
105 uar = list_entry(priv->bf_list.next, struct mlx4_uar, bf_list); 109 uar = list_entry(priv->bf_list.next, struct mlx4_uar, bf_list);
106 else { 110 else {
111 if (mlx4_bitmap_avail(&priv->uar_table.bitmap) < MLX4_NUM_RESERVED_UARS) {
112 err = -ENOMEM;
113 goto out;
114 }
107 uar = kmalloc(sizeof *uar, GFP_KERNEL); 115 uar = kmalloc(sizeof *uar, GFP_KERNEL);
108 if (!uar) { 116 if (!uar) {
109 err = -ENOMEM; 117 err = -ENOMEM;