hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/infiniband/sw/rdmavt/pd.c
....@@ -50,27 +50,20 @@
5050
5151 /**
5252 * rvt_alloc_pd - allocate a protection domain
53
- * @ibdev: ib device
54
- * @context: optional user context
53
+ * @ibpd: PD
5554 * @udata: optional user data
5655 *
5756 * Allocate and keep track of a PD.
5857 *
5958 * Return: 0 on success
6059 */
61
-struct ib_pd *rvt_alloc_pd(struct ib_device *ibdev,
62
- struct ib_ucontext *context,
63
- struct ib_udata *udata)
60
+int rvt_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
6461 {
62
+ struct ib_device *ibdev = ibpd->device;
6563 struct rvt_dev_info *dev = ib_to_rvt(ibdev);
66
- struct rvt_pd *pd;
67
- struct ib_pd *ret;
64
+ struct rvt_pd *pd = ibpd_to_rvtpd(ibpd);
65
+ int ret = 0;
6866
69
- pd = kmalloc(sizeof(*pd), GFP_KERNEL);
70
- if (!pd) {
71
- ret = ERR_PTR(-ENOMEM);
72
- goto bail;
73
- }
7467 /*
7568 * While we could continue allocating protecetion domains, being
7669 * constrained only by system resources. The IBTA spec defines that
....@@ -81,8 +74,7 @@
8174 spin_lock(&dev->n_pds_lock);
8275 if (dev->n_pds_allocated == dev->dparms.props.max_pd) {
8376 spin_unlock(&dev->n_pds_lock);
84
- kfree(pd);
85
- ret = ERR_PTR(-ENOMEM);
77
+ ret = -ENOMEM;
8678 goto bail;
8779 }
8880
....@@ -92,8 +84,6 @@
9284 /* ib_alloc_pd() will initialize pd->ibpd. */
9385 pd->user = !!udata;
9486
95
- ret = &pd->ibpd;
96
-
9787 bail:
9888 return ret;
9989 }
....@@ -101,19 +91,16 @@
10191 /**
10292 * rvt_dealloc_pd - Free PD
10393 * @ibpd: Free up PD
94
+ * @udata: Valid user data or NULL for kernel object
10495 *
10596 * Return: always 0
10697 */
107
-int rvt_dealloc_pd(struct ib_pd *ibpd)
98
+int rvt_dealloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
10899 {
109
- struct rvt_pd *pd = ibpd_to_rvtpd(ibpd);
110100 struct rvt_dev_info *dev = ib_to_rvt(ibpd->device);
111101
112102 spin_lock(&dev->n_pds_lock);
113103 dev->n_pds_allocated--;
114104 spin_unlock(&dev->n_pds_lock);
115
-
116
- kfree(pd);
117
-
118105 return 0;
119106 }