From patchwork Tue Nov 24 06:17:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 11927257 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_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 B8A8FC2D0E4 for ; Tue, 24 Nov 2020 06:20:07 +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 44B0220678 for ; Tue, 24 Nov 2020 06:20:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gn7E0dEi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 44B0220678 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:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To: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:List-Owner; bh=hqwcfDKWPeULWV8SI3JnxhJgMa+yAZWjUItgAccc74Y=; b=gn7E0dEi8rhQ5hS/tSUb89q7fS lUmc2YIHi4CIHLj+QhMUvZnQcyTOBX5MolRZlOo2Jbv2Yvu80ttljsddhF7TwrE5I1y49+cex74sL XrbnI4G0w6UCkiuqKxat5kSjRbsq/S//skowzCFKzKGx9yLcYjziTeTAFYsfuQDWFbHOkVqwkA4TO 0uSyGYug3SPc0YsrGE+ufgMxiz3XDnV0LsCikXaNYtT68d+piokul6omKy/c5i5hdSn63Z9B5YXDD QQ3GJ5dOWZgvIwYurn6+84ap8/evapWiqTWmFSmrrufWOiRjf8M764GwBGXrMeQAN24jwNSS/s0FE 0wXU5Tjg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1khRfH-0007aQ-Jd; Tue, 24 Nov 2020 06:18:59 +0000 Received: from ozlabs.ru ([107.174.27.60]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1khRf2-0007Us-7Y for linux-arm-kernel@lists.infradead.org; Tue, 24 Nov 2020 06:18:45 +0000 Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id D511EAE80253; Tue, 24 Nov 2020 01:18:08 -0500 (EST) From: Alexey Kardashevskiy To: linux-kernel@vger.kernel.org Subject: [PATCH kernel v4 6/8] genirq/irqdomain: Move hierarchical IRQ cleanup to kobject_release Date: Tue, 24 Nov 2020 17:17:18 +1100 Message-Id: <20201124061720.86766-7-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201124061720.86766-1-aik@ozlabs.ru> References: <20201124061720.86766-1-aik@ozlabs.ru> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201124_011844_410547_96661669 X-CRM114-Status: GOOD ( 13.52 ) 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 MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This moves hierarchical domain's irqs cleanup into the kobject release hook to make irq_domain_free_irqs() as simple as kobject_put. Signed-off-by: Alexey Kardashevskiy Reported-by: kernel test robot --- kernel/irq/irqdomain.c | 43 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 4779d912bb86..a0a81cc6c524 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -863,21 +863,9 @@ EXPORT_SYMBOL_GPL(irq_create_of_mapping); */ void irq_dispose_mapping(unsigned int virq) { - struct irq_data *irq_data = irq_get_irq_data(virq); - struct irq_domain *domain; + struct irq_desc *desc = irq_to_desc(virq); - if (!virq || !irq_data) - return; - - domain = irq_data->domain; - if (WARN_ON(domain == NULL)) - return; - - if (irq_domain_is_hierarchy(domain)) { - irq_domain_free_irqs(virq, 1); - } else { - irq_free_desc(virq); - } + kobject_put(&desc->kobj); } EXPORT_SYMBOL_GPL(irq_dispose_mapping); @@ -1396,6 +1384,19 @@ int irq_domain_alloc_irqs_hierarchy(struct irq_domain *domain, return domain->ops->alloc(domain, irq_base, nr_irqs, arg); } +static void irq_domain_hierarchy_free_desc(struct irq_desc *desc) +{ + unsigned int virq = desc->irq_data.irq; + struct irq_data *data = irq_get_irq_data(virq); + + mutex_lock(&irq_domain_mutex); + irq_domain_remove_irq(virq); + irq_domain_free_irqs_hierarchy(data->domain, virq, 1); + mutex_unlock(&irq_domain_mutex); + + irq_domain_free_irq_data(virq, 1); +} + int __irq_domain_alloc_irqs_data(struct irq_domain *domain, int virq, unsigned int nr_irqs, int node, void *arg, const struct irq_affinity_desc *affinity) @@ -1430,7 +1431,10 @@ int __irq_domain_alloc_irqs_data(struct irq_domain *domain, int virq, } for (i = 0; i < nr_irqs; i++) { + struct irq_desc *desc = irq_to_desc(virq + i); + irq_domain_insert_irq(virq + i); + desc->free_irq = irq_domain_hierarchy_free_desc; } mutex_unlock(&irq_domain_mutex); @@ -1675,14 +1679,11 @@ void irq_domain_free_irqs(unsigned int virq, unsigned int nr_irqs) "NULL pointer, cannot free irq\n")) return; - mutex_lock(&irq_domain_mutex); - for (i = 0; i < nr_irqs; i++) - irq_domain_remove_irq(virq + i); - irq_domain_free_irqs_hierarchy(data->domain, virq, nr_irqs); - mutex_unlock(&irq_domain_mutex); + for (i = 0; i < nr_irqs; i++) { + struct irq_desc *desc = irq_to_desc(virq + i); - irq_domain_free_irq_data(virq, nr_irqs); - irq_free_descs(virq, nr_irqs); + kobject_put(&desc->kobj); + } } /**