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>
This commit is contained in:
parent
42d1e017e2
commit
9ace5e0176
1 changed files with 8 additions and 0 deletions
|
@ -39,6 +39,10 @@
|
||||||
#include "mlx4.h"
|
#include "mlx4.h"
|
||||||
#include "icm.h"
|
#include "icm.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
MLX4_NUM_RESERVED_UARS = 8
|
||||||
|
};
|
||||||
|
|
||||||
int mlx4_pd_alloc(struct mlx4_dev *dev, u32 *pdn)
|
int mlx4_pd_alloc(struct mlx4_dev *dev, u32 *pdn)
|
||||||
{
|
{
|
||||||
struct mlx4_priv *priv = mlx4_priv(dev);
|
struct mlx4_priv *priv = mlx4_priv(dev);
|
||||||
|
@ -104,6 +108,10 @@ int mlx4_bf_alloc(struct mlx4_dev *dev, struct mlx4_bf *bf)
|
||||||
if (!list_empty(&priv->bf_list))
|
if (!list_empty(&priv->bf_list))
|
||||||
uar = list_entry(priv->bf_list.next, struct mlx4_uar, bf_list);
|
uar = list_entry(priv->bf_list.next, struct mlx4_uar, bf_list);
|
||||||
else {
|
else {
|
||||||
|
if (mlx4_bitmap_avail(&priv->uar_table.bitmap) < MLX4_NUM_RESERVED_UARS) {
|
||||||
|
err = -ENOMEM;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
uar = kmalloc(sizeof *uar, GFP_KERNEL);
|
uar = kmalloc(sizeof *uar, GFP_KERNEL);
|
||||||
if (!uar) {
|
if (!uar) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
|
|
Loading…
Add table
Reference in a new issue