mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Li, Zhen-Hua" <zhen-hual@hp.com>
To: David Woodhouse <dwmw2@infradead.org>,
	Joerg Roedel <joro@8bytes.org>,
	<iommu@lists.linux-foundation.org>,
	<linux-kernel@vger.kernel.org>
Cc: "Li, Zhen-Hua" <zhen-hual@hp.com>
Subject: [PATCH 1/1] iommu/vt-d : clear old root entry for dump kernel
Date: Mon, 18 Aug 2014 16:59:12 +0800	[thread overview]
Message-ID: <1408352352-14449-1-git-send-email-zhen-hual@hp.com> (raw)

If intel_iommu is enabled, when kdump kernel boots, the old root entry
 should be cleared, otherwise it may cause DMAR error.

To make it works for more enviroments, this patch does not use 
is_kdump_kernel() to check it,  but reads the register to check whether 
hardware is using old root entry.

Signed-off-by: Li, Zhen-Hua <zhen-hual@hp.com>
---
 drivers/iommu/dmar.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 60ab474..7b4fa90 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -66,6 +66,8 @@ static int dmar_dev_scope_status = 1;
 static int alloc_iommu(struct dmar_drhd_unit *drhd);
 static void free_iommu(struct intel_iommu *iommu);
 
+static int iommu_check_root_entry(struct intel_iommu *iommu);
+
 static void __init dmar_register_drhd_unit(struct dmar_drhd_unit *drhd)
 {
 	/*
@@ -987,6 +989,8 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)
 						       intel_iommu_groups,
 						       iommu->name);
 
+	iommu_check_root_entry(iommu);
+
 	return 0;
 
  err_unmap:
@@ -1666,5 +1670,32 @@ static int __init dmar_free_unused_resources(void)
 	return 0;
 }
 
+static int iommu_check_root_entry(struct intel_iommu *iommu)
+{
+	u64 re_pa;
+
+	re_pa = dmar_readq(iommu->reg + DMAR_RTADDR_REG);
+
+	/* This only works for hardware error and kdump kernel */
+	if (unlikely(re_pa != 0)) {
+		u32 sts;
+		unsigned long flag;
+
+		raw_spin_lock_irqsave(&iommu->register_lock, flag);
+		dmar_writeq(iommu->reg + DMAR_RTADDR_REG, 0);
+
+		writel(iommu->gcmd | DMA_GCMD_SRTP, iommu->reg + DMAR_GCMD_REG);
+
+		/* Make sure hardware complete it */
+		IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG,
+			      readl, (sts & DMA_GSTS_RTPS), sts);
+
+		raw_spin_unlock_irqrestore(&iommu->register_lock, flag);
+
+	}
+
+	return 0;
+}
+
 late_initcall(dmar_free_unused_resources);
 IOMMU_INIT_POST(detect_intel_iommu);
-- 
2.0.0-rc0


             reply	other threads:[~2014-08-18  9:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-18  8:59 Li, Zhen-Hua [this message]
2014-08-18 23:01 ` Li, Zhen-Hua
2014-08-18 23:23   ` Joerg Roedel
2014-08-18 23:27     ` Li, Zhen-Hua
2014-08-19 11:02       ` Joerg Roedel
2014-08-20  9:54         ` Li, ZhenHua
2014-08-18 23:47     ` Li, Zhen-Hua
2014-08-18 23:59       ` Li, Zhen-Hua
2014-08-19  5:49         ` Li, ZhenHua

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=1408352352-14449-1-git-send-email-zhen-hual@hp.com \
    --to=zhen-hual@hp.com \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®