From patchwork Mon Mar 5 16:03:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 130650 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp2853428lja; Mon, 5 Mar 2018 08:06:53 -0800 (PST) X-Google-Smtp-Source: AG47ELvFVwOdWJZbBTJTv+OYy8GAza75cElyOrJpBmXwm8NYUVz4GEPpwjYqDQCQpIQCsnF+RHTA X-Received: by 10.36.98.21 with SMTP id d21mr14889072itc.1.1520266013320; Mon, 05 Mar 2018 08:06:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520266013; cv=none; d=google.com; s=arc-20160816; b=Yiw3YRGMXDsmz6WiFYcPvlO87LAr1r22mFsGVGMrctI8zSwnz3+5OtyCRQOPHNHD8N ZbpWBKy/A15yHyCrPuHpREW2Y6F8sQyXSbIKHpM7nAWxOc5cdxIley8fU0YEOfTC2qtU 7ER/cJjhag38M/zsVmB8e10wUfHShtLS27IcJgkRGhniOlvbj3PdMrlNlYbm5poF1G3O fQ5ezjy6cvaCt495w4dEmVmV6KK974OzndUvOi9pQqNgOUDErjGU2eEw6TPvPmAchaD+ +H+1+0vRm/t+7JNOahJYfUNc5EAYS+ATCJ/QiPU8ZXFyCEVPQ2KEwCcwiu4htolIO2b1 2VZw== 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:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=RUtoipqEnhL4M/dH1ZXVeIrByEw+Kvhk2lHZ6T96Ztg=; b=nHwq4mkVqtOGjhqw0Shz8/qdJ1KboP3cGY2cfxT4PibKl4MuF8Qsnk3nFXqgbifCwv HFO9pMVhOrHB6Q9zIYIIw0wGFqr21WrVZphg2HvreVe/npd2KoQrTq7nRDYoNt7qGtxh QYxIYu80qx1wbtoZlQiHKVDbxRlL+C16pKvQNvJ0exkVbJ2nPg/JBys6AIjsSLlQE4YU 7Ng6HSml58AGMHxQChLMVv/NbutCwT8XiBxJJ3kQr5mIfOHjOb/si9mutWkvaexJ2TPH t2mMb89ak8sXQszGFB7eVZyW2Dm2cGxGtvhq6p4GvkO0sLkF9I/e0FcrLn114MKpXwso Dr8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=BrBVdEsH; 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 a7si9159382ioj.0.2018.03.05.08.06.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 08:06:53 -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=BrBVdEsH; 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 1essbY-0007d6-1Y; Mon, 05 Mar 2018 16:04:48 +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 1essbX-0007bM-Ap for xen-devel@lists.xenproject.org; Mon, 05 Mar 2018 16:04:47 +0000 X-Inumbo-ID: c4e57f8b-208e-11e8-ba59-bc764e045a96 Received: from mail-wr0-x242.google.com (unknown [2a00:1450:400c:c0c::242]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id c4e57f8b-208e-11e8-ba59-bc764e045a96; Mon, 05 Mar 2018 17:03:40 +0100 (CET) Received: by mail-wr0-x242.google.com with SMTP id u49so17815353wrc.10 for ; Mon, 05 Mar 2018 08:04:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oQxLYaXcfHU8tz9HgrMakMzpHqM1NQLvQH/Vr8bOWPM=; b=BrBVdEsH577Qlw09yOgzNtm1VbCxBqPalbGxxX5SuR0yoyipCkEuWl1t6061i/8rw2 440br51+qViQLllfy+1Z9kIslV2RpDHPyony3Cx90y71ISRrFSNSMUCmCTRaPHgoNA3y zt+dHQm55PRxqSgWlTy0pxmT2fxEKwwGhw5WY= 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=oQxLYaXcfHU8tz9HgrMakMzpHqM1NQLvQH/Vr8bOWPM=; b=Xt2HddTqhlFkQm1QVV5yyhdr6IDOKM56MOZHCy2Fv1ENtZbtMo3l3E85x2K5ZBWWlh LH4rs6rj65U8Zk5/Em5Szzt/KIqqVpXPj+C7A0H0omg1vNe2HVgxDZh3OIa2Ijp+ZeOS Q/FauwaBmSLj4OgRpR3bz/AlXcwf1jWDGe29KMEUvXKshZBP6O+5DVIO70VOm3sAU1sC 9utqkSg2SIk082j1CWIZRb8cdkgb2PBJzHKP9L3TmhEAuI5+OCg3YcKD+v1vCqx7X3Ll D82zUG8qz1QYl1KtybOH0NXP6Wgvblqt1iNCWk9GOlrxYYg9Rn1ofc9HksRvP+hZ4P2O zf2g== X-Gm-Message-State: APf1xPCevlpOssFQgDFpTZimDazHanmh/JSapt6RpmTKdzQKjE0C3+00 sRFoNgIPCdur+CRk56xAd3vIow== X-Received: by 10.223.173.131 with SMTP id w3mr13931534wrc.195.1520265884646; Mon, 05 Mar 2018 08:04:44 -0800 (PST) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id y6sm6574381wmy.14.2018.03.05.08.04.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Mar 2018 08:04:44 -0800 (PST) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Mon, 5 Mar 2018 16:03:40 +0000 Message-Id: <20180305160415.16760-23-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180305160415.16760-1-andre.przywara@linaro.org> References: <20180305160415.16760-1-andre.przywara@linaro.org> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH 22/57] ARM: GIC: Allow tweaking the active and pending 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 or pending state of an interrupt at some point. To prepare the GIC for that, we introduce a set_active_state() and a set_pending_state() function to let the VGIC manipulate the state of an associated hardware IRQ. Signed-off-by: Andre Przywara --- Changelog RFC ... v1: - use struct irq_desc* in the interface (instead of just the IRQ number) - add set_pending_state() (needed later) xen/arch/arm/gic-v2.c | 32 ++++++++++++++++++++++++++++++++ xen/arch/arm/gic-v3.c | 28 ++++++++++++++++++++++++++++ xen/arch/arm/gic.c | 10 ++++++++++ xen/include/asm-arm/gic.h | 10 ++++++++++ 4 files changed, 80 insertions(+) diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index c5ec0d4d35..74169b5633 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -241,6 +241,36 @@ static void gicv2_poke_irq(struct irq_desc *irqd, uint32_t offset) writel_gicd(1U << (irqd->irq % 32), offset + (irqd->irq / 32) * 4); } +static void gicv2_set_active_state(struct irq_desc *irqd, bool active) +{ + ASSERT(spin_is_locked(&irqd->lock)); + + if ( active ) + { + set_bit(_IRQ_INPROGRESS, &irqd->status); + gicv2_poke_irq(irqd, GICD_ISACTIVER); + } + else + { + gicv2_poke_irq(irqd, GICD_ICACTIVER); + } +} + +static void gicv2_set_pending_state(struct irq_desc *irqd, bool pending) +{ + ASSERT(spin_is_locked(&irqd->lock)); + + if ( pending ) + { + set_bit(_IRQ_INPROGRESS, &irqd->status); + gicv2_poke_irq(irqd, GICD_ISPENDR); + } + else + { + gicv2_poke_irq(irqd, GICD_ICPENDR); + } +} + static void gicv2_set_irq_type(struct irq_desc *desc, unsigned int type) { uint32_t cfg, actual, edgebit; @@ -1251,6 +1281,8 @@ 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_pending_state = gicv2_set_pending_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 44dfba2267..c96469f09d 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -477,6 +477,32 @@ static unsigned int gicv3_read_irq(void) return irq; } +static void gicv3_set_active_state(struct irq_desc *irqd, bool active) +{ + ASSERT(spin_is_locked(&irqd->lock)); + + if ( active ) + { + set_bit(_IRQ_INPROGRESS, &irqd->status); + gicv3_poke_irq(irqd, GICD_ISACTIVER, false); + } + else + gicv3_poke_irq(irqd, GICD_ICACTIVER, false); +} + +static void gicv3_set_pending_state(struct irq_desc *irqd, bool pending) +{ + ASSERT(spin_is_locked(&irqd->lock)); + + if ( pending ) + { + set_bit(_IRQ_INPROGRESS, &irqd->status); + gicv3_poke_irq(irqd, GICD_ISPENDR, false); + } + else + gicv3_poke_irq(irqd, GICD_ICPENDR, false); +} + static inline uint64_t gicv3_mpidr_to_affinity(int cpu) { uint64_t mpidr = cpu_logical_map(cpu); @@ -1723,6 +1749,8 @@ 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_pending_state = gicv3_set_pending_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 968e46fabb..f1329a630a 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -87,6 +87,16 @@ void gic_restore_state(struct vcpu *v) isb(); } +void gic_set_active_state(struct irq_desc *irqd, bool state) +{ + gic_hw_ops->set_active_state(irqd, state); +} + +void gic_set_pending_state(struct irq_desc *irqd, bool state) +{ + gic_hw_ops->set_pending_state(irqd, 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 89a07ae6b4..46dcb0fe7c 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -239,6 +239,12 @@ DECLARE_PER_CPU(uint64_t, lr_mask); extern enum gic_version gic_hw_version(void); +/* Force the active state of an IRQ. */ +void gic_set_active_state(struct irq_desc *irqd, bool state); + +/* Force the pending state of an IRQ. */ +void gic_set_pending_state(struct irq_desc *irqd, bool state); + /* Program the IRQ type into the GIC */ void gic_set_irq_type(struct irq_desc *desc, unsigned int type); @@ -348,6 +354,10 @@ struct gic_hw_operations { void (*deactivate_irq)(struct irq_desc *irqd); /* Read IRQ id and Ack */ unsigned int (*read_irq)(void); + /* Force the active state of an IRQ by accessing the distributor */ + void (*set_active_state)(struct irq_desc *irqd, bool state); + /* Force the pending state of an IRQ by accessing the distributor */ + void (*set_pending_state)(struct irq_desc *irqd, bool state); /* Set IRQ type */ void (*set_irq_type)(struct irq_desc *desc, unsigned int type); /* Set IRQ priority */