LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Shawn Anastasio <shawn@anastas.io>
Cc: linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au,
sbobroff@linux.ibm.com, xyjxie@linux.vnet.ibm.com,
rppt@linux.ibm.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/3] powerpc/pseries: Allow user-specified PCI resource alignment after init
Date: Wed, 29 May 2019 09:02:56 -0500 [thread overview]
Message-ID: <20190529140256.GC28250@google.com> (raw)
In-Reply-To: <20190528040313.35582-4-shawn@anastas.io>
On Mon, May 27, 2019 at 11:03:13PM -0500, Shawn Anastasio wrote:
> On pseries, custom PCI resource alignment specified with the commandline
> argument pci=resource_alignment is disabled due to PCI resources being
> managed by the firmware. However, in the case of PCI hotplug the
> resources are managed by the kernel, so custom alignments should be
> honored in these cases. This is done by only honoring custom
> alignments after initial PCI initialization is done, to ensure that
> all devices managed by the firmware are excluded.
>
> Without this ability, sub-page BARs sometimes get mapped in between
> page boundaries for hotplugged devices and are therefore unusable
> with the VFIO framework. This change allows users to request
> page alignment for devices they wish to access via VFIO using
> the pci=resource_alignment commandline argument.
>
> 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")
>
> Signed-off-by: Shawn Anastasio <shawn@anastas.io>
> ---
> arch/powerpc/include/asm/machdep.h | 3 +++
> arch/powerpc/kernel/pci-common.c | 9 +++++++++
> arch/powerpc/platforms/pseries/setup.c | 22 ++++++++++++++++++++++
> 3 files changed, 34 insertions(+)
>
> diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
> index 2fbfaa9176ed..46eb62c0954e 100644
> --- a/arch/powerpc/include/asm/machdep.h
> +++ b/arch/powerpc/include/asm/machdep.h
> @@ -179,6 +179,9 @@ struct machdep_calls {
>
> resource_size_t (*pcibios_default_alignment)(void);
>
> + /* Called when determining PCI resource alignment */
> + int (*pcibios_ignore_alignment_request)(void);
> +
> #ifdef CONFIG_PCI_IOV
> void (*pcibios_fixup_sriov)(struct pci_dev *pdev);
> resource_size_t (*pcibios_iov_resource_alignment)(struct pci_dev *, int resno);
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index ff4b7539cbdf..8e0d73b4c188 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -238,6 +238,15 @@ resource_size_t pcibios_default_alignment(void)
> return 0;
> }
>
> +int pcibios_ignore_alignment_request(void)
> +{
> + if (ppc_md.pcibios_ignore_alignment_request)
> + return ppc_md.pcibios_ignore_alignment_request();
> +
> + /* Fall back to default method of checking PCI_PROBE_ONLY */
> + return pci_has_flag(PCI_PROBE_ONLY);
> +}
> +
> #ifdef CONFIG_PCI_IOV
> resource_size_t pcibios_iov_resource_alignment(struct pci_dev *pdev, int resno)
> {
> diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
> index e4f0dfd4ae33..07f03be02afe 100644
> --- a/arch/powerpc/platforms/pseries/setup.c
> +++ b/arch/powerpc/platforms/pseries/setup.c
> @@ -82,6 +82,8 @@ EXPORT_SYMBOL(CMO_PageSize);
>
> int fwnmi_active; /* TRUE if an FWNMI handler is present */
>
> +static int initial_pci_init_done; /* TRUE if initial pcibios init has completed */
> +
> static void pSeries_show_cpuinfo(struct seq_file *m)
> {
> struct device_node *root;
> @@ -749,6 +751,23 @@ static resource_size_t pseries_pci_iov_resource_alignment(struct pci_dev *pdev,
> }
> #endif
>
> +static void pseries_after_init(void)
> +{
> + initial_pci_init_done = 1;
> +}
> +
> +static int pseries_ignore_alignment_request(void)
> +{
> + if (initial_pci_init_done)
> + /*
> + * Allow custom alignments after init for things
> + * like PCI hotplugging.
> + */
> + return 0;
Hmm, if there's any way to avoid this sort of early/late flag, that
would be nicer.
> +
> + return pci_has_flag(PCI_PROBE_ONLY);
> +}
> +
> static void __init pSeries_setup_arch(void)
> {
> set_arch_panic_timeout(10, ARCH_PANIC_TIMEOUT);
> @@ -797,6 +816,9 @@ static void __init pSeries_setup_arch(void)
> }
>
> ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare;
> + ppc_md.pcibios_after_init = pseries_after_init;
> + ppc_md.pcibios_ignore_alignment_request =
> + pseries_ignore_alignment_request;
> }
>
> static void pseries_panic(char *str)
> --
> 2.20.1
>
prev parent reply other threads:[~2019-05-29 14:02 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-28 4:03 [PATCH v3 0/3] Allow custom PCI resource alignment on pseries Shawn Anastasio
2019-05-28 4:03 ` [PATCH v3 1/3] PCI: Introduce pcibios_ignore_alignment_request Shawn Anastasio
2019-05-28 5:36 ` Oliver
2019-05-28 5:50 ` Shawn Anastasio
2019-05-28 6:27 ` Alexey Kardashevskiy
2019-05-28 7:39 ` Shawn Anastasio
2019-05-30 3:39 ` Alexey Kardashevskiy
2019-05-30 22:49 ` Shawn Anastasio
2019-05-31 3:56 ` Alexey Kardashevskiy
2019-06-03 2:23 ` Shawn Anastasio
2019-06-03 5:02 ` Alexey Kardashevskiy
2019-06-03 8:35 ` Alexey Kardashevskiy
2019-06-03 9:12 ` Shawn Anastasio
2019-05-29 14:00 ` Bjorn Helgaas
2019-05-30 6:55 ` [EXTERNAL] " Sam Bobroff
2019-05-30 22:33 ` Shawn Anastasio
2019-05-28 4:03 ` [PATCH v3 2/3] powerpc/64: Enable pcibios_after_init hook on ppc64 Shawn Anastasio
2019-05-28 4:03 ` [PATCH v3 3/3] powerpc/pseries: Allow user-specified PCI resource alignment after init Shawn Anastasio
2019-05-29 14:02 ` Bjorn Helgaas [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190529140256.GC28250@google.com \
--to=helgaas@kernel.org \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
--cc=rppt@linux.ibm.com \
--cc=sbobroff@linux.ibm.com \
--cc=shawn@anastas.io \
--cc=xyjxie@linux.vnet.ibm.com \
--subject='Re: [PATCH v3 3/3] powerpc/pseries: Allow user-specified PCI resource alignment after init' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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).