All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver O'Halloran <oohall@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Paul Mackerras <paulus@samba.org>, Oliver O'Halloran <oohall@gmail.com>
Subject: [PATCH 01/18] powerpc/pci: Add ppc_md.discover_phbs()
Date: Tue,  3 Nov 2020 15:35:06 +1100	[thread overview]
Message-ID: <20201103043523.916109-1-oohall@gmail.com> (raw)

On many powerpc platforms the discovery and initalisation of
pci_controllers (PHBs) happens inside of setup_arch(). This is very early
in boot (pre-initcalls) and means that we're initialising the PHB long
before many basic kernel services (slab allocator, debugfs, a real ioremap)
are available.

On PowerNV this causes an additional problem since we map the PHB registers
with ioremap(). As of commit d538aadc2718 ("powerpc/ioremap: warn on early
use of ioremap()") a warning is printed because we're using the "incorrect"
API to setup and MMIO mapping in searly boot. The kernel does provide
early_ioremap(), but that is not intended to create long-lived MMIO
mappings and a seperate warning is printed by generic code if
early_ioremap() mappings are "leaked."

This is all fixable with dumb hacks like using early_ioremap() to setup
the initial mapping then replacing it with a real ioremap later on in
boot, but it does raise the question: Why the hell are we setting up the
PHB's this early in boot?

The old and wise claim it's due to "hysterical rasins." Aside from amused
grapes there doesn't appear to be any real reason to maintain the current
behaviour. Already most of the newer embedded platforms perform PHB
discovery in an arch_initcall and between the end of setup_arch() and the
start of initcalls none of the generic kernel code does anything PCI
related. On powerpc scanning PHBs occurs in a subsys_initcall so it should
be possible to move the PHB discovery to a core, postcore or arch initcall.

This patch adds the ppc_md.discover_phbs hook and a core_initcall stub that
calls it. The core_initcalls are the earliest to be called so this will
any possibly issues with dependency between initcalls. This isn't just an
academic issue either since on pseries and PowerNV EEH init occurs in an
arch_initcall and depends on the pci_controllers being available, similarly
the creation of pci_dns occurs at core_initcall_sync (i.e. between core and
postcore initcalls). These problems need to be addressed seperately.

Cc: Paul Mackerras <paulus@samba.org>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 arch/powerpc/include/asm/machdep.h |  3 +++
 arch/powerpc/kernel/pci-common.c   | 10 ++++++++++
 2 files changed, 13 insertions(+)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 475687f24f4a..d319160d790c 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -59,6 +59,9 @@ struct machdep_calls {
 	int		(*pcibios_root_bridge_prepare)(struct pci_host_bridge
 				*bridge);
 
+	/* finds all the pci_controllers present at boot */
+	void 		(*discover_phbs)(void);
+
 	/* To setup PHBs when using automatic OF platform driver for PCI */
 	int		(*pci_setup_phb)(struct pci_controller *host);
 
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index be108616a721..6265e7d1c697 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1625,3 +1625,13 @@ static void fixup_hide_host_resource_fsl(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MOTOROLA, PCI_ANY_ID, fixup_hide_host_resource_fsl);
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_FREESCALE, PCI_ANY_ID, fixup_hide_host_resource_fsl);
+
+
+int __init discover_phbs(void)
+{
+	if (ppc_md.discover_phbs)
+		ppc_md.discover_phbs();
+
+	return 0;
+}
+core_initcall(discover_phbs);
-- 
2.26.2


             reply	other threads:[~2020-11-03  4:37 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03  4:35 Oliver O'Halloran [this message]
2020-11-03  4:35 ` [PATCH 02/18] powerpc/{powernv,pseries}: Move PHB discovery Oliver O'Halloran
2020-11-03  4:35 ` [PATCH 03/18] powerpc/maple: " Oliver O'Halloran
2020-11-03  4:35 ` [PATCH 04/18] powerpc/512x: " Oliver O'Halloran
2020-11-03  4:35 ` [PATCH 05/18] powerpc/52xx/efika: " Oliver O'Halloran
2020-11-03  4:35 ` [PATCH 06/18] powerpc/52xx/lite5200: " Oliver O'Halloran
2020-11-03  4:35 ` [PATCH 07/18] powerpc/52xx/media5200: " Oliver O'Halloran
2020-11-03  4:35 ` [PATCH 08/18] powerpc/52xx/mpc5200_simple: " Oliver O'Halloran
2020-11-03  4:35 ` [PATCH 09/18] powerpc/82xx/*: " Oliver O'Halloran
2020-11-03  4:35 ` [PATCH 10/18] powerpc/83xx: " Oliver O'Halloran
2020-11-03  4:35 ` [PATCH 11/18] powerpc/amigaone: " Oliver O'Halloran
2020-11-03  4:35 ` [PATCH 12/18] powerpc/chrp: " Oliver O'Halloran
2020-11-03  4:35 ` [PATCH 13/18] powerpc/embedded6xx/holly: " Oliver O'Halloran
2020-11-03  4:35 ` [PATCH 14/18] powerpc/embedded6xx/linkstation: " Oliver O'Halloran
2020-11-03  4:35 ` [PATCH 15/18] powerpc/embedded6xx/mpc7448: " Oliver O'Halloran
2020-11-03  4:35 ` [PATCH 16/18] powerpc/embedded6xx/mve5100: " Oliver O'Halloran
2020-11-03  4:35 ` [PATCH 17/18] powerpc/pasemi: " Oliver O'Halloran
2020-11-03  4:35 ` [PATCH 18/18] powerpc/powermac: " Oliver O'Halloran
2020-11-04  4:07 ` [PATCH 01/18] powerpc/pci: Add ppc_md.discover_phbs() kernel test robot
2020-11-04  4:07   ` kernel test robot
2021-02-10 12:57 ` Michael Ellerman

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=20201103043523.916109-1-oohall@gmail.com \
    --to=oohall@gmail.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.