hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/infiniband/sw/rdmavt/ah.c
....@@ -1,5 +1,5 @@
11 /*
2
- * Copyright(c) 2016 Intel Corporation.
2
+ * Copyright(c) 2016 - 2019 Intel Corporation.
33 *
44 * This file is provided under a dual BSD/GPLv2 license. When using or
55 * redistributing this file, you may do so under either license.
....@@ -89,71 +89,60 @@
8989
9090 /**
9191 * rvt_create_ah - create an address handle
92
- * @pd: the protection domain
93
- * @ah_attr: the attributes of the AH
92
+ * @ibah: the IB address handle
93
+ * @init_attr: the attributes of the AH
9494 * @udata: pointer to user's input output buffer information.
9595 *
9696 * This may be called from interrupt context.
9797 *
98
- * Return: newly allocated ah
98
+ * Return: 0 on success
9999 */
100
-struct ib_ah *rvt_create_ah(struct ib_pd *pd,
101
- struct rdma_ah_attr *ah_attr,
102
- struct ib_udata *udata)
100
+int rvt_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr,
101
+ struct ib_udata *udata)
103102 {
104
- struct rvt_ah *ah;
105
- struct rvt_dev_info *dev = ib_to_rvt(pd->device);
103
+ struct rvt_ah *ah = ibah_to_rvtah(ibah);
104
+ struct rvt_dev_info *dev = ib_to_rvt(ibah->device);
106105 unsigned long flags;
107106
108
- if (rvt_check_ah(pd->device, ah_attr))
109
- return ERR_PTR(-EINVAL);
110
-
111
- ah = kmalloc(sizeof(*ah), GFP_ATOMIC);
112
- if (!ah)
113
- return ERR_PTR(-ENOMEM);
107
+ if (rvt_check_ah(ibah->device, init_attr->ah_attr))
108
+ return -EINVAL;
114109
115110 spin_lock_irqsave(&dev->n_ahs_lock, flags);
116111 if (dev->n_ahs_allocated == dev->dparms.props.max_ah) {
117112 spin_unlock_irqrestore(&dev->n_ahs_lock, flags);
118
- kfree(ah);
119
- return ERR_PTR(-ENOMEM);
113
+ return -ENOMEM;
120114 }
121115
122116 dev->n_ahs_allocated++;
123117 spin_unlock_irqrestore(&dev->n_ahs_lock, flags);
124118
125
- rdma_copy_ah_attr(&ah->attr, ah_attr);
126
-
127
- atomic_set(&ah->refcount, 0);
119
+ rdma_copy_ah_attr(&ah->attr, init_attr->ah_attr);
128120
129121 if (dev->driver_f.notify_new_ah)
130
- dev->driver_f.notify_new_ah(pd->device, ah_attr, ah);
122
+ dev->driver_f.notify_new_ah(ibah->device,
123
+ init_attr->ah_attr, ah);
131124
132
- return &ah->ibah;
125
+ return 0;
133126 }
134127
135128 /**
136129 * rvt_destory_ah - Destory an address handle
137130 * @ibah: address handle
131
+ * @destroy_flags: destroy address handle flags (see enum rdma_destroy_ah_flags)
138132 *
139133 * Return: 0 on success
140134 */
141
-int rvt_destroy_ah(struct ib_ah *ibah)
135
+int rvt_destroy_ah(struct ib_ah *ibah, u32 destroy_flags)
142136 {
143137 struct rvt_dev_info *dev = ib_to_rvt(ibah->device);
144138 struct rvt_ah *ah = ibah_to_rvtah(ibah);
145139 unsigned long flags;
146
-
147
- if (atomic_read(&ah->refcount) != 0)
148
- return -EBUSY;
149140
150141 spin_lock_irqsave(&dev->n_ahs_lock, flags);
151142 dev->n_ahs_allocated--;
152143 spin_unlock_irqrestore(&dev->n_ahs_lock, flags);
153144
154145 rdma_destroy_ah_attr(&ah->attr);
155
- kfree(ah);
156
-
157146 return 0;
158147 }
159148