/* cancel a range of PIO buffers, used when they might be armed, but not triggered. Used at init to ensure buffer state, and also user process close, in case it died while writing to a PIO buffer Also after errors.  */
void ipath_disarm_piobufs(struct ipath_devdata *dd, unsigned first, unsigned cnt)
/* cancel a range of PIO buffers, used when they might be armed, but not triggered. Used at init to ensure buffer state, and also user process close, in case it died while writing to a PIO buffer Also after errors.  */
void ipath_disarm_piobufs(struct ipath_devdata *dd, unsigned first, unsigned cnt)
{
	unsigned i, last = first + cnt;
	unsigned long flags;
	ipath_cdbg(PKT, "disarm %u PIObufs first=%u\n", cnt, first);
	for (i = first; i < last; i++) {
		spin_lock_irqsave(&dd->ipath_sendctrl_lock, flags);
		ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl,
			dd->ipath_sendctrl | INFINIPATH_S_DISARM |
			(i << INFINIPATH_S_DISARMPIOBUF_SHIFT));
		ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
		spin_unlock_irqrestore(&dd->ipath_sendctrl_lock, flags);
	}
	ipath_force_pio_avail_update(dd);
}