Re: [PATCH 5/5] mthca: allow setting "dmabarrier" on user-allocated memory
On Wed, Oct 03, 2007 at 05:56:45AM +0300, Heikki Orsila wrote: > On Tue, Oct 02, 2007 at 07:50:07PM -0700, [EMAIL PROTECTED] wrote: > > +struct mthca_reg_mr { > > + __u32 mr_attrs; > > +#define MTHCA_MR_DMAFLUSH 0x1 /* flush in-flight DMA on a write to > > +* memory region */ > > + __u32 reserved; > > +}; > > Seems like a very odd place to #define something new.. > Lots of drivers do that - #define flags or whatever near the variable to which they apply. Didn't see any examples in the mthca driver though, so maybe it's setting a precedent there. If the maintainer objects, I'll move it. -- Arthur - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 5/5] mthca: allow setting dmabarrier on user-allocated memory
On Wed, Oct 03, 2007 at 05:56:45AM +0300, Heikki Orsila wrote: On Tue, Oct 02, 2007 at 07:50:07PM -0700, [EMAIL PROTECTED] wrote: +struct mthca_reg_mr { + __u32 mr_attrs; +#define MTHCA_MR_DMAFLUSH 0x1 /* flush in-flight DMA on a write to +* memory region */ + __u32 reserved; +}; Seems like a very odd place to #define something new.. Lots of drivers do that - #define flags or whatever near the variable to which they apply. Didn't see any examples in the mthca driver though, so maybe it's setting a precedent there. If the maintainer objects, I'll move it. -- Arthur - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 5/5] mthca: allow setting "dmabarrier" on user-allocated memory
On Tue, Oct 02, 2007 at 07:50:07PM -0700, [EMAIL PROTECTED] wrote: > +struct mthca_reg_mr { > + __u32 mr_attrs; > +#define MTHCA_MR_DMAFLUSH 0x1/* flush in-flight DMA on a write to > + * memory region */ > + __u32 reserved; > +}; Seems like a very odd place to #define something new.. -- Heikki Orsila Barbie's law: [EMAIL PROTECTED] "Math is hard, let's go shopping!" http://www.iki.fi/shd - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 5/5] mthca: allow setting "dmabarrier" on user-allocated memory
Allow setting a "dmabarrier" when the mthca driver registers user- allocated memory. Signed-off-by: Arthur Kepner <[EMAIL PROTECTED]> --- mthca_provider.c |7 ++- mthca_user.h | 10 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index 17486a4..c818708 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c @@ -1017,17 +1017,22 @@ static struct ib_mr *mthca_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, struct mthca_dev *dev = to_mdev(pd->device); struct ib_umem_chunk *chunk; struct mthca_mr *mr; + struct mthca_reg_mr ucmd; u64 *pages; int shift, n, len; int i, j, k; int err = 0; int write_mtt_size; + if (ib_copy_from_udata(, udata, sizeof ucmd)) + return ERR_PTR(-EFAULT); + mr = kmalloc(sizeof *mr, GFP_KERNEL); if (!mr) return ERR_PTR(-ENOMEM); - mr->umem = ib_umem_get(pd->uobject->context, start, length, acc, 0); + mr->umem = ib_umem_get(pd->uobject->context, start, length, acc, + ucmd.mr_attrs & MTHCA_MR_DMAFLUSH); if (IS_ERR(mr->umem)) { err = PTR_ERR(mr->umem); goto err; diff --git a/drivers/infiniband/hw/mthca/mthca_user.h b/drivers/infiniband/hw/mthca/mthca_user.h index 02cc0a7..5662aea 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 1 +#define MTHCA_UVERBS_ABI_VERSION 2 /* * Make sure that all structs defined in this file remain laid out so @@ -61,6 +61,14 @@ struct mthca_alloc_pd_resp { __u32 reserved; }; +struct mthca_reg_mr { + __u32 mr_attrs; +#define MTHCA_MR_DMAFLUSH 0x1 /* flush in-flight DMA on a write to +* memory region */ + __u32 reserved; +}; + + struct mthca_create_cq { __u32 lkey; __u32 pdn; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 5/5] mthca: allow setting dmabarrier on user-allocated memory
Allow setting a dmabarrier when the mthca driver registers user- allocated memory. Signed-off-by: Arthur Kepner [EMAIL PROTECTED] --- mthca_provider.c |7 ++- mthca_user.h | 10 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index 17486a4..c818708 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c @@ -1017,17 +1017,22 @@ static struct ib_mr *mthca_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, struct mthca_dev *dev = to_mdev(pd-device); struct ib_umem_chunk *chunk; struct mthca_mr *mr; + struct mthca_reg_mr ucmd; u64 *pages; int shift, n, len; int i, j, k; int err = 0; int write_mtt_size; + if (ib_copy_from_udata(ucmd, udata, sizeof ucmd)) + return ERR_PTR(-EFAULT); + mr = kmalloc(sizeof *mr, GFP_KERNEL); if (!mr) return ERR_PTR(-ENOMEM); - mr-umem = ib_umem_get(pd-uobject-context, start, length, acc, 0); + mr-umem = ib_umem_get(pd-uobject-context, start, length, acc, + ucmd.mr_attrs MTHCA_MR_DMAFLUSH); if (IS_ERR(mr-umem)) { err = PTR_ERR(mr-umem); goto err; diff --git a/drivers/infiniband/hw/mthca/mthca_user.h b/drivers/infiniband/hw/mthca/mthca_user.h index 02cc0a7..5662aea 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 1 +#define MTHCA_UVERBS_ABI_VERSION 2 /* * Make sure that all structs defined in this file remain laid out so @@ -61,6 +61,14 @@ struct mthca_alloc_pd_resp { __u32 reserved; }; +struct mthca_reg_mr { + __u32 mr_attrs; +#define MTHCA_MR_DMAFLUSH 0x1 /* flush in-flight DMA on a write to +* memory region */ + __u32 reserved; +}; + + struct mthca_create_cq { __u32 lkey; __u32 pdn; - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 5/5] mthca: allow setting dmabarrier on user-allocated memory
On Tue, Oct 02, 2007 at 07:50:07PM -0700, [EMAIL PROTECTED] wrote: +struct mthca_reg_mr { + __u32 mr_attrs; +#define MTHCA_MR_DMAFLUSH 0x1/* flush in-flight DMA on a write to + * memory region */ + __u32 reserved; +}; Seems like a very odd place to #define something new.. -- Heikki Orsila Barbie's law: [EMAIL PROTECTED] Math is hard, let's go shopping! http://www.iki.fi/shd - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/