All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roland Dreier <rdreier@cisco.com>
To: akepner@sgi.com
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Tony Luck <tony.luck@intel.com>,
	Jesse Barnes <jbarnes@virtuousgeek.org>,
	Jes Sorensen <jes@sgi.com>,
	Randy Dunlap <randy.dunlap@oracle.com>,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	David Miller <davem@davemloft.net>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Grant Grundler <grundler@parisc-linux.org>,
	Michael Ellerman <michael@ellerman.id.au>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3 v6] IB: expand ib_umem_get() prototype
Date: Tue, 08 Apr 2008 12:40:21 -0700	[thread overview]
Message-ID: <adar6dgm8yi.fsf@cisco.com> (raw)
In-Reply-To: <20080401013744.GE29410@sgi.com> (akepner@sgi.com's message of "Mon, 31 Mar 2008 18:37:44 -0700")

All of this looks good to me, and I'm happy we are finally fixing this
up.  However, now that it is finally ready to merge, I started thinking
about the libmthca changes required to handle this, and I realized that
we can actually avoid this:

 > --- a/drivers/infiniband/hw/mthca/mthca_user.h
 > +++ b/drivers/infiniband/hw/mthca/mthca_user.h
 > @@ -41,7 +41,7 @@
 >   * Increment this value if any changes that break userspace ABI
 >   * compatibility are made.
 >   */
 > -#define MTHCA_UVERBS_ABI_VERSION	1
 > +#define MTHCA_UVERBS_ABI_VERSION	2

Instead the mthca kernel driver can look at the size of the data passed
in from userspace, and fall back to the old behavior if it's talking to
old userspace.

I think this is a net win.  The current patch gives the following:

 old kernel, old userspace: current behavior (subtle failure on Altix)
 new kernel, old userspace: refuses to run (on all systems)
 old kernel, new userspace: current behavior (broken on Altix),
 new kernel, new userspace: works everywhere

with my proposed change, the only difference is:

 new kernel, old userspace: current behavior (subtle failure on Altix),
                            plus print a warning telling people to
                            update userspace.

and given that the vast majority of the systems where mthca is used are
*not* Altix systems, it seems more friendly to leave them working across
a kernel update.

Andrew: if Arthur agrees with this, please roll the patch below into the
current IB patch you have as part of the dma attrs series.

Thanks,
  Roland

diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index ca5bab0..d2e1429 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -367,6 +367,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 +1015,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 ucm) {
+		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);
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.h b/drivers/infiniband/hw/mthca/mthca_provider.h
index 262616c..934bf95 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.h
+++ b/drivers/infiniband/hw/mthca/mthca_provider.h
@@ -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;
diff --git a/drivers/infiniband/hw/mthca/mthca_user.h b/drivers/infiniband/hw/mthca/mthca_user.h
index f8cb3b6..e1262c9 100644
--- a/drivers/infiniband/hw/mthca/mthca_user.h
+++ b/drivers/infiniband/hw/mthca/mthca_user.h
@@ -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;
 };
 

  reply	other threads:[~2008-04-08 19:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-01  1:37 [PATCH 3/3 v6] IB: expand ib_umem_get() prototype akepner
2008-04-08 19:40 ` Roland Dreier [this message]
2008-04-08 21:29   ` akepner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=adar6dgm8yi.fsf@cisco.com \
    --to=rdreier@cisco.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=akepner@sgi.com \
    --cc=akpm@linux-foundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=davem@davemloft.net \
    --cc=grundler@parisc-linux.org \
    --cc=jbarnes@virtuousgeek.org \
    --cc=jes@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael@ellerman.id.au \
    --cc=randy.dunlap@oracle.com \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.