From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Stabellini Subject: [PATCH v9 0/12] remove maintenance interrupts Date: Tue, 10 Jun 2014 15:06:10 +0100 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xensource.com Cc: Julien Grall , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org Hi all, this patch series removes any needs for maintenance interrupts for both hardware and software interrupts in Xen. It achieves the goal by using the GICH_LR_HW bit for hardware interrupts and by checking the status of the GICH_LR registers on return to guest, clearing the registers that are invalid and handling the lifecycle of the corresponding interrupts in Xen data structures. It also improves priority handling, keeping the highest priority outstanding interrupts in the GICH_LR registers. Changes in v9: - code style fix; - add a comment; - drop patch #13; - gic_events_need_delivery: read GICH_APR to find the active group priority; - gic_events_need_delivery: simplify the search loop. Changes in v8: - fix a recursive lock bug in patch #4: only call gic_clear_lrs on hypervisor entry if we are coming from guest_mode; - fix a data abort in patch #4: do not clear_lrs for the idle domain; - rename lr_reg to lr_val; - remove double spin_lock in gic_update_one_lr; - update comment in domain.h to better reflect the renaming; - do not unify the inflight and non-inflight code paths in vgic_vcpu_inject_irq: it creates many buggy corner cases. Introduce gic_raise_inflight_irq instead; - add warnings for cases of lost interrupts; - in gic_restore_pending_irqs rename i to lr; - add in code comments in gic_restore_pending_irqs and gic_events_need_delivery; - add << 3 to mask_priority; - fix typo and hard tabs; - add a patch to fix the spin_lock taken by gic_remove_from_queues. Changes in v7: - move enter_hypervisor_head before the first use to avoid forward declaration; - improve and add in code comments; - rename gic_clear_one_lr to gic_update_one_lr; - add patch "rename GIC_IRQ_GUEST_PENDING to GIC_IRQ_GUEST_QUEUED"; - remove warning printk "Changing priority of an inflight interrupt is not supported"; - fix locking for the list_empty case in gic_restore_pending_irqs; - gic_events_need_delivery: break out of the loop as soon as we find the active irq as inflight_irqs is ordered by priority; - gic_events_need_delivery: break out of the loop if p->priority is lower than mask_priority as inflight_irqs is ordered by priority; - use find_next_zero_bit instead of find_first_zero_bit; - in gic_restore_pending_irqs remember the last position of the inner loop search and continue from there; - in gic_restore_pending_irqs use a priority check to get out of the inner loop; - add patch "introduce GIC_PRI_TO_GUEST macro". Changes in v6: - remove double spin_lock on the vgic.lock introduced in v5. Changes in v5: - introduce lr_all_full() helper; - do not rename virtual_irq to irq; - replace "const long unsigned int" with "const unsigned long"; - remove useless "& GICH_LR_PHYSICAL_MASK" in gic_set_lr; - add a comment in maintenance_interrupts to explain its new purpose; - introduce gic_clear_one_lr; - don't print p->lr in case the irq is in lr_pending, as it doesn't have an LR associate to it; - improve packing of struct pending_irq; - #define GIC_INVALID_LR and use it instead of nr_lrs; - gic_remove_from_queues need to be protected with a vgic lock; - introduce ASSERTs to check the vgic is locked and interrupts are disabled; - improve in code comments; - use list_for_each_entry_reverse instead of writing my own list walker. Changes in v4: - rebase; - merged patch #3 and #4 into a single patch; - improved in code comments; - in gic_events_need_delivery go through inflight_irqs and only consider enabled irqs; - remove debug patch. Changes in v3: - add "no need to set HCR_VI when using the vgic to inject irqs"; - add "s/gic_set_guest_irq/gic_raise_guest_irq"; - add "xen/arm: call gic_clear_lrs on entry to the hypervisor"; - do not use the PENDING and ACTIVE state for HW interrupts; - unify the inflight and non-inflight code paths in vgic_vcpu_inject_irq; - remove "avoid taking unconditionally the vgic.lock in gic_clear_lrs"; - add "xen/arm: gic_events_need_delivery and irq priorities"; - use spin_lock_irqsave and spin_unlock_irqrestore in gic_dump_info. Changes in v2: - do not assume physical IRQ == virtual IRQ; - refactor gic_set_lr; - simplify gic_clear_lrs; - disable/enable the GICH_HCR_UIE bit in GICH_HCR; - only enable GICH_HCR_UIE if this_cpu(lr_mask) == ((1 << nr_lrs) - 1); - add a patch to keep track of the LR number in pending_irq; - add a patch to set GICH_LR_PENDING to inject a second irq while the first one is still active; - add a patch to simplify and reduce the usage of gic.lock; - add a patch to reduce the usage of vgic.lock; - add a patch to use GICH_ELSR[01] to avoid reading all the GICH_LRs in gic_clear_lrs; - add a debug patch to print more info in gic_dump_info. Stefano Stabellini (12): xen/arm: no need to set HCR_VI when using the vgic to inject irqs xen/arm: remove unused virtual parameter from vgic_vcpu_inject_irq xen/arm: set GICH_HCR_UIE if all the LRs are in use xen/arm: support HW interrupts, do not request maintenance_interrupts xen/arm: nr_lrs should be uint8_t xen/arm: keep track of the GICH_LR used for the irq in struct pending_irq xen/arm: s/gic_set_guest_irq/gic_raise_guest_irq xen/arm: rename GIC_IRQ_GUEST_PENDING to GIC_IRQ_GUEST_QUEUED xen/arm: second irq injection while the first irq is still inflight xen/arm: don't protect GICH and lr_queue accesses with gic.lock xen/arm: introduce GIC_PRI_TO_GUEST macro xen/arm: gic_events_need_delivery and irq priorities xen/arch/arm/domain.c | 2 +- xen/arch/arm/gic.c | 321 ++++++++++++++++++++++++++---------------- xen/arch/arm/irq.c | 2 +- xen/arch/arm/time.c | 2 +- xen/arch/arm/traps.c | 10 ++ xen/arch/arm/vgic.c | 32 +++-- xen/arch/arm/vtimer.c | 4 +- xen/include/asm-arm/domain.h | 37 +++-- xen/include/asm-arm/gic.h | 13 +- 9 files changed, 270 insertions(+), 153 deletions(-) git://xenbits.xen.org/people/sstabellini/xen-unstable.git no_maintenance_interrupts-v9