From patchwork Thu Mar 9 16:56:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Nikolaus Schaller" X-Patchwork-Id: 67052 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp405553wrd; Thu, 9 Mar 2023 09:05:31 -0800 (PST) X-Google-Smtp-Source: AK7set8n7oDyy6qbRWlyaOmJ1ZZ/ZXPNO7QyGb2+tIue/a9MFiYetDgS5/CSWYb9/AFBK2yHX9Hp X-Received: by 2002:a17:90b:3911:b0:237:9cc7:28a6 with SMTP id ob17-20020a17090b391100b002379cc728a6mr23038454pjb.26.1678381530759; Thu, 09 Mar 2023 09:05:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1678381530; cv=pass; d=google.com; s=arc-20160816; b=M4qXnpASIx7uQADQwtMoQjlQHCgkXY6B1ReG66NmS/0zpq7fKrobNEMmms089P+9JY vaBU5zgj9ZN38XGNjpCGJwbVs05nYr1KVjAE3dNkxsg8AUGDP7HYV3Z51pgDuf5WN6ki EAO+zeTqE1786MiuyMmMOMHZ8VmqS/YfvZVypfWpvP8XpnxhRnJOFHg3fpmBYmw30mvg yERzh50Q6UuYGfqytYbRL5SCwMgvgwcoRZykjVGeeIHNLENTsgJK02tyP8oJfCmp9qgd PvRkRrEQeu1EtaCIJJT++yrgrha2rEHnTRAgnBhSvbd7i49kj7W506IVxjCGz/JpgkCt CUvw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=wHpk4aIfXvwZ9L9eYQkKUD5TX9p8N/0ABhLYcRfGxXU=; b=kxrgM3hjPJ24A/tVkefCCxIVUUOCdhHr6CR3UbFgoIqQ9QaNKaYTF51/WiTEXVDndA 7y4N/wOVi8EaeqVp5GDdKDnRWL4JW7Gt62aaWuc/BWX1LMXc2WxiHrql+LEs1EC4uh5Q 60xRaVKIr2ifQdI4R7Rolz5sQKwFlE6JStd3VlWfAzV7dxcOAmRAdK7RLJtQCLvz475v gHj/rLuymqiAVzfdmq9XfDR//9mfwFu4B/9GM8N0EsZBWr9/nWsPrVtRmV15zRYtdQAZ oRTbNwYdttZSeiz/TfpThjeVOhJzR0RAuY3KqkV8bX9dNzqRWyv8o0xfl4RjshZfdonf nbCg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@goldelico.com header.s=strato-dkim-0002 header.b=cw0tAsyD; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id in17-20020a17090b439100b0022bb4d6f7casi248505pjb.131.2023.03.09.09.05.15; Thu, 09 Mar 2023 09:05:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@goldelico.com header.s=strato-dkim-0002 header.b=cw0tAsyD; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230261AbjCIRDa (ORCPT + 99 others); Thu, 9 Mar 2023 12:03:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230224AbjCIRCr (ORCPT ); Thu, 9 Mar 2023 12:02:47 -0500 Received: from mo4-p01-ob.smtp.rzone.de (mo4-p01-ob.smtp.rzone.de [85.215.255.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27D5ADBB59; Thu, 9 Mar 2023 08:57:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678380992; cv=none; d=strato.com; s=strato-dkim-0002; b=Urcr1g8b7Xuzokx6dlPrgXfCTOjIv2+ITDDy5Gb41ZQG2ha1JQYcwRG93x2cQ8beAe QH3JGZbR/lnlDob23t925D4Rvea75E4mFVzL7bgBOuK4NGWEw4Xg9FIYMK0AYIunBjF9 ZTQscOyw2YijPx1/OgOdVs9IK3OpFn1ZcGvHzfC/JIfeAjgnL+ro8KtqA3cX+VRLFYvQ H29DoHtdywXd8u4dCb0uf50j5amaC9e3kIL2FGyWk0xQU1ikvS7K0d72FveLZb2I1bKI t6CWNtLeIWFw6+rVxypHcTbsbIa7GpCFmIUN58cEkSLcOYH2AV9y6YvHrb0HwzQ3sA0p +roQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1678380992; s=strato-dkim-0002; d=strato.com; h=Message-Id:Date:Subject:Cc:To:From:Cc:Date:From:Subject:Sender; bh=wHpk4aIfXvwZ9L9eYQkKUD5TX9p8N/0ABhLYcRfGxXU=; b=cJdK6kzAnjm/r4GZRpV17dOIhnnZa8tnA7cMenQAk4Is6xmwl8wsuDXSIi+3tbuXxz mI8l39vc3+wKiShC8aX5uCJrtFGfniiNh8PiWN642TmK3ozMgh1Z7j9Qo4WJYuqzQTTz zDbxKN650svUkkx0SSUQrsHlaz13adsRNZou4C3TZcGFju41K920jbeKjdDqKhPrxekB wB6u2YBPjVLqnlt3oSwee3M30YhQ+QJE44POa+TcZIzJjoFazTqfSydhEYU+6yKT7TuK tiTG7lE7KPYfl3420g7AdkGfPR985ZP8Q0Zo1ii2xu9Sm1rbto+0EtyWIRF8T4WgbHu9 SY0A== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo01 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1678380992; s=strato-dkim-0002; d=goldelico.com; h=Message-Id:Date:Subject:Cc:To:From:Cc:Date:From:Subject:Sender; bh=wHpk4aIfXvwZ9L9eYQkKUD5TX9p8N/0ABhLYcRfGxXU=; b=cw0tAsyD9VgZpZmtbT5TXzmlEK+/TtENmVTOWt47tbAsKCa6gCvlKGo7pyl15vXQQg zxdTNQ//B+7fcDwHOc9UUONbY7jeZgu8mdfeqyoyJKM+/AYXCAICMJlD7ZpcO09EgPcL RQp57FLqQGOTq+V5lv6yuZMbNluwwSaI7rEWFFC4nFg+q2+yxFCJgovpPL05iyZofOqS Tv2h7F/ozx3bmvIsN/ekMIYIOfaPE/fFWDFD5mheZrfB1MW9SgMOkESC6xxcBxjOsoF+ Mtu8mUOgKg2GKzd8EqNHzB11+2xaEeMhyXiiLvB4JLhcdpXPSR3XNFRbOAdTf7yS74NF MoJA== X-RZG-AUTH: ":JGIXVUS7cutRB/49FwqZ7WcJeFKiMhflhwDubTJ9o1iTDUhfN4hi3qVZrWzJ" Received: from iMac.fritz.box by smtp.strato.de (RZmta 49.3.0 DYNA|AUTH) with ESMTPSA id 2faf7dz29GuWbnB (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Thu, 9 Mar 2023 17:56:32 +0100 (CET) From: "H. Nikolaus Schaller" To: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Bjorn Helgaas , Shawn Guo , Sascha Hauer Cc: 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, "H. Nikolaus Schaller" Subject: [PATCH v2] PCI: imx6: install the fault handler only if we are really running on a compatible device Date: Thu, 9 Mar 2023 17:56:31 +0100 Message-Id: X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759910592012129361?= X-GMAIL-MSGID: =?utf-8?q?1759910592012129361?= 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. 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. 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") Reviewed-by: Richard Zhu Signed-off-by: H. Nikolaus Schaller --- Notes: Changes since v1: - replace of_find_matching_node_and_match() by of_find_matching_node() (suggested by Bjorn Helgaas ) - v1 was Reviewed-by: Richard Zhu drivers/pci/controller/dwc/pci-imx6.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 55a0405b921d6..52906f999f2bb 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -1566,6 +1566,13 @@ DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_SYNOPSYS, 0xabcd, static int __init imx6_pcie_init(void) { #ifdef CONFIG_ARM + struct device_node *np; + + np = of_find_matching_node(NULL, imx6_pcie_of_match); + 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