From patchwork Fri May 1 17:50:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 47908 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 15CC42121F for ; Fri, 1 May 2015 17:51:15 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2sf28175849lbb.0 for ; Fri, 01 May 2015 10:51:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=4hysmOHRul4Std9DbD06ZGH1EpsGyNWnoEdtjc3xGf4=; b=KWYM3M5rQl20lSDZBWUFOUD79u909xvzZslLeUI5p1eTRPABHEImmAq6/htn0YlxDJ iHaFEoUFYkfgmaNsOnwjGlr7rHbr+A1+MAsVAQ2zJPtRdLSquGyQF2cBPa/zoVgQbdPn uDDRZ1ezJfVySmHualidJWojSBObdju2vxWIDf2Zp3ehlUueNuKgyK3w/2olEI7r4+yu ZK3XCGoiJHLfdXDJLwPAWhFIyvn1M/x5iUigglqzxHG12iDSaAind+Tvv17CRTOBC5T4 +BKtNvHuNNfgDzY3bywf+fN/SDphtJs9ZQbgQya+/BP7BbL8Rhpv4nBS+pZmQaA34eNp zt5Q== X-Gm-Message-State: ALoCoQmdNYq5tK+DN4orL1IwCbPz3FsX9CPZnh+7W5ZfZd2PAqB2XCbcmoDqbpnzgBqGUI3mBeTu X-Received: by 10.180.73.137 with SMTP id l9mr159677wiv.5.1430502673938; Fri, 01 May 2015 10:51:13 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.74 with SMTP id j10ls564678lag.7.gmail; Fri, 01 May 2015 10:51:13 -0700 (PDT) X-Received: by 10.152.26.130 with SMTP id l2mr9211709lag.20.1430502673784; Fri, 01 May 2015 10:51:13 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id ld3si4378699lac.175.2015.05.01.10.51.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 May 2015 10:51:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by lagv1 with SMTP id v1so68396583lag.3 for ; Fri, 01 May 2015 10:51:13 -0700 (PDT) X-Received: by 10.113.10.134 with SMTP id ea6mr8992057lbd.29.1430502673705; Fri, 01 May 2015 10:51:13 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.67.65 with SMTP id l1csp415215lbt; Fri, 1 May 2015 10:51:13 -0700 (PDT) X-Received: by 10.180.95.10 with SMTP id dg10mr16404352wib.41.1430502652968; Fri, 01 May 2015 10:50:52 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id ht6si8824317wib.102.2015.05.01.10.50.52 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 01 May 2015 10:50:52 -0700 (PDT) Received-SPF: none (google.com: pm215@archaic.org.uk does not designate permitted sender hosts) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1YoF5I-0006lF-7X; Fri, 01 May 2015 18:50:44 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Greg Bellows , "Edgar E. Iglesias" Subject: [PATCH v4 14/17] hw/intc/arm_gic: Add grouping support to gic_update() Date: Fri, 1 May 2015 18:50:40 +0100 Message-Id: <1430502643-25909-15-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1430502643-25909-1-git-send-email-peter.maydell@linaro.org> References: <1430502643-25909-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org 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.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add support to gic_update() for determining the current IRQ and FIQ status when interrupt grouping is supported. This simply requires that instead of always raising IRQ we check the group of the highest priority pending interrupt and the GICC_CTLR.FIQEn bit to see whether we should raise IRQ or FIQ. Signed-off-by: Peter Maydell --- hw/intc/arm_gic.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 6abdb14..c1d2e70 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -60,7 +60,7 @@ void gic_update(GICState *s) int best_irq; int best_prio; int irq; - int level; + int irq_level, fiq_level; int cpu; int cm; @@ -70,6 +70,7 @@ void gic_update(GICState *s) if (!(s->ctlr & (GICD_CTLR_EN_GRP0 | GICD_CTLR_EN_GRP1)) || !(s->cpu_ctlr[cpu] & (GICC_CTLR_EN_GRP0 | GICC_CTLR_EN_GRP1))) { qemu_irq_lower(s->parent_irq[cpu]); + qemu_irq_lower(s->parent_fiq[cpu]); return; } best_prio = 0x100; @@ -83,15 +84,31 @@ void gic_update(GICState *s) } } } - level = 0; + + irq_level = fiq_level = 0; + if (best_prio < s->priority_mask[cpu]) { s->current_pending[cpu] = best_irq; if (best_prio < s->running_priority[cpu]) { - DPRINTF("Raised pending IRQ %d (cpu %d)\n", best_irq, cpu); - level = 1; + int group = GIC_TEST_GROUP(best_irq, cm); + + if (extract32(s->ctlr, group, 1) && + extract32(s->cpu_ctlr[cpu], group, 1)) { + if (group == 0 && s->cpu_ctlr[cpu] & GICC_CTLR_FIQ_EN) { + DPRINTF("Raised pending FIQ %d (cpu %d)\n", + best_irq, cpu); + fiq_level = 1; + } else { + DPRINTF("Raised pending IRQ %d (cpu %d)\n", + best_irq, cpu); + irq_level = 1; + } + } } } - qemu_set_irq(s->parent_irq[cpu], level); + + qemu_set_irq(s->parent_irq[cpu], irq_level); + qemu_set_irq(s->parent_fiq[cpu], fiq_level); } }