From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zf0Ai-0000v8-74 for kexec@lists.infradead.org; Thu, 24 Sep 2015 06:38:24 +0000 From: Baoquan He Subject: [PATCH 04/10] iommu/amd: Detect pre enabled translation Date: Thu, 24 Sep 2015 14:37:30 +0800 Message-Id: <1443076656-31776-5-git-send-email-bhe@redhat.com> In-Reply-To: <1443076656-31776-1-git-send-email-bhe@redhat.com> References: <1443076656-31776-1-git-send-email-bhe@redhat.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kexec" Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: joro@8bytes.org, iommu@lists.linux-foundation.org Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Baoquan He 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 --- 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< 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 _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec