]> xenbits.xensource.com Git - people/dariof/xen.git/commitdiff
AMD/IOMMU: Don't opencode memcpy() in queue_iommu_command()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 24 Sep 2018 10:16:21 +0000 (11:16 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 5 Oct 2018 09:53:58 +0000 (10:53 +0100)
In practice, this allows the compiler to replace the loop with a pair of movs.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Brian Woods <brian.woods@amd.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
xen/drivers/passthrough/amd/iommu_cmd.c
xen/include/asm-x86/hvm/svm/amd-iommu-defs.h

index d4d071e53e21b77bafb242887d1e261f1fed1d44..af3a1fb865338eb0e95871743e4aa7a16b2e036e 100644 (file)
@@ -24,8 +24,7 @@
 
 static int queue_iommu_command(struct amd_iommu *iommu, u32 cmd[])
 {
-    u32 tail, head, *cmd_buffer;
-    int i;
+    uint32_t tail, head;
 
     tail = iommu->cmd_buffer.tail;
     if ( ++tail == iommu->cmd_buffer.entries )
@@ -35,12 +34,9 @@ static int queue_iommu_command(struct amd_iommu *iommu, u32 cmd[])
                                       IOMMU_CMD_BUFFER_HEAD_OFFSET));
     if ( head != tail )
     {
-        cmd_buffer = (u32 *)(iommu->cmd_buffer.buffer +
-                             (iommu->cmd_buffer.tail *
-                             IOMMU_CMD_BUFFER_ENTRY_SIZE));
-
-        for ( i = 0; i < IOMMU_CMD_BUFFER_U32_PER_ENTRY; i++ )
-            cmd_buffer[i] = cmd[i];
+        memcpy(iommu->cmd_buffer.buffer +
+               (iommu->cmd_buffer.tail * IOMMU_CMD_BUFFER_ENTRY_SIZE),
+               cmd, IOMMU_CMD_BUFFER_ENTRY_SIZE);
 
         iommu->cmd_buffer.tail = tail;
         return 1;
index c479f0bb0236a49c100302fd8a43c7e90d0bbbf7..1f19cd3d27d5339b0088549d21801d8733e4e81f 100644 (file)
 
 #define IOMMU_CMD_BUFFER_ENTRY_SIZE                    16
 #define IOMMU_CMD_BUFFER_POWER_OF2_ENTRIES_PER_PAGE    8
-#define IOMMU_CMD_BUFFER_U32_PER_ENTRY         (IOMMU_CMD_BUFFER_ENTRY_SIZE / 4)
 
 #define IOMMU_CMD_OPCODE_MASK                  0xF0000000
 #define IOMMU_CMD_OPCODE_SHIFT                 28