| 53 | } |
| 54 | |
| 55 | int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd) |
| 56 | { |
| 57 | enum mc_cmd_status status; |
| 58 | uint64_t response, start_time, total_time, time_to_wait; |
| 59 | |
| 60 | if (!mc_io || !mc_io->regs) |
| 61 | return -EACCES; |
| 62 | |
| 63 | /* --- Call lock function here in case portal is shared --- */ |
| 64 | rte_spinlock_lock(&mc_portal_lock); |
| 65 | |
| 66 | mc_write_command(mc_io->regs, cmd); |
| 67 | |
| 68 | /* Wait for one second. rte_get_timer_hz() returns frequency of CPU */ |
| 69 | time_to_wait = rte_get_timer_hz(); |
| 70 | total_time = 0; |
| 71 | start_time = rte_get_timer_cycles(); |
| 72 | |
| 73 | /* Spin until status changes */ |
| 74 | do { |
| 75 | response = ioread64(mc_io->regs); |
| 76 | status = mc_cmd_read_status((struct mc_command *)&response); |
| 77 | total_time = rte_get_timer_cycles() - start_time; |
| 78 | } while (status == MC_CMD_STATUS_READY && total_time <= time_to_wait); |
| 79 | |
| 80 | if (status == MC_CMD_STATUS_READY) { |
| 81 | rte_spinlock_unlock(&mc_portal_lock); |
| 82 | |
| 83 | return mc_status_to_error(MC_CMD_STATUS_TIMEOUT); |
| 84 | } |
| 85 | |
| 86 | /* Read the response back into the command buffer */ |
| 87 | mc_read_response(mc_io->regs, cmd); |
| 88 | |
| 89 | /* --- Call unlock function here in case portal is shared --- */ |
| 90 | rte_spinlock_unlock(&mc_portal_lock); |
| 91 | |
| 92 | return mc_status_to_error(status); |
| 93 | } |
no test coverage detected