From patchwork Tue Sep 8 16:51:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 53285 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by patches.linaro.org (Postfix) with ESMTPS id E948122B05 for ; Tue, 8 Sep 2015 17:04:24 +0000 (UTC) Received: by laeb10 with SMTP id b10sf42811928lae.1 for ; Tue, 08 Sep 2015 10:04:23 -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:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=jZR9xCbTUstpXGkMtnBcT2kwBrbNrdlnCiTU4MCA7uw=; b=jwf3czT59rEHqp2SKuGv6BJ9Q9dBGq/oUczD9v1AwQUiGNPRFWInayglt+xMZ0x/Tt dCNU/2eK/FH8KS2KxGft5FFX/H6qx9PO6nHfjA3ZewgkD24YmuyE+ibcJRqHfEev8A+9 iPUSYQyUd4kMvjvmkhjQ0gL/iwZJVOmjhXwzRnCIwT1aaEqsHFP40rTLOFLKjaSoIYp5 KlVWuces/dLpdpP8iBIoxXsFmFSeFEIxEMfy0qTfAMCjdKHAF9kSNsUM2BIXHeAmX8hN z6ES/olumyZOnFcE9GRFQXmhkzeVVC1TqsNTpOACPi7Ew4S103kLV8OpS6ul6gBSnobw CKYg== X-Gm-Message-State: ALoCoQkTC0zIQlz26x/nTKi+nKYlyOOIPPJ39aTps3aTouwj6WZzicvbLtBagtpiesAgL2Vi1TdR X-Received: by 10.180.9.104 with SMTP id y8mr7028841wia.7.1441731863477; Tue, 08 Sep 2015 10:04:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.7 with SMTP id o7ls131841lao.27.gmail; Tue, 08 Sep 2015 10:04:23 -0700 (PDT) X-Received: by 10.152.36.101 with SMTP id p5mr8600273laj.123.1441731863109; Tue, 08 Sep 2015 10:04:23 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id ap9si3796314lbc.133.2015.09.08.10.04.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Sep 2015 10:04:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbcao8 with SMTP id ao8so56975460lbc.3 for ; Tue, 08 Sep 2015 10:04:22 -0700 (PDT) X-Received: by 10.112.169.66 with SMTP id ac2mr23032197lbc.32.1441731862593; Tue, 08 Sep 2015 10:04:22 -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.59.35 with SMTP id w3csp1101040lbq; Tue, 8 Sep 2015 10:04:21 -0700 (PDT) X-Received: by 10.55.33.222 with SMTP id f91mr36943095qki.64.1441731861758; Tue, 08 Sep 2015 10:04:21 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 100si4523970qgg.31.2015.09.08.10.04.21 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 08 Sep 2015 10:04:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:35895 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZMJg-0002xb-Vt for patch@linaro.org; Tue, 08 Sep 2015 13:04:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49336) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZM7c-0002fH-Di for qemu-devel@nongnu.org; Tue, 08 Sep 2015 12:51:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZM7Y-00083Z-4a for qemu-devel@nongnu.org; Tue, 08 Sep 2015 12:51:52 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:35050) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZM7X-0007xj-UF for qemu-devel@nongnu.org; Tue, 08 Sep 2015 12:51:48 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1ZZM7I-0001he-8H for qemu-devel@nongnu.org; Tue, 08 Sep 2015 17:51:32 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 8 Sep 2015 17:51:14 +0100 Message-Id: <1441731092-6513-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1441731092-6513-1-git-send-email-peter.maydell@linaro.org> References: <1441731092-6513-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Subject: [Qemu-devel] [PULL 02/20] hw/intc/arm_gic: Running priority is group priority, not full priority X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.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.217.177 as permitted sender) smtp.mailfrom=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 Priority values for the GIC are divided into a "group priority" and a "subpriority" (with the division being determined by the binary point register). The running priority is only determined by the group priority of the active interrupts, not the subpriority. In particular, this means that there can't be more than one active interrupt at any particular group priority. Signed-off-by: Peter Maydell Message-id: 1438089748-5528-3-git-send-email-peter.maydell@linaro.org --- hw/intc/arm_gic.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index a8c5d19..1b8e839 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -219,13 +219,39 @@ static uint16_t gic_get_current_pending_irq(GICState *s, int cpu, return pending_irq; } +static int gic_get_group_priority(GICState *s, int cpu, int irq) +{ + /* Return the group priority of the specified interrupt + * (which is the top bits of its priority, with the number + * of bits masked determined by the applicable binary point register). + */ + int bpr; + uint32_t mask; + + if (gic_has_groups(s) && + !(s->cpu_ctlr[cpu] & GICC_CTLR_CBPR) && + GIC_TEST_GROUP(irq, (1 << cpu))) { + bpr = s->abpr[cpu]; + } else { + bpr = s->bpr[cpu]; + } + + /* a BPR of 0 means the group priority bits are [7:1]; + * a BPR of 1 means they are [7:2], and so on down to + * a BPR of 7 meaning no group priority bits at all. + */ + mask = ~0U << ((bpr & 7) + 1); + + return GIC_GET_PRIORITY(irq, cpu) & mask; +} + static void gic_set_running_irq(GICState *s, int cpu, int irq) { s->running_irq[cpu] = irq; if (irq == 1023) { s->running_priority[cpu] = 0x100; } else { - s->running_priority[cpu] = GIC_GET_PRIORITY(irq, cpu); + s->running_priority[cpu] = gic_get_group_priority(s, cpu, irq); } gic_update(s); }