From: Chris Wright <chrisw@sous-sol.org>
To: Joerg Roedel <joerg.roedel@amd.com>
Cc: nhorman@tuxdriver.com, nhorman@redhat.com, vgoyal@redhat.com,
hbabu@us.ibm.com, ebiederm@xmission.com,
iommu@lists.linux-foundation.org, kexec@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/4] x86/amd-iommu: warn when issuing command to uninitialized cmd buffer
Date: Fri, 02 Apr 2010 18:27:53 -0700 [thread overview]
Message-ID: <20100403012817.408728532@sous-sol.org> (raw)
In-Reply-To: 20100403012751.834020949@sous-sol.org
[-- Attachment #1: amd-warn-on-early-cmd-buffer.patch --]
[-- Type: text/plain, Size: 1944 bytes --]
To catch future potential issues we can add a warning whenever we issue
a command before the command buffer is fully initialized.
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---
Or not...this is just if you think it's useful ;-)
arch/x86/include/asm/amd_iommu_types.h | 1 +
arch/x86/kernel/amd_iommu.c | 1 +
arch/x86/kernel/amd_iommu_init.c | 5 +++--
3 files changed, 5 insertions(+), 2 deletions(-)
--- a/arch/x86/include/asm/amd_iommu_types.h
+++ b/arch/x86/include/asm/amd_iommu_types.h
@@ -140,6 +140,7 @@
/* constants to configure the command buffer */
#define CMD_BUFFER_SIZE 8192
+#define CMD_BUFFER_UNINITIALIZED 1
#define CMD_BUFFER_ENTRIES 512
#define MMIO_CMD_SIZE_SHIFT 56
#define MMIO_CMD_SIZE_512 (0x9ULL << MMIO_CMD_SIZE_SHIFT)
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -392,6 +392,7 @@ static int __iommu_queue_command(struct
u32 tail, head;
u8 *target;
+ WARN_ON(iommu->cmd_buf_size & CMD_BUFFER_UNINITIALIZED);
tail = readl(iommu->mmio_base + MMIO_CMD_TAIL_OFFSET);
target = iommu->cmd_buf + tail;
memcpy_toio(target, cmd, sizeof(*cmd));
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -436,7 +436,7 @@ static u8 * __init alloc_command_buffer(
if (cmd_buf == NULL)
return NULL;
- iommu->cmd_buf_size = CMD_BUFFER_SIZE;
+ iommu->cmd_buf_size = CMD_BUFFER_SIZE | CMD_BUFFER_UNINITIALIZED;
return cmd_buf;
}
@@ -472,12 +472,13 @@ static void iommu_enable_command_buffer(
&entry, sizeof(entry));
amd_iommu_reset_cmd_buffer(iommu);
+ iommu->cmd_buf_size &= ~(CMD_BUFFER_UNINITIALIZED);
}
static void __init free_command_buffer(struct amd_iommu *iommu)
{
free_pages((unsigned long)iommu->cmd_buf,
- get_order(iommu->cmd_buf_size));
+ get_order(iommu->cmd_buf_size & ~(CMD_BUFFER_UNINITIALIZED)));
}
/* allocates the memory where the IOMMU will log its events to */
next prev parent reply other threads:[~2010-04-03 1:29 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-03 1:27 [PATCH 0/4] AMD IOMMU kdump fix plus cleanups (v2) Chris Wright
2010-04-03 1:27 ` [PATCH 1/4] x86/amd-iommu: enable iommu before attaching devices Chris Wright
2010-04-03 1:27 ` Chris Wright [this message]
2010-04-03 1:27 ` [PATCH 3/4] Revert "x86: disable IOMMUs on kernel crash" Chris Wright
2010-04-03 17:22 ` Joerg Roedel
2010-04-03 17:44 ` Eric W. Biederman
2010-04-04 8:44 ` Joerg Roedel
2010-04-04 9:16 ` Eric W. Biederman
2010-04-04 9:19 ` Eric W. Biederman
2010-04-03 17:41 ` Joerg Roedel
2010-04-03 17:49 ` Eric W. Biederman
2010-04-03 19:13 ` Joerg Roedel
2010-04-03 19:41 ` Eric W. Biederman
2010-04-04 7:24 ` Bernhard Walle
2010-04-04 7:51 ` Eric W. Biederman
2010-04-04 8:53 ` Joerg Roedel
2010-04-04 9:44 ` Eric W. Biederman
2010-04-04 10:01 ` Joerg Roedel
2010-04-06 17:42 ` Chris Wright
2010-04-06 17:51 ` Joerg Roedel
2010-04-06 20:39 ` Vivek Goyal
2010-04-06 21:13 ` Vivek Goyal
2010-04-06 21:45 ` Yinghai Lu
2010-04-06 22:10 ` Eric W. Biederman
2010-04-04 11:54 ` David Woodhouse
2010-04-03 1:27 ` [PATCH 4/4] x86/amd-iommu: use for_each_pci_dev Chris Wright
2010-04-07 10:05 ` [PATCH 0/4] AMD IOMMU kdump fix plus cleanups (v2) Joerg Roedel
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=20100403012817.408728532@sous-sol.org \
--to=chrisw@sous-sol.org \
--cc=ebiederm@xmission.com \
--cc=hbabu@us.ibm.com \
--cc=iommu@lists.linux-foundation.org \
--cc=joerg.roedel@amd.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nhorman@redhat.com \
--cc=nhorman@tuxdriver.com \
--cc=vgoyal@redhat.com \
/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