Skip to contentSkip to conversation

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

PATCH Superseded Nishanth Aravamudan 2 participants 3 messages Sep 4, 2015 PowerPC

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 aca6913f5551 ("powerpc/powernv/ioda2: Introduce helpers to allocate TCE pages")

---

Michael, I did this as a follow-on patch to my previous one. If you'd rather I made a v3 of that patch with the two fixes combined, I can resend.

arch/powerpc/platforms/powernv/pci-ioda.c +6 -0
index f1c74c28e564..73914f4bd1ab 100644
@@ -2084,6 +2084,12 @@ static long pnv_pci_ioda2_setup_default_config(struct pnv_ioda_pe *pe)
 	 */
 	const u64 window_size =
 		min((u64)pe->table_group.tce32_size, memory_hotplug_max());
+	/*
+	 * 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.
+	 */
+	window_size = __rounddown_pow_of_two(window_size);
 
 	rc = pnv_pci_ioda2_create_table(&pe->table_group, 0,
 			IOMMU_PAGE_SHIFT_4K,
#1 lore raw
Quoted 23 lines · Nishanth Aravamudan

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 aca6913f5551 ("powerpc/powernv/ioda2: Introduce helpers to allocate TCE pages")

---

Michael, I did this as a follow-on patch to my previous one. If you'd rather I made a v3 of that patch with the two fixes combined, I can resend.

arch/powerpc/platforms/powernv/pci-ioda.c +0 -0
index f1c74c28e564..73914f4bd1ab 100644

arch/powerpc/platforms/powernv/pci-ioda.c static long pnv_pci_ioda2_setup_default_config(struct pnv_ioda_pe *pe) · line 2092

Quoted 9 lines
arch/powerpc/platforms/powernv/pci-ioda.c +6 -0
@@ -2084,6 +2084,12 @@ static long pnv_pci_ioda2_setup_default_config(struct pnv_ioda_pe *pe)
 	 */
 	const u64 window_size =
 		min((u64)pe->table_group.tce32_size, memory_hotplug_max());
+	/*
+	 * 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.
+	 */
+	window_size = __rounddown_pow_of_two(window_size);

Hi,

Just wondering if this won't hide potential alignment issues of "table_group.tce32_size", that now trigger EINVAL down the road and if it wouldn't be safer to round only "memory_hotplug_max()?

  const __u64 hotplug_max_p2 = __rounddown_pow_of_two(memory_hotplug_max());
  const __u64 window_size =
            min((u64)pe->table_group.tce32_size, hotplug_max_p2);

Regards,
Jan

Quoted 3 lines
arch/powerpc/platforms/powernv/pci-ioda.c +0 -0
 	rc = pnv_pci_ioda2_create_table(&pe->table_group, 0,
 			IOMMU_PAGE_SHIFT_4K,
#2 lore raw
Quoted 36 lines · Jan Stancek
Quoted 23 lines · Nishanth Aravamudan

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 aca6913f5551 ("powerpc/powernv/ioda2: Introduce helpers to allocate TCE pages")

---

Michael, I did this as a follow-on patch to my previous one. If you'd rather I made a v3 of that patch with the two fixes combined, I can resend.

arch/powerpc/platforms/powernv/pci-ioda.c +0 -0
index f1c74c28e564..73914f4bd1ab 100644

arch/powerpc/platforms/powernv/pci-ioda.c static long pnv_pci_ioda2_setup_default_config(struct pnv_ioda_pe *pe) · line 2092

Quoted 9 lines
arch/powerpc/platforms/powernv/pci-ioda.c +6 -0
@@ -2084,6 +2084,12 @@ static long pnv_pci_ioda2_setup_default_config(struct pnv_ioda_pe *pe)
 	 */
 	const u64 window_size =
 		min((u64)pe->table_group.tce32_size, memory_hotplug_max());
+	/*
+	 * 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.
+	 */
+	window_size = __rounddown_pow_of_two(window_size);

Hi,

Quoted 7 lines

Just wondering if this won't hide potential alignment issues of "table_group.tce32_size", that now trigger EINVAL down the road and if it wouldn't be safer to round only "memory_hotplug_max()?

  const __u64 hotplug_max_p2 = __rounddown_pow_of_two(memory_hotplug_max());
  const __u64 window_size =
            min((u64)pe->table_group.tce32_size, hotplug_max_p2);

Fair point, v2 on its way.