From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CB825C7115C for ; Wed, 25 Jun 2025 09:53:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fByzgtv8mcZjWKw7PpHu+TzxbnDgxSDmIJtMiU2P8Ow=; b=eDPZS/dKlM0hhM g+nj1wO46RfBwy+TinSaIEEDMHT0+40SHBwHttBUt+KOF307OLaoKXR9k2tmuBm8sXEY3uL11IPNA JqazBezZYZJethazCy0fOT7XSBZsxwxaEqqvJdqpE/eon4g5+U36ldvrkYfoa99htbXQdHQWdhmhG fF5OGM29/WHdGQd0lRXoClU8H4RPv9z75RicDQxa+kS+9XuO5pXHDFjPDZR/+s94bQ7KNSsG/yqqF ABc19l4dgqpZAmLkpkFckRnIKSLgcq12m7K3Y4kW+NVCz3tCrpFp8ciWfvga1I66TldUBKVbGrLuZ 2ohde756l3BYfG8Q80bQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uUMp9-00000008D8d-19wp; Wed, 25 Jun 2025 09:53:47 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uUKlt-00000007qpt-1iu4; Wed, 25 Jun 2025 07:42:17 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id D39CA615F1; Wed, 25 Jun 2025 07:42:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 825FEC4CEEA; Wed, 25 Jun 2025 07:42:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750837336; bh=ee5KpT/bkyI5pdWN+/FTJfhNU5lp2kqGEPaGJ/4m8CI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=QptVOFEzhdEF/NA7m5AHYEde2n+dfbMvp+8KFy1dXur2sGa2Tcjk1RmuP6iAvVKgM 8x4c3JKrqlwCWZ6zzEJr5hwC2tOVr0FaKR3TdhqzbvT5iZmbfwvRobsJGMlQnUdNwC tFnifQXNaglfKS0iSseuGVAW5PEkdBcSk9IhnXYCCJLwTlJuDJGSwEBH8b0Piby14I BiyyjAgmXDmcqRPqNHTAq0eRqAR0QQwZY6WpNSbhcImoI8XQB23rAAyENA7E4tKvVt AP/rSsqc9K8yqPmDCyZo9x03Y3vou1mxA6tU83ojz7jgnUTWO9AFQOKP5nGVj8tCj3 BK3df+3YaYFsA== Received: from sofa.misterjones.org ([185.219.108.64] helo=lobster-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1uUKlq-009m7c-1v; Wed, 25 Jun 2025 08:42:14 +0100 Date: Wed, 25 Jun 2025 08:42:13 +0100 Message-ID: <875xgkfesq.wl-maz@kernel.org> From: Marc Zyngier To: Bjorn Helgaas , Geert Uytterhoeven Cc: Alyssa Rosenzweig , Rob Herring , Manivannan Sadhasivam , Will Deacon , Lorenzo Pieralisi , Krzysztof =?UTF-8?B?V2lsY3p5?= =?UTF-8?B?xYRza2k=?= , Conor Dooley , Daire McNamara , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] PCI: host-generic: Set driver_data before calling gen_pci_init() In-Reply-To: <774290708a6f0f683711914fda110742c18a7fb2.1750787223.git.geert+renesas@glider.be> References: <774290708a6f0f683711914fda110742c18a7fb2.1750787223.git.geert+renesas@glider.be> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: bhelgaas@google.com, geert+renesas@glider.be, alyssa@rosenzweig.io, robh@kernel.org, mani@kernel.org, will@kernel.org, lpieralisi@kernel.org, kwilczynski@kernel.org, conor.dooley@microchip.com, daire.mcnamara@microchip.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Tue, 24 Jun 2025 18:50:10 +0100, Geert Uytterhoeven wrote: > > On MicroChip MPFS Icicle: > > microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges: > microchip-pcie 2000000000.pcie: Parsing ranges property... > microchip-pcie 2000000000.pcie: MEM 0x2008000000..0x2087ffffff -> 0x0008000000 > Unable to handle kernel NULL pointer dereference at virtual address 0000000000000368 > Current swapper/0 pgtable: 4K pagesize, 39-bit VAs, pgdp=0x00000000814f1000 > [0000000000000368] pgd=0000000000000000, p4d=0000000000000000, pud=0000000000000000 > Oops [#1] > Modules linked in: > CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.15.0-rc1-icicle-00003-gafc0a570bb61 #232 NONE > Hardware name: Microchip PolarFire-SoC Icicle Kit (DT) > [...] > [] plda_pcie_setup_iomems+0xe/0x78 > [] mc_platform_init+0x80/0x1d2 > [] pci_ecam_create+0x104/0x1e2 > [] pci_host_common_init+0x120/0x228 > [] pci_host_common_probe+0x7c/0x8a > > The initialization of driver_data was moved after the call to > gen_pci_init(), while the pci_ecam_ops.init() callback > mc_platform_init() expects it has already been initialized. > > Fix this by moving the initialization of driver_data up. > > Fixes: afc0a570bb613871 ("PCI: host-generic: Extract an ECAM bridge creation helper from pci_host_common_probe()") > Signed-off-by: Geert Uytterhoeven > --- > Notes: > 1. Before, driver_data was initialized before calling > of_pci_check_probe_only(), but the latter doesn't rely on that, > 2. drivers/pci/controller/plda/pcie-microchip-host.c seems to be the > only driver relying on driver_data being set. > --- > drivers/pci/controller/pci-host-common.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/pci/controller/pci-host-common.c b/drivers/pci/controller/pci-host-common.c > index b0992325dd65f0da..b37052863847162d 100644 > --- a/drivers/pci/controller/pci-host-common.c > +++ b/drivers/pci/controller/pci-host-common.c > @@ -64,13 +64,13 @@ int pci_host_common_init(struct platform_device *pdev, > > of_pci_check_probe_only(); > > + platform_set_drvdata(pdev, bridge); > + > /* Parse and map our Configuration Space windows */ > cfg = gen_pci_init(dev, bridge, ops); > if (IS_ERR(cfg)) > return PTR_ERR(cfg); > > - platform_set_drvdata(pdev, bridge); > - > bridge->sysdata = cfg; > bridge->ops = (struct pci_ops *)&ops->pci_ops; > bridge->enable_device = ops->enable_device; This is going to break what was introduced in 4900454b4f819 ("PCI: ecam: Allow cfg->priv to be pre-populated from the root port device"). The Apple PCIe driver uses drvdata to pass a pointer to its root port structure from its probe routine to the .init ECAM callback. If we overwrite drvdata with the bridge *before* calling pci_ecam_create(), this data is lost, and drama follows. Obviously, multi-purpose private fields are not great... If we are going down the road of going back to the previous situation, two things need to be done: - the Apple PCIe driver needs to grow some form of root port registration in order to map a 'struct device' back to the pcie tracking structure - 4900454b4f819 needs to be reverted, because it obviously doesn't serve any purpose anymore. I'll look into the first point. Thanks, M. -- Jazz isn't dead. It just smells funny. _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv