[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] xen/arm: gicv3: Computation of GICD_TYPER.IDbits



On Fri, Sep 18, 2015 at 2:03 PM, Ian Campbell <ian.campbell@xxxxxxxxxx> wrote:
> On Fri, 2015-09-18 at 12:56 +0530, Vijay Kilari wrote:
>> Hi Julien,
>>
>>  static int vgic_v3_distr_mmio_read(struct vcpu *v, mmio_info_t *info)
>>  {
>>      ...
>>            case GICD_TYPER:
>>            {
>>                /*
>>                 * Number of interrupt identifier bits supported by the
>> GIC
>>                 * Stream Protocol Interface
>>                 */
>>                unsigned int irq_bits =
>> get_count_order(vgic_num_irqs(v->domain));
>> }
>>
>> I think we should use ilog2() instead of get_count_order()?
>
> Please explain why.

For a given value, get_count_order returns next highest 2^n bit that can contain
this number, where as ilog2 returns number max highest bit set to
contain the value.
(Here is the output of get_count_order() and ilog2() for various sizes )

128K get_count_order 17 log2 17
64K get_count_order   16 log2 16
48K get_count_order   16 log2 15
32K get_count_order   15 log2 15
24K get_count_order   15 log2 14
16K get_count_order   14 log2 14
8K get_count_order     13 log2 13

Here if irq_bits should specify number of bits required to specify the number.
So log2 is more appropriate. Even Linux ITS driver uses ilog2 to count number
of bits required.

Regards
Vijay

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.