/* Wait for device to signal completion of submitted requests  */
STATIC EFI_STATUS PvScsiWaitForRequestCompletion(IN CONST PVSCSI_DEV *Dev)
/* Wait for device to signal completion of submitted requests  */
STATIC EFI_STATUS PvScsiWaitForRequestCompletion(IN CONST PVSCSI_DEV *Dev)
{
  EFI_STATUS  Status;
  UINT32      IntrStatus;
  for ( ; ;) {
    Status = PvScsiMmioRead32 (Dev, PvScsiRegOffsetIntrStatus, &IntrStatus);
    if (EFI_ERROR (Status)) {
      return Status;
    }
    if ((IntrStatus & PVSCSI_INTR_CMPL_MASK) != 0) {
      break;
    }
    gBS->Stall (Dev->WaitForCmpStallInUsecs);
  }
  return PvScsiMmioWrite32 (
           Dev,
           PvScsiRegOffsetIntrStatus,
           PVSCSI_INTR_CMPL_MASK
           );
}