/* This function waits until an IOMMU has completed a completion wait command  */
static void __iommu_wait_for_completion(struct amd_iommu *iommu)
/* This function waits until an IOMMU has completed a completion wait command  */
static void __iommu_wait_for_completion(struct amd_iommu *iommu)
{
	int ready = 0;
	unsigned status = 0;
	unsigned long i = 0;
	INC_STATS_COUNTER(compl_wait);
	while (!ready && (i < EXIT_LOOP_COUNT)) {
		++i;
		status = readl(iommu->mmio_base + MMIO_STATUS_OFFSET);
		ready = status & MMIO_STATUS_COM_WAIT_INT_MASK;
	}
	status &= ~MMIO_STATUS_COM_WAIT_INT_MASK;
	writel(status, iommu->mmio_base + MMIO_STATUS_OFFSET);
	if (unlikely(i == EXIT_LOOP_COUNT))
		iommu->reset_in_progress = true;
}