From patchwork Fri Oct 27 07:24:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 158791 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp420788vqb; Fri, 27 Oct 2023 00:24:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHg11NvG0Mtor7uuE0iyLlNvVcVcTCyVJsZVHgUE+dvazBP8RNcgKycZEO6aKV1c+QVbwwP X-Received: by 2002:a81:af46:0:b0:5a7:b892:b299 with SMTP id x6-20020a81af46000000b005a7b892b299mr3527555ywj.19.1698391469807; Fri, 27 Oct 2023 00:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698391469; cv=none; d=google.com; s=arc-20160816; b=uWSYOzvBLq7N/c6xM+vC/ed6bFkapGSaVvT3yzqTWimMKOx56dwhZbcPbTJw2jXDBZ cjwqb2c3VItFcxRda8R9AFlRZ/ujo5E9X5MGt6X5JCLW1IfwlaDE0jLK/XfXJbwL1weL mu25/7uiTTjnfYY/dNMoubceEAQ9KFdCcphIAlI2dLeIgOQ3K0FNg04XgalXU25+bOGL DSPQWdldsbjk73/rRrTihfRq5fv1tpuXJt9p3Bf0sldLA7xgG0RwQXcvmL2LVElh5bCQ 90XAFmCD11aSqupNpMl3fdUBn4U/c4DKQbCHEwhBw7i25X0S7D8nZfCR3gKYL4P8yn59 kH6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=W6Dghujogbztdmwt/jqBXHDqaTSSB292Ldx3Ap8/ojs=; fh=VRUZ+ygEIvJ7uZBFOY/Y3lnLTC7tUJ9VtP4rNTJB5kU=; b=mXXV0jc9sJA82AYsC3yOoY8uAnADzff72Q4JV/rGX5KD1S4j09YNhIQWkeF34TTK5e 2vWZfPpEf7X/W/31+AauZl8i0ilmepkgXqs1ZF6lGpViKvykzF1fbDJQ95on4oum2PMM VAVdXefWI197jU7LVISaBZwwXLljDPVdIKsQBMWRDF0ziJUhm7DNxz5puDKuU+J5ynub uddKRlcCcsBkfqx8X6jjDsDa6Y8dG3w2Djl4b47eRUKGMmJh7z9xIvEBevPQBPxA9esM NkgvpSbqub1i1UM0VkNNV/vW7rxrQtF1rGNjc9Uerx6//fJMmLfNtJqN1ZJG/htlf/1G 0TSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bxI4eeO0; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id s65-20020a815e44000000b005920925b1e0si1869532ywb.184.2023.10.27.00.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 00:24:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bxI4eeO0; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C9820832659A; Fri, 27 Oct 2023 00:24:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345409AbjJ0HYH (ORCPT + 26 others); Fri, 27 Oct 2023 03:24:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231233AbjJ0HYE (ORCPT ); Fri, 27 Oct 2023 03:24:04 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A1A3192; Fri, 27 Oct 2023 00:24:02 -0700 (PDT) Date: Fri, 27 Oct 2023 07:24:00 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1698391441; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W6Dghujogbztdmwt/jqBXHDqaTSSB292Ldx3Ap8/ojs=; b=bxI4eeO0wIqXfcGStkvU4dBwkvt2xon/Ec3JWufxozWqkLiTOY0ucG9rlTSAwFi9OvXjwO bOG7dGGkdeqDS97gVPZu+Zo1EmxzD62KK0kQao0YIRbM1w11MQSate2opRQdIW4+x5Qdzb GjWJeu6KnPUQjcotdTbCdO6bfTSNhdkBnbUj2xW2zWvCRFKstcbIPDrlf3TS4aZcBXJeUM bLqbJdaA43NVPSIN428SOuIGcxG7FUm5sdfFKGpjB068ULsHyX+Ebu8oUYmOGQUpUXokNC uQZoF2ODvYFPafyV8bAkgdyKxTxKhRqOANSTsEyN45OTjvE1vXmixAHL90881Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1698391441; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W6Dghujogbztdmwt/jqBXHDqaTSSB292Ldx3Ap8/ojs=; b=rkc7B6nRgb7TpPIOcgHz4laIoXwc2FUpnqg6b+fFot6jhA4ryoL39PrCZ0Pf3P/28Zmv4p 4ux8QMnZ5WxqD1Cw== From: "tip-bot2 for Herve Codina" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] genirq/generic_chip: Make irq_remove_generic_chip() irqdomain aware Cc: Herve Codina , Thomas Gleixner , stable@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org In-Reply-To: <20231024150335.322282-1-herve.codina@bootlin.com> References: <20231024150335.322282-1-herve.codina@bootlin.com> MIME-Version: 1.0 Message-ID: <169839144046.3135.18250117406954696469.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 27 Oct 2023 00:24:26 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780892533878349581 X-GMAIL-MSGID: 1780892533878349581 The following commit has been merged into the irq/core branch of tip: Commit-ID: 5e7afb2eb7b2a7c81e9f608cbdf74a07606fd1b5 Gitweb: https://git.kernel.org/tip/5e7afb2eb7b2a7c81e9f608cbdf74a07606fd1b5 Author: Herve Codina AuthorDate: Tue, 24 Oct 2023 17:03:35 +02:00 Committer: Thomas Gleixner CommitterDate: Fri, 27 Oct 2023 09:15:44 +02:00 genirq/generic_chip: Make irq_remove_generic_chip() irqdomain aware irq_remove_generic_chip() calculates the Linux interrupt number for removing the handler and interrupt chip based on gc::irq_base as a linear function of the bit positions of set bits in the @msk argument. When the generic chip is present in an irq domain, i.e. created with a call to irq_alloc_domain_generic_chips(), gc::irq_base contains not the base Linux interrupt number. It contains the base hardware interrupt for this chip. It is set to 0 for the first chip in the domain, 0 + N for the next chip, where $N is the number of hardware interrupts per chip. That means the Linux interrupt number cannot be calculated based on gc::irq_base for irqdomain based chips without a domain map lookup, which is currently missing. Rework the code to take the irqdomain case into account and calculate the Linux interrupt number by a irqdomain lookup of the domain specific hardware interrupt number. [ tglx: Massage changelog. Reshuffle the logic and add a proper comment. ] Fixes: cfefd21e693d ("genirq: Add chip suspend and resume callbacks") Signed-off-by: Herve Codina Signed-off-by: Thomas Gleixner Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20231024150335.322282-1-herve.codina@bootlin.com --- kernel/irq/generic-chip.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c index 81ecca0..d39a40b 100644 --- a/kernel/irq/generic-chip.c +++ b/kernel/irq/generic-chip.c @@ -548,21 +548,34 @@ EXPORT_SYMBOL_GPL(irq_setup_alt_chip); void irq_remove_generic_chip(struct irq_chip_generic *gc, u32 msk, unsigned int clr, unsigned int set) { - unsigned int i = gc->irq_base; + unsigned int i, virq; raw_spin_lock(&gc_lock); list_del(&gc->list); raw_spin_unlock(&gc_lock); - for (; msk; msk >>= 1, i++) { + for (i = 0; msk; msk >>= 1, i++) { if (!(msk & 0x01)) continue; + /* + * Interrupt domain based chips store the base hardware + * interrupt number in gc::irq_base. Otherwise gc::irq_base + * contains the base Linux interrupt number. + */ + if (gc->domain) { + virq = irq_find_mapping(gc->domain, gc->irq_base + i); + if (!virq) + continue; + } else { + virq = gc->irq_base + i; + } + /* Remove handler first. That will mask the irq line */ - irq_set_handler(i, NULL); - irq_set_chip(i, &no_irq_chip); - irq_set_chip_data(i, NULL); - irq_modify_status(i, clr, set); + irq_set_handler(virq, NULL); + irq_set_chip(virq, &no_irq_chip); + irq_set_chip_data(virq, NULL); + irq_modify_status(virq, clr, set); } } EXPORT_SYMBOL_GPL(irq_remove_generic_chip);