Received: by 10.213.65.68 with SMTP id h4csp278294imn; Fri, 23 Mar 2018 04:34:55 -0700 (PDT) X-Google-Smtp-Source: AG47ELv7K452wtJ5b49tvg6SF44K/xoQRvGc2p9ujdZNc3kKM5YabIi6YDgDmUeZNyqv9Kkq4ifa X-Received: by 2002:a17:902:7c18:: with SMTP id x24-v6mr23263201pll.112.1521804894973; Fri, 23 Mar 2018 04:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521804894; cv=none; d=google.com; s=arc-20160816; b=xLLBcvue+bgexDFs/I2jtY0YXjN/msQFvyImQqgraqDw5Yw+HrRviOQ/98qXmkIkO6 +v+cTrAHv/k72xQESoT3nnZ4m74CLOfSVADQoANjO75OtpiLZJsBvw3Rx5cPDz9pa+SJ +6ZlVcz1y7mYmYkbi4Nf8Jmx9p66+mxJm9UyZlxCC/WZif4Em6VPuJnnBLiE31D/kn2Y o4W607Pz9g5RNgo2uL7xqwjYZ9UH5/etgwHV9qxhAS8cJH5/zVZUDGjS59BWHg95t+JR NyG2CBpTHbgN6X+GwZn0H7BoyitngfRc7YvMx4WBKe8LD4GSoMpadiIbWeaScyFCInTk N3MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=/solamJ3C2DLK86rvKoeJYqum0a8MDBsZDjVAi7QB6c=; b=r4tscQdGExV5v7EtUJQYi7JB5+8+crGKSQPC4HCK2r+7SVEg02gzK4Ju1DRtRu2E2u 1VJ+jVSq3fUEraIvHTDy7X1o28F/IN1+VOPZVo6aQaJRC4qhdqn6ih6c+H0AnH7skKhE W3ajezRJVY6qUXjBifXeXJlCq4Oez3pOIeJB2vKxLIKeCpWzoSvmV8TwhffvotqnRUwr 0aYw22yq/wJxkEWE9NP0E7DDKXAvTiKWl/9ObCaJdbFrY0xe71U3A4WSL+qgnwVqv3b1 TKQtuSVt/pN2bxBR1BfMO4edRE1hrXYG8qkmQLOAzjXvicJKPk80o6PR3/LpodYZh28P nMpg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f127si3190237pfa.221.2018.03.23.04.34.40; Fri, 23 Mar 2018 04:34:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755014AbeCWKFc (ORCPT + 99 others); Fri, 23 Mar 2018 06:05:32 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:39712 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754935AbeCWKF3 (ORCPT ); Fri, 23 Mar 2018 06:05:29 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 67DFF140A; Fri, 23 Mar 2018 10:05:28 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Burton , Matt Redfearn , linux-mips@linux-mips.org, Jason Cooper , Marc Zyngier , Ralf Baechle , Thomas Gleixner , Sasha Levin Subject: [PATCH 4.9 037/177] irqchip/mips-gic: Separate IPI reservation & usage tracking Date: Fri, 23 Mar 2018 10:52:45 +0100 Message-Id: <20180323094206.787496927@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094205.090519271@linuxfoundation.org> References: <20180323094205.090519271@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paul Burton [ Upstream commit f8dcd9e81797ae24acc44c84f0eb3b9e6cee9791 ] Since commit 2af70a962070 ("irqchip/mips-gic: Add a IPI hierarchy domain") introduced the GIC IPI IRQ domain we have tracked both reservation of interrupts & their use with a single bitmap - ipi_resrv. If an interrupt is reserved for use as an IPI but not actually in use then the appropriate bit is set in ipi_resrv. If an interrupt is either not reserved for use as an IPI or has been allocated as one then the appropriate bit is clear in ipi_resrv. Unfortunately this means that checking whether a bit is set in ipi_resrv to prevent IPI interrupts being allocated for use with a device is broken, because if the interrupt has been allocated as an IPI first then its bit will be clear. Fix this by separating the tracking of IPI reservation & usage, introducing a separate ipi_available bitmap for the latter. This means that ipi_resrv will now always have bits set corresponding to all interrupts reserved for use as IPIs, whether or not they have been allocated yet, and therefore that checking it when allocating device interrupts works as expected. Fixes: 2af70a962070 ("irqchip/mips-gic: Add a IPI hierarchy domain") Signed-off-by: Paul Burton Signed-off-by: Matt Redfearn Cc: linux-mips@linux-mips.org Cc: Jason Cooper Cc: Marc Zyngier Cc: Ralf Baechle Link: http://lkml.kernel.org/r/1492679256-14513-2-git-send-email-matt.redfearn@imgtec.com Signed-off-by: Thomas Gleixner Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/irqchip/irq-mips-gic.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c @@ -55,6 +55,7 @@ static unsigned int gic_cpu_pin; static unsigned int timer_cpu_pin; static struct irq_chip gic_level_irq_controller, gic_edge_irq_controller; DECLARE_BITMAP(ipi_resrv, GIC_MAX_INTRS); +DECLARE_BITMAP(ipi_available, GIC_MAX_INTRS); static void __gic_irq_dispatch(void); @@ -746,17 +747,17 @@ static int gic_irq_domain_alloc(struct i return gic_setup_dev_chip(d, virq, spec->hwirq); } else { - base_hwirq = find_first_bit(ipi_resrv, gic_shared_intrs); + base_hwirq = find_first_bit(ipi_available, gic_shared_intrs); if (base_hwirq == gic_shared_intrs) { return -ENOMEM; } /* check that we have enough space */ for (i = base_hwirq; i < nr_irqs; i++) { - if (!test_bit(i, ipi_resrv)) + if (!test_bit(i, ipi_available)) return -EBUSY; } - bitmap_clear(ipi_resrv, base_hwirq, nr_irqs); + bitmap_clear(ipi_available, base_hwirq, nr_irqs); /* map the hwirq for each cpu consecutively */ i = 0; @@ -787,7 +788,7 @@ static int gic_irq_domain_alloc(struct i return 0; error: - bitmap_set(ipi_resrv, base_hwirq, nr_irqs); + bitmap_set(ipi_available, base_hwirq, nr_irqs); return ret; } @@ -802,7 +803,7 @@ void gic_irq_domain_free(struct irq_doma return; base_hwirq = GIC_HWIRQ_TO_SHARED(irqd_to_hwirq(data)); - bitmap_set(ipi_resrv, base_hwirq, nr_irqs); + bitmap_set(ipi_available, base_hwirq, nr_irqs); } int gic_irq_domain_match(struct irq_domain *d, struct device_node *node, @@ -1066,6 +1067,7 @@ static void __init __gic_init(unsigned l 2 * gic_vpes); } + bitmap_copy(ipi_available, ipi_resrv, GIC_MAX_INTRS); gic_basic_init(); }