From patchwork Sat Oct 25 11:06:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 39518 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9A1A12145E for ; Sat, 25 Oct 2014 11:09:58 +0000 (UTC) Received: by mail-wg0-f70.google.com with SMTP id x12sf54565wgg.1 for ; Sat, 25 Oct 2014 04:09:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=87o1LjwNJmS5480lQOPi7pe+8nsV8aWEo2n7EmsLA9c=; b=FjDn2kWoVMJ7FI+2GBex0aAEgEmBTAXS6a80+zYW9wyq4oXan7IZkrRjP//talVHJR 4PX/4ivIeyqT1MW2Ilr1r11rgBKq1GSzwOFZVlyENQbn7GKvAFVVLToA0CsBEWsokfES 5pPPs7aUEH5YGYv0sqUGC7JqTSh8QLqpynzYSjuQYgwzRigM2pv1GNORwc7D6gtCkMy2 6bKR3yZuNQsxm98DKW1cD7mD414xIiqiYopI+D5rsS2dE7uR4eCovrmK3Ubx3pkBn7vD RaqAsJTtVgXb60NJRZ+dpuD0rLPasjQRrh5uP39L283eg8VodvKZO7HRqHMNi/MWNoD1 UoQw== X-Gm-Message-State: ALoCoQmeSipL6y4BdQXdQjDqrVgFD1j/zyFga7CbrXpScFWsdVeOEN/1KitvtxykIYU6WAwhKW8o X-Received: by 10.112.55.10 with SMTP id n10mr54203lbp.14.1414235397241; Sat, 25 Oct 2014 04:09:57 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.206.8 with SMTP id lk8ls447337lac.17.gmail; Sat, 25 Oct 2014 04:09:56 -0700 (PDT) X-Received: by 10.112.135.229 with SMTP id pv5mr10314221lbb.52.1414235396957; Sat, 25 Oct 2014 04:09:56 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id h4si10858483lbd.53.2014.10.25.04.09.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 25 Oct 2014 04:09:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id hz20so3737183lab.25 for ; Sat, 25 Oct 2014 04:09:56 -0700 (PDT) X-Received: by 10.152.87.98 with SMTP id w2mr10151045laz.27.1414235396321; Sat, 25 Oct 2014 04:09:56 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp24167lbz; Sat, 25 Oct 2014 04:09:55 -0700 (PDT) X-Received: by 10.70.44.70 with SMTP id c6mr282015pdm.141.1414235394364; Sat, 25 Oct 2014 04:09:54 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id x3si6310186pdm.53.2014.10.25.04.09.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Oct 2014 04:09:54 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XhzC5-0004Mg-5n; Sat, 25 Oct 2014 11:07:37 +0000 Received: from inca-roads.misterjones.org ([213.251.177.50]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XhzC1-0004LQ-40 for linux-arm-kernel@lists.infradead.org; Sat, 25 Oct 2014 11:07:34 +0000 Received: from [90.219.10.17] (helo=why.wild-wind.fr.eu.org) by cheepnis.misterjones.org with esmtpsa (TLSv1.2:AES128-SHA256:128) (Exim 4.80) (envelope-from ) id 1XhzBa-00075o-Dy; Sat, 25 Oct 2014 13:07:06 +0200 From: Marc Zyngier To: Thomas Gleixner , Jason Cooper Subject: [PATCH 3/3] irqchip: GICv3: Convert to EOImode == 1 Date: Sat, 25 Oct 2014 12:06:55 +0100 Message-Id: <1414235215-10468-4-git-send-email-marc.zyngier@arm.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1414235215-10468-1-git-send-email-marc.zyngier@arm.com> References: <1414235215-10468-1-git-send-email-marc.zyngier@arm.com> X-SA-Exim-Connect-IP: 90.219.10.17 X-SA-Exim-Rcpt-To: tglx@linutronix.de, jason@lakedaemon.net, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-SA-Exim-Mail-From: marc.zyngier@arm.com X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141025_040733_310260_3CB7FDAA X-CRM114-Status: GOOD ( 17.99 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: marc.zyngier@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 So far, GICv3 has been used in with EOImode == 0. The effect of this mode is to perform the priority drop and the deactivation of the interrupt at the same time. While this works perfectly for Linux (we only have a single priority), it causes issues when an interrupt is forwarded to a guest, and when we want the guest to perform the EOI itself. This is also rather inefficient for threaded interrupts, as it forces us to hit the distributor (which is slower, specially when using virtualization). For this case, the GIC architecture provides EOImode == 1, where: - A write to ICC_EOIR1_EL1 drops the priority of the interrupt and leaves it active. Other interrupts at the same priority level can now be taken, but the active interrupt cannot be taken again - A write to ICC_DIR_EL1 marks the interrupt as inactive, meaning it can now be taken again. This patch converts the driver to this new mode when virtualization is enabled. Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-gic-v3.c | 30 ++++++++++++++++++++++++++++-- include/linux/irqchip/arm-gic-v3.h | 10 ++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 666c14e..c7f8a25 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "irq-gic-common.h" #include "irqchip.h" @@ -45,6 +46,7 @@ struct gic_chip_data { }; static struct gic_chip_data gic_data __read_mostly; +static bool supports_deactivate = false; #define gic_data_rdist() (this_cpu_ptr(gic_data.rdist)) #define gic_data_rdist_rd_base() (*gic_data_rdist()) @@ -289,6 +291,16 @@ static void gic_eoi_irq(struct irq_data *d) gic_write_eoir(gic_irq(d)); } +static void gic_priority_drop_irq(struct irq_data *d) +{ + gic_write_eoir(gic_irq(d)); +} + +static void gic_deactivate_irq(struct irq_data *d) +{ + gic_write_dir(gic_irq(d)); +} + static int gic_set_type(struct irq_data *d, unsigned int type) { unsigned int irq = gic_irq(d); @@ -345,6 +357,8 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs } if (irqnr < 16) { gic_write_eoir(irqnr); + if (supports_deactivate) + gic_write_dir(irqnr); #ifdef CONFIG_SMP handle_IPI(irqnr, regs); #else @@ -441,8 +455,13 @@ static void gic_cpu_sys_reg_init(void) /* Set priority mask register */ gic_write_pmr(DEFAULT_PMR_VALUE); - /* EOI deactivates interrupt too (mode 0) */ - gic_write_ctlr(ICC_CTLR_EL1_EOImode_drop_dir); + if (supports_deactivate) { + /* EOI drops priority only (mode 1) */ + gic_write_ctlr(ICC_CTLR_EL1_EOImode_drop); + } else { + /* EOI deactivates interrupt too (mode 0) */ + gic_write_ctlr(ICC_CTLR_EL1_EOImode_drop_dir); + } /* ... and let's hit the road... */ gic_write_grpen1(1); @@ -738,6 +757,13 @@ static int __init gic_of_init(struct device_node *node, struct device_node *pare if (of_property_read_u64(node, "redistributor-stride", &redist_stride)) redist_stride = 0; + if (is_hyp_mode_available()) { + supports_deactivate = true; + gic_chip.flags = IRQCHIP_EOI_THREADED, + gic_chip.irq_priority_drop = gic_priority_drop_irq; + gic_chip.irq_eoi = gic_deactivate_irq; + } + gic_data.dist_base = dist_base; gic_data.redist_base = redist_base; gic_data.redist_regions = redist_regions; diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h index 03a4ea3..9875502 100644 --- a/include/linux/irqchip/arm-gic-v3.h +++ b/include/linux/irqchip/arm-gic-v3.h @@ -74,6 +74,9 @@ #define GICR_SYNCR 0x00C0 #define GICR_MOVLPIR 0x0100 #define GICR_MOVALLR 0x0110 +#define GICR_ISACTIVER GICD_ISACTIVER +#define GICR_ICACTIVER GICD_ICACTIVER +#define GICR_IDREGS GICD_IDREGS #define GICR_PIDR2 GICD_PIDR2 #define GICR_WAKER_ProcessorSleep (1U << 1) @@ -128,6 +131,7 @@ #define ICH_VMCR_PMR_MASK (0xffUL << ICH_VMCR_PMR_SHIFT) #define ICC_EOIR1_EL1 sys_reg(3, 0, 12, 12, 1) +#define ICC_DIR_EL1 sys_reg(3, 0, 12, 11, 1) #define ICC_IAR1_EL1 sys_reg(3, 0, 12, 12, 0) #define ICC_SGI1R_EL1 sys_reg(3, 0, 12, 11, 5) #define ICC_PMR_EL1 sys_reg(3, 0, 4, 6, 0) @@ -195,6 +199,12 @@ static inline void gic_write_eoir(u64 irq) isb(); } +static inline void gic_write_dir(u64 irq) +{ + asm volatile("msr_s " __stringify(ICC_DIR_EL1) ", %0" : : "r" (irq)); + isb(); +} + #endif #endif