From: Chris Wright <chrisw@sous-sol.org>
To: Joerg Roedel <joerg.roedel@amd.com>
Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] amd-iommu: initialization fixes
Date: Thu, 11 Jun 2009 20:05:11 -0700 [thread overview]
Message-ID: <20090612030511.GS20823@sequoia.sous-sol.org> (raw)
In-Reply-To: <20090612030341.GQ20823@sequoia.sous-sol.org>
If the kernel in initialized w/out coming out of reset (e.g. kexec/kdump), the
prior kernel may leave the IOMMU running. Here's some fixes just to
ensure all initialization is done in a sane manner.
1) disable IOMMU when discovered, will get renabled after it's set up
2) disable event log handling while setting up the event log buffer.
the spec says:
Software Note: If EventLen or EventBase is changed while the
EventLogRun=1, the IOMMU behavior is undefined.
3) ensure the head/tail event log buffer pointers are initialized to zero
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---
arch/x86/kernel/amd_iommu_init.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -252,6 +252,11 @@ static void __init iommu_enable(struct a
iommu_feature_enable(iommu, CONTROL_IOMMU_EN);
}
+static void __init iommu_disable(struct amd_iommu *iommu)
+{
+ iommu_feature_disable(iommu, CONTROL_IOMMU_EN);
+}
+
/* Function to enable IOMMU event logging and event interrupts */
static void __init iommu_enable_event_logging(struct amd_iommu *iommu)
{
@@ -259,6 +264,12 @@ static void __init iommu_enable_event_lo
iommu_feature_enable(iommu, CONTROL_EVT_INT_EN);
}
+static void __init iommu_disable_event_logging(struct amd_iommu *iommu)
+{
+ iommu_feature_disable(iommu, CONTROL_EVT_INT_EN);
+ iommu_feature_disable(iommu, CONTROL_EVT_LOG_EN);
+}
+
/*
* mapping and unmapping functions for the IOMMU MMIO space. Each AMD IOMMU in
* the system has one.
@@ -453,12 +464,19 @@ static u8 * __init alloc_event_buffer(st
if (iommu->evt_buf == NULL)
return NULL;
+ /* disable event logging while setting it up */
+ iommu_disable_event_logging(iommu);
+
entry = (u64)virt_to_phys(iommu->evt_buf) | EVT_LEN_MASK;
memcpy_toio(iommu->mmio_base + MMIO_EVT_BUF_OFFSET,
&entry, sizeof(entry));
iommu->evt_buf_size = EVT_BUFFER_SIZE;
+ /* set head and tail to zero manually */
+ writel(0x00, iommu->mmio_base + MMIO_EVT_HEAD_OFFSET);
+ writel(0x00, iommu->mmio_base + MMIO_EVT_TAIL_OFFSET);
+
return iommu->evt_buf;
}
@@ -713,6 +731,9 @@ static int __init init_iommu_one(struct
if (!iommu->mmio_base)
return -ENOMEM;
+ /* disable IOMMU in case it was left on */
+ iommu_disable(iommu);
+
iommu_set_device_table(iommu);
iommu->cmd_buf = alloc_command_buffer(iommu);
if (!iommu->cmd_buf)
next prev parent reply other threads:[~2009-06-12 3:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-12 3:03 [PATCH 0/2] amd-iommu: kdump bugfix and couple defensive cleanups Chris Wright
2009-06-12 3:04 ` [PATCH 1/2] amd-iommu: fix issues with kdump Chris Wright
2009-06-12 3:05 ` Chris Wright [this message]
2009-06-15 9:48 ` [PATCH 0/2] amd-iommu: kdump bugfix and couple defensive cleanups Joerg Roedel
2009-06-15 16:33 ` Chris Wright
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=20090612030511.GS20823@sequoia.sous-sol.org \
--to=chrisw@sous-sol.org \
--cc=iommu@lists.linux-foundation.org \
--cc=joerg.roedel@amd.com \
--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
Powered by JetHome