File kdump-calibrate-swiotlb.patch of Package kdump
From: Petr Tesarik <ptesarik@suse.com>
Date: Fri Nov 6 11:21:48 2015 +0100
Subject: calibrate: Add memory for SWIOTLB if maxpfn is above 4G
References: bsc#952141
Patch-mainline: v.0.8.16
Git-commit: f08aa2803415cff5d67c32b1320dc7d8a5251055
The kernel may need a SWIOTLB if a system has RAM above 4G. Note that
a system may have less than 4G total RAM but still physical addresses
above 4G (because of memory holes). Consequently, the code must check
/proc/iomem rather than just memtotal.
Of course, if the system has a hardware IOMMU, software IO TLB may
not be needed. There is no (straightforward) way to check on a
running system if SWIOTLB is used or not, so let's always reserve
the memory for it, except when running on a system with all RAM
below 4G. This is acceptable, because only such small systems may
be concerned about reducing available RAM by 64M.
Signed-off-by: Petr Tesarik <ptesarik@suse.com>
---
kdumptool/calibrate.cc | 9 +++++++++
1 file changed, 9 insertions(+)
--- a/kdumptool/calibrate.cc
+++ b/kdumptool/calibrate.cc
@@ -1029,6 +1029,15 @@ void Calibrate::execute()
#if defined(__x86_64__)
unsigned long long base = mm.find(required << 10, 16UL << 20);
unsigned long low, high;
+
+ Debug::debug()->dbg("Estimated crash area base: 0x%llx", base);
+
+ // If maxpfn is above 4G, SWIOTLB may be needed
+ if ((base + (required << 10)) >= (1ULL<<32)) {
+ Debug::debug()->dbg("Adding 64 MiB for SWIOTLB");
+ required += MB(64);
+ }
+
if (base < (1ULL<<32)) {
low = 0;
high = required;