Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1231887
| From | Baoquan He <bhe@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 04/10] iommu/amd: Detect pre enabled translation |
| Date | 2015-09-24 08:40 +0200 |
| Message-ID | <qc8me-3vB-13@gated-at.bofh.it> (permalink) |
| References | <qc8md-3vB-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Add functions to check whether translation is already enabled in IOMMU.
Maybe it need be checked per IOMMU. Currently for debugging I didn't do
like that.
Signed-off-by: Baoquan He <bhe@redhat.com>
---
drivers/iommu/amd_iommu_init.c | 26 ++++++++++++++++++++++++++
drivers/iommu/amd_iommu_proto.h | 4 ++++
2 files changed, 30 insertions(+)
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 5845918..1fc369e 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -229,6 +229,27 @@ static int amd_iommu_enable_interrupts(void);
static int __init iommu_go_to_state(enum iommu_init_state state);
static void init_device_table_dma(void);
+static u8 g_pre_enabled;
+
+bool translation_pre_enabled(void)
+{
+ return !!g_pre_enabled;
+}
+
+void clear_translation_pre_enabled(void)
+{
+ g_pre_enabled = 0;
+}
+
+static void init_translation_status(struct amd_iommu *iommu)
+{
+ u32 ctrl;
+
+ ctrl = readl(iommu->mmio_base + MMIO_CONTROL_OFFSET);
+ if (ctrl & (1<<CONTROL_IOMMU_EN))
+ g_pre_enabled = 1;
+}
+
static inline void update_last_devid(u16 devid)
{
if (devid > amd_iommu_last_bdf)
@@ -1142,6 +1163,11 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h)
iommu->int_enabled = false;
+ init_translation_status(iommu);
+
+ if (translation_pre_enabled())
+ pr_warn("Translation is already enabled - trying to copy translation structures\n");
+
ret = init_iommu_from_acpi(iommu, h);
if (ret)
return ret;
diff --git a/drivers/iommu/amd_iommu_proto.h b/drivers/iommu/amd_iommu_proto.h
index 0bd9eb3..743e209 100644
--- a/drivers/iommu/amd_iommu_proto.h
+++ b/drivers/iommu/amd_iommu_proto.h
@@ -98,4 +98,8 @@ static inline bool iommu_feature(struct amd_iommu *iommu, u64 f)
return !!(iommu->features & f);
}
+/* kdump checking */
+extern bool translation_pre_enabled(void);
+extern void clear_translation_pre_enabled(void);
+
#endif /* _ASM_X86_AMD_IOMMU_PROTO_H */
--
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