From patchwork Fri Feb 9 14:39:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 127817 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp679522ljc; Fri, 9 Feb 2018 06:41:54 -0800 (PST) X-Google-Smtp-Source: AH8x225VOx7qDNt9TjPsRoy6JbVjAfBATIlKiZE2wznYfmsD4wEwWa7SqONjbGg2Apa32a65XGvk X-Received: by 10.107.142.68 with SMTP id q65mr3329967iod.133.1518187313940; Fri, 09 Feb 2018 06:41:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518187313; cv=none; d=google.com; s=arc-20160816; b=YPja0YAQy1AzwMnqP78UAi3YRoN6RH0sCRcLPb39gTksvjJRKJxpvw1IVCyZJZz7LZ EaYeEfz13vYBZjKjAtzC9T8wIjBpw8nwN46iFIUc1CNUhb2bQxcWm3as3hAmI2cuBm/r IpyAhd4cOlfDVsjEudo/jsSS4UlnP3usZ2dx3DC2k2ITKvCoWo9ZIkKEDYKimvMAXl4b swwyHS9IlV+0RyJp481/4aNqU8M1Rme+onM/zIpb+pX4biT4vFOIGQXHmIas/XX9FiMN DIjxJJlMBXKy1HlbA8Y0wTe1H2+uJmJcnxuiSFH7wNn1pSoWLVzJalYadRaVr+tO8m9y idMA== 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=EvHUhIx3NE7arXbh+L5Ah9MYKgO2C8vA4dc5tSqrtHI=; b=XMY9Y4g/zZb4gzb82VVVa8rDVc54eMEkbiufhE+fvaPQ/FxTRg6O0PmxoaZmy/kVyR T+AVGOo5mur2wdqLGBq44hkn/kFHA2LUFDdqj4OOzT7BfchreSUJ3zV/3rr/NYLdE3/S hG7taC6mMe2PEHRRfuu8P25MA8jPe7/PTls5bk2Nry1vneHTVmsZ3rjK1FNnWmIU8Cvs yMl1exvPvBSFuKfFcqjBNi5bllVYpKqjEvro22wfwtMt4UjdlGPZdMNQdUsZLJsN/r0l yTt3uEwGXG55V8laxtsxRQ+OXKWNWhOYRimAGMbMm0vmsU0gLuKBbGESy2tYaXYaY76c Be0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=b//OOKYJ; 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 c8si1601842iob.343.2018.02.09.06.41.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Feb 2018 06:41: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=b//OOKYJ; 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 1ek9qP-0000O0-SH; Fri, 09 Feb 2018 14:40:05 +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 1ek9qO-00008r-8E for xen-devel@lists.xenproject.org; Fri, 09 Feb 2018 14:40:04 +0000 X-Inumbo-ID: 0bc28904-0da7-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 0bc28904-0da7-11e8-ba59-bc764e045a96; Fri, 09 Feb 2018 15:39:35 +0100 (CET) Received: by mail-wr0-x242.google.com with SMTP id t94so8459874wrc.5 for ; Fri, 09 Feb 2018 06:40:03 -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=KrjIuExR5VcwJ5D8PmFPWPecsXDh7KwuCbg3xxjuvus=; b=b//OOKYJM7dvZzd8K8ch/yY55iydjQX+7FnEOurzreAtwf3YjDOpd+uGvsqs37kHXK MUQJDZPdXHm/SvHKH2aA7eRt+CZkUtz9rI+Qmer4SCEa2t0EZrmhH3YNUlKKsI7PZBad gJvEd9j5uF2clFkTJaSa+i4Bf8QfQPogbeYWM= 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=KrjIuExR5VcwJ5D8PmFPWPecsXDh7KwuCbg3xxjuvus=; b=o4iHnqWKFkFBuyNTM3KbsuIWJgzX4/1WLfTRqYJrIqEt8YxWGR8SeaeaDpQUgpVXjm PNJnOaR9qysEOE8MnAD30FysOhy/USKHmGRmYxKWiwluaFIeoT7vIUuLgACf8sMeV9lz sHThnx7l3BWybYOyCNICwqegFJ+cyclT4wYjuQRPDqRhJLEphGHxHOeYXzWucweYs12q C3v+7oQzup/FvIKpW07A4ZCugDyYmwGOZV9agXjO/lJMCYGC3WtTz13bONFjrrLvxEvt YApBM59SdU1bukDFmP2SpgdliAG2CGfw+1fVfbhMSumQSGgjhuDjToYEKNVVumvZJlND HFrA== X-Gm-Message-State: APf1xPBVQOLLTVsK0LgavuIkX8e6DJBQ2WUWsEibeFw5Sj4bdNdRM4sa tAejLfKRe9Gua1MOGW3lld5iaSLv2q8= X-Received: by 10.223.171.24 with SMTP id q24mr2733104wrc.206.1518187202059; Fri, 09 Feb 2018 06:40:02 -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.40.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Feb 2018 06:40:01 -0800 (PST) From: Andre Przywara To: Stefano Stabellini , Julien Grall , xen-devel@lists.xenproject.org Date: Fri, 9 Feb 2018 14:39:04 +0000 Message-Id: <20180209143937.28866-17-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 16/49] ARM: GIC: allow reading pending state of a hardware 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" To synchronize level triggered interrupts which are mapped into a guest, we need to update the virtual line level at certain points in time. For a hardware mapped interrupt the GIC is the only place where we can easily access this information. Implement a gic_hw_operations member to return the pending state of a particular interrupt. Due to hardware limitations this only works for private interrupts of the current CPU, so there is not CPU field in the prototype. Signed-off-by: Andre Przywara --- xen/arch/arm/gic-v2.c | 6 ++++++ xen/arch/arm/gic-v3.c | 13 +++++++++++++ xen/arch/arm/gic.c | 5 +++++ xen/include/asm-arm/gic.h | 5 +++++ 4 files changed, 29 insertions(+) diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index 5339f69fbc..30081640ac 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -514,6 +514,11 @@ static unsigned int gicv2_read_apr(int apr_reg) return readl_gich(GICH_APR); } +bool gicv2_read_pending_state(int irq) +{ + return readl_gicd(GICD_ISPENDR + (irq / 32) * 4) & (1U << (irq % 32)); +} + static void gicv2_irq_enable(struct irq_desc *desc) { unsigned long flags; @@ -1261,6 +1266,7 @@ const static struct gic_hw_operations gicv2_ops = { .write_lr = gicv2_write_lr, .read_vmcr_priority = gicv2_read_vmcr_priority, .read_apr = gicv2_read_apr, + .read_pending_state = gicv2_read_pending_state, .make_hwdom_dt_node = gicv2_make_hwdom_dt_node, .make_hwdom_madt = gicv2_make_hwdom_madt, .get_hwdom_extra_madt_size = gicv2_get_hwdom_extra_madt_size, diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index 595eaef43a..2cbfeb8e03 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -1081,6 +1081,18 @@ static unsigned int gicv3_read_apr(int apr_reg) } } +static bool gicv3_read_pending_state(int irq) +{ + void __iomem *base; + + if ( irq >= NR_GIC_LOCAL_IRQS) + base = GICD + (irq / 32) * 4; + else + base = GICD_RDIST_SGI_BASE; + + return readl(base + GICD_ISPENDR) & (1U << (irq % 32)); +} + static void gicv3_irq_enable(struct irq_desc *desc) { unsigned long flags; @@ -1749,6 +1761,7 @@ static const struct gic_hw_operations gicv3_ops = { .write_lr = gicv3_write_lr, .read_vmcr_priority = gicv3_read_vmcr_priority, .read_apr = gicv3_read_apr, + .read_pending_state = gicv3_read_pending_state, .secondary_init = gicv3_secondary_cpu_init, .make_hwdom_dt_node = gicv3_make_hwdom_dt_node, .make_hwdom_madt = gicv3_make_hwdom_madt, diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index dfc2108c4d..ce9ab2367e 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -116,6 +116,11 @@ static void gic_set_irq_priority(struct irq_desc *desc, unsigned int priority) gic_hw_ops->set_irq_priority(desc, priority); } +bool gic_read_pending_state(int irq) +{ + return gic_hw_ops->read_pending_state(irq); +} + /* Program the GIC to route an interrupt to the host (i.e. Xen) * - needs to be called with desc.lock held */ diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index d330860580..d7fd18fd47 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -244,6 +244,9 @@ 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); +/* Read the pending state of an interrupt from the distributor. */ +bool gic_read_pending_state(int irq); + /* Program the GIC to route an interrupt */ extern void gic_route_irq_to_xen(struct irq_desc *desc, unsigned int priority); extern int gic_route_irq_to_guest(struct domain *, unsigned int virq, @@ -376,6 +379,8 @@ struct gic_hw_operations { unsigned int (*read_vmcr_priority)(void); /* Read APRn register */ unsigned int (*read_apr)(int apr_reg); + /* Query the pending state of an interrupt at the distributor level. */ + bool (*read_pending_state)(int irq); /* Secondary CPU init */ int (*secondary_init)(void); /* Create GIC node for the hardware domain */