All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] x86/SVM-IOMMU: Don't opencode memcpy() in queue_iommu_command()
@ 2018-09-24 10:55 Andrew Cooper
  2018-09-24 10:55 ` [PATCH 2/2] x86/SVM-IOMMU: Drop get_field_from_byte() Andrew Cooper
                   ` (4 more replies)
  0 siblings, 5 replies; 19+ messages in thread
From: Andrew Cooper @ 2018-09-24 10:55 UTC (permalink / raw)
  To: Xen-devel
  Cc: Wei Liu, Jan Beulich, Andrew Cooper, Paul Durrant,
	Suravee Suthikulpanit, Brian Woods, Roger Pau Monné

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>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Paul Durrant <paul.durrant@citrix.com>
CC: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
CC: Brian Woods <brian.woods@amd.com>
---
 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 08247fa..c6c0b4f 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 c479f0b..1f19cd3 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
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2018-10-05  8:22 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-24 10:55 [PATCH 1/2] x86/SVM-IOMMU: Don't opencode memcpy() in queue_iommu_command() Andrew Cooper
2018-09-24 10:55 ` [PATCH 2/2] x86/SVM-IOMMU: Drop get_field_from_byte() Andrew Cooper
2018-09-24 12:07   ` Paul Durrant
2018-09-24 12:17   ` Jan Beulich
2018-10-04 23:00   ` Woods, Brian
2018-10-05  8:22   ` Roger Pau Monné
2018-09-24 11:59 ` [PATCH 1/2] x86/SVM-IOMMU: Don't opencode memcpy() in queue_iommu_command() Paul Durrant
2018-09-24 12:05   ` Andrew Cooper
2018-09-24 12:09     ` Paul Durrant
2018-09-24 12:16       ` Jan Beulich
2018-09-24 12:18         ` Paul Durrant
2018-09-24 12:24           ` Andrew Cooper
2018-09-24 12:28             ` Paul Durrant
2018-09-24 12:32           ` Jan Beulich
2018-09-24 12:19       ` Andrew Cooper
2018-09-24 12:09   ` Jan Beulich
2018-09-24 12:14 ` Jan Beulich
2018-10-04 23:03 ` Woods, Brian
2018-10-05  8:22 ` Roger Pau Monné

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.