linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/powernv/pci-ioda: fix kdump with non-power-of-2 crashkernel=
@ 2015-09-04 16:59 Nishanth Aravamudan
  2015-09-04 18:01 ` Jan Stancek
  0 siblings, 1 reply; 3+ messages in thread
From: Nishanth Aravamudan @ 2015-09-04 16:59 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Hari Bathini, Gavin Shan, Alexey Kardashevskiy, Ben Herrenschmidt,
	Paul Mackerras, David Gibson, Wei Yang, linuxppc-dev

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")
Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Cc: stable@vger.kernel.org # 4.2

---

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.

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index f1c74c28e564..73914f4bd1ab 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -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,

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: powerpc/powernv/pci-ioda: fix kdump with non-power-of-2 crashkernel=
  2015-09-04 16:59 [PATCH] powerpc/powernv/pci-ioda: fix kdump with non-power-of-2 crashkernel= Nishanth Aravamudan
@ 2015-09-04 18:01 ` Jan Stancek
  2015-09-04 18:18   ` Nishanth Aravamudan
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Stancek @ 2015-09-04 18:01 UTC (permalink / raw)
  To: Nishanth Aravamudan
  Cc: Michael Ellerman, Wei Yang, Alexey Kardashevskiy, Gavin Shan,
	Hari Bathini, Paul Mackerras, linuxppc-dev, David Gibson

On Fri, Sep 04, 2015 at 09:59:38AM -0700, Nishanth Aravamudan wrote:
> 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")
> Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
> Cc: stable@vger.kernel.org # 4.2
> ---
> 
> 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.
> 
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index f1c74c28e564..73914f4bd1ab 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -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

>  
>  	rc = pnv_pci_ioda2_create_table(&pe->table_group, 0,
>  			IOMMU_PAGE_SHIFT_4K,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: powerpc/powernv/pci-ioda: fix kdump with non-power-of-2 crashkernel=
  2015-09-04 18:01 ` Jan Stancek
@ 2015-09-04 18:18   ` Nishanth Aravamudan
  0 siblings, 0 replies; 3+ messages in thread
From: Nishanth Aravamudan @ 2015-09-04 18:18 UTC (permalink / raw)
  To: Jan Stancek
  Cc: Michael Ellerman, Wei Yang, Alexey Kardashevskiy, Gavin Shan,
	Hari Bathini, Paul Mackerras, linuxppc-dev, David Gibson

On 04.09.2015 [20:01:22 +0200], Jan Stancek wrote:
> On Fri, Sep 04, 2015 at 09:59:38AM -0700, Nishanth Aravamudan wrote:
> > 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")
> > Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
> > Cc: stable@vger.kernel.org # 4.2
> > ---
> > 
> > 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.
> > 
> > diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> > index f1c74c28e564..73914f4bd1ab 100644
> > --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> > +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> > @@ -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);

Fair point, v2 on its way.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-09-04 18:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-04 16:59 [PATCH] powerpc/powernv/pci-ioda: fix kdump with non-power-of-2 crashkernel= Nishanth Aravamudan
2015-09-04 18:01 ` Jan Stancek
2015-09-04 18:18   ` Nishanth Aravamudan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).