]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/infiniband/hw/ehca/ehca_cq.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
[linux-2.6-omap-h63xx.git] / drivers / infiniband / hw / ehca / ehca_cq.c
index 0467c158d4a997f2254b52f06d5fe281ae5f88f6..2f4c28a30271694f0d62c5add9b625716e027e4c 100644 (file)
@@ -43,8 +43,6 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <asm/current.h>
-
 #include "ehca_iverbs.h"
 #include "ehca_classes.h"
 #include "ehca_irq.h"
@@ -134,10 +132,19 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
        if (cqe >= 0xFFFFFFFF - 64 - additional_cqe)
                return ERR_PTR(-EINVAL);
 
+       if (!atomic_add_unless(&shca->num_cqs, 1, shca->max_num_cqs)) {
+               ehca_err(device, "Unable to create CQ, max number of %i "
+                       "CQs reached.", shca->max_num_cqs);
+               ehca_err(device, "To increase the maximum number of CQs "
+                       "use the number_of_cqs module parameter.\n");
+               return ERR_PTR(-ENOSPC);
+       }
+
        my_cq = kmem_cache_zalloc(cq_cache, GFP_KERNEL);
        if (!my_cq) {
                ehca_err(device, "Out of memory for ehca_cq struct device=%p",
                         device);
+               atomic_dec(&shca->num_cqs);
                return ERR_PTR(-ENOMEM);
        }
 
@@ -148,7 +155,6 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
        spin_lock_init(&my_cq->task_lock);
        atomic_set(&my_cq->nr_events, 0);
        init_waitqueue_head(&my_cq->wait_completion);
-       my_cq->ownpid = current->tgid;
 
        cq = &my_cq->ib_cq;
 
@@ -270,6 +276,9 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
        for (i = 0; i < QP_HASHTAB_LEN; i++)
                INIT_HLIST_HEAD(&my_cq->qp_hashtab[i]);
 
+       INIT_LIST_HEAD(&my_cq->sqp_err_list);
+       INIT_LIST_HEAD(&my_cq->rqp_err_list);
+
        if (context) {
                struct ipz_queue *ipz_queue = &my_cq->ipz_queue;
                struct ehca_create_cq_resp resp;
@@ -308,6 +317,7 @@ create_cq_exit2:
 create_cq_exit1:
        kmem_cache_free(cq_cache, my_cq);
 
+       atomic_dec(&shca->num_cqs);
        return cq;
 }
 
@@ -320,7 +330,6 @@ int ehca_destroy_cq(struct ib_cq *cq)
        struct ehca_shca *shca = container_of(device, struct ehca_shca,
                                              ib_device);
        struct ipz_adapter_handle adapter_handle = shca->ipz_hca_handle;
-       u32 cur_pid = current->tgid;
        unsigned long flags;
 
        if (cq->uobject) {
@@ -329,12 +338,6 @@ int ehca_destroy_cq(struct ib_cq *cq)
                                 "user space cq_num=%x", my_cq->cq_number);
                        return -EINVAL;
                }
-               if (my_cq->ownpid != cur_pid) {
-                       ehca_err(device, "Invalid caller pid=%x ownpid=%x "
-                                "cq_num=%x",
-                                cur_pid, my_cq->ownpid, my_cq->cq_number);
-                       return -EINVAL;
-               }
        }
 
        /*
@@ -369,20 +372,12 @@ int ehca_destroy_cq(struct ib_cq *cq)
        ipz_queue_dtor(NULL, &my_cq->ipz_queue);
        kmem_cache_free(cq_cache, my_cq);
 
+       atomic_dec(&shca->num_cqs);
        return 0;
 }
 
 int ehca_resize_cq(struct ib_cq *cq, int cqe, struct ib_udata *udata)
 {
-       struct ehca_cq *my_cq = container_of(cq, struct ehca_cq, ib_cq);
-       u32 cur_pid = current->tgid;
-
-       if (cq->uobject && my_cq->ownpid != cur_pid) {
-               ehca_err(cq->device, "Invalid caller pid=%x ownpid=%x",
-                        cur_pid, my_cq->ownpid);
-               return -EINVAL;
-       }
-
        /* TODO: proper resize needs to be done */
        ehca_err(cq->device, "not implemented yet");