hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/infiniband/sw/rxe/rxe_queue.c
....@@ -1,34 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
12 /*
23 * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved.
34 * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved.
4
- *
5
- * This software is available to you under a choice of one of two
6
- * licenses. You may choose to be licensed under the terms of the GNU
7
- * General Public License (GPL) Version 2, available from the file
8
- * COPYING in the main directory of this source tree, or the
9
- * OpenIB.org BSD license below:
10
- *
11
- * Redistribution and use in source and binary forms, with or
12
- * without modification, are permitted provided that the following
13
- * conditions are met:
14
- *
15
- * - Redistributions of source code must retain the above
16
- * copyright notice, this list of conditions and the following
17
- * disclaimer.
18
- *
19
- * - Redistributions in binary form must retailuce the above
20
- * copyright notice, this list of conditions and the following
21
- * disclaimer in the documentation and/or other materials
22
- * provided with the distribution.
23
- *
24
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
- * SOFTWARE.
325 */
336
347 #include <linux/vmalloc.h>
....@@ -36,24 +9,24 @@
369 #include "rxe_loc.h"
3710 #include "rxe_queue.h"
3811
39
-int do_mmap_info(struct rxe_dev *rxe,
40
- struct mminfo __user *outbuf,
41
- struct ib_ucontext *context,
42
- struct rxe_queue_buf *buf,
43
- size_t buf_size,
44
- struct rxe_mmap_info **ip_p)
12
+int do_mmap_info(struct rxe_dev *rxe, struct mminfo __user *outbuf,
13
+ struct ib_udata *udata, struct rxe_queue_buf *buf,
14
+ size_t buf_size, struct rxe_mmap_info **ip_p)
4515 {
4616 int err;
4717 struct rxe_mmap_info *ip = NULL;
4818
4919 if (outbuf) {
50
- ip = rxe_create_mmap_info(rxe, buf_size, context, buf);
51
- if (!ip)
20
+ ip = rxe_create_mmap_info(rxe, buf_size, udata, buf);
21
+ if (IS_ERR(ip)) {
22
+ err = PTR_ERR(ip);
5223 goto err1;
24
+ }
5325
54
- err = copy_to_user(outbuf, &ip->info, sizeof(ip->info));
55
- if (err)
26
+ if (copy_to_user(outbuf, &ip->info, sizeof(ip->info))) {
27
+ err = -EFAULT;
5628 goto err2;
29
+ }
5730
5831 spin_lock_bh(&rxe->pending_lock);
5932 list_add(&ip->pending_mmaps, &rxe->pending_mmaps);
....@@ -67,7 +40,7 @@
6740 err2:
6841 kfree(ip);
6942 err1:
70
- return -EINVAL;
43
+ return err;
7144 }
7245
7346 inline void rxe_queue_reset(struct rxe_queue *q)
....@@ -153,12 +126,9 @@
153126 return 0;
154127 }
155128
156
-int rxe_queue_resize(struct rxe_queue *q,
157
- unsigned int *num_elem_p,
158
- unsigned int elem_size,
159
- struct ib_ucontext *context,
160
- struct mminfo __user *outbuf,
161
- spinlock_t *producer_lock,
129
+int rxe_queue_resize(struct rxe_queue *q, unsigned int *num_elem_p,
130
+ unsigned int elem_size, struct ib_udata *udata,
131
+ struct mminfo __user *outbuf, spinlock_t *producer_lock,
162132 spinlock_t *consumer_lock)
163133 {
164134 struct rxe_queue *new_q;
....@@ -170,7 +140,7 @@
170140 if (!new_q)
171141 return -ENOMEM;
172142
173
- err = do_mmap_info(new_q->rxe, outbuf, context, new_q->buf,
143
+ err = do_mmap_info(new_q->rxe, outbuf, udata, new_q->buf,
174144 new_q->buf_size, &new_q->ip);
175145 if (err) {
176146 vfree(new_q->buf);