forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/drivers/infiniband/hw/hns/hns_roce_cmd.c
....@@ -103,7 +103,6 @@
103103 context->out_param = out_param;
104104 complete(&context->done);
105105 }
106
-EXPORT_SYMBOL_GPL(hns_roce_cmd_event);
107106
108107 /* this should be called with "use_events" */
109108 static int __hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param,
....@@ -162,7 +161,7 @@
162161 u64 out_param, unsigned long in_modifier,
163162 u8 op_modifier, u16 op, unsigned long timeout)
164163 {
165
- int ret = 0;
164
+ int ret;
166165
167166 down(&hr_dev->cmd.event_sem);
168167 ret = __hns_roce_cmd_mbox_wait(hr_dev, in_param, out_param,
....@@ -176,19 +175,34 @@
176175 unsigned long in_modifier, u8 op_modifier, u16 op,
177176 unsigned long timeout)
178177 {
179
- if (hr_dev->is_reset)
180
- return 0;
178
+ int ret;
179
+
180
+ if (hr_dev->hw->rst_prc_mbox) {
181
+ ret = hr_dev->hw->rst_prc_mbox(hr_dev);
182
+ if (ret == CMD_RST_PRC_SUCCESS)
183
+ return 0;
184
+ else if (ret == CMD_RST_PRC_EBUSY)
185
+ return -EBUSY;
186
+ }
181187
182188 if (hr_dev->cmd.use_events)
183
- return hns_roce_cmd_mbox_wait(hr_dev, in_param, out_param,
184
- in_modifier, op_modifier, op,
185
- timeout);
189
+ ret = hns_roce_cmd_mbox_wait(hr_dev, in_param, out_param,
190
+ in_modifier, op_modifier, op,
191
+ timeout);
186192 else
187
- return hns_roce_cmd_mbox_poll(hr_dev, in_param, out_param,
188
- in_modifier, op_modifier, op,
189
- timeout);
193
+ ret = hns_roce_cmd_mbox_poll(hr_dev, in_param, out_param,
194
+ in_modifier, op_modifier, op,
195
+ timeout);
196
+
197
+ if (ret == CMD_RST_PRC_EBUSY)
198
+ return -EBUSY;
199
+
200
+ if (ret && (hr_dev->hw->rst_prc_mbox &&
201
+ hr_dev->hw->rst_prc_mbox(hr_dev) == CMD_RST_PRC_SUCCESS))
202
+ return 0;
203
+
204
+ return ret;
190205 }
191
-EXPORT_SYMBOL_GPL(hns_roce_cmd_mbox);
192206
193207 int hns_roce_cmd_init(struct hns_roce_dev *hr_dev)
194208 {
....@@ -197,7 +211,6 @@
197211 mutex_init(&hr_dev->cmd.hcr_mutex);
198212 sema_init(&hr_dev->cmd.poll_sem, 1);
199213 hr_dev->cmd.use_events = 0;
200
- hr_dev->cmd.toggle = 1;
201214 hr_dev->cmd.max_cmds = CMD_MAX_NUM;
202215 hr_dev->cmd.pool = dma_pool_create("hns_roce_cmd", dev,
203216 HNS_ROCE_MAILBOX_SIZE,
....@@ -238,23 +251,15 @@
238251 hr_cmd->token_mask = CMD_TOKEN_MASK;
239252 hr_cmd->use_events = 1;
240253
241
- down(&hr_cmd->poll_sem);
242
-
243254 return 0;
244255 }
245256
246257 void hns_roce_cmd_use_polling(struct hns_roce_dev *hr_dev)
247258 {
248259 struct hns_roce_cmdq *hr_cmd = &hr_dev->cmd;
249
- int i;
250
-
251
- hr_cmd->use_events = 0;
252
-
253
- for (i = 0; i < hr_cmd->max_cmds; ++i)
254
- down(&hr_cmd->event_sem);
255260
256261 kfree(hr_cmd->context);
257
- up(&hr_cmd->poll_sem);
262
+ hr_cmd->use_events = 0;
258263 }
259264
260265 struct hns_roce_cmd_mailbox
....@@ -275,7 +280,6 @@
275280
276281 return mailbox;
277282 }
278
-EXPORT_SYMBOL_GPL(hns_roce_alloc_cmd_mailbox);
279283
280284 void hns_roce_free_cmd_mailbox(struct hns_roce_dev *hr_dev,
281285 struct hns_roce_cmd_mailbox *mailbox)
....@@ -286,4 +290,3 @@
286290 dma_pool_free(hr_dev->cmd.pool, mailbox->buf, mailbox->dma);
287291 kfree(mailbox);
288292 }
289
-EXPORT_SYMBOL_GPL(hns_roce_free_cmd_mailbox);