Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1231892
| From | Baoquan He <bhe@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 05/10] iommu/amd: Add function copy_dev_tables |
| Date | 2015-09-24 08:50 +0200 |
| Message-ID | <qc8vT-3GJ-7@gated-at.bofh.it> (permalink) |
| References | <qc8md-3vB-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Signed-off-by: Baoquan He <bhe@redhat.com>
---
drivers/iommu/amd_iommu_init.c | 26 ++++++++++++++++++++++++++
drivers/iommu/amd_iommu_types.h | 2 ++
2 files changed, 28 insertions(+)
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 1fc369e..913a718 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -690,6 +690,32 @@ static void iommu_enable_gt(struct amd_iommu *iommu)
iommu_feature_enable(iommu, CONTROL_GT_EN);
}
+static void copy_dev_tables(void)
+{
+ u64 entry;
+ u32 lo, hi;
+ phys_addr_t old_devtb_phys;
+ struct dev_table_entry *old_devtb;
+ struct amd_iommu *iommu;
+ u16 dom_id;
+ u32 devid;
+
+ for_each_iommu(iommu) {
+ lo = readl(iommu->mmio_base + MMIO_DEV_TABLE_OFFSET);
+ hi = readl(iommu->mmio_base + MMIO_DEV_TABLE_OFFSET + 4);
+ entry = (((u64) hi) << 32) + lo;
+ old_devtb_phys = entry & PAGE_MASK;
+ old_devtb = ioremap_cache(old_devtb_phys, dev_table_size);
+ for (devid = 0; devid <= amd_iommu_last_bdf; ++devid) {
+ amd_iommu_dev_table[devid] = old_devtb[devid];
+ dom_id = amd_iommu_dev_table[devid].data[1] & DEV_DOMID_MASK;
+ __set_bit(dom_id, amd_iommu_pd_alloc_bitmap);
+ }
+ iounmap(old_devtb);
+ }
+
+}
+
/* sets a specific bit in the device table entry. */
static void set_dev_entry_bit(u16 devid, u8 bit)
{
diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h
index f659088..d0f0cfb 100644
--- a/drivers/iommu/amd_iommu_types.h
+++ b/drivers/iommu/amd_iommu_types.h
@@ -194,6 +194,8 @@
#define DEV_ENTRY_MODE_MASK 0x07
#define DEV_ENTRY_MODE_SHIFT 0x09
+#define DEV_DOMID_MASK 0xffff
+
#define MAX_DEV_TABLE_ENTRIES 0xffff
/* constants to configure the command buffer */
--
2.4.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/10] Fix AMD IOMMU faults in kdump kernel Baoquan He <bhe@redhat.com> - 2015-09-24 08:40 +0200
[PATCH 04/10] iommu/amd: Detect pre enabled translation Baoquan He <bhe@redhat.com> - 2015-09-24 08:40 +0200
[PATCH 09/10] iommu/amd: Clear the iommu pre enabled setting Baoquan He <bhe@redhat.com> - 2015-09-24 08:40 +0200
Re: [PATCH 09/10] iommu/amd: Clear the iommu pre enabled setting Joerg Roedel <joro@8bytes.org> - 2015-09-29 18:20 +0200
[PATCH 08/10] iommu/amd: Do not update the information of domain to devtables before device driver init Baoquan He <bhe@redhat.com> - 2015-09-24 08:40 +0200
[PATCH 05/10] iommu/amd: Add function copy_dev_tables Baoquan He <bhe@redhat.com> - 2015-09-24 08:50 +0200
[PATCH 02/10] iommu/amd: Adjust functons which get first/last devid by reading pci config Baoquan He <bhe@redhat.com> - 2015-09-24 08:50 +0200
[PATCH 03/10] iommu/amd: Get the first/last device of iommu earlier Baoquan He <bhe@redhat.com> - 2015-09-24 08:50 +0200
csiph-web