From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: Re: [PATCH 01/10] xen/arm: vgic-v3: Correctly set GICD_TYPER.IDbits Date: Tue, 20 Jan 2015 17:16:55 +0000 Message-ID: <54BE8D87.7060500@linaro.org> References: <1421684957-29884-1-git-send-email-julien.grall@linaro.org> <1421684957-29884-2-git-send-email-julien.grall@linaro.org> <1421768042.10440.292.camel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YDcQo-0004Yi-2X for xen-devel@lists.xenproject.org; Tue, 20 Jan 2015 17:17:34 +0000 Received: by mail-we0-f172.google.com with SMTP id k11so39046171wes.3 for ; Tue, 20 Jan 2015 09:17:32 -0800 (PST) In-Reply-To: <1421768042.10440.292.camel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: xen-devel@lists.xenproject.org, tim@xen.org, stefano.stabellini@citrix.com List-Id: xen-devel@lists.xenproject.org Hi Ian, On 20/01/15 15:34, Ian Campbell wrote: > On Mon, 2015-01-19 at 16:29 +0000, Julien Grall wrote: >> + unsigned int order; >> + >> if ( dabt.size != DABT_WORD ) goto bad_width; >> /* No secure world support for guests. */ >> *r = (((v->domain->max_vcpus << 5) & GICD_TYPE_CPUS ) | >> ((v->domain->arch.vgic.nr_lines / 32) & GICD_TYPE_LINES)); >> + >> + /* >> + * Calculate number of interrupt identifier bits supported by >> + * the GIC Stream Protocol Interface >> + */ >> + irqs--; >> + for ( order = 0; irqs; order++ ) >> + irqs >>= 1; > > This is some variant on fls(). See get_bitmask_order() or > get_count_order() for an example of use, possibly even one you could > call. get_count_order sounds the best function to use. I will give a try. Regards, -- Julien Grall