From patchwork Wed Jun 19 14:28:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13703915 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 E723AC27C79 for ; Wed, 19 Jun 2024 14:28:56 +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-Transfer-Encoding: Content-Type:MIME-Version:Message-ID:Date:Subject:Cc: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=i5inz4Sda3pJRvKjkLncpTIP6NakKnZBawHW8MdFQoY=; b=APVoND90Brl735JZfXO7TRu9MU 0R93/5dz4KBnhf1XFb95whU5mt121MPMU7hdd9V+35ljC+D8/FLVNGYzdIt5Dy1RRGe3hu5Aq3/3P FLb/C1lT2UtRqo8UqhBNgzzX7JI0UsDfekStHR65b0PTS+cnRAMAkaXUbU4oRqVYKW/OYwFu8oCnt PgNcIWvtZVi0vxPncMam8E8KVC5WPguFV3QX3AD2KYodv4hcjUYTyhpMvglqDe6L5G/6dETX/auAr Cvk7e1omcTXHTDU9qf0N8dSQ2bk+i1gJuh03LaoAY9TqYWaiwCXLHpd/JLr/r51atElM/HYvULxDv nOKjt83g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJwIi-00000001X30-3VH3; Wed, 19 Jun 2024 14:28:40 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJwIe-00000001WzF-1KXM for linux-arm-kernel@lists.infradead.org; Wed, 19 Jun 2024 14:28:39 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 34E8061E48; Wed, 19 Jun 2024 14:28:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02184C2BBFC; Wed, 19 Jun 2024 14:28:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718807313; bh=9THZQoWcY7pppy+k12IgOUowco4lraaYF67MhxmEgwk=; h=From:To:Cc:Subject:Date:From; b=lr7mkG2mp+xYIAx5A27QwHO7pYZ0TgqquCvOqy/8/rbuUjMgLySUqF1NXkKytmhNN /h0HQahap1RPH27H8wtnDR+UL2kYAHTM65s8daPzCKeH+CptmGh3IlvzguPeOZO2rG Q0ZfF2MZPHvYI+wAQ0PZotJEKMNLnwBBQNIKA0rn8glu5oZXr6lbqxAk198pktbt8l XGj1yv+bqMdo5R3vVpUtpsKNcmSlG7TvV2XnJ/lX9seH7gWuMf0PPcuS9Zh33wr0rC kIcaQGVBQSZM/RqJ1Q/RI5p6gonPbODX05gstRcwdPxuRixsNCHOW0IN11hkPm4lDc +5QkyBx7Ps/KQ== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Bjorn Helgaas , Andrew Lunn , Gregory Clement Cc: Thomas Petazzoni , Rob Herring , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] PCI: mvebu: Dispose INTx irqs prior to removing INTx domain Date: Wed, 19 Jun 2024 16:28:29 +0200 Message-ID: <20240619142829.2804-1-kabel@kernel.org> X-Mailer: git-send-email 2.44.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240619_072836_489189_0A05EFDD X-CRM114-Status: GOOD ( 13.64 ) 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 From: Pali Rohár 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 Reviewed-by: Marek Behún [ refactored a little ] Signed-off-by: Marek Behún Reviewed-by: Manivannan Sadhasivam --- This was discussed back in 2022 https://lore.kernel.org/linux-arm-kernel/20220709161858.15031-1-pali@kernel.org/ IMO Pali gave good arguments about why it should be applied, and Lorenzo agreed. Can we get this applied? --- 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 29fe09c99e7d..91a02b23aeb1 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -1683,8 +1683,15 @@ static void mvebu_pcie_remove(struct platform_device *pdev) irq_set_chained_handler_and_data(irq, NULL, NULL); /* Remove IRQ domains. */ - if (port->intx_irq_domain) + if (port->intx_irq_domain) { + for (int j = 0; j < PCI_NUM_INTX; j++) { + int 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);