From: Baoquan He <bhe@redhat.com>
To: joro@8bytes.org, iommu@lists.linux-foundation.org
Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
Baoquan He <bhe@redhat.com>
Subject: [PATCH 06/10] iommu/amd: Add functions copy_command_buffer/copy_event_buffer
Date: Thu, 24 Sep 2015 14:37:32 +0800 [thread overview]
Message-ID: <1443076656-31776-7-git-send-email-bhe@redhat.com> (raw)
In-Reply-To: <1443076656-31776-1-git-send-email-bhe@redhat.com>
Copy command buffer and event buffer from the old to kdump kernel.
Still there are 2 problems:
1) Not very sure if this is necessary. If do not copy the old command buffer, and
only set the newly allocated command buffer, is there anything wrong?
2) If copy is needed, do we need to take care of the head and tail pointers? Since
in section 3.3 of AMD IOMMU spec it says: "Any or all command buffer entries may be
copied from the old command buffer to the new and software must set the head and tail
pointers appropriately." However from the spec the command buffer head pointer and
tail register store an offset from the base address, which point to the next command
to be read/written separately.
Signed-off-by: Baoquan He <bhe@redhat.com>
---
drivers/iommu/amd_iommu_init.c | 37 +++++++++++++++++++++++++++++++++++++
drivers/iommu/amd_iommu_types.h | 1 +
2 files changed, 38 insertions(+)
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 913a718..a334d14 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -713,7 +713,44 @@ static void copy_dev_tables(void)
}
iounmap(old_devtb);
}
+}
+
+static void copy_command_buffer(void)
+{
+ u64 entry;
+ u32 lo, hi;
+ phys_addr_t old_phys;
+ u64 old_virt;
+ struct amd_iommu *iommu;
+ for_each_iommu(iommu) {
+ lo = readl(iommu->mmio_base + MMIO_CMD_BUF_OFFSET);
+ hi = readl(iommu->mmio_base + MMIO_CMD_BUF_OFFSET + 4);
+ entry = (((u64) hi) << 32) + lo;
+ old_phys &= (1<<MMIO_CMD_SIZE_SHIFT) -1;
+ old_virt = ioremap_cache(old_phys, CMD_BUFFER_SIZE);
+ memcpy(iommu->cmd_buf, old_virt, CMD_BUFFER_SIZE);
+ iounmap(old_virt);
+ }
+}
+
+static void copy_event_buffer(void)
+{
+ u64 entry;
+ u32 lo, hi;
+ phys_addr_t old_phys;
+ u64 old_virt;
+ struct amd_iommu *iommu;
+
+ for_each_iommu(iommu) {
+ lo = readl(iommu->mmio_base + MMIO_EVT_BUF_OFFSET);
+ hi = readl(iommu->mmio_base + MMIO_EVT_BUF_OFFSET + 4);
+ entry = (((u64) hi) << 32) + lo;
+ old_phys &= (1<<MMIO_EVT_SIZE_SHIFT) -1;
+ old_virt = ioremap_cache(old_phys, EVT_BUFFER_SIZE);
+ memcpy(iommu->evt_buf, old_virt, EVT_BUFFER_SIZE);
+ iounmap(old_virt);
+ }
}
/* sets a specific bit in the device table entry. */
diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h
index d0f0cfb..250384e 100644
--- a/drivers/iommu/amd_iommu_types.h
+++ b/drivers/iommu/amd_iommu_types.h
@@ -208,6 +208,7 @@
/* constants for event buffer handling */
#define EVT_BUFFER_SIZE 8192 /* 512 entries */
#define EVT_LEN_MASK (0x9ULL << 56)
+#define MMIO_EVT_SIZE_SHIFT 56
/* Constants for PPR Log handling */
#define PPR_LOG_ENTRIES 512
--
2.4.0
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2015-09-24 6:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-24 6:37 [PATCH 00/10] Fix AMD IOMMU faults in kdump kernel Baoquan He
2015-09-24 6:37 ` [PATCH 01/10] iommu/amd: Use standard bitmap operation to set bitmap Baoquan He
2015-09-24 6:37 ` [PATCH 02/10] iommu/amd: Adjust functons which get first/last devid by reading pci config Baoquan He
2015-09-24 6:37 ` [PATCH 03/10] iommu/amd: Get the first/last device of iommu earlier Baoquan He
2015-09-24 6:37 ` [PATCH 04/10] iommu/amd: Detect pre enabled translation Baoquan He
2015-09-24 6:37 ` [PATCH 05/10] iommu/amd: Add function copy_dev_tables Baoquan He
2015-09-24 6:37 ` Baoquan He [this message]
[not found] ` <20150929160439.GN3036@8bytes.org>
2015-10-10 12:24 ` [PATCH 06/10] iommu/amd: Add functions copy_command_buffer/copy_event_buffer Baoquan He
2015-09-24 6:37 ` [PATCH 07/10] iommu/amd: copy old dev tables and do not touch dev tables Baoquan He
[not found] ` <20150929160808.GO3036@8bytes.org>
2015-10-10 12:28 ` Baoquan He
2015-09-24 6:37 ` [PATCH 08/10] iommu/amd: Do not update the information of domain to devtables before device driver init Baoquan He
2015-09-24 6:37 ` [PATCH 09/10] iommu/amd: Clear the iommu pre enabled setting Baoquan He
[not found] ` <20150929160949.GP3036@8bytes.org>
2015-10-10 12:30 ` Baoquan He
2015-09-24 6:37 ` [PATCH 10/10] iommu/amd: Copy the old ir table Baoquan He
[not found] ` <20150929161140.GQ3036@8bytes.org>
2015-10-10 12:40 ` Baoquan He
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=1443076656-31776-7-git-send-email-bhe@redhat.com \
--to=bhe@redhat.com \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.org \
--cc=kexec@lists.infradead.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