| 1745 | } |
| 1746 | |
| 1747 | static int |
| 1748 | its_cmd_send(device_t dev, struct its_cmd_desc *desc) |
| 1749 | { |
| 1750 | struct gicv3_its_softc *sc; |
| 1751 | struct its_cmd *cmd, *cmd_sync, *cmd_write; |
| 1752 | struct its_col col_sync; |
| 1753 | struct its_cmd_desc desc_sync; |
| 1754 | uint64_t target, cwriter; |
| 1755 | |
| 1756 | sc = device_get_softc(dev); |
| 1757 | mtx_lock_spin(&sc->sc_its_cmd_lock); |
| 1758 | cmd = its_cmd_alloc_locked(dev); |
| 1759 | if (cmd == NULL) { |
| 1760 | device_printf(dev, "could not allocate ITS command\n"); |
| 1761 | mtx_unlock_spin(&sc->sc_its_cmd_lock); |
| 1762 | return (EBUSY); |
| 1763 | } |
| 1764 | |
| 1765 | target = its_cmd_prepare(cmd, desc); |
| 1766 | its_cmd_sync(sc, cmd); |
| 1767 | |
| 1768 | if (target != ITS_TARGET_NONE) { |
| 1769 | cmd_sync = its_cmd_alloc_locked(dev); |
| 1770 | if (cmd_sync != NULL) { |
| 1771 | desc_sync.cmd_type = ITS_CMD_SYNC; |
| 1772 | col_sync.col_target = target; |
| 1773 | desc_sync.cmd_desc_sync.col = &col_sync; |
| 1774 | its_cmd_prepare(cmd_sync, &desc_sync); |
| 1775 | its_cmd_sync(sc, cmd_sync); |
| 1776 | } |
| 1777 | } |
| 1778 | |
| 1779 | /* Update GITS_CWRITER */ |
| 1780 | cwriter = sc->sc_its_cmd_next_idx * sizeof(struct its_cmd); |
| 1781 | gic_its_write_8(sc, GITS_CWRITER, cwriter); |
| 1782 | cmd_write = &sc->sc_its_cmd_base[sc->sc_its_cmd_next_idx]; |
| 1783 | mtx_unlock_spin(&sc->sc_its_cmd_lock); |
| 1784 | |
| 1785 | its_cmd_wait_completion(dev, cmd, cmd_write); |
| 1786 | |
| 1787 | return (0); |
| 1788 | } |
| 1789 | |
| 1790 | /* Handlers to send commands */ |
| 1791 | static void |
no test coverage detected