Skip to contentSkip to conversation

Patch: Support for Xeon Phi

PATCH Bryce Lelbach 2 participants 2 messages May 24, 2013 1 message not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

The attached patch modifies the kernel Infiniband drivers to support the Xeon Phi co-processor.

This patch is a modified version of a patch from Intel's MPSS framework (specifically, from the "KNC_gold_update_1-2.1.4982-15-rhel-6.3" package), which will apply to a 3.7.8 kernel (I am about to try it on a 3.8 kernel). To the best of my knowledge, newer RHEL kernels are shipped with this patch.

Signature · 11 lines
Bryce Adelstein-Lelbach aka wash
STE||AR Group, Center for Computation and Technology, LSU
--
225-317-3866 - iPhone
225-578-6182 - Work (no voicemail)
--
stellar.cct.lsu.edu
boost-spirit.com
llvm.linuxfoundation.org
cppnow.org
--
drivers/infiniband/core/sysfs.c +1 -0
diff -u -r -N linux-source-3.7/drivers/infiniband/core/sysfs.c linux-source-3.7-xeon-phi/drivers/infiniband/core/sysfs.c
@@ -610,6 +610,7 @@
 	case RDMA_NODE_RNIC:	  return sprintf(buf, "%d: RNIC\n", dev->node_type);
 	case RDMA_NODE_IB_SWITCH: return sprintf(buf, "%d: switch\n", dev->node_type);
 	case RDMA_NODE_IB_ROUTER: return sprintf(buf, "%d: router\n", dev->node_type);
+	case RDMA_NODE_MIC:	  return sprintf(buf, "%d: MIC\n", dev->node_type);
 	default:		  return sprintf(buf, "%d: <unknown>\n", dev->node_type);
 	}
 }
drivers/infiniband/core/umem.c +39 -6

76 lines not on this page · raw message

drivers/infiniband/core/uverbs_cmd.c +17 -0
diff -u -r -N linux-source-3.7/drivers/infiniband/core/uverbs_cmd.c linux-source-3.7-xeon-phi/drivers/infiniband/core/uverbs_cmd.c
@@ -54,8 +54,24 @@
 static struct uverbs_lock_class srq_lock_class	= { .name = "SRQ-uobj" };
 static struct uverbs_lock_class xrcd_lock_class = { .name = "XRCD-uobj" };
 
+static int uverbs_copy_from_udata(void *dest, struct ib_udata *udata, size_t len)
+{
+	return copy_from_user(dest, udata->inbuf, len) ? -EFAULT : 0;
+}
+
+static int uverbs_copy_to_udata(struct ib_udata *udata, void *src, size_t len)
+{
+	return copy_to_user(udata->outbuf, src, len) ? -EFAULT : 0;
+}
+
+static struct ib_udata_ops uverbs_copy = {
+	.copy_from = uverbs_copy_from_udata,
+	.copy_to   = uverbs_copy_to_udata
+};
+
 #define INIT_UDATA(udata, ibuf, obuf, ilen, olen)			\
 	do {								\
+		(udata)->ops    = &uverbs_copy;				\
 		(udata)->inbuf  = (void __user *) (ibuf);		\
 		(udata)->outbuf = (void __user *) (obuf);		\
 		(udata)->inlen  = (ilen);				\
@@ -321,6 +337,7 @@
 		goto err;
 	}
 
+	ucontext->umem_ops = NULL;
 	ucontext->device = ibdev;
 	INIT_LIST_HEAD(&ucontext->pd_list);
 	INIT_LIST_HEAD(&ucontext->mr_list);
drivers/infiniband/core/verbs.c +2 -0
diff -u -r -N linux-source-3.7/drivers/infiniband/core/verbs.c linux-source-3.7-xeon-phi/drivers/infiniband/core/verbs.c
@@ -114,6 +114,8 @@
 		return RDMA_TRANSPORT_IB;
 	case RDMA_NODE_RNIC:
 		return RDMA_TRANSPORT_IWARP;
+	case RDMA_NODE_MIC:
+		return RDMA_TRANSPORT_SCIF;
 	default:
 		BUG();
 		return 0;
drivers/infiniband/hw/mthca/mthca_memfree.c +58 -2

125 lines not on this page · raw message

include/rdma/ib_verbs.h +31 -8
diff -u -r -N linux-source-3.7/include/rdma/ib_verbs.h linux-source-3.7-xeon-phi/include/rdma/ib_verbs.h
@@ -67,12 +67,14 @@
 	RDMA_NODE_IB_CA 	= 1,
 	RDMA_NODE_IB_SWITCH,
 	RDMA_NODE_IB_ROUTER,
-	RDMA_NODE_RNIC
+	RDMA_NODE_RNIC,
+	RDMA_NODE_MIC
 };
 
 enum rdma_transport_type {
 	RDMA_TRANSPORT_IB,
-	RDMA_TRANSPORT_IWARP
+	RDMA_TRANSPORT_IWARP,
+	RDMA_TRANSPORT_SCIF
 };
 
 enum rdma_transport_type
@@ -82,6 +84,7 @@
 	IB_LINK_LAYER_UNSPECIFIED,
 	IB_LINK_LAYER_INFINIBAND,
 	IB_LINK_LAYER_ETHERNET,
+	IB_LINK_LAYER_SCIF
 };
 
 enum ib_device_cap_flags {
@@ -877,7 +880,18 @@
 	u8	page_shift;
 };
 
+struct ib_ucontext;
+struct ib_umem_ops {
+	struct ib_umem	     *(*get)(struct ib_ucontext *context,
+				     unsigned long addr, size_t size,
+				     int access, int dmasync);
+	void		      (*release)(struct ib_umem *umem);
+	int		      (*page_count)(struct ib_umem *umem);
+};
+
 struct ib_ucontext {
+	struct ib_umem_ops     *umem_ops;	/* set to NULL for default ops */
+	void		       *umem_private_data;
 	struct ib_device       *device;
 	struct list_head	pd_list;
 	struct list_head	mr_list;
@@ -901,11 +915,20 @@
 	int			live;
 };
 
+struct ib_udata;
+struct ib_udata_ops {
+	int		      (*copy_from)(void *dest, struct ib_udata *udata,
+					    size_t len);
+	int		      (*copy_to)(struct ib_udata *udata, void *src,
+					  size_t len);
+};
+
 struct ib_udata {
-	void __user *inbuf;
-	void __user *outbuf;
-	size_t       inlen;
-	size_t       outlen;
+	struct ib_udata_ops    *ops;
+	void __user	       *inbuf;
+	void __user	       *outbuf;
+	size_t			inlen;
+	size_t			outlen;
 };
 
 struct ib_pd {
@@ -1281,12 +1304,12 @@
 
 static inline int ib_copy_from_udata(void *dest, struct ib_udata *udata, size_t len)
 {
-	return copy_from_user(dest, udata->inbuf, len) ? -EFAULT : 0;
+	return udata->ops->copy_from(dest, udata, len);
 }
 
 static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len)
 {
-	return copy_to_user(udata->outbuf, src, len) ? -EFAULT : 0;
+	return udata->ops->copy_to(udata, src, len);
 }
 
 /**

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 7 lines · Bryce Lelbach

The attached patch modifies the kernel Infiniband drivers to support the Xeon Phi co-processor.

This patch is a modified version of a patch from Intel's MPSS framework (specifically, from the "KNC_gold_update_1-2.1.4982-15-rhel-6.3" package), which will apply to a 3.7.8 kernel (I am about to try it on a 3.8 kernel). To the best of my knowledge, newer RHEL kernels are shipped with this patch.

Please have a look at https://www.kernel.org/doc/Documentation/SubmittingPatches and please fix at least the whitespace errors in your patch. This is what checkpatch reports for your patch:

WARNING: line over 80 characters
#8: FILE: drivers/infiniband/core/sysfs.c:613:
+ case RDMA_NODE_MIC: return sprintf(buf, "%d: MIC\n", dev->node_type);

WARNING: line over 80 characters
#103: FILE: drivers/infiniband/core/uverbs_cmd.c:57:
+static int uverbs_copy_from_udata(void *dest, struct ib_udata *udata, size_t len)

WARNING: Avoid CamelCase: <mthca_MAP_ICM_page> #202: FILE: drivers/infiniband/hw/mthca/mthca_memfree.c:503:
+ ret = mthca_MAP_ICM_page(dev, sg_dma_address(&chunk->page_list[0]),

WARNING: suspect code indent for conditional statements (8, 7) #213: FILE: drivers/infiniband/hw/mthca/mthca_memfree.c:523:
if (ret) {
[...]
+ ib_umem_release(db_tab->page[i].umem);

WARNING: please, no spaces at the start of a line #215: FILE: drivers/infiniband/hw/mthca/mthca_memfree.c:525:
+ ib_umem_release(db_tab->page[i].umem);$

WARNING: Avoid CamelCase: <mthca_UNMAP_ICM>
#238: FILE: drivers/infiniband/hw/mthca/mthca_memfree.c:555:
+ mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, uar, i), 1);

ERROR: code indent should use tabs where possible #272: FILE: drivers/infiniband/hw/mthca/mthca_memfree.c:611:
+ ib_umem_release(db_tab->page[i].umem);$

WARNING: please, no spaces at the start of a line #272: FILE: drivers/infiniband/hw/mthca/mthca_memfree.c:611:
+ ib_umem_release(db_tab->page[i].umem);$

WARNING: line over 80 characters
#322: FILE: include/rdma/ib_verbs.h:893:
+ struct ib_umem_ops *umem_ops; /* set to NULL for default ops */

ERROR: Missing Signed-off-by: line(s)

total: 2 errors, 8 warnings, 326 lines checked

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html