1. 08 Feb, 2021 1 commit
    • Oliver O'Halloran's avatar
      powerpc/pci: Move PHB discovery for PCI_DN using platforms · fbbefb32
      Oliver O'Halloran authored
      Make powernv, pseries, powermac and maple use ppc_mc.discover_phbs.
      These platforms need to be done together because they all depend on
      pci_dn's being created from the DT. The pci_dn contains a pointer to
      the relevant pci_controller so they need to be created after the
      pci_controller structures are available, but before PCI devices are
      scanned. Currently this ordering is provided by initcalls and the
      sequence is:
      
        1. PHBs are discovered (setup_arch) (early boot, pre-initcalls)
        2. pci_dn are created from the unflattended DT (core initcall)
        3. PHBs are scanned pcibios_init() (subsys initcall)
      
      The new ppc_md.discover_phbs() function is also a core_initcall so we
      can't guarantee ordering between the creation of pci_controllers and
      the creation of pci_dn's which require a pci_controller. We could use
      the postcore, or core_sync initcall levels, but it's cleaner to just
      move the pci_dn setup into the per-PHB inits which occur inside of
      .discover_phb() for these platforms. This brings the boot-time path in
      line with the PHB hotplug path that is used for pseries DLPAR
      operations too.
      Signed-off-by: default avatarOliver O'Halloran <oohall@gmail.com>
      [mpe: Squash powermac & maple in to avoid breakage those platforms,
            convert memblock allocs to use kmalloc to avoid warnings]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20201103043523.916109-2-oohall@gmail.com
      fbbefb32
  2. 02 Feb, 2021 1 commit
    • Oliver O'Halloran's avatar
      powerpc/pci: Add ppc_md.discover_phbs() · 5537fcb3
      Oliver O'Halloran authored
      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 d538aadc ("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.
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarOliver O'Halloran <oohall@gmail.com>
      [mpe: Make discover_phbs() static]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20201103043523.916109-1-oohall@gmail.com
      5537fcb3
  3. 31 Jan, 2021 23 commits
  4. 30 Jan, 2021 15 commits