hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/infiniband/hw/hns/hns_roce_cmd.c
....@@ -36,9 +36,9 @@
3636 #include "hns_roce_device.h"
3737 #include "hns_roce_cmd.h"
3838
39
-#define CMD_POLL_TOKEN 0xffff
40
-#define CMD_MAX_NUM 32
41
-#define CMD_TOKEN_MASK 0x1f
39
+#define CMD_POLL_TOKEN 0xffff
40
+#define CMD_MAX_NUM 32
41
+#define CMD_TOKEN_MASK 0x1f
4242
4343 static int hns_roce_cmd_mbox_post_hw(struct hns_roce_dev *hr_dev, u64 in_param,
4444 u64 out_param, u32 in_modifier,
....@@ -93,8 +93,8 @@
9393 void hns_roce_cmd_event(struct hns_roce_dev *hr_dev, u16 token, u8 status,
9494 u64 out_param)
9595 {
96
- struct hns_roce_cmd_context
97
- *context = &hr_dev->cmd.context[token & hr_dev->cmd.token_mask];
96
+ struct hns_roce_cmd_context *context =
97
+ &hr_dev->cmd.context[token % hr_dev->cmd.max_cmds];
9898
9999 if (token != context->token)
100100 return;
....@@ -164,8 +164,8 @@
164164 int ret;
165165
166166 down(&hr_dev->cmd.event_sem);
167
- ret = __hns_roce_cmd_mbox_wait(hr_dev, in_param, out_param,
168
- in_modifier, op_modifier, op, timeout);
167
+ ret = __hns_roce_cmd_mbox_wait(hr_dev, in_param, out_param, in_modifier,
168
+ op_modifier, op, timeout);
169169 up(&hr_dev->cmd.event_sem);
170170
171171 return ret;
....@@ -231,9 +231,8 @@
231231 struct hns_roce_cmdq *hr_cmd = &hr_dev->cmd;
232232 int i;
233233
234
- hr_cmd->context = kmalloc_array(hr_cmd->max_cmds,
235
- sizeof(*hr_cmd->context),
236
- GFP_KERNEL);
234
+ hr_cmd->context =
235
+ kcalloc(hr_cmd->max_cmds, sizeof(*hr_cmd->context), GFP_KERNEL);
237236 if (!hr_cmd->context)
238237 return -ENOMEM;
239238
....@@ -262,8 +261,8 @@
262261 hr_cmd->use_events = 0;
263262 }
264263
265
-struct hns_roce_cmd_mailbox
266
- *hns_roce_alloc_cmd_mailbox(struct hns_roce_dev *hr_dev)
264
+struct hns_roce_cmd_mailbox *
265
+hns_roce_alloc_cmd_mailbox(struct hns_roce_dev *hr_dev)
267266 {
268267 struct hns_roce_cmd_mailbox *mailbox;
269268
....@@ -271,8 +270,8 @@
271270 if (!mailbox)
272271 return ERR_PTR(-ENOMEM);
273272
274
- mailbox->buf = dma_pool_alloc(hr_dev->cmd.pool, GFP_KERNEL,
275
- &mailbox->dma);
273
+ mailbox->buf =
274
+ dma_pool_alloc(hr_dev->cmd.pool, GFP_KERNEL, &mailbox->dma);
276275 if (!mailbox->buf) {
277276 kfree(mailbox);
278277 return ERR_PTR(-ENOMEM);