From patchwork Fri Dec 9 14:01:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31769 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp795688wrr; Fri, 9 Dec 2022 06:08:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf7DJTCur+OmDM1xeKG+0wOEFiQ0h9B+QKe71cRFk5CXZXDFzI5O8FoqvyQ9r7CyOcqCkAbE X-Received: by 2002:a05:6a20:6f06:b0:a2:e391:f8f3 with SMTP id gt6-20020a056a206f0600b000a2e391f8f3mr6897411pzb.34.1670594911948; Fri, 09 Dec 2022 06:08:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594911; cv=none; d=google.com; s=arc-20160816; b=hwYBWCoYN4VpX7JGPpJDxcMsHlr+CVNuh/CqB90KqcSotZMfhz1Fa5Et8Ls30qMG1R 5Uek29ZWuRuGA27/cRWLwkOp/9Wcgz3VleDHK6cIlyJNr8VCnCmiFInI4xGxOHnloZ6R LeQNca/Aw1iOc8FFnrFmAReHJhiAvoofVnK6nJOXh4yWVQxtlKGlrWRPAvCpu3O4N5kM M48dTFYaOZk71SfrJ7iG7eJCfYlCD7Xr/JFRk4VWBdY4cj/Cri9OZXrQ9Vsu3u03I56e qkT7rz89WpA+k/WJzqNlBgus5ofSV4qOeMd9Dr4cGWiwSQtt2J/Hq4nfFANCnAz8RS1o sL+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HY98ER5wylNvGJb8LiSDKkJHDekI/BolkpLmVwke0iA=; b=v+UjNg4XWKKfBNpRLIYpO9ThJzUIHx9r07NsMGNCyG2VoxKaK/L/OYSSHYMfRmoi0I dr2Njudmrf2rIrep0T3+92/fh8sq9ajXvOPPkgGAkVCLJD0gf9WlQFtrBrSOYllb4IfT l5Dcb0f8mLO2hB2g7S6aF1td0AMu+HEb8Ovt8b1PCEIOOqe8ZAZ/KaKx+sNhSnpua4b3 2EvdSaCQ9iXl/lBmshljbHcmpDaTqzz+1eg2qsSPIv/2PEVwNf4VSs6pk128dBdoIbVQ oMNTN6faEe6+Oe0/4ThranWb/ZyFY6Z9Fb8nQkjQaKGMcF7OX9Lg0vB+lhRc2FpBlQdR R7Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VKfmdud8; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v11-20020aa799cb000000b0056d480f7b92si1702413pfi.378.2022.12.09.06.08.17; Fri, 09 Dec 2022 06:08:31 -0800 (PST) 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=VKfmdud8; 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 S230148AbiLIOGG (ORCPT + 99 others); Fri, 9 Dec 2022 09:06:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229947AbiLIOFV (ORCPT ); Fri, 9 Dec 2022 09:05:21 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0774977209; Fri, 9 Dec 2022 06:05:16 -0800 (PST) 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 3206862277; Fri, 9 Dec 2022 14:05:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9572C4332B; Fri, 9 Dec 2022 14:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594713; bh=oPl4pvwV1ibYKGzWqPE8Z/9v5b9TU2RoMS/4leBXqsM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VKfmdud8A78pJzExYNYQ+U4s3u8OKfVXagECsOzWHPXy66/hT0yis1zPJ5bTEJwkf 2TESlFeolRO7vpH0WOyJMkk8sAelvUHhlQO1sAHQXs5T9fpSjE83hgDCOciThGTXRe ht/FDTPHI4NWTkn9AGNi8YcGcAF/HTLYotvk/fj/fx8R2K/JnTnsZi1CsW8b4RAgQx SX+/rbaGDuMlw1Te7sM12DSA/1p54pRAYqpeIAhhrdMeAuZ2i9uuKOw/xN/hFqLpZC YYrDjw3kP8pMZ1yrdqn2w+tBGSbHZ2lDiUdJMSODa46qWfH7wmrOpPMNRjomDPr6Vk EMlo4QMH46JXA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0J-0000Rp-21; Fri, 09 Dec 2022 15:05:31 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH v3 10/19] irqdomain: Clean up irq_domain_push/pop_irq() Date: Fri, 9 Dec 2022 15:01:41 +0100 Message-Id: <20221209140150.1453-11-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751745730437480484?= X-GMAIL-MSGID: =?utf-8?q?1751745730437480484?= The irq_domain_push_irq() interface is used to add a new (outmost) level to a hierarchical domain after IRQs have been allocated. Possibly due to differing mental images of hierarchical domains, the names used for the irq_data variables make these functions much harder to understand than what they need to be. Rename the struct irq_data pointer to the data embedded in the descriptor as simply 'irq_data' and refer to the data allocated by this interface as 'parent_irq_data' so that the names reflect how hierarchical domains are implemented. Signed-off-by: Johan Hovold Reviewed-by: Philippe Mathieu-Daudé --- kernel/irq/irqdomain.c | 65 +++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 7232947eee3e..6f2b8a1248e1 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -1571,8 +1571,8 @@ static void irq_domain_fix_revmap(struct irq_data *d) */ int irq_domain_push_irq(struct irq_domain *domain, int virq, void *arg) { - struct irq_data *child_irq_data; - struct irq_data *root_irq_data = irq_get_irq_data(virq); + struct irq_data *irq_data = irq_get_irq_data(virq); + struct irq_data *parent_irq_data; struct irq_desc *desc; int rv = 0; @@ -1597,45 +1597,44 @@ int irq_domain_push_irq(struct irq_domain *domain, int virq, void *arg) if (WARN_ON(!irq_domain_is_hierarchy(domain))) return -EINVAL; - if (!root_irq_data) + if (!irq_data) return -EINVAL; - if (domain->parent != root_irq_data->domain) + if (domain->parent != irq_data->domain) return -EINVAL; - child_irq_data = kzalloc_node(sizeof(*child_irq_data), GFP_KERNEL, - irq_data_get_node(root_irq_data)); - if (!child_irq_data) + parent_irq_data = kzalloc_node(sizeof(*parent_irq_data), GFP_KERNEL, + irq_data_get_node(irq_data)); + if (!parent_irq_data) return -ENOMEM; mutex_lock(&irq_domain_mutex); /* Copy the original irq_data. */ - *child_irq_data = *root_irq_data; + *parent_irq_data = *irq_data; /* - * Overwrite the root_irq_data, which is embedded in struct - * irq_desc, with values for this domain. + * Overwrite the irq_data, which is embedded in struct irq_desc, with + * values for this domain. */ - root_irq_data->parent_data = child_irq_data; - root_irq_data->domain = domain; - root_irq_data->mask = 0; - root_irq_data->hwirq = 0; - root_irq_data->chip = NULL; - root_irq_data->chip_data = NULL; + irq_data->parent_data = parent_irq_data; + irq_data->domain = domain; + irq_data->mask = 0; + irq_data->hwirq = 0; + irq_data->chip = NULL; + irq_data->chip_data = NULL; /* May (probably does) set hwirq, chip, etc. */ rv = irq_domain_alloc_irqs_hierarchy(domain, virq, 1, arg); if (rv) { /* Restore the original irq_data. */ - *root_irq_data = *child_irq_data; - kfree(child_irq_data); + *irq_data = *parent_irq_data; + kfree(parent_irq_data); goto error; } - irq_domain_fix_revmap(child_irq_data); - irq_domain_set_mapping(domain, root_irq_data->hwirq, root_irq_data); - + irq_domain_fix_revmap(parent_irq_data); + irq_domain_set_mapping(domain, irq_data->hwirq, irq_data); error: mutex_unlock(&irq_domain_mutex); @@ -1653,8 +1652,8 @@ EXPORT_SYMBOL_GPL(irq_domain_push_irq); */ int irq_domain_pop_irq(struct irq_domain *domain, int virq) { - struct irq_data *root_irq_data = irq_get_irq_data(virq); - struct irq_data *child_irq_data; + struct irq_data *irq_data = irq_get_irq_data(virq); + struct irq_data *parent_irq_data; struct irq_data *tmp_irq_data; struct irq_desc *desc; @@ -1676,37 +1675,37 @@ int irq_domain_pop_irq(struct irq_domain *domain, int virq) if (domain == NULL) return -EINVAL; - if (!root_irq_data) + if (!irq_data) return -EINVAL; tmp_irq_data = irq_domain_get_irq_data(domain, virq); /* We can only "pop" if this domain is at the top of the list */ - if (WARN_ON(root_irq_data != tmp_irq_data)) + if (WARN_ON(irq_data != tmp_irq_data)) return -EINVAL; - if (WARN_ON(root_irq_data->domain != domain)) + if (WARN_ON(irq_data->domain != domain)) return -EINVAL; - child_irq_data = root_irq_data->parent_data; - if (WARN_ON(!child_irq_data)) + parent_irq_data = irq_data->parent_data; + if (WARN_ON(!parent_irq_data)) return -EINVAL; mutex_lock(&irq_domain_mutex); - root_irq_data->parent_data = NULL; + irq_data->parent_data = NULL; - irq_domain_clear_mapping(domain, root_irq_data->hwirq); + irq_domain_clear_mapping(domain, irq_data->hwirq); irq_domain_free_irqs_hierarchy(domain, virq, 1); /* Restore the original irq_data. */ - *root_irq_data = *child_irq_data; + *irq_data = *parent_irq_data; - irq_domain_fix_revmap(root_irq_data); + irq_domain_fix_revmap(irq_data); mutex_unlock(&irq_domain_mutex); - kfree(child_irq_data); + kfree(parent_irq_data); return 0; }