[ofa-general] [PATCH] IB/mlx4 mlx4_ib: fix doorbell allocations

Roland Dreier rdreier at cisco.com
Sun May 6 09:28:07 PDT 2007


another good catch.  let's make the lock a mutex instead, rather than
relying on atomic allocations:

commit 7a62f478170f69225fa8f35d0502dbaf26652615
Author: Roland Dreier <rolandd at cisco.com>
Date:   Sun May 6 09:26:16 2007 -0700

    IB/mlx4: Convert pgdir_lock to pgdir_mutex
    
    Doorbell record pages are allocated inside the pgdir lock, so change
    the lock to a mutex so we can use GFP_KERNEL allocations.
    
    Pointed out by Eli Cohen <eli at mellanox.co.il>.
    
    Signed-off-by: Roland Dreier <rolandd at cisco.com>

diff --git a/drivers/infiniband/hw/mlx4/doorbell.c b/drivers/infiniband/hw/mlx4/doorbell.c
index e55c286..2e36cee 100644
--- a/drivers/infiniband/hw/mlx4/doorbell.c
+++ b/drivers/infiniband/hw/mlx4/doorbell.c
@@ -101,7 +101,7 @@ int mlx4_ib_db_alloc(struct mlx4_ib_dev *dev, struct mlx4_ib_db *db, int order)
 	struct mlx4_ib_db_pgdir *pgdir;
 	int ret = 0;
 
-	spin_lock(&dev->pgdir_lock);
+	mutex_lock(&dev->pgdir_mutex);
 
 	list_for_each_entry(pgdir, &dev->pgdir_list, list)
 		if (!mlx4_ib_alloc_db_from_pgdir(pgdir, db, order))
@@ -119,7 +119,7 @@ int mlx4_ib_db_alloc(struct mlx4_ib_dev *dev, struct mlx4_ib_db *db, int order)
 	WARN_ON(mlx4_ib_alloc_db_from_pgdir(pgdir, db, order));
 
 out:
-	spin_unlock(&dev->pgdir_lock);
+	mutex_unlock(&dev->pgdir_mutex);
 
 	return ret;
 }
@@ -129,7 +129,7 @@ void mlx4_ib_db_free(struct mlx4_ib_dev *dev, struct mlx4_ib_db *db)
 	int o;
 	int i;
 
-	spin_lock(&dev->pgdir_lock);
+	mutex_lock(&dev->pgdir_mutex);
 
 	o = db->order;
 
@@ -148,7 +148,7 @@ void mlx4_ib_db_free(struct mlx4_ib_dev *dev, struct mlx4_ib_db *db)
 		kfree(db->u.pgdir);
 	}
 
-	spin_unlock(&dev->pgdir_lock);
+	mutex_unlock(&dev->pgdir_mutex);
 }
 
 struct mlx4_ib_user_db_page {
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index b3af928..5ef6d19 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -490,7 +490,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 		goto err_uar;
 
 	INIT_LIST_HEAD(&ibdev->pgdir_list);
-	spin_lock_init(&ibdev->pgdir_lock);
+	mutex_init(&ibdev->pgdir_mutex);
 
 	ibdev->dev = dev;
 
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index bb866b0..62be599 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -152,7 +152,7 @@ struct mlx4_ib_dev {
 	void __iomem	       *uar_map;
 
 	struct list_head	pgdir_list;
-	spinlock_t		pgdir_lock;
+	struct mutex		pgdir_mutex;
 
 	struct mlx4_uar		priv_uar;
 	u32			priv_pdn;



More information about the general mailing list