.. | .. |
---|
36 | 36 | #include "hns_roce_device.h" |
---|
37 | 37 | #include "hns_roce_cmd.h" |
---|
38 | 38 | |
---|
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 |
---|
42 | 42 | |
---|
43 | 43 | static int hns_roce_cmd_mbox_post_hw(struct hns_roce_dev *hr_dev, u64 in_param, |
---|
44 | 44 | u64 out_param, u32 in_modifier, |
---|
.. | .. |
---|
93 | 93 | void hns_roce_cmd_event(struct hns_roce_dev *hr_dev, u16 token, u8 status, |
---|
94 | 94 | u64 out_param) |
---|
95 | 95 | { |
---|
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]; |
---|
98 | 98 | |
---|
99 | 99 | if (token != context->token) |
---|
100 | 100 | return; |
---|
.. | .. |
---|
164 | 164 | int ret; |
---|
165 | 165 | |
---|
166 | 166 | 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); |
---|
169 | 169 | up(&hr_dev->cmd.event_sem); |
---|
170 | 170 | |
---|
171 | 171 | return ret; |
---|
.. | .. |
---|
231 | 231 | struct hns_roce_cmdq *hr_cmd = &hr_dev->cmd; |
---|
232 | 232 | int i; |
---|
233 | 233 | |
---|
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); |
---|
237 | 236 | if (!hr_cmd->context) |
---|
238 | 237 | return -ENOMEM; |
---|
239 | 238 | |
---|
.. | .. |
---|
262 | 261 | hr_cmd->use_events = 0; |
---|
263 | 262 | } |
---|
264 | 263 | |
---|
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) |
---|
267 | 266 | { |
---|
268 | 267 | struct hns_roce_cmd_mailbox *mailbox; |
---|
269 | 268 | |
---|
.. | .. |
---|
271 | 270 | if (!mailbox) |
---|
272 | 271 | return ERR_PTR(-ENOMEM); |
---|
273 | 272 | |
---|
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); |
---|
276 | 275 | if (!mailbox->buf) { |
---|
277 | 276 | kfree(mailbox); |
---|
278 | 277 | return ERR_PTR(-ENOMEM); |
---|