2019-05-28 01:56:11

by Shawn Anastasio

[permalink] [raw]
Subject: [PATCH v2 0/3] Allow custom PCI resource alignment on pseries

Changes from v1 to v2:
- Fix function declaration warnings caught by sparse

Hello all,

This patch set implements support for user-specified PCI resource
alignment on the pseries platform for hotplugged PCI devices.
Currently on pseries, PCI resource alignments specified with the
pci=resource_alignment commandline argument are ignored, since
the firmware is in charge of managing the PCI resources. In the
case of hotplugged devices, though, the kernel is in charge of
configuring the resources and should obey alignment requirements.

The current behavior of ignoring the alignment for hotplugged devices
results in sub-page BARs landing between page boundaries and
becoming un-mappable from userspace via the VFIO framework.
This issue was observed on a pseries KVM guest with hotplugged
ivshmem devices.

With these changes, users can specify an appropriate
pci=resource_alignment argument on boot for devices they wish to use
with VFIO.

In the future, this could be extended to provide page-aligned
resources by default for hotplugged devices, similar to what is done
on powernv by commit 382746376993 ("powerpc/powernv: Override
pcibios_default_alignment() to force PCI devices to be page aligned").

Feedback is appreciated.

Thanks,
Shawn

Shawn Anastasio (3):
PCI: Introduce pcibios_ignore_alignment_request
powerpc/64: Enable pcibios_after_init hook on ppc64
powerpc/pseries: Allow user-specified PCI resource alignment after
init

arch/powerpc/include/asm/machdep.h | 6 ++++--
arch/powerpc/kernel/pci-common.c | 9 +++++++++
arch/powerpc/kernel/pci_64.c | 4 ++++
arch/powerpc/platforms/pseries/setup.c | 22 ++++++++++++++++++++++
drivers/pci/pci.c | 9 +++++++--
include/linux/pci.h | 1 +
6 files changed, 47 insertions(+), 4 deletions(-)

--
2.20.1


2019-05-28 01:58:04

by Shawn Anastasio

[permalink] [raw]
Subject: [PATCH v2 2/3] powerpc/64: Enable pcibios_after_init hook on ppc64

Enable the pcibios_after_init hook on all powerpc platforms.
This hook is executed at the end of pcibios_init and was previously
only available on CONFIG_PPC32.

Since it is useful and not inherently limited to 32-bit mode,
remove the limitation and allow it on all powerpc platforms.

Signed-off-by: Shawn Anastasio <[email protected]>
---
arch/powerpc/include/asm/machdep.h | 3 +--
arch/powerpc/kernel/pci_64.c | 4 ++++
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 2f0ca6560e47..2fbfaa9176ed 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -150,6 +150,7 @@ struct machdep_calls {
void (*init)(void);

void (*kgdb_map_scc)(void);
+#endif /* CONFIG_PPC32 */

/*
* optional PCI "hooks"
@@ -157,8 +158,6 @@ struct machdep_calls {
/* Called at then very end of pcibios_init() */
void (*pcibios_after_init)(void);

-#endif /* CONFIG_PPC32 */
-
/* Called in indirect_* to avoid touching devices */
int (*pci_exclude_device)(struct pci_controller *, unsigned char, unsigned char);

diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 9d8c10d55407..fba7fe6e4a50 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -68,6 +68,10 @@ static int __init pcibios_init(void)

printk(KERN_DEBUG "PCI: Probing PCI hardware done\n");

+ /* Call machine dependent post-init code */
+ if (ppc_md.pcibios_after_init)
+ ppc_md.pcibios_after_init();
+
return 0;
}

--
2.20.1