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 038BCC678D5 for ; Wed, 8 Mar 2023 18:50:31 +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:In-Reply-To:MIME-Version:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=4opv0AgvtWaf77oYK2VoO1lNlPOIn+sqoYRTDV3qoTU=; b=sBt3j5Vw4epkt2 /yiE9IM8beFKSl7NXaIugTYGIlxwtyAllng2uQqvjvHIVfcuTdQMkTCIRVmZ8YU/9SlLp0ifjHXfy RZF6j2XNNh8g+3zrz0rzdfz8Xdj1CCDEPovXefbDN0/6sxM6N7Uu93eLzRzo8F75yzqf/N5ysQrLE epVNxoNcH1l7621joFD1wtjH0ES0dXrRfhp+dBWhecWs6NJQC1pq4bDtMElz9oyYz+js6RGbqYo1Z 6wJT0Yv6Dy5Xi9vMuE4RUh0UUkXRJocqDTMUMjElkaKihYamNp86akdf7IVwoMEXRaRmuX4jLaHG0 LZI/87XEi1W9Hgy8iG8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZyqy-006PZl-Ny; Wed, 08 Mar 2023 18:49:32 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZyqu-006PXT-TV for linux-arm-kernel@lists.infradead.org; Wed, 08 Mar 2023 18:49:30 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 749126190E; Wed, 8 Mar 2023 18:49:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 999C3C433D2; Wed, 8 Mar 2023 18:49:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678301363; bh=hjqn5JVWJwWwnk2YIxMMq8dT+5sWwomaupQDfPrK2R4=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=tQRMEAoBGTJJH0VOZd7LunGNwgg1NH/ZDCaZvTDRvRUfhDaFu7SW1LAd5BC1tDzrJ m/oCYcNn2ny4evrU2DK1pJqKxX25/pSp4+mcLVBFOmNv2QeUTlZkP6sTi52Xx/9ftU DM9mPVuz6B7TAUNR+I0fv4Sl2bJYnAoxFw15MWli2IfwuIEO7V3O9rC0CGwJDqQpe1 LuzkQSfJjsKgq/098vkeFpOlORZPTldzi2A5sgDWOiV5rdm4uxeBvf1si56NcUk2gc /FImIfHa2Ys5wCkXCrjcIqfINSM/oRPDnoAZRHLxeqKs6SLKESFeBqj3kC8sWSyXYD fqx9WA9WLWv6w== Date: Wed, 8 Mar 2023 12:49:22 -0600 From: Bjorn Helgaas To: "H. Nikolaus Schaller" Cc: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Bjorn Helgaas , Shawn Guo , Sascha Hauer , Rob Herring , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, letux-kernel@openphoenux.org, kernel@pyra-handheld.com Subject: Re: [PATCH] PCI: imx6: install the fault handler only if we are really running on a compatible device Message-ID: <20230308184922.GA1029723@bhelgaas> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230308_104929_050947_80028973 X-CRM114-Status: GOOD ( 35.05 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Feb 28, 2023 at 09:43:54AM +0100, H. Nikolaus Schaller wrote: > commit bb38919ec56e ("PCI: imx6: Add support for i.MX6 PCIe controller") > added a fault hook to this driver in the probe function. So it was only > installed if needed. > > commit bde4a5a00e76 ("PCI: imx6: Allow probe deferral by reset GPIO") > moved it from probe to driver init which installs the hook unconditionally > as soon as the driver is compiled into a kernel. > > When this driver is compiled as a module, the hook is not registered > until after the driver has been matched with a .compatible and > loaded. > > commit 415b6185c541 ("PCI: imx6: Fix config read timeout handling") > extended the fault handling code. > > commit 2d8ed461dbc9 ("PCI: imx6: Add support for i.MX8MQ") > added some protection for non-ARM architectures, but this does not > protect non-i.MX ARM architectures. Are *all* these commits relevant? Question also applies to Fixes: below. > Since fault handlers can be triggered on any architecture for different > reasons, there is no guarantee that they will be triggered only for the > assumed situation, leading to improper error handling (i.MX6-specific > imx6q_pcie_abort_handler) on foreign systems. > > I had seen strange L3 imprecise external abort messages several times on > OMAP4 and OMAP5 devices and couldn't make sense of them until I realized > they were related to this unused imx6q driver because I had > CONFIG_PCI_IMX6=y. Apparently imx6q_pcie_abort_handler() assumes it is always called because of a PCI abort? If so, that sounds problematic. If non-PCI imprecise aborts happen on OMAP4 and OMAP5 where imx6q is unused and imx6q_pcie_abort_handler() is not appropriate, I assume similar non-PCI aborts can also happen on systems where imx6q *is* used. So imx6q_pcie_abort_handler() may be trying to fixup non-PCI aborts when it shouldn't? > Note that CONFIG_PCI_IMX6=y is useful for kernel binaries that are designed > to run on different ARM SoC and be differentiated only by device tree > binaries. So turning off CONFIG_PCI_IMX6 is not a solution. > > Therefore we check the compatible in the init function before registering > the fault handler. > > Fixes: bde4a5a00e76 ("PCI: imx6: Allow probe deferral by reset GPIO") > Fixes: 415b6185c541 ("PCI: imx6: Fix config read timeout handling") > Fixes: 2d8ed461dbc9 ("PCI: imx6: Add support for i.MX8MQ") > > Signed-off-by: H. Nikolaus Schaller > --- > drivers/pci/controller/dwc/pci-imx6.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c > index 1dde5c579edc8..89774aa187ae8 100644 > --- a/drivers/pci/controller/dwc/pci-imx6.c > +++ b/drivers/pci/controller/dwc/pci-imx6.c > @@ -1402,6 +1402,15 @@ DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_SYNOPSYS, 0xabcd, > static int __init imx6_pcie_init(void) > { > #ifdef CONFIG_ARM > + const struct of_device_id *reboot_id; > + struct device_node *np; > + > + np = of_find_matching_node_and_match(NULL, imx6_pcie_of_match, > + &reboot_id); Since you don't need reboot_id, I think you should use of_find_matching_node() instead. > + if (!np) > + return -ENODEV; > + of_node_put(np); > + > /* > * Since probe() can be deferred we need to make sure that > * hook_fault_code is not called after __init memory is freed > -- > 2.38.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel