From: Wei Wang <wei.wang2@amd.com>
To: JBeulich@suse.com
Cc: xen-devel@lists.xensource.com
Subject: [PATCH 4 of 4] amd iommu: Support INVALIDATE_IOMMU_ALL command
Date: Fri, 18 Nov 2011 11:42:25 +0100 [thread overview]
Message-ID: <9d4fecddb805b0780e2e.1321612945@gran.amd.com> (raw)
In-Reply-To: <patchbomb.1321612941@gran.amd.com>
# HG changeset patch
# User Wei Wang <wei.wang2@amd.com>
# Date 1321612881 -3600
# Node ID 9d4fecddb805b0780e2eeab9f1f69cc585eac7b8
# Parent 6ef12cc262fb3ac11f9ea58707afb4f7778017ac
amd iommu: Support INVALIDATE_IOMMU_ALL command.
It is one of the new architectural commands supported by iommu v2.It instructs
iommu to clear all address translation and interrupt remapping caches for all
devices and all domains.
Signed-off-by: Wei Wang <wei.wang2@amd.com>
diff -r 6ef12cc262fb -r 9d4fecddb805 xen/drivers/passthrough/amd/iommu_cmd.c
--- a/xen/drivers/passthrough/amd/iommu_cmd.c Fri Nov 18 11:07:40 2011 +0100
+++ b/xen/drivers/passthrough/amd/iommu_cmd.c Fri Nov 18 11:41:21 2011 +0100
@@ -277,6 +277,20 @@ static void invalidate_interrupt_table(s
send_iommu_command(iommu, cmd);
}
+void invalidate_iommu_all(struct amd_iommu *iommu)
+{
+ u32 cmd[4], entry;
+
+ cmd[3] = cmd[2] = cmd[0] = 0;
+
+ set_field_in_reg_u32(IOMMU_CMD_INVALIDATE_IOMMU_ALL, 0,
+ IOMMU_CMD_OPCODE_MASK, IOMMU_CMD_OPCODE_SHIFT,
+ &entry);
+ cmd[1] = entry;
+
+ send_iommu_command(iommu, cmd);
+}
+
void amd_iommu_flush_iotlb(struct pci_dev *pdev,
uint64_t gaddr, unsigned int order)
{
@@ -380,3 +394,11 @@ void amd_iommu_flush_intremap(struct amd
invalidate_interrupt_table(iommu, bdf);
flush_command_buffer(iommu);
}
+
+void amd_iommu_flush_all_caches(struct amd_iommu *iommu)
+{
+ ASSERT( spin_is_locked(&iommu->lock) );
+
+ invalidate_iommu_all(iommu);
+ flush_command_buffer(iommu);
+}
diff -r 6ef12cc262fb -r 9d4fecddb805 xen/drivers/passthrough/amd/iommu_init.c
--- a/xen/drivers/passthrough/amd/iommu_init.c Fri Nov 18 11:07:40 2011 +0100
+++ b/xen/drivers/passthrough/amd/iommu_init.c Fri Nov 18 11:41:21 2011 +0100
@@ -598,6 +598,9 @@ static void enable_iommu(struct amd_iomm
set_iommu_event_log_control(iommu, IOMMU_CONTROL_ENABLED);
set_iommu_translation_control(iommu, IOMMU_CONTROL_ENABLED);
+ if ( iommu_has_feature(iommu, IOMMU_EXT_FEATURE_IASUP_SHIFT) )
+ amd_iommu_flush_all_caches(iommu);
+
iommu->enabled = 1;
spin_unlock_irqrestore(&iommu->lock, flags);
@@ -970,6 +973,9 @@ void amd_iommu_resume(void)
}
/* flush all cache entries after iommu re-enabled */
- invalidate_all_devices();
- invalidate_all_domain_pages();
+ if ( !iommu_has_feature(iommu, IOMMU_EXT_FEATURE_IASUP_SHIFT) )
+ {
+ invalidate_all_devices();
+ invalidate_all_domain_pages();
+ }
}
diff -r 6ef12cc262fb -r 9d4fecddb805 xen/include/asm-x86/hvm/svm/amd-iommu-defs.h
--- a/xen/include/asm-x86/hvm/svm/amd-iommu-defs.h Fri Nov 18 11:07:40 2011 +0100
+++ b/xen/include/asm-x86/hvm/svm/amd-iommu-defs.h Fri Nov 18 11:41:21 2011 +0100
@@ -192,6 +192,7 @@
#define IOMMU_CMD_INVALIDATE_IOMMU_PAGES 0x3
#define IOMMU_CMD_INVALIDATE_IOTLB_PAGES 0x4
#define IOMMU_CMD_INVALIDATE_INT_TABLE 0x5
+#define IOMMU_CMD_INVALIDATE_IOMMU_ALL 0x8
/* COMPLETION_WAIT command */
#define IOMMU_COMP_WAIT_DATA_BUFFER_SIZE 8
diff -r 6ef12cc262fb -r 9d4fecddb805 xen/include/asm-x86/hvm/svm/amd-iommu-proto.h
--- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h Fri Nov 18 11:07:40 2011 +0100
+++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h Fri Nov 18 11:41:21 2011 +0100
@@ -78,6 +78,7 @@ void amd_iommu_flush_iotlb(struct pci_de
unsigned int order);
void amd_iommu_flush_device(struct amd_iommu *iommu, uint16_t bdf);
void amd_iommu_flush_intremap(struct amd_iommu *iommu, uint16_t bdf);
+void amd_iommu_flush_all_caches(struct amd_iommu *iommu);
/* find iommu for bdf */
struct amd_iommu *find_iommu_for_device(int seg, int bdf);
next prev parent reply other threads:[~2011-11-18 10:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-18 10:42 [PATCH 0 of 4] amd iommu: IOMMUv2 support Wei Wang
2011-11-18 10:42 ` [PATCH 1 of 4] amd iommu: Advertise iommu extended feature bits to xen Wei Wang
2011-11-18 10:42 ` [PATCH 2 of 4] amd iommu: Fix incorrect definitions Wei Wang
2011-11-18 10:42 ` [PATCH 3 of 4] amd iommu: Factor out iommu command handling functions, Wei Wang
2011-11-18 10:42 ` Wei Wang [this message]
2011-11-18 14:59 ` [PATCH 0 of 4] amd iommu: IOMMUv2 support George Dunlap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9d4fecddb805b0780e2e.1321612945@gran.amd.com \
--to=wei.wang2@amd.com \
--cc=JBeulich@suse.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).