| 1629 | } |
| 1630 | |
| 1631 | static struct its_cmd * |
| 1632 | its_cmd_alloc_locked(device_t dev) |
| 1633 | { |
| 1634 | struct gicv3_its_softc *sc; |
| 1635 | struct its_cmd *cmd; |
| 1636 | size_t us_left; |
| 1637 | |
| 1638 | sc = device_get_softc(dev); |
| 1639 | |
| 1640 | /* |
| 1641 | * XXX ARM64TODO: This is obviously a significant delay. |
| 1642 | * The reason for that is that currently the time frames for |
| 1643 | * the command to complete (and therefore free the descriptor) |
| 1644 | * are not known. |
| 1645 | */ |
| 1646 | us_left = 1000000; |
| 1647 | |
| 1648 | mtx_assert(&sc->sc_its_cmd_lock, MA_OWNED); |
| 1649 | while (its_cmd_queue_full(sc)) { |
| 1650 | if (us_left-- == 0) { |
| 1651 | /* Timeout while waiting for free command */ |
| 1652 | device_printf(dev, |
| 1653 | "Timeout while waiting for free command\n"); |
| 1654 | return (NULL); |
| 1655 | } |
| 1656 | DELAY(1); |
| 1657 | } |
| 1658 | |
| 1659 | cmd = &sc->sc_its_cmd_base[sc->sc_its_cmd_next_idx]; |
| 1660 | sc->sc_its_cmd_next_idx++; |
| 1661 | sc->sc_its_cmd_next_idx %= ITS_CMDQ_SIZE / sizeof(struct its_cmd); |
| 1662 | |
| 1663 | return (cmd); |
| 1664 | } |
| 1665 | |
| 1666 | static uint64_t |
| 1667 | its_cmd_prepare(struct its_cmd *cmd, struct its_cmd_desc *desc) |
no test coverage detected