/* Force an update of in-memory copy of the pioavail registers, when needed for any of a variety of reasons. We read the scratch register to make it highly likely that the update will have happened by the time we return. If already off (as in cancel_sends above), this routine is a nop, on the assumption that the caller will "do the
right thing".  */
void ipath_force_pio_avail_update(struct ipath_devdata *dd)
/* Force an update of in-memory copy of the pioavail registers, when needed for any of a variety of reasons. We read the scratch register to make it highly likely that the update will have happened by the time we return. If already off (as in cancel_sends above), this routine is a nop, on the assumption that the caller will "do the
right thing".  */
void ipath_force_pio_avail_update(struct ipath_devdata *dd)
{
	unsigned long flags;
	spin_lock_irqsave(&dd->ipath_sendctrl_lock, flags);
	if (dd->ipath_sendctrl & INFINIPATH_S_PIOBUFAVAILUPD) {
		ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl,
			dd->ipath_sendctrl & ~INFINIPATH_S_PIOBUFAVAILUPD);
		ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
		ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl,
			dd->ipath_sendctrl);
		ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
	}
	spin_unlock_irqrestore(&dd->ipath_sendctrl_lock, flags);
}