Merge branches 'cma', 'misc', 'mlx4', 'nes', 'qib' and 'uverbs' into for-next
authorRoland Dreier <roland@purestorage.com>
Wed, 4 Jan 2012 17:18:20 +0000 (09:18 -0800)
committerRoland Dreier <roland@purestorage.com>
Wed, 4 Jan 2012 17:18:20 +0000 (09:18 -0800)
19 files changed:
drivers/infiniband/core/cm_msgs.h
drivers/infiniband/core/uverbs_cmd.c
drivers/infiniband/hw/mlx4/ah.c
drivers/infiniband/hw/mlx4/cq.c
drivers/infiniband/hw/mlx4/qp.c
drivers/infiniband/hw/nes/nes_cm.c
drivers/infiniband/hw/nes/nes_hw.c
drivers/infiniband/hw/nes/nes_utils.c
drivers/infiniband/hw/qib/qib_7220.h
drivers/infiniband/hw/qib/qib_driver.c
drivers/infiniband/hw/qib/qib_iba6120.c
drivers/infiniband/hw/qib/qib_iba7220.c
drivers/infiniband/hw/qib/qib_iba7322.c
drivers/infiniband/hw/qib/qib_init.c
drivers/infiniband/hw/qib/qib_pcie.c
drivers/infiniband/hw/qib/qib_qsfp.h
drivers/infiniband/hw/qib/qib_sd7220.c
drivers/infiniband/hw/qib/qib_sysfs.c
drivers/infiniband/hw/qib/qib_verbs.c

index 505db2a59e7f4f46b85422c94955459b6b00b85a..7da9b2102341c2f364f31989aa656d4d750272ee 100644 (file)
@@ -799,6 +799,7 @@ struct cm_apr_msg {
 
        u8 info_length;
        u8 ap_status;
+       __be16 rsvd;
        u8 info[IB_CM_APR_INFO_LENGTH];
 
        u8 private_data[IB_CM_APR_PRIVATE_DATA_SIZE];
index e26193f5f8541ead3001f83c91edac702a96dec9..b930da4c0c632e64019c38b0ebcab9562e15bf65 100644 (file)
@@ -241,11 +241,24 @@ static struct ib_qp *idr_read_qp(int qp_handle, struct ib_ucontext *context)
        return idr_read_obj(&ib_uverbs_qp_idr, qp_handle, context, 0);
 }
 
+static struct ib_qp *idr_write_qp(int qp_handle, struct ib_ucontext *context)
+{
+       struct ib_uobject *uobj;
+
+       uobj = idr_write_uobj(&ib_uverbs_qp_idr, qp_handle, context);
+       return uobj ? uobj->object : NULL;
+}
+
 static void put_qp_read(struct ib_qp *qp)
 {
        put_uobj_read(qp->uobject);
 }
 
+static void put_qp_write(struct ib_qp *qp)
+{
+       put_uobj_write(qp->uobject);
+}
+
 static struct ib_srq *idr_read_srq(int srq_handle, struct ib_ucontext *context)
 {
        return idr_read_obj(&ib_uverbs_srq_idr, srq_handle, context, 0);
@@ -2375,7 +2388,7 @@ ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file,
        if (copy_from_user(&cmd, buf, sizeof cmd))
                return -EFAULT;
 
-       qp = idr_read_qp(cmd.qp_handle, file->ucontext);
+       qp = idr_write_qp(cmd.qp_handle, file->ucontext);
        if (!qp)
                return -EINVAL;
 
@@ -2404,7 +2417,7 @@ ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file,
                kfree(mcast);
 
 out_put:
-       put_qp_read(qp);
+       put_qp_write(qp);
 
        return ret ? ret : in_len;
 }
@@ -2422,7 +2435,7 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
        if (copy_from_user(&cmd, buf, sizeof cmd))
                return -EFAULT;
 
-       qp = idr_read_qp(cmd.qp_handle, file->ucontext);
+       qp = idr_write_qp(cmd.qp_handle, file->ucontext);
        if (!qp)
                return -EINVAL;
 
@@ -2441,7 +2454,7 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
                }
 
 out_put:
-       put_qp_read(qp);
+       put_qp_write(qp);
 
        return ret ? ret : in_len;
 }
index 4b8f9c49397e2c23cd9471ad854936ce1af8ed46..a251becdaa987dc1653ef59b7e23b61889e22636 100644 (file)
@@ -126,7 +126,7 @@ static struct ib_ah *create_iboe_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr
                ah->av.ib.dlid = cpu_to_be16(0xc000);
 
        memcpy(ah->av.eth.dgid, ah_attr->grh.dgid.raw, 16);
-       ah->av.eth.sl_tclass_flowlabel = cpu_to_be32(ah_attr->sl << 28);
+       ah->av.eth.sl_tclass_flowlabel = cpu_to_be32(ah_attr->sl << 29);
 
        return &ah->ibah;
 }
index e8df155bc3b0762dad6da57b4eed64c53140b733..5ecf38d97269f1d98189c5e8543198fcab26ecbc 100644 (file)
@@ -715,13 +715,17 @@ repoll:
                }
 
                wc->slid           = be16_to_cpu(cqe->rlid);
-               wc->sl             = be16_to_cpu(cqe->sl_vid) >> 12;
                g_mlpath_rqpn      = be32_to_cpu(cqe->g_mlpath_rqpn);
                wc->src_qp         = g_mlpath_rqpn & 0xffffff;
                wc->dlid_path_bits = (g_mlpath_rqpn >> 24) & 0x7f;
                wc->wc_flags      |= g_mlpath_rqpn & 0x80000000 ? IB_WC_GRH : 0;
                wc->pkey_index     = be32_to_cpu(cqe->immed_rss_invalid) & 0x7f;
                wc->csum_ok        = mlx4_ib_ipoib_csum_ok(cqe->status, cqe->checksum);
+               if (rdma_port_get_link_layer(wc->qp->device,
+                               (*cur_qp)->port) == IB_LINK_LAYER_ETHERNET)
+                       wc->sl  = be16_to_cpu(cqe->sl_vid) >> 13;
+               else
+                       wc->sl  = be16_to_cpu(cqe->sl_vid) >> 12;
        }
 
        return 0;
index a16f0c8e6f3f692a10b166f6577ebffe663346d5..aa2aefa4236c1295ad53aba2b21422e244974a97 100644 (file)
@@ -962,7 +962,7 @@ static int mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
 
        if (is_eth) {
                path->sched_queue = MLX4_IB_DEFAULT_SCHED_QUEUE |
-                       ((port - 1) << 6) | ((ah->sl & 7) << 3) | ((ah->sl & 8) >> 1);
+                       ((port - 1) << 6) | ((ah->sl & 7) << 3);
 
                if (!(ah->ah_flags & IB_AH_GRH))
                        return -1;
@@ -1437,7 +1437,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
                        u16 pcp;
 
                        sqp->ud_header.vlan.type = cpu_to_be16(MLX4_IB_IBOE_ETHERTYPE);
-                       pcp = (be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) >> 27 & 3) << 13;
+                       pcp = (be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) >> 29) << 13;
                        sqp->ud_header.vlan.tag = cpu_to_be16(vlan | pcp);
                }
        } else {
index 0a52d72371ee5f6cf2f938ba81fa0c887fd00070..db0831dc533cd812f8dd1d3c9bab9868c6f6ba29 100644 (file)
@@ -2838,6 +2838,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
                issue_disconn = 1;
                issue_close = 1;
                nesqp->cm_id = NULL;
+               del_timer(&nesqp->terminate_timer);
                if (nesqp->flush_issued == 0) {
                        nesqp->flush_issued = 1;
                        issue_flush = 1;
index 7c0ff19ce382d71db8f39e93e7697fdda0f56ce6..055f4b545df00a73069da6978a0164895e17754c 100644 (file)
@@ -1529,7 +1529,7 @@ int nes_init_phy(struct nes_device *nesdev)
        } else {
                /* setup 10G MDIO operation */
                tx_config &= 0xFFFFFFE3;
-               tx_config |= 0x15;
+               tx_config |= 0x1D;
        }
        nes_write_indexed(nesdev, NES_IDX_MAC_TX_CONFIG, tx_config);
 
@@ -3619,10 +3619,6 @@ static void nes_process_iwarp_aeqe(struct nes_device *nesdev,
                        }
                        break;
                case NES_AEQE_AEID_LLP_CLOSE_COMPLETE:
-                       if (nesqp->term_flags) {
-                               nes_terminate_done(nesqp, 0);
-                               return;
-                       }
                        spin_lock_irqsave(&nesqp->lock, flags);
                        nesqp->hw_iwarp_state = iwarp_state;
                        nesqp->hw_tcp_state = tcp_state;
index cd10968bfa22efbd04736b64172fb5b44d65df0d..8b4c2ff548887e967c567a600e50c828aa7946d8 100644 (file)
@@ -56,7 +56,7 @@ static u16 nes_read16_eeprom(void __iomem *addr, u16 offset);
 u32 mh_detected;
 u32 mh_pauses_sent;
 
-u32 nes_set_pau(struct nes_device *nesdev)
+static u32 nes_set_pau(struct nes_device *nesdev)
 {
        u32 ret = 0;
        u32 counter;
index 21f374aa0631ac564dcdecea9509653b405d957a..a5356cb4252ebb7c7efa609a0881dc26a4ec94e8 100644 (file)
@@ -97,7 +97,7 @@ struct qib_chippport_specific {
        u64 iblnkerrsnap;
        u64 ibcctrl; /* kr_ibcctrl shadow */
        u64 ibcddrctrl; /* kr_ibcddrctrl shadow */
-       u64 chase_end;
+       unsigned long chase_end;
        u32 last_delay_mult;
 };
 
index c90a55f4120fe6b23972a4762b6c0d9ee0e27872..6fc9365ba8a6032225e953f5bc4e2203390afcc4 100644 (file)
@@ -371,9 +371,8 @@ static u32 qib_rcv_hdrerr(struct qib_ctxtdata *rcd, struct qib_pportdata *ppd,
                                                lnh == QIB_LRH_GRH,
                                                qp,
                                                be32_to_cpu(ohdr->bth[0]));
-                               if (ruc_res) {
+                               if (ruc_res)
                                        goto unlock;
-                               }
 
                                /* Only deal with RDMA Writes for now */
                                if (opcode <
index 781a802a321f069d3a8b6552713a3cb550d52803..4f18e2d332dfd79ba8dcfc66a6c9251347a562c1 100644 (file)
@@ -2076,9 +2076,11 @@ static void qib_6120_config_ctxts(struct qib_devdata *dd)
 static void qib_update_6120_usrhead(struct qib_ctxtdata *rcd, u64 hd,
                                    u32 updegr, u32 egrhd, u32 npkts)
 {
-       qib_write_ureg(rcd->dd, ur_rcvhdrhead, hd, rcd->ctxt);
        if (updegr)
                qib_write_ureg(rcd->dd, ur_rcvegrindexhead, egrhd, rcd->ctxt);
+       mmiowb();
+       qib_write_ureg(rcd->dd, ur_rcvhdrhead, hd, rcd->ctxt);
+       mmiowb();
 }
 
 static u32 qib_6120_hdrqempty(struct qib_ctxtdata *rcd)
index 439d3c503cd5d8b66ec06d945e35a4758480ec02..3c722f79d6f640cf4930a011bd5f3d8ccc2084cd 100644 (file)
@@ -1051,7 +1051,7 @@ static void reenable_7220_chase(unsigned long opaque)
 static void handle_7220_chase(struct qib_pportdata *ppd, u64 ibcst)
 {
        u8 ibclt;
-       u64 tnow;
+       unsigned long tnow;
 
        ibclt = (u8)SYM_FIELD(ibcst, IBCStatus, LinkTrainingState);
 
@@ -1066,9 +1066,9 @@ static void handle_7220_chase(struct qib_pportdata *ppd, u64 ibcst)
        case IB_7220_LT_STATE_CFGWAITRMT:
        case IB_7220_LT_STATE_TXREVLANES:
        case IB_7220_LT_STATE_CFGENH:
-               tnow = get_jiffies_64();
+               tnow = jiffies;
                if (ppd->cpspec->chase_end &&
-                   time_after64(tnow, ppd->cpspec->chase_end)) {
+                   time_after(tnow, ppd->cpspec->chase_end)) {
                        ppd->cpspec->chase_end = 0;
                        qib_set_ib_7220_lstate(ppd,
                                QLOGIC_IB_IBCC_LINKCMD_DOWN,
@@ -2725,9 +2725,11 @@ static int qib_7220_set_loopback(struct qib_pportdata *ppd, const char *what)
 static void qib_update_7220_usrhead(struct qib_ctxtdata *rcd, u64 hd,
                                    u32 updegr, u32 egrhd, u32 npkts)
 {
-       qib_write_ureg(rcd->dd, ur_rcvhdrhead, hd, rcd->ctxt);
        if (updegr)
                qib_write_ureg(rcd->dd, ur_rcvegrindexhead, egrhd, rcd->ctxt);
+       mmiowb();
+       qib_write_ureg(rcd->dd, ur_rcvhdrhead, hd, rcd->ctxt);
+       mmiowb();
 }
 
 static u32 qib_7220_hdrqempty(struct qib_ctxtdata *rcd)
index 1d5895941e193e35e5ff88804fb00a9c29c8a5fa..41e92089e41b1aafb1fc55dc4c14b573f5e27fe0 100644 (file)
@@ -615,8 +615,8 @@ struct qib_chippport_specific {
        u64 ibmalfsnap;
        u64 ibcctrl_a; /* krp_ibcctrl_a shadow */
        u64 ibcctrl_b; /* krp_ibcctrl_b shadow */
-       u64 qdr_dfe_time;
-       u64 chase_end;
+       unsigned long qdr_dfe_time;
+       unsigned long chase_end;
        u32 autoneg_tries;
        u32 recovery_init;
        u32 qdr_dfe_on;
@@ -1672,7 +1672,8 @@ static void reenable_chase(unsigned long opaque)
                QLOGIC_IB_IBCC_LINKINITCMD_POLL);
 }
 
-static void disable_chase(struct qib_pportdata *ppd, u64 tnow, u8 ibclt)
+static void disable_chase(struct qib_pportdata *ppd, unsigned long tnow,
+               u8 ibclt)
 {
        ppd->cpspec->chase_end = 0;
 
@@ -1688,7 +1689,7 @@ static void disable_chase(struct qib_pportdata *ppd, u64 tnow, u8 ibclt)
 static void handle_serdes_issues(struct qib_pportdata *ppd, u64 ibcst)
 {
        u8 ibclt;
-       u64 tnow;
+       unsigned long tnow;
 
        ibclt = (u8)SYM_FIELD(ibcst, IBCStatusA_0, LinkTrainingState);
 
@@ -1703,9 +1704,9 @@ static void handle_serdes_issues(struct qib_pportdata *ppd, u64 ibcst)
        case IB_7322_LT_STATE_CFGWAITRMT:
        case IB_7322_LT_STATE_TXREVLANES:
        case IB_7322_LT_STATE_CFGENH:
-               tnow = get_jiffies_64();
+               tnow = jiffies;
                if (ppd->cpspec->chase_end &&
-                    time_after64(tnow, ppd->cpspec->chase_end))
+                    time_after(tnow, ppd->cpspec->chase_end))
                        disable_chase(ppd, tnow, ibclt);
                else if (!ppd->cpspec->chase_end)
                        ppd->cpspec->chase_end = tnow + QIB_CHASE_TIME;
@@ -2714,7 +2715,7 @@ static noinline void unknown_7322_gpio_intr(struct qib_devdata *dd)
                        pins >>= SYM_LSB(EXTStatus, GPIOIn);
                        if (!(pins & mask)) {
                                ++handled;
-                               qd->t_insert = get_jiffies_64();
+                               qd->t_insert = jiffies;
                                queue_work(ib_wq, &qd->work);
                        }
                }
@@ -3602,7 +3603,7 @@ static void qib_7322_config_ctxts(struct qib_devdata *dd)
        if (qib_rcvhdrcnt)
                dd->rcvhdrcnt = max(dd->cspec->rcvegrcnt, qib_rcvhdrcnt);
        else
-               dd->rcvhdrcnt = max(dd->cspec->rcvegrcnt,
+               dd->rcvhdrcnt = 2 * max(dd->cspec->rcvegrcnt,
                                    dd->num_pports > 1 ? 1024U : 2048U);
 }
 
@@ -4082,10 +4083,12 @@ static void qib_update_7322_usrhead(struct qib_ctxtdata *rcd, u64 hd,
         */
        if (hd >> IBA7322_HDRHEAD_PKTINT_SHIFT)
                adjust_rcv_timeout(rcd, npkts);
-       qib_write_ureg(rcd->dd, ur_rcvhdrhead, hd, rcd->ctxt);
-       qib_write_ureg(rcd->dd, ur_rcvhdrhead, hd, rcd->ctxt);
        if (updegr)
                qib_write_ureg(rcd->dd, ur_rcvegrindexhead, egrhd, rcd->ctxt);
+       mmiowb();
+       qib_write_ureg(rcd->dd, ur_rcvhdrhead, hd, rcd->ctxt);
+       qib_write_ureg(rcd->dd, ur_rcvhdrhead, hd, rcd->ctxt);
+       mmiowb();
 }
 
 static u32 qib_7322_hdrqempty(struct qib_ctxtdata *rcd)
@@ -4794,7 +4797,7 @@ static void qib_get_7322_faststats(unsigned long opaque)
                    (ppd->lflags & (QIBL_LINKINIT | QIBL_LINKARMED |
                                    QIBL_LINKACTIVE)) &&
                    ppd->cpspec->qdr_dfe_time &&
-                   time_after64(get_jiffies_64(), ppd->cpspec->qdr_dfe_time)) {
+                   time_is_before_jiffies(ppd->cpspec->qdr_dfe_time)) {
                        ppd->cpspec->qdr_dfe_on = 0;
 
                        qib_write_kreg_port(ppd, krp_static_adapt_dis(2),
@@ -5240,7 +5243,7 @@ static int qib_7322_ib_updown(struct qib_pportdata *ppd, int ibup, u64 ibcs)
                        /* schedule the qsfp refresh which should turn the link
                           off */
                        if (ppd->dd->flags & QIB_HAS_QSFP) {
-                               qd->t_insert = get_jiffies_64();
+                               qd->t_insert = jiffies;
                                queue_work(ib_wq, &qd->work);
                        }
                        spin_lock_irqsave(&ppd->sdma_lock, flags);
@@ -5592,7 +5595,7 @@ static void qsfp_7322_event(struct work_struct *work)
 {
        struct qib_qsfp_data *qd;
        struct qib_pportdata *ppd;
-       u64 pwrup;
+       unsigned long pwrup;
        unsigned long flags;
        int ret;
        u32 le2;
@@ -5620,8 +5623,7 @@ static void qsfp_7322_event(struct work_struct *work)
                 * to insertion.
                 */
                while (1) {
-                       u64 now = get_jiffies_64();
-                       if (time_after64(now, pwrup))
+                       if (time_is_before_jiffies(pwrup))
                                break;
                        msleep(20);
                }
@@ -7506,7 +7508,7 @@ static int serdes_7322_init_old(struct qib_pportdata *ppd)
 
 static int serdes_7322_init_new(struct qib_pportdata *ppd)
 {
-       u64 tstart;
+       unsigned long tend;
        u32 le_val, rxcaldone;
        int chan, chan_done = (1 << SERDES_CHANS) - 1;
 
@@ -7611,10 +7613,8 @@ static int serdes_7322_init_new(struct qib_pportdata *ppd)
        msleep(20);
        /*       Start Calibration */
        ibsd_wr_allchans(ppd, 4, (1 << 10), BMASK(10, 10));
-       tstart = get_jiffies_64();
-       while (chan_done &&
-              !time_after64(get_jiffies_64(),
-                       tstart + msecs_to_jiffies(500))) {
+       tend = jiffies + msecs_to_jiffies(500);
+       while (chan_done && !time_is_before_jiffies(tend)) {
                msleep(20);
                for (chan = 0; chan < SERDES_CHANS; ++chan) {
                        rxcaldone = ahb_mod(ppd->dd, IBSD(ppd->hw_pidx),
index 58b0f8ad4a2936aed396da2b10361f080d74197a..cf0cd30adc8d07667956eb1244cd2b06f9e00cf1 100644 (file)
@@ -1015,7 +1015,7 @@ static int __devinit qib_init_one(struct pci_dev *,
 #define DRIVER_LOAD_MSG "QLogic " QIB_DRV_NAME " loaded: "
 #define PFX QIB_DRV_NAME ": "
 
-static const struct pci_device_id qib_pci_tbl[] = {
+static DEFINE_PCI_DEVICE_TABLE(qib_pci_tbl) = {
        { PCI_DEVICE(PCI_VENDOR_ID_PATHSCALE, PCI_DEVICE_ID_QLOGIC_IB_6120) },
        { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_IB_7220) },
        { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_IB_7322) },
index 97a8bdf68e605267f635edf4423ccfdf366a4971..f695061d688e06ce026c312c79415f04a51aac70 100644 (file)
@@ -560,9 +560,9 @@ static int qib_tune_pcie_coalesce(struct qib_devdata *dd)
  * BIOS may not set PCIe bus-utilization parameters for best performance.
  * Check and optionally adjust them to maximize our throughput.
  */
-static int qib_pcie_caps;
+static int qib_pcie_caps = 0x51;
 module_param_named(pcie_caps, qib_pcie_caps, int, S_IRUGO);
-MODULE_PARM_DESC(pcie_caps, "Max PCIe tuning: Payload (4lsb), ReadReq (D4..7)");
+MODULE_PARM_DESC(pcie_caps, "Max PCIe tuning: Payload (0..3), ReadReq (4..7)");
 
 static int qib_tune_pcie_caps(struct qib_devdata *dd)
 {
index 46002a9417c0ac73f1b38ed709f487eeb8c9d8fa..91908f533a2b00ef01fbb90a7fa3ac6d7c96dd6f 100644 (file)
@@ -177,7 +177,7 @@ struct qib_qsfp_data {
        struct qib_pportdata *ppd;
        struct work_struct work;
        struct qib_qsfp_cache cache;
-       u64 t_insert;
+       unsigned long t_insert;
        u8 modpresent;
 };
 
index de1a4b2f33c084aee485b5ea6454702ea78455d9..ac065dd6b693b91360da99a65cef1571eb1ea679 100644 (file)
@@ -300,7 +300,7 @@ bail:
 }
 
 static void qib_sd_trimdone_monitor(struct qib_devdata *dd,
-       const char *where)
+       const char *where)
 {
        int ret, chn, baduns;
        u64 val;
index 78fbd56879d417610fc4b88dd4898741b56843d3..dae51604cfcd24f287790467892d9960884905e0 100644 (file)
@@ -150,7 +150,7 @@ static ssize_t show_status(struct qib_pportdata *ppd, char *buf)
  * For userland compatibility, these offsets must remain fixed.
  * They are strings for QIB_STATUS_*
  */
-static const char *qib_status_str[] = {
+static const char * const qib_status_str[] = {
        "Initted",
        "",
        "",
index a894762da462c73b304e9e2abc314582d84cd6ab..7b6c3bffa9d9fa0cd1090b5498bb663d1cbc5b6f 100644 (file)
@@ -913,8 +913,8 @@ static void copy_io(u32 __iomem *piobuf, struct qib_sge_state *ss,
                __raw_writel(last, piobuf);
 }
 
-static struct qib_verbs_txreq *get_txreq(struct qib_ibdev *dev,
-                                        struct qib_qp *qp, int *retp)
+static noinline struct qib_verbs_txreq *__get_txreq(struct qib_ibdev *dev,
+                                          struct qib_qp *qp)
 {
        struct qib_verbs_txreq *tx;
        unsigned long flags;
@@ -926,8 +926,9 @@ static struct qib_verbs_txreq *get_txreq(struct qib_ibdev *dev,
                struct list_head *l = dev->txreq_free.next;
 
                list_del(l);
+               spin_unlock(&dev->pending_lock);
+               spin_unlock_irqrestore(&qp->s_lock, flags);
                tx = list_entry(l, struct qib_verbs_txreq, txreq.list);
-               *retp = 0;
        } else {
                if (ib_qib_state_ops[qp->state] & QIB_PROCESS_RECV_OK &&
                    list_empty(&qp->iowait)) {
@@ -935,14 +936,33 @@ static struct qib_verbs_txreq *get_txreq(struct qib_ibdev *dev,
                        qp->s_flags |= QIB_S_WAIT_TX;
                        list_add_tail(&qp->iowait, &dev->txwait);
                }
-               tx = NULL;
                qp->s_flags &= ~QIB_S_BUSY;
-               *retp = -EBUSY;
+               spin_unlock(&dev->pending_lock);
+               spin_unlock_irqrestore(&qp->s_lock, flags);
+               tx = ERR_PTR(-EBUSY);
        }
+       return tx;
+}
 
-       spin_unlock(&dev->pending_lock);
-       spin_unlock_irqrestore(&qp->s_lock, flags);
+static inline struct qib_verbs_txreq *get_txreq(struct qib_ibdev *dev,
+                                        struct qib_qp *qp)
+{
+       struct qib_verbs_txreq *tx;
+       unsigned long flags;
 
+       spin_lock_irqsave(&dev->pending_lock, flags);
+       /* assume the list non empty */
+       if (likely(!list_empty(&dev->txreq_free))) {
+               struct list_head *l = dev->txreq_free.next;
+
+               list_del(l);
+               spin_unlock_irqrestore(&dev->pending_lock, flags);
+               tx = list_entry(l, struct qib_verbs_txreq, txreq.list);
+       } else {
+               /* call slow path to get the extra lock */
+               spin_unlock_irqrestore(&dev->pending_lock, flags);
+               tx =  __get_txreq(dev, qp);
+       }
        return tx;
 }
 
@@ -1122,9 +1142,9 @@ static int qib_verbs_send_dma(struct qib_qp *qp, struct qib_ib_header *hdr,
                goto bail;
        }
 
-       tx = get_txreq(dev, qp, &ret);
-       if (!tx)
-               goto bail;
+       tx = get_txreq(dev, qp);
+       if (IS_ERR(tx))
+               goto bail_tx;
 
        control = dd->f_setpbc_control(ppd, plen, qp->s_srate,
                                       be16_to_cpu(hdr->lrh[0]) >> 12);
@@ -1195,6 +1215,9 @@ unaligned:
        ibp->n_unaligned++;
 bail:
        return ret;
+bail_tx:
+       ret = PTR_ERR(tx);
+       goto bail;
 }
 
 /*
This page took 0.037763 seconds and 5 git commands to generate.