IB/ehca: Lock renaming, static initializers
authorJoachim Fenkes <fenkes@de.ibm.com>
Mon, 9 Jul 2007 13:29:03 +0000 (15:29 +0200)
committerRoland Dreier <rolandd@cisco.com>
Tue, 10 Jul 2007 03:12:27 +0000 (20:12 -0700)
- Rename all spinlock flags to "flags", matching the vast majority of kernel
  code.
- Move hcall_lock into the only file it's used in.
- Replaced spin_lock_init() and friends with static initializers for
  global variables.

Signed-off-by: Joachim Fenkes <fenkes@de.ibm.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/hw/ehca/ehca_classes.h
drivers/infiniband/hw/ehca/ehca_cq.c
drivers/infiniband/hw/ehca/ehca_main.c
drivers/infiniband/hw/ehca/ehca_qp.c
drivers/infiniband/hw/ehca/ehca_reqs.c
drivers/infiniband/hw/ehca/hcp_if.c

index 9d689aeb928a4030a8033ec8d8e9e1b64812e7cf..3550047c13759017ab72e392c72b2b3a69afc630 100644 (file)
@@ -295,7 +295,6 @@ void ehca_cleanup_mrmw_cache(void);
 
 extern spinlock_t ehca_qp_idr_lock;
 extern spinlock_t ehca_cq_idr_lock;
-extern spinlock_t hcall_lock;
 extern struct idr ehca_qp_idr;
 extern struct idr ehca_cq_idr;
 
index 67f0670fe3b18624cd752a9ed01b65a660165d81..94bad273b34c7da4b8c479bdf5c70411af4d0074 100644 (file)
@@ -56,11 +56,11 @@ int ehca_cq_assign_qp(struct ehca_cq *cq, struct ehca_qp *qp)
 {
        unsigned int qp_num = qp->real_qp_num;
        unsigned int key = qp_num & (QP_HASHTAB_LEN-1);
-       unsigned long spl_flags;
+       unsigned long flags;
 
-       spin_lock_irqsave(&cq->spinlock, spl_flags);
+       spin_lock_irqsave(&cq->spinlock, flags);
        hlist_add_head(&qp->list_entries, &cq->qp_hashtab[key]);
-       spin_unlock_irqrestore(&cq->spinlock, spl_flags);
+       spin_unlock_irqrestore(&cq->spinlock, flags);
 
        ehca_dbg(cq->ib_cq.device, "cq_num=%x real_qp_num=%x",
                 cq->cq_number, qp_num);
@@ -74,9 +74,9 @@ int ehca_cq_unassign_qp(struct ehca_cq *cq, unsigned int real_qp_num)
        unsigned int key = real_qp_num & (QP_HASHTAB_LEN-1);
        struct hlist_node *iter;
        struct ehca_qp *qp;
-       unsigned long spl_flags;
+       unsigned long flags;
 
-       spin_lock_irqsave(&cq->spinlock, spl_flags);
+       spin_lock_irqsave(&cq->spinlock, flags);
        hlist_for_each(iter, &cq->qp_hashtab[key]) {
                qp = hlist_entry(iter, struct ehca_qp, list_entries);
                if (qp->real_qp_num == real_qp_num) {
@@ -88,7 +88,7 @@ int ehca_cq_unassign_qp(struct ehca_cq *cq, unsigned int real_qp_num)
                        break;
                }
        }
-       spin_unlock_irqrestore(&cq->spinlock, spl_flags);
+       spin_unlock_irqrestore(&cq->spinlock, flags);
        if (ret)
                ehca_err(cq->ib_cq.device,
                         "qp not found cq_num=%x real_qp_num=%x",
index ca215bac974261bcb90aacbd8c6ac3dc55c4577c..32396b203f1413208fb36b6e9b90697e6f2e44f2 100644 (file)
@@ -96,15 +96,13 @@ MODULE_PARM_DESC(static_rate,
 MODULE_PARM_DESC(scaling_code,
                 "set scaling code (0: disabled/default, 1: enabled)");
 
-spinlock_t ehca_qp_idr_lock;
-spinlock_t ehca_cq_idr_lock;
-spinlock_t hcall_lock;
+DEFINE_SPINLOCK(ehca_qp_idr_lock);
+DEFINE_SPINLOCK(ehca_cq_idr_lock);
 DEFINE_IDR(ehca_qp_idr);
 DEFINE_IDR(ehca_cq_idr);
 
-
-static struct list_head shca_list; /* list of all registered ehcas */
-static spinlock_t shca_list_lock;
+static LIST_HEAD(shca_list); /* list of all registered ehcas */
+static DEFINE_SPINLOCK(shca_list_lock);
 
 static struct timer_list poll_eqs_timer;
 
@@ -864,14 +862,6 @@ int __init ehca_module_init(void)
 
        printk(KERN_INFO "eHCA Infiniband Device Driver "
               "(Rel.: SVNEHCA_0023)\n");
-       idr_init(&ehca_qp_idr);
-       idr_init(&ehca_cq_idr);
-       spin_lock_init(&ehca_qp_idr_lock);
-       spin_lock_init(&ehca_cq_idr_lock);
-       spin_lock_init(&hcall_lock);
-
-       INIT_LIST_HEAD(&shca_list);
-       spin_lock_init(&shca_list_lock);
 
        if ((ret = ehca_create_comp_pool())) {
                ehca_gen_err("Cannot create comp pool.");
index ec34ff43290095f0ffe1aada55af384bba22f9d5..31d21526df5e15256fdc86cd8422a02be3b3bebb 100644 (file)
@@ -933,7 +933,7 @@ static int internal_modify_qp(struct ib_qp *ibqp,
        u64 h_ret;
        int bad_wqe_cnt = 0;
        int squeue_locked = 0;
-       unsigned long spl_flags = 0;
+       unsigned long flags = 0;
 
        /* do query_qp to obtain current attr values */
        mqpcb = ehca_alloc_fw_ctrlblock(GFP_KERNEL);
@@ -1074,7 +1074,7 @@ static int internal_modify_qp(struct ib_qp *ibqp,
                if (!ibqp->uobject) {
                        struct ehca_wqe *wqe;
                        /* lock send queue */
-                       spin_lock_irqsave(&my_qp->spinlock_s, spl_flags);
+                       spin_lock_irqsave(&my_qp->spinlock_s, flags);
                        squeue_locked = 1;
                        /* mark next free wqe */
                        wqe = (struct ehca_wqe*)
@@ -1360,7 +1360,7 @@ static int internal_modify_qp(struct ib_qp *ibqp,
 
 modify_qp_exit2:
        if (squeue_locked) { /* this means: sqe -> rts */
-               spin_unlock_irqrestore(&my_qp->spinlock_s, spl_flags);
+               spin_unlock_irqrestore(&my_qp->spinlock_s, flags);
                my_qp->sqerr_purgeflag = 1;
        }
 
index b5664fa34de3d19dc15cb81be51a0137317599a9..73f0c0652a008e7b9b564235f664fa0506b00225 100644 (file)
@@ -363,10 +363,10 @@ int ehca_post_send(struct ib_qp *qp,
        struct ehca_wqe *wqe_p;
        int wqe_cnt = 0;
        int ret = 0;
-       unsigned long spl_flags;
+       unsigned long flags;
 
        /* LOCK the QUEUE */
-       spin_lock_irqsave(&my_qp->spinlock_s, spl_flags);
+       spin_lock_irqsave(&my_qp->spinlock_s, flags);
 
        /* loop processes list of send reqs */
        for (cur_send_wr = send_wr; cur_send_wr != NULL;
@@ -408,7 +408,7 @@ int ehca_post_send(struct ib_qp *qp,
 
 post_send_exit0:
        /* UNLOCK the QUEUE */
-       spin_unlock_irqrestore(&my_qp->spinlock_s, spl_flags);
+       spin_unlock_irqrestore(&my_qp->spinlock_s, flags);
        iosync(); /* serialize GAL register access */
        hipz_update_sqa(my_qp, wqe_cnt);
        return ret;
@@ -423,7 +423,7 @@ static int internal_post_recv(struct ehca_qp *my_qp,
        struct ehca_wqe *wqe_p;
        int wqe_cnt = 0;
        int ret = 0;
-       unsigned long spl_flags;
+       unsigned long flags;
 
        if (unlikely(!HAS_RQ(my_qp))) {
                ehca_err(dev, "QP has no RQ  ehca_qp=%p qp_num=%x ext_type=%d",
@@ -432,7 +432,7 @@ static int internal_post_recv(struct ehca_qp *my_qp,
        }
 
        /* LOCK the QUEUE */
-       spin_lock_irqsave(&my_qp->spinlock_r, spl_flags);
+       spin_lock_irqsave(&my_qp->spinlock_r, flags);
 
        /* loop processes list of send reqs */
        for (cur_recv_wr = recv_wr; cur_recv_wr != NULL;
@@ -473,7 +473,7 @@ static int internal_post_recv(struct ehca_qp *my_qp,
        } /* eof for cur_recv_wr */
 
 post_recv_exit0:
-       spin_unlock_irqrestore(&my_qp->spinlock_r, spl_flags);
+       spin_unlock_irqrestore(&my_qp->spinlock_r, flags);
        iosync(); /* serialize GAL register access */
        hipz_update_rqa(my_qp, wqe_cnt);
        return ret;
@@ -536,7 +536,7 @@ poll_cq_one_read_cqe:
        if (unlikely(cqe->status & WC_STATUS_PURGE_BIT)) {
                struct ehca_qp *qp=ehca_cq_get_qp(my_cq, cqe->local_qp_number);
                int purgeflag;
-               unsigned long spl_flags;
+               unsigned long flags;
                if (!qp) {
                        ehca_err(cq->device, "cq_num=%x qp_num=%x "
                                 "could not find qp -> ignore cqe",
@@ -546,9 +546,9 @@ poll_cq_one_read_cqe:
                        /* ignore this purged cqe */
                        goto poll_cq_one_read_cqe;
                }
-               spin_lock_irqsave(&qp->spinlock_s, spl_flags);
+               spin_lock_irqsave(&qp->spinlock_s, flags);
                purgeflag = qp->sqerr_purgeflag;
-               spin_unlock_irqrestore(&qp->spinlock_s, spl_flags);
+               spin_unlock_irqrestore(&qp->spinlock_s, flags);
 
                if (purgeflag) {
                        ehca_dbg(cq->device, "Got CQE with purged bit qp_num=%x "
@@ -633,7 +633,7 @@ int ehca_poll_cq(struct ib_cq *cq, int num_entries, struct ib_wc *wc)
        int nr;
        struct ib_wc *current_wc = wc;
        int ret = 0;
-       unsigned long spl_flags;
+       unsigned long flags;
 
        if (num_entries < 1) {
                ehca_err(cq->device, "Invalid num_entries=%d ehca_cq=%p "
@@ -642,14 +642,14 @@ int ehca_poll_cq(struct ib_cq *cq, int num_entries, struct ib_wc *wc)
                goto poll_cq_exit0;
        }
 
-       spin_lock_irqsave(&my_cq->spinlock, spl_flags);
+       spin_lock_irqsave(&my_cq->spinlock, flags);
        for (nr = 0; nr < num_entries; nr++) {
                ret = ehca_poll_cq_one(cq, current_wc);
                if (ret)
                        break;
                current_wc++;
        } /* eof for nr */
-       spin_unlock_irqrestore(&my_cq->spinlock, spl_flags);
+       spin_unlock_irqrestore(&my_cq->spinlock, flags);
        if (ret == -EAGAIN  || !ret)
                ret = nr;
 
index b0783773f1c8e10c879144d9e63660147009f9d7..4776a8b0feec4f02bbf6f90e8de04f79e0e9dbda 100644 (file)
@@ -81,6 +81,8 @@
 #define H_MP_SHUTDOWN                   EHCA_BMASK_IBM(48, 48)
 #define H_MP_RESET_QKEY_CTR             EHCA_BMASK_IBM(49, 49)
 
+static DEFINE_SPINLOCK(hcall_lock);
+
 static u32 get_longbusy_msecs(int longbusy_rc)
 {
        switch (longbusy_rc) {