]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/infiniband/hw/nes/nes_verbs.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq
[linux-2.6-omap-h63xx.git] / drivers / infiniband / hw / nes / nes_verbs.c
index a651e9d9f0efdba6e38612b738f9455ccf2a1bcf..9ae397a0ff7e4d9d88155a1278ee3cc8b41540e7 100644 (file)
@@ -49,6 +49,7 @@ atomic_t mod_qp_timouts;
 atomic_t qps_created;
 atomic_t sw_qps_destroyed;
 
+static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
 
 /**
  * nes_alloc_mw
@@ -1043,10 +1044,10 @@ static int nes_setup_virt_qp(struct nes_qp *nesqp, struct nes_pbl *nespbl,
        u8 sq_pbl_entries;
 
        pbl_entries = nespbl->pbl_size >> 3;
-       nes_debug(NES_DBG_QP, "Userspace PBL, pbl_size=%u, pbl_entries = %d pbl_vbase=%p, pbl_pbase=%p\n",
+       nes_debug(NES_DBG_QP, "Userspace PBL, pbl_size=%u, pbl_entries = %d pbl_vbase=%p, pbl_pbase=%lx\n",
                        nespbl->pbl_size, pbl_entries,
                        (void *)nespbl->pbl_vbase,
-                       (void *)nespbl->pbl_pbase);
+                       (unsigned long) nespbl->pbl_pbase);
        pbl = (__le64 *) nespbl->pbl_vbase; /* points to first pbl entry */
        /* now lets set the sq_vbase as well as rq_vbase addrs we will assign */
        /* the first pbl to be fro the rq_vbase... */
@@ -1074,9 +1075,9 @@ static int nes_setup_virt_qp(struct nes_qp *nesqp, struct nes_pbl *nespbl,
        /* nesqp->hwqp.rq_vbase = bus_to_virt(*pbl); */
        /*nesqp->hwqp.rq_vbase = phys_to_virt(*pbl); */
 
-       nes_debug(NES_DBG_QP, "QP sq_vbase= %p sq_pbase=%p rq_vbase=%p rq_pbase=%p\n",
-                       nesqp->hwqp.sq_vbase, (void *)nesqp->hwqp.sq_pbase,
-                       nesqp->hwqp.rq_vbase, (void *)nesqp->hwqp.rq_pbase);
+       nes_debug(NES_DBG_QP, "QP sq_vbase= %p sq_pbase=%lx rq_vbase=%p rq_pbase=%lx\n",
+                 nesqp->hwqp.sq_vbase, (unsigned long) nesqp->hwqp.sq_pbase,
+                 nesqp->hwqp.rq_vbase, (unsigned long) nesqp->hwqp.rq_pbase);
        spin_lock_irqsave(&nesadapter->pbl_lock, flags);
        if (!nesadapter->free_256pbl) {
                pci_free_consistent(nesdev->pcidev, nespbl->pbl_size, nespbl->pbl_vbase,
@@ -1251,6 +1252,9 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
        u8 rq_encoded_size;
        /* int counter; */
 
+       if (init_attr->create_flags)
+               return ERR_PTR(-EINVAL);
+
        atomic_inc(&qps_created);
        switch (init_attr->qp_type) {
                case IB_QPT_RC:
@@ -1908,13 +1912,13 @@ static int nes_destroy_cq(struct ib_cq *ib_cq)
                nesadapter->free_256pbl++;
                if (nesadapter->free_256pbl > nesadapter->max_256pbl) {
                        printk(KERN_ERR PFX "%s: free 256B PBLs(%u) has exceeded the max(%u)\n",
-                                       __FUNCTION__, nesadapter->free_256pbl, nesadapter->max_256pbl);
+                                       __func__, nesadapter->free_256pbl, nesadapter->max_256pbl);
                }
        } else if (nescq->virtual_cq == 2) {
                nesadapter->free_4kpbl++;
                if (nesadapter->free_4kpbl > nesadapter->max_4kpbl) {
                        printk(KERN_ERR PFX "%s: free 4K PBLs(%u) has exceeded the max(%u)\n",
-                                       __FUNCTION__, nesadapter->free_4kpbl, nesadapter->max_4kpbl);
+                                       __func__, nesadapter->free_4kpbl, nesadapter->max_4kpbl);
                }
                opcode |= NES_CQP_CQ_4KB_CHUNK;
        }
@@ -1972,7 +1976,7 @@ static int nes_destroy_cq(struct ib_cq *ib_cq)
 
        if (nescq->cq_mem_size)
                pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size,
-                               (void *)nescq->hw_cq.cq_vbase, nescq->hw_cq.cq_pbase);
+                                   nescq->hw_cq.cq_vbase, nescq->hw_cq.cq_pbase);
        kfree(nescq);
 
        return ret;
@@ -2373,7 +2377,7 @@ static struct ib_mr *nes_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
        u8 single_page = 1;
        u8 stag_key;
 
-       region = ib_umem_get(pd->uobject->context, start, length, acc);
+       region = ib_umem_get(pd->uobject->context, start, length, acc, 0);
        if (IS_ERR(region)) {
                return (struct ib_mr *)region;
        }
@@ -2653,10 +2657,10 @@ static struct ib_mr *nes_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
 
                        nespbl->pbl_vbase = (u64 *)pbl;
                        nespbl->user_base = start;
-                       nes_debug(NES_DBG_MR, "Allocated PBL memory, %u bytes, pbl_pbase=%p,"
+                       nes_debug(NES_DBG_MR, "Allocated PBL memory, %u bytes, pbl_pbase=%lx,"
                                        " pbl_vbase=%p user_base=0x%lx\n",
-                                       nespbl->pbl_size, (void *)nespbl->pbl_pbase,
-                                       (void*)nespbl->pbl_vbase, nespbl->user_base);
+                                 nespbl->pbl_size, (unsigned long) nespbl->pbl_pbase,
+                                 (void *) nespbl->pbl_vbase, nespbl->user_base);
 
                        list_for_each_entry(chunk, &region->chunk_list, list) {
                                for (nmap_index = 0; nmap_index < chunk->nmap; ++nmap_index) {
@@ -2796,10 +2800,11 @@ static int nes_dereg_mr(struct ib_mr *ib_mr)
 /**
  * show_rev
  */
-static ssize_t show_rev(struct class_device *cdev, char *buf)
+static ssize_t show_rev(struct device *dev, struct device_attribute *attr,
+                       char *buf)
 {
        struct nes_ib_device *nesibdev =
-                       container_of(cdev, struct nes_ib_device, ibdev.class_dev);
+                       container_of(dev, struct nes_ib_device, ibdev.dev);
        struct nes_vnic *nesvnic = nesibdev->nesvnic;
 
        nes_debug(NES_DBG_INIT, "\n");
@@ -2810,10 +2815,11 @@ static ssize_t show_rev(struct class_device *cdev, char *buf)
 /**
  * show_fw_ver
  */
-static ssize_t show_fw_ver(struct class_device *cdev, char *buf)
+static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr,
+                          char *buf)
 {
        struct nes_ib_device *nesibdev =
-                       container_of(cdev, struct nes_ib_device, ibdev.class_dev);
+                       container_of(dev, struct nes_ib_device, ibdev.dev);
        struct nes_vnic *nesvnic = nesibdev->nesvnic;
 
        nes_debug(NES_DBG_INIT, "\n");
@@ -2827,7 +2833,8 @@ static ssize_t show_fw_ver(struct class_device *cdev, char *buf)
 /**
  * show_hca
  */
-static ssize_t show_hca(struct class_device *cdev, char *buf)
+static ssize_t show_hca(struct device *dev, struct device_attribute *attr,
+                       char *buf)
 {
        nes_debug(NES_DBG_INIT, "\n");
        return sprintf(buf, "NES020\n");
@@ -2837,23 +2844,24 @@ static ssize_t show_hca(struct class_device *cdev, char *buf)
 /**
  * show_board
  */
-static ssize_t show_board(struct class_device *cdev, char *buf)
+static ssize_t show_board(struct device *dev, struct device_attribute *attr,
+                         char *buf)
 {
        nes_debug(NES_DBG_INIT, "\n");
        return sprintf(buf, "%.*s\n", 32, "NES020 Board ID");
 }
 
 
-static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
-static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
-static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
-static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
+static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
+static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
+static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
+static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
 
-static struct class_device_attribute *nes_class_attributes[] = {
-       &class_device_attr_hw_rev,
-       &class_device_attr_fw_ver,
-       &class_device_attr_hca_type,
-       &class_device_attr_board_id
+static struct device_attribute *nes_dev_attributes[] = {
+       &dev_attr_hw_rev,
+       &dev_attr_fw_ver,
+       &dev_attr_hca_type,
+       &dev_attr_board_id
 };
 
 
@@ -3602,6 +3610,12 @@ static int nes_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *entry)
        while (cqe_count < num_entries) {
                if (le32_to_cpu(nescq->hw_cq.cq_vbase[head].cqe_words[NES_CQE_OPCODE_IDX]) &
                                NES_CQE_VALID) {
+                       /*
+                        * Make sure we read CQ entry contents *after*
+                        * we've checked the valid bit.
+                        */
+                       rmb();
+
                        cqe = nescq->hw_cq.cq_vbase[head];
                        nescq->hw_cq.cq_vbase[head].cqe_words[NES_CQE_OPCODE_IDX] = 0;
                        u32temp = le32_to_cpu(cqe.cqe_words[NES_CQE_COMP_COMP_CTX_LOW_IDX]);
@@ -3778,7 +3792,7 @@ struct nes_ib_device *nes_init_ofa_device(struct net_device *netdev)
        nesibdev->ibdev.phys_port_cnt = 1;
        nesibdev->ibdev.num_comp_vectors = 1;
        nesibdev->ibdev.dma_device = &nesdev->pcidev->dev;
-       nesibdev->ibdev.class_dev.dev = &nesdev->pcidev->dev;
+       nesibdev->ibdev.dev.parent = &nesdev->pcidev->dev;
        nesibdev->ibdev.query_device = nes_query_device;
        nesibdev->ibdev.query_port = nes_query_port;
        nesibdev->ibdev.modify_port = nes_modify_port;
@@ -3873,13 +3887,13 @@ int nes_register_ofa_device(struct nes_ib_device *nesibdev)
        nesibdev->max_qp = (nesadapter->max_qp-NES_FIRST_QPN) / nesadapter->port_count;
        nesibdev->max_pd = nesadapter->max_pd / nesadapter->port_count;
 
-       for (i = 0; i < ARRAY_SIZE(nes_class_attributes); ++i) {
-               ret = class_device_create_file(&nesibdev->ibdev.class_dev, nes_class_attributes[i]);
+       for (i = 0; i < ARRAY_SIZE(nes_dev_attributes); ++i) {
+               ret = device_create_file(&nesibdev->ibdev.dev, nes_dev_attributes[i]);
                if (ret) {
                        while (i > 0) {
                                i--;
-                               class_device_remove_file(&nesibdev->ibdev.class_dev,
-                                               nes_class_attributes[i]);
+                               device_remove_file(&nesibdev->ibdev.dev,
+                                                  nes_dev_attributes[i]);
                        }
                        ib_unregister_device(&nesibdev->ibdev);
                        return ret;
@@ -3895,16 +3909,13 @@ int nes_register_ofa_device(struct nes_ib_device *nesibdev)
 /**
  * nes_unregister_ofa_device
  */
-void nes_unregister_ofa_device(struct nes_ib_device *nesibdev)
+static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev)
 {
        struct nes_vnic *nesvnic = nesibdev->nesvnic;
        int i;
 
-       if (nesibdev == NULL)
-               return;
-
-       for (i = 0; i < ARRAY_SIZE(nes_class_attributes); ++i) {
-               class_device_remove_file(&nesibdev->ibdev.class_dev, nes_class_attributes[i]);
+       for (i = 0; i < ARRAY_SIZE(nes_dev_attributes); ++i) {
+               device_remove_file(&nesibdev->ibdev.dev, nes_dev_attributes[i]);
        }
 
        if (nesvnic->of_device_registered) {