From patchwork Thu Jan 3 23:25:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Wood X-Patchwork-Id: 209333 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 B75A42C0089 for ; Fri, 4 Jan 2013 10:26:40 +1100 (EST) Received: from localhost ([::1]:44920 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TquBK-0000vG-Rn for incoming@patchwork.ozlabs.org; Thu, 03 Jan 2013 18:26:38 -0500 Received: from eggs.gnu.org ([208.118.235.92]:60462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TquAh-0007wG-Ea for qemu-devel@nongnu.org; Thu, 03 Jan 2013 18:26:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TquAe-0001PT-2t for qemu-devel@nongnu.org; Thu, 03 Jan 2013 18:25:59 -0500 Received: from co9ehsobe004.messaging.microsoft.com ([207.46.163.27]:54746 helo=co9outboundpool.messaging.microsoft.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TquAX-0001OF-PF; Thu, 03 Jan 2013 18:25:50 -0500 Received: from mail87-co9-R.bigfish.com (10.236.132.226) by CO9EHSOBE041.bigfish.com (10.236.130.104) with Microsoft SMTP Server id 14.1.225.23; Thu, 3 Jan 2013 23:25:48 +0000 Received: from mail87-co9 (localhost [127.0.0.1]) by mail87-co9-R.bigfish.com (Postfix) with ESMTP id 4EBDF260268; Thu, 3 Jan 2013 23:25:48 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1de0h1202h1e76h1d1ah1d2ahzz8275bhz2dh2a8h668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1155h) Received: from mail87-co9 (localhost.localdomain [127.0.0.1]) by mail87-co9 (MessageSwitch) id 1357255546365796_16744; Thu, 3 Jan 2013 23:25:46 +0000 (UTC) Received: from CO9EHSMHS003.bigfish.com (unknown [10.236.132.227]) by mail87-co9.bigfish.com (Postfix) with ESMTP id 5653E40005E; Thu, 3 Jan 2013 23:25:46 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO9EHSMHS003.bigfish.com (10.236.130.13) with Microsoft SMTP Server (TLS) id 14.1.225.23; Thu, 3 Jan 2013 23:25:46 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server (TLS) id 14.2.318.3; Thu, 3 Jan 2013 23:25:45 +0000 Received: from snotra.am.freescale.net ([10.214.87.239]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id r03NPfjm016263; Thu, 3 Jan 2013 16:25:44 -0700 From: Scott Wood To: Alexander Graf Date: Thu, 3 Jan 2013 17:25:38 -0600 Message-ID: <1357255540-28689-3-git-send-email-scottwood@freescale.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1357255540-28689-1-git-send-email-scottwood@freescale.com> References: <1357255540-28689-1-git-send-email-scottwood@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 X-Received-From: 207.46.163.27 Cc: Scott Wood , qemu-ppc@nongnu.org, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH v2 2/4] 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 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 --- v2: use find_next_bit hw/openpic.c | 28 ++++++++++++++++------------ 1 file 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; }