From patchwork Mon Jan 7 15:38:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 209984 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DC7542C0085 for ; Tue, 8 Jan 2013 03:44:13 +1100 (EST) Received: from localhost ([::1]:49986 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsFo4-0004rx-0g for incoming@patchwork.ozlabs.org; Mon, 07 Jan 2013 11:44:12 -0500 Received: from eggs.gnu.org ([208.118.235.92]:41181) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsEnO-00053V-8p for qemu-devel@nongnu.org; Mon, 07 Jan 2013 10:39:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TsEnJ-0007CM-HM for qemu-devel@nongnu.org; Mon, 07 Jan 2013 10:39:26 -0500 Received: from cantor2.suse.de ([195.135.220.15]:39921 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsEnJ-0007C7-9B; Mon, 07 Jan 2013 10:39:21 -0500 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id BFAD9A51F7; Mon, 7 Jan 2013 16:39:20 +0100 (CET) From: Alexander Graf To: qemu-devel@nongnu.org Date: Mon, 7 Jan 2013 16:38:52 +0100 Message-Id: <1357573140-8877-24-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1357573140-8877-1-git-send-email-agraf@suse.de> References: <1357573140-8877-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: Blue Swirl , Scott Wood , qemu-ppc@nongnu.org, Aurelien Jarno Subject: [Qemu-devel] [PATCH 23/31] openpic: IRQ_check: search the queue a word at a time 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Scott Wood Search the queue more efficiently by first looking for a non-zero word, and then using the common bit-searching function to find the bit within the word. It would be even nicer if bitops_ffsl() could be hooked up to the compiler intrinsic so that bit-searching instructions could be used, but that's another matter. Signed-off-by: Scott Wood Signed-off-by: Alexander Graf --- hw/openpic.c | 28 ++++++++++++++++------------ 1 files changed, 16 insertions(+), 12 deletions(-) diff --git a/hw/openpic.c b/hw/openpic.c index 66179c2..7645d67 100644 --- a/hw/openpic.c +++ b/hw/openpic.c @@ -277,21 +277,25 @@ static inline int IRQ_testbit(IRQQueue *q, int n_IRQ) static void IRQ_check(OpenPICState *opp, IRQQueue *q) { - int next, i; - int priority; + int irq = -1; + int next = -1; + int priority = -1; - next = -1; - priority = -1; - for (i = 0; i < opp->max_irq; i++) { - if (IRQ_testbit(q, i)) { - DPRINTF("IRQ_check: irq %d set ivpr_pr=%d pr=%d\n", - i, IVPR_PRIORITY(opp->src[i].ivpr), priority); - if (IVPR_PRIORITY(opp->src[i].ivpr) > priority) { - next = i; - priority = IVPR_PRIORITY(opp->src[i].ivpr); - } + for (;;) { + irq = find_next_bit(q->queue, opp->max_irq, irq + 1); + if (irq == opp->max_irq) { + break; + } + + DPRINTF("IRQ_check: irq %d set ivpr_pr=%d pr=%d\n", + irq, IVPR_PRIORITY(opp->src[irq].ivpr), priority); + + if (IVPR_PRIORITY(opp->src[irq].ivpr) > priority) { + next = irq; + priority = IVPR_PRIORITY(opp->src[irq].ivpr); } } + q->next = next; q->priority = priority; }