IB/ehca: Serialize hypervisor calls in ehca_register_mr()
authorStefan Roscher <stefan.roscher@de.ibm.com>
Wed, 9 May 2007 11:47:56 +0000 (13:47 +0200)
committerRoland Dreier <rolandd@cisco.com>
Mon, 14 May 2007 20:38:11 +0000 (13:38 -0700)
Some pSeries hypervisor versions show a race condition in the allocate
MR hCall.  Serialize this call per adapter to circumvent this problem.

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_main.c
drivers/infiniband/hw/ehca/hcp_if.c

index f64d42b08674a9f60fad0aa2635e9f585b747b57..1d286d3cc2d5b05aa357e5ebd87015cace5a6bce 100644 (file)
@@ -277,6 +277,7 @@ 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 fe90e7454560c98884f91e184dcd0e5284db127e..b917cc130e486fae7659be573bdf0287cd7f0890 100644 (file)
@@ -98,6 +98,7 @@ MODULE_PARM_DESC(scaling_code,
 
 spinlock_t ehca_qp_idr_lock;
 spinlock_t ehca_cq_idr_lock;
+spinlock_t hcall_lock;
 DEFINE_IDR(ehca_qp_idr);
 DEFINE_IDR(ehca_cq_idr);
 
@@ -817,6 +818,7 @@ int __init ehca_module_init(void)
        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);
index b564fcd3b282a2924b9b9a40242e36f83c7b830f..7f0beec74f7006e76fff3e3ee07e81aecbfa9bc0 100644 (file)
@@ -154,7 +154,8 @@ static long ehca_plpar_hcall9(unsigned long opcode,
                              unsigned long arg9)
 {
        long ret;
-       int i, sleep_msecs;
+       int i, sleep_msecs, lock_is_set = 0;
+       unsigned long flags;
 
        ehca_gen_dbg("opcode=%lx arg1=%lx arg2=%lx arg3=%lx arg4=%lx "
                     "arg5=%lx arg6=%lx arg7=%lx arg8=%lx arg9=%lx",
@@ -162,10 +163,18 @@ static long ehca_plpar_hcall9(unsigned long opcode,
                     arg8, arg9);
 
        for (i = 0; i < 5; i++) {
+               if ((opcode == H_ALLOC_RESOURCE) && (arg2 == 5)) {
+                       spin_lock_irqsave(&hcall_lock, flags);
+                       lock_is_set = 1;
+               }
+
                ret = plpar_hcall9(opcode, outs,
                                   arg1, arg2, arg3, arg4, arg5,
                                   arg6, arg7, arg8, arg9);
 
+               if (lock_is_set)
+                       spin_unlock_irqrestore(&hcall_lock, flags);
+
                if (H_IS_LONG_BUSY(ret)) {
                        sleep_msecs = get_longbusy_msecs(ret);
                        msleep_interruptible(sleep_msecs);
@@ -193,11 +202,11 @@ static long ehca_plpar_hcall9(unsigned long opcode,
                             opcode, ret, outs[0], outs[1], outs[2], outs[3],
                             outs[4], outs[5], outs[6], outs[7], outs[8]);
                return ret;
-
        }
 
        return H_BUSY;
 }
+
 u64 hipz_h_alloc_resource_eq(const struct ipz_adapter_handle adapter_handle,
                             struct ehca_pfeq *pfeq,
                             const u32 neq_control,