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 BB264CF31AC for ; Wed, 19 Nov 2025 11:30:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=b/b+J52YvfnUOURPB/nCFNdj8A+ZdzY1+CvUcxQ0xTI=; b=Uq4kU5wnSMPrfdb1n8QKDRYwNg he37j6le+qmghJed3jolMjG2LLPjDfMv9i5GNu+hQn4GkIXrRY+R4kIFFnjxFaE0ms5jZGuBqtPRf lk/wOj7sQqhbM+1iHqMn6N7DOEwuCsOCnzMTAU14nbbtVzG6n5+LsKXfFlW13t1V5XQv/ZGKdvfx7 ABbWOzV96owv9tQFc8HMz/NwWRKgk92zX+e6f2v+HqcYscTEYZWYtohGRqVErlCoV32kDXOJSXhcW Gbj6hj216bFiHHTFgmc83c9s2ZXKHckeEcRF14l4c0YBbiECAIblJIjJQZ+IgtCMY0qHzfufelnj9 nAetQ6kw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vLgOc-000000031uH-1FOy; Wed, 19 Nov 2025 11:30:46 +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 1vLgOb-000000031u5-1O10 for linux-arm-kernel@lists.infradead.org; Wed, 19 Nov 2025 11:30:45 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 72F2A60123; Wed, 19 Nov 2025 11:30:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5D8DC2BCC4; Wed, 19 Nov 2025 11:30:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763551844; bh=+5YXdMx46saMCGpp0KfgT4nTqpINGY6N6o3Z2+eXPTE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=tsCZ3b90FimZTdmqyKH7ucxujhM3RDOJEucEDRLCZK+PUzWI1DGqTA+smX8vh3SmE e2U2LfTyTs75TS1B4x9wKLllf3zvmRfSBmnHTeATzS/xCcuX3P3YsM3NL0V84M5Ty5 UpHN51yCpVxP0rkB9fxWoM7ySuIAE168EC7gXpb+DboICC8zCGSXabmPjsn8xR386o DsrlrHxoZvPwEBTGC1iTtaZoyWocNV7DBCOlEH3vBV/gvP28oQIyFFU2cox04BGTt6 3AVG12DxJ1kZo7nXkK/i/7UQ8LYny9VTyMW0BjfNE7RlZbio31UqfOy3EyLh5x1tGT g6OizM7QjNXfw== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vLgOX-00000006Vas-0yGm; Wed, 19 Nov 2025 11:30:41 +0000 Date: Wed, 19 Nov 2025 11:30:40 +0000 Message-ID: <86ldk2s1i7.wl-maz@kernel.org> From: Marc Zyngier To: Radu Rendec Cc: Bjorn Helgaas , Manivannan Sadhasivam , Will Deacon , Rob Herring , Krzysztof =?UTF-8?B?V2lsY3p5xYRza2k=?= , Lorenzo Pieralisi , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] PCI: apple: Store private pointer in platform device's drvdata In-Reply-To: <20251118221244.372423-3-rrendec@redhat.com> References: <20251118221244.372423-1-rrendec@redhat.com> <20251118221244.372423-3-rrendec@redhat.com> 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") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: rrendec@redhat.com, bhelgaas@google.com, mani@kernel.org, will@kernel.org, robh@kernel.org, kwilczynski@kernel.org, lpieralisi@kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@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-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 18 Nov 2025 22:12:44 +0000, Radu Rendec wrote: > > Now pci_host_common_init() no longer uses the platform device's drvdata > to store the pointer to the allocated struct pci_host_bridge. Use the > drvdata to store the pointer to the driver's private data, which is the > struct apple_pcie allocated in apple_pcie_probe(). This eliminates the > need to store these pointers in a separate mapping table. > > This reverts most of the changes in commit 643c0c9d0496 ("PCI: apple: > Add tracking of probed root ports"). No "Fixes" tag is added because > nothing is broken in that commit. This is just a simplification. > > Signed-off-by: Radu Rendec > --- > drivers/pci/controller/pcie-apple.c | 53 ++++------------------------- > 1 file changed, 7 insertions(+), 46 deletions(-) > > diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c > index 0380d300adca6..75bb6d51d31c2 100644 > --- a/drivers/pci/controller/pcie-apple.c > +++ b/drivers/pci/controller/pcie-apple.c > @@ -187,7 +187,6 @@ struct apple_pcie { > const struct hw_info *hw; > unsigned long *bitmap; > struct list_head ports; > - struct list_head entry; > struct completion event; > struct irq_fwspec fwspec; > u32 nvecs; > @@ -206,9 +205,6 @@ struct apple_pcie_port { > int idx; > }; > > -static LIST_HEAD(pcie_list); > -static DEFINE_MUTEX(pcie_list_lock); > - > static void rmw_set(u32 set, void __iomem *addr) > { > writel_relaxed(readl_relaxed(addr) | set, addr); > @@ -724,45 +720,13 @@ static int apple_msi_init(struct apple_pcie *pcie) > return 0; > } > > -static void apple_pcie_register(struct apple_pcie *pcie) > -{ > - guard(mutex)(&pcie_list_lock); > - > - list_add_tail(&pcie->entry, &pcie_list); > -} > - > -static void apple_pcie_unregister(struct apple_pcie *pcie) > -{ > - guard(mutex)(&pcie_list_lock); > - > - list_del(&pcie->entry); > -} > - > -static struct apple_pcie *apple_pcie_lookup(struct device *dev) > -{ > - struct apple_pcie *pcie; > - > - guard(mutex)(&pcie_list_lock); > - > - list_for_each_entry(pcie, &pcie_list, entry) { > - if (pcie->dev == dev) > - return pcie; > - } > - > - return NULL; > -} > - > static struct apple_pcie_port *apple_pcie_get_port(struct pci_dev *pdev) > { > struct pci_config_window *cfg = pdev->sysdata; > - struct apple_pcie *pcie; > + struct apple_pcie *pcie = platform_get_drvdata(to_platform_device(cfg->parent)); Isn't that an overly complicated way to write: struct apple_pcie *pcie = dev_get_drvdata(cfg->parent); > struct pci_dev *port_pdev; > struct apple_pcie_port *port; > > - pcie = apple_pcie_lookup(cfg->parent); > - if (WARN_ON(!pcie)) > - return NULL; > - > /* Find the root port this device is on */ > port_pdev = pcie_find_root_port(pdev); > > @@ -843,13 +807,9 @@ static void apple_pcie_disable_device(struct pci_host_bridge *bridge, struct pci > static int apple_pcie_init(struct pci_config_window *cfg) > { > struct device *dev = cfg->parent; > - struct apple_pcie *pcie; > + struct apple_pcie *pcie = platform_get_drvdata(to_platform_device(dev)); > int ret; > > - pcie = apple_pcie_lookup(dev); > - if (WARN_ON(!pcie)) > - return -ENOENT; > - > for_each_available_child_of_node_scoped(dev->of_node, of_port) { > ret = apple_pcie_setup_port(pcie, of_port); > if (ret) { > @@ -876,6 +836,7 @@ static int apple_pcie_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > struct apple_pcie *pcie; > + struct pci_host_bridge *bridge; > int ret; > > pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); > @@ -897,11 +858,11 @@ static int apple_pcie_probe(struct platform_device *pdev) > if (ret) > return ret; > > - apple_pcie_register(pcie); > + bridge = pci_host_common_init(pdev, &apple_pcie_cfg_ecam_ops); > + if (IS_ERR(bridge)) > + return PTR_ERR(bridge); > > - ret = pci_host_common_init(pdev, &apple_pcie_cfg_ecam_ops); > - if (ret) > - apple_pcie_unregister(pcie); > + platform_set_drvdata(pdev, pcie); Not quite. You probably want to look at: - when struct pci_ecam_ops::init() is called... - ... compared to when you populate the driver data. Thanks, M. -- Without deviation from the norm, progress is not possible.