]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
IB/mthca: Avoid changing userspace ABI to handle DMA write barrier attribute
authorRoland Dreier <rolandd@cisco.com>
Tue, 29 Apr 2008 20:46:53 +0000 (13:46 -0700)
committerRoland Dreier <rolandd@cisco.com>
Tue, 29 Apr 2008 20:46:53 +0000 (13:46 -0700)
Commit cb9fbc5c ("IB: expand ib_umem_get() prototype") changed the
mthca userspace ABI to provide a way for userspace to indicate which
memory regions need the DMA write barrier attribute.  However, it is
possible to handle this without breaking existing userspace, by having
the mthca kernel driver recognize whether it is talking to old or new
userspace, depending on the size of the register MR structure passed in.

The only potential drawback of this is that is allows old userspace
(which has a bug with DMA ordering on large SGI Altix systems) to
continue to run on new kernels, but the advantage of allowing old
userspace to continue to work on unaffected systems seems to outweigh
this, and we can print a warning to push people to upgrade their
userspace.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/hw/mthca/mthca_provider.c
drivers/infiniband/hw/mthca/mthca_provider.h
drivers/infiniband/hw/mthca/mthca_user.h

index 2a9f460cf06137665d0cfee18b2e15660db192a6..be34f99ca62579b916970d5387110b370b99602d 100644 (file)
@@ -39,6 +39,8 @@
 #include <rdma/ib_smi.h>
 #include <rdma/ib_umem.h>
 #include <rdma/ib_user_verbs.h>
+
+#include <linux/sched.h>
 #include <linux/mm.h>
 
 #include "mthca_dev.h"
@@ -367,6 +369,8 @@ static struct ib_ucontext *mthca_alloc_ucontext(struct ib_device *ibdev,
                return ERR_PTR(-EFAULT);
        }
 
+       context->reg_mr_warned = 0;
+
        return &context->ibucontext;
 }
 
@@ -1013,7 +1017,15 @@ static struct ib_mr *mthca_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
        int err = 0;
        int write_mtt_size;
 
-       if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd))
+       if (udata->inlen - sizeof (struct ib_uverbs_cmd_hdr) < sizeof ucmd) {
+               if (!to_mucontext(pd->uobject->context)->reg_mr_warned) {
+                       mthca_warn(dev, "Process '%s' did not pass in MR attrs.\n",
+                                  current->comm);
+                       mthca_warn(dev, "  Update libmthca to fix this.\n");
+               }
+               ++to_mucontext(pd->uobject->context)->reg_mr_warned;
+               ucmd.mr_attrs = 0;
+       } else if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd))
                return ERR_PTR(-EFAULT);
 
        mr = kmalloc(sizeof *mr, GFP_KERNEL);
index 262616c8ebb644d75ab603e5ce12b5f668baa5ac..934bf9544037c582aaeb60754d78ad534aef618c 100644 (file)
@@ -67,6 +67,7 @@ struct mthca_ucontext {
        struct ib_ucontext          ibucontext;
        struct mthca_uar            uar;
        struct mthca_user_db_table *db_tab;
+       int                         reg_mr_warned;
 };
 
 struct mthca_mtt;
index f8cb3b664d377b37b0955347cfdbc4c32bcd8e14..e1262c942db8c6ae31c91ec5b006454e239b2331 100644 (file)
@@ -41,7 +41,7 @@
  * Increment this value if any changes that break userspace ABI
  * compatibility are made.
  */
-#define MTHCA_UVERBS_ABI_VERSION       2
+#define MTHCA_UVERBS_ABI_VERSION       1
 
 /*
  * Make sure that all structs defined in this file remain laid out so
@@ -62,10 +62,12 @@ struct mthca_alloc_pd_resp {
 };
 
 struct mthca_reg_mr {
+/*
+ * Mark the memory region with a DMA attribute that causes
+ * in-flight DMA to be flushed when the region is written to:
+ */
+#define MTHCA_MR_DMASYNC       0x1
        __u32 mr_attrs;
-#define MTHCA_MR_DMASYNC 0x1
-/* mark the memory region with a DMA attribute that causes
- * in-flight DMA to be flushed when the region is written to */
        __u32 reserved;
 };