aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2008-04-29 16:46:53 -0400
committerRoland Dreier <rolandd@cisco.com>2008-04-29 16:46:53 -0400
commitbaaad380c0aa955f7d62e846467316c94067f1a5 (patch)
tree12c85eebd88793ddf7cb0643063ff93c8755dfae /drivers/infiniband/hw
parent0bfe151cc4049f3f304adf28b37ea5437d02ad96 (diff)
IB/mthca: Avoid changing userspace ABI to handle DMA write barrier attribute
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>
Diffstat (limited to 'drivers/infiniband/hw')
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.c14
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.h1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_user.h10
3 files changed, 20 insertions, 5 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index 2a9f460cf061..be34f99ca625 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -39,6 +39,8 @@
39#include <rdma/ib_smi.h> 39#include <rdma/ib_smi.h>
40#include <rdma/ib_umem.h> 40#include <rdma/ib_umem.h>
41#include <rdma/ib_user_verbs.h> 41#include <rdma/ib_user_verbs.h>
42
43#include <linux/sched.h>
42#include <linux/mm.h> 44#include <linux/mm.h>
43 45
44#include "mthca_dev.h" 46#include "mthca_dev.h"
@@ -367,6 +369,8 @@ static struct ib_ucontext *mthca_alloc_ucontext(struct ib_device *ibdev,
367 return ERR_PTR(-EFAULT); 369 return ERR_PTR(-EFAULT);
368 } 370 }
369 371
372 context->reg_mr_warned = 0;
373
370 return &context->ibucontext; 374 return &context->ibucontext;
371} 375}
372 376
@@ -1013,7 +1017,15 @@ static struct ib_mr *mthca_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
1013 int err = 0; 1017 int err = 0;
1014 int write_mtt_size; 1018 int write_mtt_size;
1015 1019
1016 if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) 1020 if (udata->inlen - sizeof (struct ib_uverbs_cmd_hdr) < sizeof ucmd) {
1021 if (!to_mucontext(pd->uobject->context)->reg_mr_warned) {
1022 mthca_warn(dev, "Process '%s' did not pass in MR attrs.\n",
1023 current->comm);
1024 mthca_warn(dev, " Update libmthca to fix this.\n");
1025 }
1026 ++to_mucontext(pd->uobject->context)->reg_mr_warned;
1027 ucmd.mr_attrs = 0;
1028 } else if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd))
1017 return ERR_PTR(-EFAULT); 1029 return ERR_PTR(-EFAULT);
1018 1030
1019 mr = kmalloc(sizeof *mr, GFP_KERNEL); 1031 mr = kmalloc(sizeof *mr, GFP_KERNEL);
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.h b/drivers/infiniband/hw/mthca/mthca_provider.h
index 262616c8ebb6..934bf9544037 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.h
+++ b/drivers/infiniband/hw/mthca/mthca_provider.h
@@ -67,6 +67,7 @@ struct mthca_ucontext {
67 struct ib_ucontext ibucontext; 67 struct ib_ucontext ibucontext;
68 struct mthca_uar uar; 68 struct mthca_uar uar;
69 struct mthca_user_db_table *db_tab; 69 struct mthca_user_db_table *db_tab;
70 int reg_mr_warned;
70}; 71};
71 72
72struct mthca_mtt; 73struct mthca_mtt;
diff --git a/drivers/infiniband/hw/mthca/mthca_user.h b/drivers/infiniband/hw/mthca/mthca_user.h
index f8cb3b664d37..e1262c942db8 100644
--- a/drivers/infiniband/hw/mthca/mthca_user.h
+++ b/drivers/infiniband/hw/mthca/mthca_user.h
@@ -41,7 +41,7 @@
41 * Increment this value if any changes that break userspace ABI 41 * Increment this value if any changes that break userspace ABI
42 * compatibility are made. 42 * compatibility are made.
43 */ 43 */
44#define MTHCA_UVERBS_ABI_VERSION 2 44#define MTHCA_UVERBS_ABI_VERSION 1
45 45
46/* 46/*
47 * Make sure that all structs defined in this file remain laid out so 47 * Make sure that all structs defined in this file remain laid out so
@@ -62,10 +62,12 @@ struct mthca_alloc_pd_resp {
62}; 62};
63 63
64struct mthca_reg_mr { 64struct mthca_reg_mr {
65/*
66 * Mark the memory region with a DMA attribute that causes
67 * in-flight DMA to be flushed when the region is written to:
68 */
69#define MTHCA_MR_DMASYNC 0x1
65 __u32 mr_attrs; 70 __u32 mr_attrs;
66#define MTHCA_MR_DMASYNC 0x1
67/* mark the memory region with a DMA attribute that causes
68 * in-flight DMA to be flushed when the region is written to */
69 __u32 reserved; 71 __u32 reserved;
70}; 72};
71 73