From patchwork Fri Feb 9 14:39:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 127814 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp679450ljc; Fri, 9 Feb 2018 06:41:50 -0800 (PST) X-Google-Smtp-Source: AH8x224mdOLMVjiOQnvfXsoEY7liMrXv8UVzXYxKN9BlQ1fVzkbTBoT1mtKEMn6WoaWiFmtKVThg X-Received: by 10.36.16.137 with SMTP id 131mr3676242ity.111.1518187309889; Fri, 09 Feb 2018 06:41:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518187309; cv=none; d=google.com; s=arc-20160816; b=vjX5UWlhIWr07cnNoV94X0sEkbEDyHynEHNY5DRn8smz6INChPuaFLK5zRyUlZ0tjI heL/d7RVDdFTY5tYJRr/lYG+7Mge6QFLdM/LHpeL0D7TXEQL/7DoUVONUmupdZ1i6MNs u1E/PbZlZuT2IZWFc5BYBjkDO3MpGhtXowYYr2Dob7dPYAmF29okTjzPcwcXxjvV9ESv n0VkmizUSwxf64CbLJdgXjX6bLJve+6N0JYhDq0q1FwRILnet7KJNCbeSVWoxbOpMF56 xU3XpqSEVKFgP2MdkHpf3GzmVqf6ND9hwHUhjuNsbr1+Xl30oByyzCgUPsh9+OfRI69D ZgJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=VbeGceEsxicT3S6LTm9OfsKHg6Y3TEt0f79IyFudt8k=; b=WsgxeiaRZUWznHXuOghZWxnfcLHVwnAbQzFnBGpWUCAJ3/sx6KTIL5B6SEhrtLPRoO 7jKLqMuhQWdUK1Z3Dh7v9SocezxwGnuk9fDkbfUBqCXckUBOjlnkU+wNf2opJvXxSFPK 8VzyJzP9R0QAL+lxSBnuD8z4F5n7Vl2KYiDvoXVi6iuBKLJy/J+tNH7uLC/463lXKGPZ pniTY7EAcT4IbdRkLOFBf+lMlm3PR5J8tWwGQ940HiHKTF3y+25gplbRXfWUMvkyNMM4 uwyIimZ8WSYD+QURWOxLKsxMwQMJvRTRJYe0Bjg+Xh8aq5ajS/CUFr/Dq0ldWYayNoNt E/gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jfFyP6jL; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id y103si77548ioi.116.2018.02.09.06.41.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Feb 2018 06:41:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jfFyP6jL; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ek9qO-0000Hn-KJ; Fri, 09 Feb 2018 14:40:04 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ek9qN-0008W7-QO for xen-devel@lists.xenproject.org; Fri, 09 Feb 2018 14:40:03 +0000 X-Inumbo-ID: 0b09bac6-0da7-11e8-ba59-bc764e045a96 Received: from mail-wm0-x244.google.com (unknown [2a00:1450:400c:c09::244]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 0b09bac6-0da7-11e8-ba59-bc764e045a96; Fri, 09 Feb 2018 15:39:33 +0100 (CET) Received: by mail-wm0-x244.google.com with SMTP id 143so15756380wma.5 for ; Fri, 09 Feb 2018 06:40:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=HKMPSoi/A68L04x6q2GDpKeMl0drydqgyzhMtwCcPdQ=; b=jfFyP6jLoZFtj1W/9wfImgL3ix6WJ7YannJaYpRj3bSsvDDIL/ALjDUQ2iPv9i9Okm rTGWs/z0COle9gnJNDCvP9i7JiH3gP2PlBc/OEDhuZJR21YzqImznXsWLro5LdcgU9/7 RSpMAzEzot8kG76a7+LnCQEG76Rnl6qNIESYU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=HKMPSoi/A68L04x6q2GDpKeMl0drydqgyzhMtwCcPdQ=; b=kCaoHyY7MLui/2R//DBeWAO0NdJNEdqupm+Kz/8lGNJY2WZ3CQsjcK8mzm+vm+iZ7k stVbL6H+w0OQnWBounFUffqS2R2PijWVmxeZ6/GJDTG/n12SxoNQAagq5mva/Kgg478c m61KZ049uxTTr/enGkIW3QaX4Bwh+AnBvEq+9iZJV0SJYPrHxn3D4RbE2hGyR1aP/tfo MBviuGI+G+SHnd606UOllInBVMjJ0FxDRtck50X5TNkjr+bxVGqA686KoQtVftbMvT9I HOJ0UiwF/RN1g9cwlcfKtP21YCWCsoKTaUHN31/mLrP2xf7Zfgy7uPt9xUHNAnzQRoME yNdg== X-Gm-Message-State: APf1xPAAcLCxLDIm5awkoFtW+0mGi5gQPkVTrMyDOB40tpQ9aOgnDD3y DIya8xPF9kyXlDPWHVcnJCsB4A== X-Received: by 10.28.74.66 with SMTP id x63mr2134874wma.4.1518187200886; Fri, 09 Feb 2018 06:40:00 -0800 (PST) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id b35sm2552229wra.13.2018.02.09.06.39.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Feb 2018 06:40:00 -0800 (PST) From: Andre Przywara To: Stefano Stabellini , Julien Grall , xen-devel@lists.xenproject.org Date: Fri, 9 Feb 2018 14:39:03 +0000 Message-Id: <20180209143937.28866-16-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180209143937.28866-1-andre.przywara@linaro.org> References: <20180209143937.28866-1-andre.przywara@linaro.org> Subject: [Xen-devel] [RFC PATCH 15/49] ARM: GIC: Allow tweaking the active state of an IRQ X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" When playing around with hardware mapped, level triggered virtual IRQs, there is the need to explicitly set the active state of an interrupt at some point in time. To prepare the GIC for that, we introduce a set_active_state() function to let the VGIC manipulate the state of an associated hardware IRQ. Signed-off-by: Andre Przywara --- xen/arch/arm/gic-v2.c | 9 +++++++++ xen/arch/arm/gic-v3.c | 16 ++++++++++++++++ xen/arch/arm/gic.c | 5 +++++ xen/include/asm-arm/gic.h | 5 +++++ 4 files changed, 35 insertions(+) diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index 2e35892881..5339f69fbc 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -235,6 +235,14 @@ static unsigned int gicv2_read_irq(void) return (readl_gicc(GICC_IAR) & GICC_IA_IRQ); } +static void gicv2_set_active_state(int irq, bool active) +{ + if (active) + writel_gicd(1U << (irq % 32), GICD_ISACTIVER + (irq / 32) * 4); + else + writel_gicd(1U << (irq % 32), GICD_ICACTIVER + (irq / 32) * 4); +} + static void gicv2_set_irq_type(struct irq_desc *desc, unsigned int type) { uint32_t cfg, actual, edgebit; @@ -1241,6 +1249,7 @@ const static struct gic_hw_operations gicv2_ops = { .eoi_irq = gicv2_eoi_irq, .deactivate_irq = gicv2_dir_irq, .read_irq = gicv2_read_irq, + .set_active_state = gicv2_set_active_state, .set_irq_type = gicv2_set_irq_type, .set_irq_priority = gicv2_set_irq_priority, .send_SGI = gicv2_send_SGI, diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index 08d4703687..595eaef43a 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -475,6 +475,21 @@ static unsigned int gicv3_read_irq(void) return irq; } +static void gicv3_set_active_state(int irq, bool active) +{ + void __iomem *base; + + if ( irq >= NR_GIC_LOCAL_IRQS) + base = GICD + (irq / 32) * 4; + else + base = GICD_RDIST_SGI_BASE; + + if ( active ) + writel(1U << (irq % 32), base + GICD_ISACTIVER); + else + writel(1U << (irq % 32), base + GICD_ICACTIVER); +} + static inline uint64_t gicv3_mpidr_to_affinity(int cpu) { uint64_t mpidr = cpu_logical_map(cpu); @@ -1722,6 +1737,7 @@ static const struct gic_hw_operations gicv3_ops = { .eoi_irq = gicv3_eoi_irq, .deactivate_irq = gicv3_dir_irq, .read_irq = gicv3_read_irq, + .set_active_state = gicv3_set_active_state, .set_irq_type = gicv3_set_irq_type, .set_irq_priority = gicv3_set_irq_priority, .send_SGI = gicv3_send_sgi, diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 89873c1df4..dfc2108c4d 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -92,6 +92,11 @@ void gic_restore_state(struct vcpu *v) isb(); } +void gic_set_active_state(int irq, bool state) +{ + gic_hw_ops->set_active_state(irq, state); +} + /* desc->irq needs to be disabled before calling this function */ void gic_set_irq_type(struct irq_desc *desc, unsigned int type) { diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index c4c68c7770..d330860580 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -238,6 +238,9 @@ DECLARE_PER_CPU(uint64_t, lr_mask); extern enum gic_version gic_hw_version(void); extern int gic_get_nr_lrs(void); +/* Force the state of an IRQ to active. */ +void gic_set_active_state(int irq, bool state); + /* Program the IRQ type into the GIC */ void gic_set_irq_type(struct irq_desc *desc, unsigned int type); @@ -347,6 +350,8 @@ struct gic_hw_operations { void (*deactivate_irq)(struct irq_desc *irqd); /* Read IRQ id and Ack */ unsigned int (*read_irq)(void); + /* Force the state of an IRQ to active */ + void (*set_active_state)(int irq, bool state); /* Set IRQ type */ void (*set_irq_type)(struct irq_desc *desc, unsigned int type); /* Set IRQ priority */