From patchwork Tue Nov 24 06:17:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 11927241 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3DDCC64E7B for ; Tue, 24 Nov 2020 06:18:46 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5EDE42080A for ; Tue, 24 Nov 2020 06:18:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WR2PPXwx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5EDE42080A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ozlabs.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=FRFluwUyBxW+fxDSbGqEZ7oDvURYhhwhT6wb3ZStbP0=; b=WR2PPXwxLKwpUACI+Y/lpePovy Q4/tPgN69053BdSsT7S0HZiILcMMIQmwImdtoXpYC3DUySq8H5sm+/PmA8ZbG3SGuzBzgsuliiItD I9V7Mh/wSEacMTIvFiBn9qPrXEi3kSmsR56VbE6JoNm/Ws7TJru5ddQIv5hzWTSc+nOMEKgwvlQYM TxTJm1xnyppMRXSGPBFuSaVqpYflp6GYACYxdCtNfGGXhIX72ZO+LCZTICSoV+60sq0V0gOUloIS/ yQ+uGi+TMFUHM/NS0iSU+sDffwkuEH8rZ2GElDGf9JRbC7+bmOnxI7M1aQH29UmhSDwMu7j7ojFrb fcu3z4TA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1khReb-0007KN-Ri; Tue, 24 Nov 2020 06:18:17 +0000 Received: from ozlabs.ru ([107.174.27.60]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1khReQ-0007Hq-1T for linux-arm-kernel@lists.infradead.org; Tue, 24 Nov 2020 06:18:07 +0000 Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 28792AE80001; Tue, 24 Nov 2020 01:17:29 -0500 (EST) From: Alexey Kardashevskiy To: linux-kernel@vger.kernel.org Subject: [PATCH kernel v4 0/8] genirq/irqdomain: Add reference counting to IRQs Date: Tue, 24 Nov 2020 17:17:12 +1100 Message-Id: <20201124061720.86766-1-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201124_011806_229183_D79224C2 X-CRM114-Status: GOOD ( 13.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , Marc Zyngier , x86@kernel.org, linux-gpio@vger.kernel.org, Oliver O'Halloran , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Frederic Barrat , Thomas Gleixner , =?utf-8?q?Michal_Such=C3=A1nek?= , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This is another attempt to add reference counting to IRQ descriptors; or - more to the point - reuse already existing kobj from irq_desc. This allows the same IRQ to be used several times (such as legacy PCI INTx) and when disposing those, only the last reference drop clears the hardware mappings. Domains do not add references to irq_desc as the whole point of this exercise is to move actual cleanup in hardware to the last reference drop. This only changes sparse interrupts (no idea about the other case yet). No changelog as it is all completely rewritten. I am still running tests but I hope this demonstrates the idea. Some context from Cedric: The background context for such a need is that the POWER9 and POWER10 processors have a new XIVE interrupt controller which uses MMIO pages for interrupt management. Each interrupt has a pair of pages which are required to be unmapped in some environment, like PHB removal. And so, all interrupts need to be unmmaped. 1/8 .. 3/8 are removing confusing "realloc" which not strictly required but I was touching this anyway and legacy interrupts should probably use the new counting anyway; 4/8 .. 6/8 is reordering irq_desc disposal; 7/8 adds extra references (probably missed other places); 8/8 is the fix for the original XIVE bug; it is here for demonstration. I am cc'ing ppc list so people can pull the patches from that patchworks. This is based on sha1 418baf2c28f3 Linus Torvalds "Linux 5.10-rc5". and pushed out to https://github.com/aik/linux/commits/irqs sha1 3955f97c448242f6a Please comment. Thanks. Alexey Kardashevskiy (7): genirq/ipi: Simplify irq_reserve_ipi genirq/irqdomain: Clean legacy IRQ allocation genirq/irqdomain: Drop unused realloc parameter from __irq_domain_alloc_irqs genirq: Free IRQ descriptor via embedded kobject genirq: Add free_irq hook for IRQ descriptor and use for mapping disposal genirq/irqdomain: Move hierarchical IRQ cleanup to kobject_release genirq/irqdomain: Reference irq_desc for already mapped irqs Oliver O'Halloran (1): powerpc/pci: Remove LSI mappings on device teardown include/linux/irqdesc.h | 1 + include/linux/irqdomain.h | 9 +- include/linux/irqhandler.h | 1 + arch/powerpc/kernel/pci-common.c | 21 ++++ arch/x86/kernel/apic/io_apic.c | 13 ++- drivers/gpio/gpiolib.c | 1 - drivers/irqchip/irq-armada-370-xp.c | 2 +- drivers/irqchip/irq-bcm2836.c | 3 +- drivers/irqchip/irq-gic-v3.c | 3 +- drivers/irqchip/irq-gic-v4.c | 6 +- drivers/irqchip/irq-gic.c | 3 +- drivers/irqchip/irq-ixp4xx.c | 1 - kernel/irq/ipi.c | 16 +-- kernel/irq/irqdesc.c | 45 +++----- kernel/irq/irqdomain.c | 160 +++++++++++++++++----------- kernel/irq/msi.c | 2 +- 16 files changed, 158 insertions(+), 129 deletions(-)