[PATCH v4 09/13] ARM: KVM: VGIC interrupt injection

Christoffer Dall c.dall at virtualopensystems.com
Mon Dec 3 09:58:09 EST 2012


[...]

>>> +
>>> +static bool vgic_update_irq_state(struct kvm *kvm, int cpuid,
>>> +                              unsigned int irq_num, bool level)
>>> +{
>>> +    struct vgic_dist *dist = &kvm->arch.vgic;
>>> +    struct kvm_vcpu *vcpu;
>>> +    int is_edge, is_level, state;
>>> +    int enabled;
>>> +    bool ret = true;
>>> +
>>> +    spin_lock(&dist->lock);
>>> +
>>> +    is_edge = vgic_irq_is_edge(dist, irq_num);
>>> +    is_level = !is_edge;
>>> +    state = vgic_bitmap_get_irq_val(&dist->irq_state, cpuid, irq_num);
>>> +
>>> +    /*
>>> +     * Only inject an interrupt if:
>>> +     * - level triggered and we change level
>>> +     * - edge triggered and we have a rising edge
>>> +     */
>>> +    if ((is_level && !(state ^ level)) || (is_edge && (state || !level))) {
>>> +            ret = false;
>>> +            goto out;
>>> +    }
>>
>> Eek, more of the edge/level combo. Can this be be restructured so that we
>> have vgic_update_{edge,level}_irq_state, which are called from here
>> appropriately?
>
> I'll have a look.
>
oh, you're no fun anymore. That if statement is one of the funniest
pieces of this code.

-Christoffer



More information about the linux-arm-kernel mailing list