Commit fa144869 authored by Nishanth Aravamudan's avatar Nishanth Aravamudan Committed by Michael Ellerman

powerpc/powernv/pci-ioda: fix kdump with non-power-of-2 crashkernel=

The 32-bit TCE table initialization relies on the DMA window having a
size equal to a power of 2 (and checks for it explicitly). But
crashkernel= has no constraint that requires a power-of-2 be specified.
This causes the kdump kernel to fail to boot as none of the PCI devices
(including the disk controller) are successfully initialized.

After this change, the PCI devices successfully set up the 32-bit TCE
table and kdump succeeds.

Fixes: aca6913f ("powerpc/powernv/ioda2: Introduce helpers to allocate TCE pages")
Signed-off-by: default avatarNishanth Aravamudan <nacc@linux.vnet.ibm.com>
Cc: stable@vger.kernel.org # 4.2
Tested-by: default avatarJan Stancek <jstancek@redhat.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent bb005455
...@@ -2049,13 +2049,19 @@ static long pnv_pci_ioda2_setup_default_config(struct pnv_ioda_pe *pe) ...@@ -2049,13 +2049,19 @@ static long pnv_pci_ioda2_setup_default_config(struct pnv_ioda_pe *pe)
struct iommu_table *tbl = NULL; struct iommu_table *tbl = NULL;
long rc; long rc;
/*
* crashkernel= specifies the kdump kernel's maximum memory at
* some offset and there is no guaranteed the result is a power
* of 2, which will cause errors later.
*/
const u64 max_memory = __rounddown_pow_of_two(memory_hotplug_max());
/* /*
* In memory constrained environments, e.g. kdump kernel, the * In memory constrained environments, e.g. kdump kernel, the
* DMA window can be larger than available memory, which will * DMA window can be larger than available memory, which will
* cause errors later. * cause errors later.
*/ */
const u64 window_size = min((u64)pe->table_group.tce32_size, const u64 window_size = min((u64)pe->table_group.tce32_size, max_memory);
memory_hotplug_max());
rc = pnv_pci_ioda2_create_table(&pe->table_group, 0, rc = pnv_pci_ioda2_create_table(&pe->table_group, 0,
IOMMU_PAGE_SHIFT_4K, IOMMU_PAGE_SHIFT_4K,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment