Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3519471pxf; Mon, 15 Mar 2021 11:21:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzx2QvIJfk/zZrq2clrfKfGMRr5FSKG/0A5z9mGZNz5GwBpJmgpJ3rzbpgb9Sq/ZpX+xAf2 X-Received: by 2002:a17:906:dfcc:: with SMTP id jt12mr25558875ejc.31.1615832488319; Mon, 15 Mar 2021 11:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832488; cv=none; d=google.com; s=arc-20160816; b=erDBQlrJRhoDVxbhGdd1aCoEQn0C8aOeG4sDK0QrSaT2/A3VghTFwkagnpdru6JyDM /n9CKhYsPhXGOzMlQyKRkqdKS6gfZMw56HuPDgv2a/4P7+5mSSnsMHAnrhrZojRo+OIj 9MJNS1e6VkCDlGs8cIsxrv0K+xCZi75iXSG2ciJJ9da+3YSXxQAYl5peQekAEllMtU6X Od4AMyxB53Wjv7dB53yxOlZT1ByrLTVALKEOoxIePyhEPZ89oGdDf8dR81U+cyL3A2B8 5NYTLX8XbOQ1HZATcw+fF9OX/GGKiK8aFwuY1Tq/QbriH8etoKxm9rCP9UWrbqY1+6CS wHnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SVUF8O4WbQB9zo+pjGlWOe9MGlFMgt1D0zN1ZkKoYNY=; b=FNaTiuP5W3/PImulSz0/eEo4Cns4JCLquJHIP6agK+39Dr11GowQf6qVTzOPKWpNAn rERZpulz+RAEyp2RrGjsVFw/OEIX5DuWqStfqcPaODdIfk6xkLnaFZiU7CdmpRwsMYJw FYzUx2X//Oj7X8YXOTjN6XZmeTeFHYUFlKUKNNIyFGp0OMRxMGe3A691q5C44Ctoop4i 9tEQU7UcfzphGJv+yHLGablQcU4dkkLv4g4eh99Qz890POcYUzPbGBijUgWzx5v9rcRX Hsg9NBybetu5KI0H3kDuBoMelMKGlwwVJ77LWVDslBubyQ1X6P9vp891QdIVXFY/sLDY u1xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kmyfbzV7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f16si11844002edj.210.2021.03.15.11.21.05; Mon, 15 Mar 2021 11:21:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kmyfbzV7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236920AbhCOOSS (ORCPT + 99 others); Mon, 15 Mar 2021 10:18:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:35610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232709AbhCON7e (ORCPT ); Mon, 15 Mar 2021 09:59:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E5B2D64EF8; Mon, 15 Mar 2021 13:59:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816753; bh=kol0b5+/ojhi/yo0EFUta2fsH/+c12bzCTFGnWEiiQI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kmyfbzV7g7EQmCnHFbQoDvLrVBIp8q/yaDRmYTNQK4cebRqj4F6mbuhzFetZ4G9dl /Z/gZxrfERNMbn9l5M3Mt278IL7brqyEDzKa2p4exldINFGDhJ07ypo0B6Ca9i4PYc giRKf7ixHON6qcMseubd5OC71PL3/K0HaM5YMfm4= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Oliver OHalloran , Michael Ellerman , Sasha Levin Subject: [PATCH 4.19 046/120] powerpc/pci: Add ppc_md.discover_phbs() Date: Mon, 15 Mar 2021 14:56:37 +0100 Message-Id: <20210315135721.500089603@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135720.002213995@linuxfoundation.org> References: <20210315135720.002213995@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Oliver O'Halloran [ Upstream commit 5537fcb319d016ce387f818dd774179bc03217f5 ] 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. Reported-by: kernel test robot Signed-off-by: Oliver O'Halloran [mpe: Make discover_phbs() static] Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20201103043523.916109-1-oohall@gmail.com Signed-off-by: Sasha Levin --- 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 a47de82fb8e2..bda87cbf106d 100644 --- a/arch/powerpc/include/asm/machdep.h +++ b/arch/powerpc/include/asm/machdep.h @@ -71,6 +71,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 88e4f69a09e5..74628aca2bf1 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1671,3 +1671,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); + + +static int __init discover_phbs(void) +{ + if (ppc_md.discover_phbs) + ppc_md.discover_phbs(); + + return 0; +} +core_initcall(discover_phbs); -- 2.30.1