[xen master] AMD/IOMMU: Don't opencode memcpy() in queue_iommu_command()

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[xen master] AMD/IOMMU: Don't opencode memcpy() in queue_iommu_command()

patchbot
commit 3ccfe3ca9ab89a4f879ac7a51d286bed64dfc83f
Author:     Andrew Cooper <[hidden email]>
AuthorDate: Mon Sep 24 11:16:21 2018 +0100
Commit:     Andrew Cooper <[hidden email]>
CommitDate: Fri Oct 5 10:53:58 2018 +0100

    AMD/IOMMU: Don't opencode memcpy() in queue_iommu_command()
   
    In practice, this allows the compiler to replace the loop with a pair of movs.
   
    No functional change.
   
    Signed-off-by: Andrew Cooper <[hidden email]>
    Reviewed-by: Jan Beulich <[hidden email]>
    Reviewed-by: Brian Woods <[hidden email]>
    Reviewed-by: Roger Pau Monné <[hidden email]>
---
 xen/drivers/passthrough/amd/iommu_cmd.c      | 12 ++++--------
 xen/include/asm-x86/hvm/svm/amd-iommu-defs.h |  1 -
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/xen/drivers/passthrough/amd/iommu_cmd.c b/xen/drivers/passthrough/amd/iommu_cmd.c
index d4d071e53e..af3a1fb865 100644
--- a/xen/drivers/passthrough/amd/iommu_cmd.c
+++ b/xen/drivers/passthrough/amd/iommu_cmd.c
@@ -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;
diff --git a/xen/include/asm-x86/hvm/svm/amd-iommu-defs.h b/xen/include/asm-x86/hvm/svm/amd-iommu-defs.h
index c479f0bb02..1f19cd3d27 100644
--- a/xen/include/asm-x86/hvm/svm/amd-iommu-defs.h
+++ b/xen/include/asm-x86/hvm/svm/amd-iommu-defs.h
@@ -187,7 +187,6 @@
 
 #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
--
generated by git-patchbot for /home/xen/git/xen.git#master


_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog