Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp513152imu; Tue, 27 Nov 2018 02:05:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/X7H1HQH5Sui7Ey3Wy7GflR8AKZAFzFyNBB60AEMNECudCE7NBLLG2lvtEUeXlJNKcO+vwW X-Received: by 2002:a17:902:d206:: with SMTP id t6mr32125435ply.193.1543313106372; Tue, 27 Nov 2018 02:05:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543313106; cv=none; d=google.com; s=arc-20160816; b=DU2q/uGies8BQUraZx4kOKK18aW3OvyCfLwehpkSSXxkk2qHhQ7S9cJjIv70v8wnNJ YzEVcOP1lNG+Fdb86TzI/z8YQGwuFY0bBZ6KSPVoks9N3Enj/pSC7aHpq5gEC0B1iATI 700Lq+Fxh5BYOS0GFJdHnIhDTrTjTPWDPEtHPGRlaaQj15XF0rOh9IUDZbbnA8gEd/P9 yQGcfEfwKZre3EkkhfTg5Ss92IK0bqDRsnOLBrackMxQxZuTkOY5dI1ShaDF5qPn8Xz0 PDXvCOXIH4Zba82k4EoVGXz28BFQ+3kIgWT4pfCUkG262j2uO1Rx80k7NtMG+WOXJC5W HYbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=arjeBMdw9sCQtY7MdQAlVkfUbrvemGUsW01G3n51jWI=; b=MHRlqCDU+I5k+qSUy+FOZen+tB4lkCtGkb68XqGjKviTEcCxOAl3hJoz3ytb4wjb1v U3ME9O6LGUXz69pBLJ+cENZRTFNkqno0fWwN6DD1Sy6hcYRedciqAJuQ8BQChkob2dPm nvdUYy6M24OTIl5jsb1xyXJicqtKoO5teul8QYfDzywq8EUbHnr6bhSV7slf6Ukt1bDI ExVFTkvDsKikld1SowcVZIgItBTjLvJWC5mpQPFqhlP1MjsOpPpCOLSAShMU2CfBmxw8 gXmFK0C1l8TiTUT/1tpL4s5jgycKiwjK1k77tJM48vhErmK/Ex4PY1pcZwe13fXl2nlP lQqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=KCPo0TX6; 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 z18si3356147plo.89.2018.11.27.02.04.51; Tue, 27 Nov 2018 02:05:06 -0800 (PST) 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; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=KCPo0TX6; 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 S1730563AbeK0VBI (ORCPT + 99 others); Tue, 27 Nov 2018 16:01:08 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:38467 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730371AbeK0VBH (ORCPT ); Tue, 27 Nov 2018 16:01:07 -0500 Received: by mail-pf1-f195.google.com with SMTP id q1so8115840pfi.5 for ; Tue, 27 Nov 2018 02:03:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=arjeBMdw9sCQtY7MdQAlVkfUbrvemGUsW01G3n51jWI=; b=KCPo0TX60Z45IB5BeS5G7Sm/miAkY91wN3wEOAgkNTzBD4uM3Dz8duXoAi1+x99lzD 7159m3jNaF6GdMhdwLxYRww9baUAYmMBTLA42HOrmKQP3GAPWk+JH/btZBLEyaam5/z3 d0wyISCHqiBRgOsdvEiiZO4YQructIsdP8vBOCHAL5YYMz7QAFYGC8w3S1p7EXw+khXF x5pDtU6mBmAg6Z7P1ouRX7NWkFeekZQJM4xQFKTyDnMmUuORUjTUiXdhNM8+/xLxggcl 866cynbFqqvQQxWAwuOkYkay79h1TF8qUtaVU6JYI5niU8+lFfKNUoPFiPnnkw34+6QX t6VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=arjeBMdw9sCQtY7MdQAlVkfUbrvemGUsW01G3n51jWI=; b=OCbQBAXsweZ6km/ZAaDjT+0KMLiUJJfhA5Ek+34HD7DaA+JDMrmijuJwN3Z7bftwD4 lzgNMfujqlb586DuqrO3r/362U86ztRQ60g926tyKLJ/kB06PnMrqTI6HAOx2J8vZ2uY C8sE2Ezn24+sSgBun2IGl1gTv53fwv40jRxnF8GrF2ZQXQwqXe1sI+T4VYHWbOQ2KQ/f 0NBi/oC7Yi2UKceJRVJGMehXZgwwPKb/q8bcRIoV8pzvMCbTuKQxzzU0w1hPFxFK1+HG 3BBq5DMmYG1laKtmHq8uLor+UFf4ol1LHIsmduVq5Lhi0iArxukzk+SjB7kdKIdtxy+B Nc7A== X-Gm-Message-State: AA+aEWbUyVPLRqDa+5/MNyk5FXgvzUdG3QsJin7aFW31Z3DEVa3LdQ+M nlbCUBnA4SrzskLFCajuzDlfgA== X-Received: by 2002:a63:334a:: with SMTP id z71mr28779865pgz.400.1543313024612; Tue, 27 Nov 2018 02:03:44 -0800 (PST) Received: from anup-ubuntu64.qualcomm.com ([49.207.48.241]) by smtp.googlemail.com with ESMTPSA id t87sm9519590pfk.122.2018.11.27.02.03.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Nov 2018 02:03:43 -0800 (PST) From: Anup Patel To: Palmer Dabbelt , Albert Ou , Daniel Lezcano , Thomas Gleixner , Jason Cooper , Marc Zyngier Cc: Atish Patra , Christoph Hellwig , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel Subject: [PATCH v2 3/4] irqchip: sifive-plic: Differentiate between PLIC handler and context Date: Tue, 27 Nov 2018 15:33:16 +0530 Message-Id: <20181127100317.12809-4-anup@brainfault.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181127100317.12809-1-anup@brainfault.org> References: <20181127100317.12809-1-anup@brainfault.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We explicitly differentiate between PLIC handler and context because PLIC context is for given mode of HART whereas PLIC handler is per-CPU software construct meant for handling interrupts from a particular PLIC context. Signed-off-by: Anup Patel --- drivers/irqchip/irq-sifive-plic.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index 95b4b92ca9b8..ffd4deaca057 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -66,8 +66,8 @@ static DEFINE_PER_CPU(struct plic_handler, plic_handlers); struct plic_hw { u32 nr_irqs; + u32 nr_contexts; u32 nr_handlers; - u32 nr_mapped; void __iomem *regs; struct irq_domain *irqdomain; }; @@ -191,10 +191,10 @@ static int __init plic_init(struct device_node *node, if (WARN_ON(!plic.nr_irqs)) goto out_iounmap; - plic.nr_handlers = of_irq_count(node); - if (WARN_ON(!plic.nr_handlers)) + plic.nr_contexts = of_irq_count(node); + if (WARN_ON(!plic.nr_contexts)) goto out_iounmap; - if (WARN_ON(plic.nr_handlers < num_possible_cpus())) + if (WARN_ON(plic.nr_contexts < num_possible_cpus())) goto out_iounmap; plic.irqdomain = irq_domain_add_linear(node, plic.nr_irqs + 1, @@ -202,7 +202,7 @@ static int __init plic_init(struct device_node *node, if (WARN_ON(!plic.irqdomain)) goto out_iounmap; - for (i = 0; i < plic.nr_handlers; i++) { + for (i = 0; i < plic.nr_contexts; i++) { struct of_phandle_args parent; struct plic_handler *handler; irq_hw_number_t hwirq; @@ -225,6 +225,11 @@ static int __init plic_init(struct device_node *node, cpu = riscv_hartid_to_cpuid(hartid); handler = per_cpu_ptr(&plic_handlers, cpu); + if (handler->present) { + pr_warn("handler not available for context %d.\n", i); + continue; + } + handler->present = true; handler->hart_base = plic.regs + CONTEXT_BASE + i * CONTEXT_PER_HART; @@ -237,11 +242,11 @@ static int __init plic_init(struct device_node *node, for (hwirq = 1; hwirq <= plic.nr_irqs; hwirq++) plic_toggle(handler, hwirq, 0); - plic.nr_mapped++; + plic.nr_handlers++; } - pr_info("mapped %d interrupts to %d (out of %d) handlers.\n", - plic.nr_irqs, plic.nr_mapped, plic.nr_handlers); + pr_info("mapped %d interrupts with %d handlers for %d contexts.\n", + plic.nr_irqs, plic.nr_handlers, plic.nr_contexts); set_handle_irq(plic_handle_irq); return 0; -- 2.17.1