rk: revert 20f3d0b+v3.0.66 to v3.0
[firefly-linux-kernel-4.4.55.git] / arch / x86 / kernel / amd_iommu.c
index bfd75ff5d5bda6083651eaa23cfc86e8f3a843de..7c3a95e54ec57cae2f9dd96a831bc5b7f53a6f69 100644 (file)
@@ -531,9 +531,7 @@ static void build_inv_all(struct iommu_cmd *cmd)
  * Writes the command to the IOMMUs command buffer and informs the
  * hardware about the new command.
  */
-static int iommu_queue_command_sync(struct amd_iommu *iommu,
-                                   struct iommu_cmd *cmd,
-                                   bool sync)
+static int iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)
 {
        u32 left, tail, head, next_tail;
        unsigned long flags;
@@ -567,18 +565,13 @@ again:
        copy_cmd_to_buffer(iommu, cmd, tail);
 
        /* We need to sync now to make sure all commands are processed */
-       iommu->need_sync = sync;
+       iommu->need_sync = true;
 
        spin_unlock_irqrestore(&iommu->lock, flags);
 
        return 0;
 }
 
-static int iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)
-{
-       return iommu_queue_command_sync(iommu, cmd, true);
-}
-
 /*
  * This function queues a completion wait command into the command
  * buffer of an IOMMU
@@ -594,7 +587,7 @@ static int iommu_completion_wait(struct amd_iommu *iommu)
 
        build_completion_wait(&cmd, (u64)&sem);
 
-       ret = iommu_queue_command_sync(iommu, &cmd, false);
+       ret = iommu_queue_command(iommu, &cmd);
        if (ret)
                return ret;
 
@@ -780,9 +773,14 @@ static void domain_flush_complete(struct protection_domain *domain)
 static void domain_flush_devices(struct protection_domain *domain)
 {
        struct iommu_dev_data *dev_data;
+       unsigned long flags;
+
+       spin_lock_irqsave(&domain->lock, flags);
 
        list_for_each_entry(dev_data, &domain->dev_list, list)
                device_flush_dte(dev_data->dev);
+
+       spin_unlock_irqrestore(&domain->lock, flags);
 }
 
 /****************************************************************************
@@ -1203,7 +1201,7 @@ static int alloc_new_range(struct dma_ops_domain *dma_dom,
                if (!pte || !IOMMU_PTE_PRESENT(*pte))
                        continue;
 
-               dma_ops_reserve_addresses(dma_dom, i >> PAGE_SHIFT, 1);
+               dma_ops_reserve_addresses(dma_dom, i << PAGE_SHIFT, 1);
        }
 
        update_domain(&dma_dom->domain);