From patchwork Mon Jul 11 12:06:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 12913443 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 87213C43334 for ; Mon, 11 Jul 2022 12:11:44 +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: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=TpWNQoFCKp0lJli31V8o3LRtOSZ+LyRX9VVF+mSH/YY=; b=abKbx2a4LzM1RJ ITbhm2bgIwqKvmiTkrtjUJkpxzCdSMiRVJ35eNIJRbeaEP8HMxzpFlaFpkUqQzri7w+6/RnZOmZU1 4D+6iw7c6fJBOZOwrmBkyOYC6kdnUy4OlAP/bnbXP1OdcQh5wjvsKO4I0Ic0WTgOtaR8GU3Jyk2bm RWKCJ422CCiGNeO9hhu7BH2WNdELyf9RoL/g5iZZgxVhRA2Q18ywnSL5Voo6MHYUct5xd+kUbLWY4 diHoyr5UHeIkWgAciHuZox83rHYgwQXZ3lraYj1PVIK+bNxrQur7QXWmfWPYWo3HMQxEy4Z7qmJaW C92yh1AxCCwuLf37NZ0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAsFV-001JL0-Fq; Mon, 11 Jul 2022 12:10:49 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAsFT-001JJD-4c for linux-arm-kernel@lists.infradead.org; Mon, 11 Jul 2022 12:10:48 +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 94491611F2; Mon, 11 Jul 2022 12:10:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D09B6C34115; Mon, 11 Jul 2022 12:10:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657541444; bh=UhBDGGujuZLS3CJAhdKmbeMA357lNLuZ6bu22I/qh4A=; h=From:To:Cc:Subject:Date:From; b=glwCOyvV3axdfL+tWz2pua8rdElVCMNOlQzDZgTqkg6bkBUQflkGYTDBloo5+qn34 YAWULHW98zKKiF+4HtfR22GfgSW63DJSJwtRfOiWKEkf59aofgKHR/OPoXQ2SBYBNI lPzNRvJLM/njn7/ReVj17yBf6IAE2qBNEZGQCpy0z9uotk7wDlzWy4P2G5rZl+IEA1 wKv65EdTpqCL56+cSM8+plBiBmTLKo6xJEdlrJuVOtWzthZ5uoMGQqvaNMEkoRgPgs KlQph1Y+1tpHtU+wJiMz3B6ap7tNcHJZyJO022mFBvvkJA/wpGdQi4ELsnrDaqTIPL W8zflwMU86cyg== Received: by pali.im (Postfix) id 874E09D7; Mon, 11 Jul 2022 14:10:41 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Thomas Petazzoni , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] PCI: aardvark: Dispose INTx irqs prior to removing INTx domain Date: Mon, 11 Jul 2022 14:06:24 +0200 Message-Id: <20220711120626.11492-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220711_051047_262794_95BB8E66 X-CRM114-Status: GOOD ( 14.30 ) 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 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-aardvark.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: 526a76991b7b ("PCI: aardvark: Implement driver 'remove' function and allow to build it as module") Signed-off-by: Pali Rohár --- drivers/pci/controller/pci-aardvark.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index ffec82c8a523..6cb65e64859d 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1433,6 +1433,14 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie) static void advk_pcie_remove_irq_domain(struct advk_pcie *pcie) { + int virq, i; + + for (i = 0; i < PCI_NUM_INTX; i++) { + virq = irq_find_mapping(pcie->irq_domain, i); + if (virq > 0) + irq_dispose_mapping(virq); + } + irq_domain_remove(pcie->irq_domain); } From patchwork Mon Jul 11 12:06:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 12913445 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 1DB9DC43334 for ; Mon, 11 Jul 2022 12:11: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=mWmnwKt2gsg8qDhXEwLEgxAH2plChnhKYM5NNoH4rHs=; b=Pq+5t3LJYDsWv4 EZs9BQi9yOtfCoz0p6SlqMuf2xFqKkHr8kZ6YdJIX+eoOh5jRjXPwFEH5vLvLRsl6GB5dVKZALXTF upVEctfI5E05EJ9jbYxtYNQ/6y2A56rmMucjNdmcaCyFYB5yF/0taKwO6VvjrUdIuIhZwJD1/XpDi P6eu6G9+QoOi81GBTwdrdDgxkQH2TiG5c0xcNqR/0xnefSCjbDyi05bSdPMdv/uJJgOD775zrUYKk QAKzhIklfCmkK+3Fx2bii+JyvzVgPGvHo7S3KxR8qludF/HhQozbEb/ywFEzg+WMEJe+SjhN9uh5d VvVp+zAZMRdD6XV9pNhQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAsFm-001JQC-Ff; Mon, 11 Jul 2022 12:11:06 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAsFT-001JJT-Kh for linux-arm-kernel@lists.infradead.org; Mon, 11 Jul 2022 12:10:49 +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 ams.source.kernel.org (Postfix) with ESMTPS id B6A5EB80EC0; Mon, 11 Jul 2022 12:10:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4ED5AC341CD; Mon, 11 Jul 2022 12:10:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657541444; bh=s2hcWfrzOt/eRRX9Dn00HKwF/BMj8aqOvof1DioxKO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tchk8X2Ik8KgJcy+3Y30fPgbo8x29dRap611vgKQ+8IpK46gQ54jszkZisuYrYLT1 TSTfOo7iNglhfmhlhhBzSdGnTSKPlH0pulGY3yPulajIKXLWAm5RBI0JDPRykuUzjP Ab5kDOQE4xZa4tH6NQKnfvyDtAWYdLsAVxvkXW1Ii4hVjdMFATkBsXarvP7uPwPN6X M77McHeZF9lsDpQiqvZ3WI5OcPJxVL24BjHPLUb+ycd7OOVlv4qTqkRpMu8FHWcmxz u4T5wtL4/tCZm5QAkkpiQxQ0ucmq6CbcPXzYp+Y8m8wL9c/SL19XBaHl14QbPSzJm8 pYg/0t9Yr1Aiw== Received: by pali.im (Postfix) id E5673276E; Mon, 11 Jul 2022 14:10:41 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Thomas Petazzoni , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] PCI: aardvark: Dispose bridge irq prior to removing bridge domain Date: Mon, 11 Jul 2022 14:06:25 +0200 Message-Id: <20220711120626.11492-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220711120626.11492-1-pali@kernel.org> References: <20220711120626.11492-1-pali@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220711_051047_868860_2777CF29 X-CRM114-Status: GOOD ( 12.88 ) 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 Documentation for irq_domain_remove() says that all mapping within the domain must be disposed prior to domain remove. Currently bridge irq is not disposed in pci-aardvark.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: 815bc3136867 ("PCI: aardvark: Use separate INTA interrupt for emulated root bridge") Signed-off-by: Pali Rohár --- drivers/pci/controller/pci-aardvark.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 6cb65e64859d..8bea5801d50a 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1479,6 +1479,12 @@ static int advk_pcie_init_rp_irq_domain(struct advk_pcie *pcie) static void advk_pcie_remove_rp_irq_domain(struct advk_pcie *pcie) { + int virq; + + virq = irq_find_mapping(pcie->rp_irq_domain, 0); + if (virq > 0) + irq_dispose_mapping(virq); + irq_domain_remove(pcie->rp_irq_domain); } From patchwork Mon Jul 11 12:06:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 12913444 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 51588C43334 for ; Mon, 11 Jul 2022 12:11:50 +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:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=AnzsbZ3pNmuxu0PQCSlTlusqMI73y1BIeZwyycYryh4=; b=p2e32sFN4eYt5o XZ7ug3F0OVJwotTfD/GRtoRGBu2NqC6q+wl3hFfWeE7Uli+/UHgYYu3wfMfDYI9nhhIUPLmvlYD3r 3TaciZ55hV556RZsrJ3vugVNwQ8mwwwmvAibkxl6OEaTKjZU0A6GUVjlIRQUXBuQiVmgQpyNbKYEo rfkPV1eLYl5/NLCe7A4GJE2IcjbOj2YHOwIr9fQ2DlKiqihRlW3teqr+iQnTZnNZe0p1vH/exVouU Bd9C1EV+VIokY9sOpn1aEay4jP41UIJhcXgamrdBVW7Q+2VpeO/ot5Nt4pLRovSXciqqaRpjRdn8h q6DW7CBJwFfCjXRUBgdg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAsFe-001JO2-4n; Mon, 11 Jul 2022 12:10:58 +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 1oAsFT-001JJQ-3e for linux-arm-kernel@lists.infradead.org; Mon, 11 Jul 2022 12:10:48 +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 903BE611F3; Mon, 11 Jul 2022 12:10:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8895C34115; Mon, 11 Jul 2022 12:10:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657541445; bh=A2vqBbzpMVWKfDpC3m2AhDB490zHtivAEnRyuR6TAjY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ue5p6kKSr04mMCumm+ey6QjwRCScrVXkcQFvhov3N8VFxcOvj1Z8hMxH8tMHH8sU+ HnydaS6OeroOUvNXnn/dJ8URrtOrgMgRd0mQKua7ZsNX7tRDmvHm2ez85poO1yTcbk dHVo2Id1iTcVl+nMk6j4bxs1nJqOBVRnOlkNWfEZxMJCqPxj5qMvt6FlVehufTNhTj oD0Smi6zULtkbVrVl+oeUv9YyuZGUQpL29jKNepGzajkFEu6Md12wRDVGQUZaQ7kpX Kv6nwALF2Afz+F4iwpDKAs5DvNFzZKIXTSB5WDlmwwOM/l4k0AeyZ26qulfxUuiFWT alfxwduBeHAVA== Received: by pali.im (Postfix) id 61D32276F; Mon, 11 Jul 2022 14:10:42 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Thomas Petazzoni , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] PCI: aardvark: Do static allocation of irq_chip Date: Mon, 11 Jul 2022 14:06:26 +0200 Message-Id: <20220711120626.11492-3-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220711120626.11492-1-pali@kernel.org> References: <20220711120626.11492-1-pali@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220711_051047_262753_838B34D9 X-CRM114-Status: GOOD ( 16.09 ) 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 There is no need to allocate struct irq_chip in pci-aardvark.c dynamically at runtime. Use static allocation like for any other irq_chip usage. Signed-off-by: Pali Rohár --- drivers/pci/controller/pci-aardvark.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 8bea5801d50a..74511f015168 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -274,7 +274,6 @@ struct advk_pcie { u8 wins_count; struct irq_domain *rp_irq_domain; struct irq_domain *irq_domain; - struct irq_chip irq_chip; raw_spinlock_t irq_lock; struct irq_domain *msi_domain; struct irq_domain *msi_inner_domain; @@ -1328,13 +1327,19 @@ static void advk_pcie_irq_unmask(struct irq_data *d) raw_spin_unlock_irqrestore(&pcie->irq_lock, flags); } +static struct irq_chip advk_irq_chip = { + .name = "advk-INTx", + .irq_mask = advk_pcie_irq_mask, + .irq_unmask = advk_pcie_irq_unmask, +}; + static int advk_pcie_irq_map(struct irq_domain *h, unsigned int virq, irq_hw_number_t hwirq) { struct advk_pcie *pcie = h->host_data; irq_set_status_flags(virq, IRQ_LEVEL); - irq_set_chip_and_handler(virq, &pcie->irq_chip, + irq_set_chip_and_handler(virq, &advk_irq_chip, handle_level_irq); irq_set_chip_data(virq, pcie); @@ -1394,7 +1399,6 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie) struct device *dev = &pcie->pdev->dev; struct device_node *node = dev->of_node; struct device_node *pcie_intc_node; - struct irq_chip *irq_chip; int ret = 0; raw_spin_lock_init(&pcie->irq_lock); @@ -1405,28 +1409,14 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie) return -ENODEV; } - irq_chip = &pcie->irq_chip; - - irq_chip->name = devm_kasprintf(dev, GFP_KERNEL, "%s-irq", - dev_name(dev)); - if (!irq_chip->name) { - ret = -ENOMEM; - goto out_put_node; - } - - irq_chip->irq_mask = advk_pcie_irq_mask; - irq_chip->irq_unmask = advk_pcie_irq_unmask; - pcie->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, &advk_pcie_irq_domain_ops, pcie); if (!pcie->irq_domain) { dev_err(dev, "Failed to get a INTx IRQ domain\n"); ret = -ENOMEM; - goto out_put_node; } -out_put_node: of_node_put(pcie_intc_node); return ret; }