hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/infiniband/sw/rdmavt/mmap.c
....@@ -48,7 +48,7 @@
4848 #include <linux/slab.h>
4949 #include <linux/vmalloc.h>
5050 #include <linux/mm.h>
51
-#include <asm/pgtable.h>
51
+#include <rdma/uverbs_ioctl.h>
5252 #include "mmap.h"
5353
5454 /**
....@@ -150,21 +150,22 @@
150150 * rvt_create_mmap_info - allocate information for hfi1_mmap
151151 * @rdi: rvt dev struct
152152 * @size: size in bytes to map
153
- * @context: user context
153
+ * @udata: user data (must be valid!)
154154 * @obj: opaque pointer to a cq, wq etc
155155 *
156
- * Return: rvt_mmap struct on success
156
+ * Return: rvt_mmap struct on success, ERR_PTR on failure
157157 */
158
-struct rvt_mmap_info *rvt_create_mmap_info(struct rvt_dev_info *rdi,
159
- u32 size,
160
- struct ib_ucontext *context,
161
- void *obj)
158
+struct rvt_mmap_info *rvt_create_mmap_info(struct rvt_dev_info *rdi, u32 size,
159
+ struct ib_udata *udata, void *obj)
162160 {
163161 struct rvt_mmap_info *ip;
164162
163
+ if (!udata)
164
+ return ERR_PTR(-EINVAL);
165
+
165166 ip = kmalloc_node(sizeof(*ip), GFP_KERNEL, rdi->dparms.node);
166167 if (!ip)
167
- return ip;
168
+ return ERR_PTR(-ENOMEM);
168169
169170 size = PAGE_ALIGN(size);
170171
....@@ -177,7 +178,9 @@
177178
178179 INIT_LIST_HEAD(&ip->pending_mmaps);
179180 ip->size = size;
180
- ip->context = context;
181
+ ip->context =
182
+ container_of(udata, struct uverbs_attr_bundle, driver_udata)
183
+ ->context;
181184 ip->obj = obj;
182185 kref_init(&ip->ref);
183186