Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2006652imw; Sat, 9 Jul 2022 17:35:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vkiYd888S3YP5/vNrEMuj75QqP2YAEyabU+DZoE6KsMvmzlPj+Xjr1TiQ8F1ujwQUplHh8 X-Received: by 2002:a17:903:25d6:b0:16c:20a9:d023 with SMTP id jc22-20020a17090325d600b0016c20a9d023mr11080775plb.148.1657413318685; Sat, 09 Jul 2022 17:35:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657413318; cv=none; d=google.com; s=arc-20160816; b=ZsobuW39yaCYtc2DsMy20jd9JDmfd0VHqitUZGLzvh3JbbmTvaL56RKjGjj2lKJvq6 SoJz1aXvx9y0fgfVwi43qhowPIXp25YUwhgMdduZpnorNBqG7ogDuD5964ouoxTf+DRL FEKzaNbiIUtDCzOqPPGz9yTVjLKiv7zP5lXDgAaJ3XMh5FWrqHX/lO+SmpocSUi9nmYQ bIOXO2nu+y2LTCt8NpzrVVdUUtDyyojukbumJiyzkPmUYlxjGe4ETa1FAiptxTBe6VGN iebZxuHKlyJTGX+rMEWvSWnL6mGjKkzJWodlzTH5rc8+yDWE4qyvO17UiqrjMSEMp8lc 3o9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Scyei8rmKCUZIEMaBchhRjBmz4qZrr/V43Cr+WbqCsA=; b=UbzfhPwOVWGKdCLtJpT5bdJ4+rV4yszTh6WUIY3t5xXbL7HDHlhKQ4fUF7sbcwgjq4 lvskOkZ3kxTQXOn29Y3WJMsp0E0T5eOsq4o0Mk0PkHJmEzQc6GNcpVom4qDuJRWQQZLz V66q1JRsoUJ0u/nbNDSZNEXojCo/A4YoC05GBgShzr2Yn12kYyVaVMSKZR5Cthg1Ylzs nCgTqZO0wwLKd3WOwifLfw2f5fzcPQ6TbYioOigWpyFv41v1lX72/4dBlvTDa6+hP9jB Huuw28/AcF39zSySyuuW71rKktMD7AMlHQkxb0Qx/x7GNjpv8IsQgrZ3sgY8nloK6kjN PpWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QpZVJTNk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020a17090a748400b001efa6cbe9f0si7352164pjk.111.2022.07.09.17.34.41; Sat, 09 Jul 2022 17:35:18 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=QpZVJTNk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229497AbiGJAO2 (ORCPT + 99 others); Sat, 9 Jul 2022 20:14:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbiGJAO1 (ORCPT ); Sat, 9 Jul 2022 20:14:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82DA8E0BF; Sat, 9 Jul 2022 17:14:26 -0700 (PDT) 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 1837360F70; Sun, 10 Jul 2022 00:14:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C564C3411C; Sun, 10 Jul 2022 00:14:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657412065; bh=QwS6fBtfFVuN6cg1cW7OD0kOuwOSpsZ8EWICHcvBKF8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QpZVJTNkz8J31rlRtIcyJkpowaKWge27eSJWfQd7MMeFsTm0RAoBfRJ/zIxYaPrNK OjDRQDtbuePKrIDJ8aNzQdhHLVdcIVnuUG+U/jk8OpqS/y+nyXnZ0SqwHQomMHTh7x CRcbJn+kSQ64gFASIjaVzVrEc8vBTPdEA+rNEU6tHbIDU5h6vXpd+l0lUCMi0QELb3 9GZwelxzOF41yH7pRVyNYG1LBSrfqVyx/fx1+xB/DVOrQeCS/XTi/YKqf6ANRc1LkS NvL5KtwwDLDZJ4WcAocWZlgoeKVsQlGpLyILAOqMHyWAP33LRyEyIH2CNhdhNN9i6T ObXJNx7zi0i/g== Received: by pali.im (Postfix) id 0A931AFA; Sun, 10 Jul 2022 02:14:21 +0200 (CEST) Date: Sun, 10 Jul 2022 02:14:21 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Bjorn Helgaas , Thomas Petazzoni , Lorenzo Pieralisi , Rob Herring , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Hajo Noerenberg Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] PCI: mvebu: Dispose INTx irqs prior to removing INTx domain Message-ID: <20220710001421.lqwprzgn5jrblqcu@pali> References: <20220709161858.15031-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220709161858.15031-1-pali@kernel.org> User-Agent: NeoMutt/20180716 X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Saturday 09 July 2022 18:18:58 Pali Rohár wrote: > Documentation for irq_domain_remove() says that all mapping within the > domain must be disposed prior to domain remove. > > Currently INTx irqs are not disposed in pci-mvebu.c device unbind callback > which cause that kernel crashes after unloading driver and trying to read > /sys/kernel/debug/irq/irqs/ or /proc/interrupts. > > Fixes: ec075262648f ("PCI: mvebu: Implement support for legacy INTx interrupts") > Reported-by: Hajo Noerenberg > Signed-off-by: Pali Rohár Just to note, Hajo Noerenberg observed this issue during testing and debugging other unrelated issue in bugzilla [1] and triggered this crash just by calling: rmmod pci_mvebu && modprobe pci-mvebu && cat /proc/interrupts I suppose that other pci controller drivers with unbind / rmmod support would suffer from same issues. [1] - https://bugzilla.kernel.org/show_bug.cgi?id=216094 > --- > Depends on patch: > https://lore.kernel.org/linux-pci/20220524122817.7199-1-pali@kernel.org/ > > Here is the captured kernel crash which happens without this patch: > > $ cat /sys/kernel/debug/irq/irqs/64 > [ 301.571370] 8<--- cut here --- > [ 301.574496] Unable to handle kernel paging request at virtual address 0a00002a > [ 301.581736] [0a00002a] *pgd=00000000 > [ 301.585323] Internal error: Oops: 80000005 [#1] SMP ARM > [ 301.590560] Modules linked in: > [ 301.593621] CPU: 1 PID: 4641 Comm: cat Not tainted 5.16.0-rc1+ #192 > [ 301.599905] Hardware name: Marvell Armada 380/385 (Device Tree) > [ 301.605836] PC is at 0xa00002a > [ 301.608896] LR is at irq_debug_show+0x210/0x2d4 > [ 301.613440] pc : [<0a00002a>] lr : [] psr: 200000b3 > [ 301.619721] sp : c797fdd8 ip : 0000000b fp : 0a00002b > [ 301.624957] r10: c0d9a364 r9 : 00000001 r8 : 00000000 > [ 301.630192] r7 : c18fee18 r6 : c0da2a74 r5 : c18fee00 r4 : c66ec050 > [ 301.636734] r3 : 00000001 r2 : c18fee18 r1 : 00000000 r0 : c66ec050 > [ 301.643275] Flags: nzCv IRQs off FIQs on Mode SVC_32 ISA Thumb Segment none > [ 301.650689] Control: 10c5387d Table: 0790c04a DAC: 00000051 > [ 301.656446] Register r0 information: slab seq_file start c66ec050 pointer offset 0 > [ 301.664040] Register r1 information: NULL pointer > [ 301.668755] Register r2 information: slab kmalloc-256 start c18fee00 pointer offset 24 size 256 > [ 301.677480] Register r3 information: non-paged memory > [ 301.682543] Register r4 information: slab seq_file start c66ec050 pointer offset 0 > [ 301.690133] Register r5 information: slab kmalloc-256 start c18fee00 pointer offset 0 size 256 > [ 301.698770] Register r6 information: non-slab/vmalloc memory > [ 301.704442] Register r7 information: slab kmalloc-256 start c18fee00 pointer offset 24 size 256 > [ 301.713165] Register r8 information: NULL pointer > [ 301.717879] Register r9 information: non-paged memory > [ 301.722941] Register r10 information: non-slab/vmalloc memory > [ 301.728699] Register r11 information: non-paged memory > [ 301.733848] Register r12 information: non-paged memory > [ 301.738997] Process cat (pid: 4641, stack limit = 0xf591166e) > [ 301.744756] Stack: (0xc797fdd8 to 0xc7980000) > [ 301.749123] fdc0: 0000000a 830d3f3e > [ 301.757321] fde0: c1004f48 c0d9a374 c7a9cc10 c66ec050 00000000 c88af900 c797fe80 7ffff000 > [ 301.765518] fe00: 00400cc0 c66ec068 00000001 c02c5cb8 00000000 00000000 c66ec078 c797fe68 > [ 301.773715] fe20: c1cdf6c0 c7a9cc10 ffffffea c88af900 00000010 00000000 00000000 c88af900 > [ 301.781911] fe40: c1004f48 c797ff78 00001000 00004004 c03efcb8 c02c6100 00001000 00000000 > [ 301.790108] fe60: bec73e04 00001000 00000000 00000000 00001000 c797fe60 00000001 00000000 > [ 301.798304] fe80: c88af900 00000000 00000000 00000000 00000000 00000000 00000000 40040000 > [ 301.806501] fea0: 00000000 00000000 c1004f48 830d3f3e c88af900 c02c6018 c1c7a770 bec73e04 > [ 301.814697] fec0: 00001000 c797ff78 00000001 c03efd0c 00001000 c88af900 00000000 bec73e04 > [ 301.822894] fee0: c1004f48 c797ff78 00000001 c029c728 c887ca20 01100cca 0000004f 0045f000 > [ 301.831091] ff00: 00000254 c790c010 c790c010 00000000 00000000 00000000 c5f6117c eeece9b8 > [ 301.839288] ff20: 00000000 830d3f3e 00000000 c797ffb0 c79fc000 80000007 0045f5b8 00000254 > [ 301.847484] ff40: c79fc040 00000004 c887ca20 830d3f3e 00000000 c1004f48 c88af900 00000000 > [ 301.855681] ff60: 00000000 c88af900 bec73e04 00001000 00000000 c029cd68 00000000 00000000 > [ 301.863877] ff80: 00000000 830d3f3e 00000000 00000000 01000000 00000003 c0100284 c1b8abc0 > [ 301.872074] ffa0: 00000003 c0100060 00000000 00000000 00000003 bec73e04 00001000 00000000 > [ 301.880270] ffc0: 00000000 00000000 01000000 00000003 00000003 00000001 00000001 00000000 > [ 301.888468] ffe0: bec73d98 bec73d88 b6f81f88 b6f81410 60000010 00000003 00000000 00000000 > [ 301.896666] [] (irq_debug_show) from [] (seq_read_iter+0x1a4/0x504) > [ 301.904700] [] (seq_read_iter) from [] (seq_read+0xe8/0x12c) > [ 301.912117] [] (seq_read) from [] (full_proxy_read+0x54/0x70) > [ 301.919623] [] (full_proxy_read) from [] (vfs_read+0xa0/0x2c8) > [ 301.927214] [] (vfs_read) from [] (ksys_read+0x58/0xd0) > [ 301.934195] [] (ksys_read) from [] (ret_fast_syscall+0x0/0x54) > [ 301.941785] Exception stack(0xc797ffa8 to 0xc797fff0) > [ 301.946849] ffa0: 00000000 00000000 00000003 bec73e04 00001000 00000000 > [ 301.955045] ffc0: 00000000 00000000 01000000 00000003 00000003 00000001 00000001 00000000 > [ 301.963241] ffe0: bec73d98 bec73d88 b6f81f88 b6f81410 > [ 301.968304] Code: bad PC value > [ 301.971365] ---[ end trace fe25fd26d042b605 ]--- > [ 301.975992] Kernel panic - not syncing: Fatal exception > [ 301.981229] CPU0: stopping > [ 301.983946] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G D 5.16.0-rc1+ #192 > [ 301.991884] Hardware name: Marvell Armada 380/385 (Device Tree) > [ 301.997817] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) > [ 302.005587] [] (show_stack) from [] (dump_stack_lvl+0x40/0x4c) > [ 302.013179] [] (dump_stack_lvl) from [] (do_handle_IPI+0xf4/0x128) > [ 302.021117] [] (do_handle_IPI) from [] (ipi_handler+0x18/0x20) > [ 302.028707] [] (ipi_handler) from [] (handle_percpu_devid_irq+0x78/0x124) > [ 302.037256] [] (handle_percpu_devid_irq) from [] (generic_handle_domain_irq+0x44/0x88) > [ 302.046938] [] (generic_handle_domain_irq) from [] (gic_handle_irq+0x74/0x88) > [ 302.055839] [] (gic_handle_irq) from [] (generic_handle_arch_irq+0x34/0x44) > [ 302.064564] [] (generic_handle_arch_irq) from [] (__irq_svc+0x50/0x68) > [ 302.072851] Exception stack(0xc1001f00 to 0xc1001f48) > [ 302.077916] 1f00: 000d6830 00000000 00000001 c0116be0 c1004f90 c1004fd4 00000001 00000000 > [ 302.086114] 1f20: c1004f48 c0f5d2a8 c1009e80 00000000 00000000 c1001f50 c01076f4 c01076f8 > [ 302.094309] 1f40: 60000013 ffffffff > [ 302.097804] [] (__irq_svc) from [] (arch_cpu_idle+0x38/0x3c) > [ 302.105223] [] (arch_cpu_idle) from [] (default_idle_call+0x1c/0x2c) > [ 302.113338] [] (default_idle_call) from [] (do_idle+0x1c8/0x218) > [ 302.121106] [] (do_idle) from [] (cpu_startup_entry+0x18/0x20) > [ 302.128697] [] (cpu_startup_entry) from [] (start_kernel+0x650/0x694) > [ 302.136901] Rebooting in 3 seconds.. > --- > drivers/pci/controller/pci-mvebu.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c > index 31f53a019b8f..951030052358 100644 > --- a/drivers/pci/controller/pci-mvebu.c > +++ b/drivers/pci/controller/pci-mvebu.c > @@ -1713,8 +1713,15 @@ static int mvebu_pcie_remove(struct platform_device *pdev) > mvebu_writel(port, ~PCIE_INT_ALL_MASK, PCIE_INT_CAUSE_OFF); > > /* Remove IRQ domains. */ > - if (port->intx_irq_domain) > + if (port->intx_irq_domain) { > + int virq, j; > + for (j = 0; j < PCI_NUM_INTX; j++) { > + virq = irq_find_mapping(port->intx_irq_domain, j); > + if (virq > 0) > + irq_dispose_mapping(virq); > + } > irq_domain_remove(port->intx_irq_domain); > + } > > /* Free config space for emulated root bridge. */ > pci_bridge_emul_cleanup(&port->bridge); > -- > 2.20.1 >