From patchwork Thu Aug 10 08:21:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 9892991 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A723360236 for ; Thu, 10 Aug 2017 08:22:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9845F28AD9 for ; Thu, 10 Aug 2017 08:22:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CF4728ADB; Thu, 10 Aug 2017 08:22:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1437E28AD9 for ; Thu, 10 Aug 2017 08:22:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=oElzKeqHtchrLqc0gTATZWkXi8Uu+rIIarDFIq+13O8=; b=VTz RuRtXaBi1tgRH4tfUi0zRo2G2QHYNdoLqZUDWuuhPvQbkmSZKa76S8uUZtm5ok1AOzgl+ErnO+jOK DvuyuZGojvm0iJjDRaHFOvJ3HdEALHEPTui9B9OwsY86mtiuc0/owK/RMwN0NqBgjuJDlR2cSMpMh 8t1O9Klrjo7caTresJ+PsiFL7VnApCYUzkYhZKcz2H6bAzG0OHU1BmyXQgf3iutvupQZMjB0clUEg wXbd4ag70ZC0GLSdKjpKE9wnvPOXUp33k7bx6zYkhO2Wo1dNaOJDEmqV9m8G5jNnqn3QVStqKJw04 YB4YfpsSbZv6TSZAAKJNdsrwUWRk5mA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dfijZ-00034t-7z; Thu, 10 Aug 2017 08:22:25 +0000 Received: from lucky1.263xmail.com ([211.157.147.133]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dfijV-000330-Ip for linux-rockchip@lists.infradead.org; Thu, 10 Aug 2017 08:22:23 +0000 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.193]) by lucky1.263xmail.com (Postfix) with ESMTP id 70DF58F465; Thu, 10 Aug 2017 16:21:54 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 1F76B3F8; Thu, 10 Aug 2017 16:21:54 +0800 (CST) X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: bhelgaas@google.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <1d6778119811ecaa581d834158d13b48> X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 31462K43593; Thu, 10 Aug 2017 16:21:55 +0800 (CST) From: Shawn Lin To: Bjorn Helgaas , Marc Zyngier , Thomas Gleixner Subject: [RFC PATCH] PCI: rockchip: fix system hang up if activate CONFIG_DEBUG_SHIRQ Date: Thu, 10 Aug 2017 16:21:13 +0800 Message-Id: <1502353273-123788-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170810_012221_977783_BB76625B X-CRM114-Status: GOOD ( 11.81 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jeffy Chen , Heiko Stuebner , linux-pci@vger.kernel.org, Shawn Lin , Brian Norris , Douglas Anderson , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP With CONFIG_DEBUG_SHIRQ enabled, the irq tear down routine would still access the irq handler registed as a shard irq. Per the comment within the function of __free_irq, it says "It's a shared IRQ -- the driver ought to be prepared for an IRQ event to happen even now it's being freed". However when failing to probe the driver, it may disable the clock for accessing the register and the following check for shared irq state would call the irq handler which accesses the register w/o the clk enabled. That will hang the system forever. With adding some dump_stack we could see how that happened. calling rockchip_pcie_driver_init+0x0/0x28 @ 1 rockchip-pcie f8000000.pcie: no vpcie3v3 regulator found rockchip-pcie f8000000.pcie: no vpcie1v8 regulator found rockchip-pcie f8000000.pcie: no vpcie0v9 regulator found rockchip-pcie f8000000.pcie: PCIe link training gen1 timeout! CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.13.0-rc3-next-20170807-ARCH+ #189 Hardware name: Firefly-RK3399 Board (DT) Call trace: [] dump_backtrace+0x0/0x250 [] show_stack+0x20/0x28 [] dump_stack+0x90/0xb0 [] rockchip_pcie_read.isra.11+0x54/0x58 [] rockchip_pcie_client_irq_handler+0x30/0x1a0 [] __free_irq+0x1c8/0x2dc [] free_irq+0x44/0x74 [] devm_irq_release+0x24/0x2c [] release_nodes+0x1d8/0x30c [] devres_release_all+0x3c/0x5c [] driver_probe_device+0x244/0x494 [] __driver_attach+0x120/0x124 [] bus_for_each_dev+0x6c/0xac [] driver_attach+0x2c/0x34 [] bus_add_driver+0x244/0x2b0 [] driver_register+0x70/0x110 [] platform_driver_register+0x60/0x6c [] rockchip_pcie_driver_init+0x20/0x28 [] do_one_initcall+0xc8/0x130 [] kernel_init_freeable+0x1a0/0x238 [] kernel_init+0x18/0x108 [] ret_from_fork+0x10/0x50 In order to fix this, we check the clk state before accessing the pcie register in rockchip_pcie_read, but don't touch rockchip_pcie_write as no case to trigger that from write routine. Signed-off-by: Shawn Lin --- Hi Bjorn, Thomas and Marc, This fix looks more like a hack, but I don't know the legit way to deal with that case. Just quick look into the drivers/pci/host, and I see almost all drivers register shard irq and also disable the clk in their probe's error handle path. So I guess this is NOT pcie-rockchip specified even not pcie host drivers specified, but folks just luckily didn't trip over it. Could you give some suggestion on this? drivers/pci/host/pcie-rockchip.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/pci/host/pcie-rockchip.c b/drivers/pci/host/pcie-rockchip.c index 39aafe2..daaa868b 100644 --- a/drivers/pci/host/pcie-rockchip.c +++ b/drivers/pci/host/pcie-rockchip.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -252,6 +253,9 @@ struct rockchip_pcie { static u32 rockchip_pcie_read(struct rockchip_pcie *rockchip, u32 reg) { + if (!__clk_is_enabled(rockchip->hclk_pcie)) + return 0; + return readl(rockchip->apb_base + reg); }