Lines Matching refs:xive
390 static void xive_vm_scan_for_rerouted_irqs(struct kvmppc_xive *xive, in xive_vm_scan_for_rerouted_irqs() argument
423 sb = kvmppc_xive_find_source(xive, irq, &src); in xive_vm_scan_for_rerouted_irqs()
459 struct kvmppc_xive *xive = vcpu->kvm->arch.xive; in xive_vm_h_cppr() local
505 xive_vm_scan_for_rerouted_irqs(xive, xc); in xive_vm_h_cppr()
517 struct kvmppc_xive *xive = vcpu->kvm->arch.xive; in xive_vm_h_eoi() local
550 sb = kvmppc_xive_find_source(xive, irq, &src); in xive_vm_h_eoi()
674 struct kvmppc_xive *xive = xc->xive; in kvmppc_xive_check_save_restore() local
676 if (xive->flags & KVMPPC_XIVE_FLAG_SAVE_RESTORE) in kvmppc_xive_check_save_restore()
939 struct kvmppc_xive *xive = xc->xive; in xive_provision_queue() local
948 qpage = (__be32 *)__get_free_pages(GFP_KERNEL, xive->q_page_order); in xive_provision_queue()
954 memset(qpage, 0, 1 << xive->q_order); in xive_provision_queue()
964 xive->q_order, true); in xive_provision_queue()
974 struct kvmppc_xive *xive = kvm->arch.xive; in xive_check_provisioning() local
979 lockdep_assert_held(&xive->lock); in xive_check_provisioning()
982 if (xive->qmap & (1 << prio)) in xive_check_provisioning()
992 if (rc == 0 && !kvmppc_xive_has_single_escalation(xive)) in xive_check_provisioning()
994 kvmppc_xive_has_single_escalation(xive)); in xive_check_provisioning()
1001 xive->qmap |= (1 << prio); in xive_check_provisioning()
1084 static u8 xive_lock_and_mask(struct kvmppc_xive *xive, in xive_lock_and_mask() argument
1143 static void xive_finish_unmask(struct kvmppc_xive *xive, in xive_finish_unmask() argument
1187 struct kvmppc_xive *xive = kvm->arch.xive; in xive_target_interrupt() local
1224 kvmppc_xive_vp(xive, server), in xive_target_interrupt()
1271 struct kvmppc_xive *xive = kvm->arch.xive; in kvmppc_xive_set_xive() local
1278 if (!xive) in kvmppc_xive_set_xive()
1286 mutex_lock(&xive->lock); in kvmppc_xive_set_xive()
1287 rc = xive_check_provisioning(xive->kvm, in kvmppc_xive_set_xive()
1289 mutex_unlock(&xive->lock); in kvmppc_xive_set_xive()
1296 sb = kvmppc_xive_find_source(xive, irq, &idx); in kvmppc_xive_set_xive()
1316 xive_lock_and_mask(xive, sb, state); in kvmppc_xive_set_xive()
1357 xive_finish_unmask(xive, sb, state, priority); in kvmppc_xive_set_xive()
1372 struct kvmppc_xive *xive = kvm->arch.xive; in kvmppc_xive_get_xive() local
1377 if (!xive) in kvmppc_xive_get_xive()
1380 sb = kvmppc_xive_find_source(xive, irq, &idx); in kvmppc_xive_get_xive()
1394 struct kvmppc_xive *xive = kvm->arch.xive; in kvmppc_xive_int_on() local
1399 if (!xive) in kvmppc_xive_int_on()
1402 sb = kvmppc_xive_find_source(xive, irq, &idx); in kvmppc_xive_int_on()
1425 xive_finish_unmask(xive, sb, state, state->saved_priority); in kvmppc_xive_int_on()
1433 struct kvmppc_xive *xive = kvm->arch.xive; in kvmppc_xive_int_off() local
1438 if (!xive) in kvmppc_xive_int_off()
1441 sb = kvmppc_xive_find_source(xive, irq, &idx); in kvmppc_xive_int_off()
1451 state->saved_priority = xive_lock_and_mask(xive, sb, state); in kvmppc_xive_int_off()
1457 static bool xive_restore_pending_irq(struct kvmppc_xive *xive, u32 irq) in xive_restore_pending_irq() argument
1463 sb = kvmppc_xive_find_source(xive, irq, &idx); in xive_restore_pending_irq()
1495 struct kvmppc_xive *xive = vcpu->kvm->arch.xive; in kvmppc_xive_set_icp() local
1499 if (!xc || !xive) in kvmppc_xive_set_icp()
1542 if (xisr > XICS_IPI && !xive_restore_pending_irq(xive, xisr)) { in kvmppc_xive_set_icp()
1544 xive->delayed_irqs++; in kvmppc_xive_set_icp()
1554 struct kvmppc_xive *xive = kvm->arch.xive; in kvmppc_xive_set_mapped() local
1564 if (!xive) in kvmppc_xive_set_mapped()
1570 sb = kvmppc_xive_find_source(xive, guest_irq, &idx); in kvmppc_xive_set_mapped()
1599 prio = xive_lock_and_mask(xive, sb, state); in kvmppc_xive_set_mapped()
1610 if (xive->ops && xive->ops->reset_mapped) in kvmppc_xive_set_mapped()
1611 xive->ops->reset_mapped(kvm, guest_irq); in kvmppc_xive_set_mapped()
1624 kvmppc_xive_vp(xive, state->act_server), in kvmppc_xive_set_mapped()
1652 struct kvmppc_xive *xive = kvm->arch.xive; in kvmppc_xive_clr_mapped() local
1659 if (!xive) in kvmppc_xive_clr_mapped()
1664 sb = kvmppc_xive_find_source(xive, guest_irq, &idx); in kvmppc_xive_clr_mapped()
1674 prio = xive_lock_and_mask(xive, sb, state); in kvmppc_xive_clr_mapped()
1701 if (xive->ops && xive->ops->reset_mapped) { in kvmppc_xive_clr_mapped()
1702 xive->ops->reset_mapped(kvm, guest_irq); in kvmppc_xive_clr_mapped()
1707 kvmppc_xive_vp(xive, state->act_server), in kvmppc_xive_clr_mapped()
1733 struct kvmppc_xive *xive = kvm->arch.xive; in kvmppc_xive_disable_vcpu_interrupts() local
1736 for (i = 0; i <= xive->max_sbid; i++) { in kvmppc_xive_disable_vcpu_interrupts()
1737 struct kvmppc_xive_src_block *sb = xive->src_blocks[i]; in kvmppc_xive_disable_vcpu_interrupts()
1807 struct kvmppc_xive *xive = vcpu->kvm->arch.xive; in kvmppc_xive_cleanup_vcpu() local
1828 if (kvmppc_xive_has_single_escalation(xc->xive)) in kvmppc_xive_cleanup_vcpu()
1849 xive->q_page_order); in kvmppc_xive_cleanup_vcpu()
1867 static bool kvmppc_xive_vcpu_id_valid(struct kvmppc_xive *xive, u32 cpu) in kvmppc_xive_vcpu_id_valid() argument
1872 return kvmppc_pack_vcpu_id(xive->kvm, cpu) < xive->nr_servers; in kvmppc_xive_vcpu_id_valid()
1875 int kvmppc_xive_compute_vp_id(struct kvmppc_xive *xive, u32 cpu, u32 *vp) in kvmppc_xive_compute_vp_id() argument
1879 if (!kvmppc_xive_vcpu_id_valid(xive, cpu)) { in kvmppc_xive_compute_vp_id()
1884 if (xive->vp_base == XIVE_INVALID_VP) { in kvmppc_xive_compute_vp_id()
1885 xive->vp_base = xive_native_alloc_vp_block(xive->nr_servers); in kvmppc_xive_compute_vp_id()
1886 pr_devel("VP_Base=%x nr_servers=%d\n", xive->vp_base, xive->nr_servers); in kvmppc_xive_compute_vp_id()
1888 if (xive->vp_base == XIVE_INVALID_VP) in kvmppc_xive_compute_vp_id()
1892 vp_id = kvmppc_xive_vp(xive, cpu); in kvmppc_xive_compute_vp_id()
1893 if (kvmppc_xive_vp_in_use(xive->kvm, vp_id)) { in kvmppc_xive_compute_vp_id()
1906 struct kvmppc_xive *xive = dev->private; in kvmppc_xive_connect_vcpu() local
1917 if (xive->kvm != vcpu->kvm) in kvmppc_xive_connect_vcpu()
1923 mutex_lock(&xive->lock); in kvmppc_xive_connect_vcpu()
1925 r = kvmppc_xive_compute_vp_id(xive, cpu, &vp_id); in kvmppc_xive_connect_vcpu()
1936 xc->xive = xive; in kvmppc_xive_connect_vcpu()
1974 r = xive_native_enable_vp(xc->vp_id, kvmppc_xive_has_single_escalation(xive)); in kvmppc_xive_connect_vcpu()
1991 if (i == 7 && kvmppc_xive_has_single_escalation(xive)) in kvmppc_xive_connect_vcpu()
1995 if (xive->qmap & (1 << i)) { in kvmppc_xive_connect_vcpu()
1997 if (r == 0 && !kvmppc_xive_has_single_escalation(xive)) in kvmppc_xive_connect_vcpu()
1999 vcpu, i, kvmppc_xive_has_single_escalation(xive)); in kvmppc_xive_connect_vcpu()
2014 r = kvmppc_xive_attach_escalation(vcpu, 0, kvmppc_xive_has_single_escalation(xive)); in kvmppc_xive_connect_vcpu()
2024 mutex_unlock(&xive->lock); in kvmppc_xive_connect_vcpu()
2037 static void xive_pre_save_set_queued(struct kvmppc_xive *xive, u32 irq) in xive_pre_save_set_queued() argument
2043 sb = kvmppc_xive_find_source(xive, irq, &idx); in xive_pre_save_set_queued()
2067 static void xive_pre_save_mask_irq(struct kvmppc_xive *xive, in xive_pre_save_mask_irq() argument
2077 state->saved_scan_prio = xive_lock_and_mask(xive, sb, state); in xive_pre_save_mask_irq()
2087 static void xive_pre_save_unmask_irq(struct kvmppc_xive *xive, in xive_pre_save_unmask_irq() argument
2105 xive_finish_unmask(xive, sb, state, state->saved_scan_prio); in xive_pre_save_unmask_irq()
2111 static void xive_pre_save_queue(struct kvmppc_xive *xive, struct xive_q *q) in xive_pre_save_queue() argument
2120 xive_pre_save_set_queued(xive, irq); in xive_pre_save_queue()
2124 static void xive_pre_save_scan(struct kvmppc_xive *xive) in xive_pre_save_scan() argument
2134 for (i = 0; i <= xive->max_sbid; i++) { in xive_pre_save_scan()
2135 struct kvmppc_xive_src_block *sb = xive->src_blocks[i]; in xive_pre_save_scan()
2139 xive_pre_save_mask_irq(xive, sb, j); in xive_pre_save_scan()
2143 kvm_for_each_vcpu(i, vcpu, xive->kvm) { in xive_pre_save_scan()
2149 xive_pre_save_queue(xive, &xc->queues[j]); in xive_pre_save_scan()
2154 for (i = 0; i <= xive->max_sbid; i++) { in xive_pre_save_scan()
2155 struct kvmppc_xive_src_block *sb = xive->src_blocks[i]; in xive_pre_save_scan()
2159 xive_pre_save_unmask_irq(xive, sb, j); in xive_pre_save_scan()
2163 static void xive_post_save_scan(struct kvmppc_xive *xive) in xive_post_save_scan() argument
2168 for (i = 0; i <= xive->max_sbid; i++) { in xive_post_save_scan()
2169 struct kvmppc_xive_src_block *sb = xive->src_blocks[i]; in xive_post_save_scan()
2177 xive->saved_src_count = 0; in xive_post_save_scan()
2183 static int xive_get_source(struct kvmppc_xive *xive, long irq, u64 addr) in xive_get_source() argument
2191 sb = kvmppc_xive_find_source(xive, irq, &idx); in xive_get_source()
2218 if (xive->saved_src_count == 0) in xive_get_source()
2219 xive_pre_save_scan(xive); in xive_get_source()
2220 xive->saved_src_count++; in xive_get_source()
2256 if (xive->saved_src_count == xive->src_count) in xive_get_source()
2257 xive_post_save_scan(xive); in xive_get_source()
2267 struct kvmppc_xive *xive, int irq) in kvmppc_xive_create_src_block() argument
2274 mutex_lock(&xive->lock); in kvmppc_xive_create_src_block()
2277 if (xive->src_blocks[bid]) in kvmppc_xive_create_src_block()
2295 xive->src_blocks[bid] = sb; in kvmppc_xive_create_src_block()
2297 if (bid > xive->max_sbid) in kvmppc_xive_create_src_block()
2298 xive->max_sbid = bid; in kvmppc_xive_create_src_block()
2301 mutex_unlock(&xive->lock); in kvmppc_xive_create_src_block()
2302 return xive->src_blocks[bid]; in kvmppc_xive_create_src_block()
2305 static bool xive_check_delayed_irq(struct kvmppc_xive *xive, u32 irq) in xive_check_delayed_irq() argument
2307 struct kvm *kvm = xive->kvm; in xive_check_delayed_irq()
2319 xive->delayed_irqs--; in xive_check_delayed_irq()
2326 static int xive_set_source(struct kvmppc_xive *xive, long irq, u64 addr) in xive_set_source() argument
2343 sb = kvmppc_xive_find_source(xive, irq, &idx); in xive_set_source()
2346 sb = kvmppc_xive_create_src_block(xive, irq); in xive_set_source()
2388 xive_lock_and_mask(xive, sb, state); in xive_set_source()
2411 mutex_lock(&xive->lock); in xive_set_source()
2412 rc = xive_check_provisioning(xive->kvm, act_prio); in xive_set_source()
2413 mutex_unlock(&xive->lock); in xive_set_source()
2417 rc = xive_target_interrupt(xive->kvm, state, in xive_set_source()
2430 if (xive->delayed_irqs && xive_check_delayed_irq(xive, irq)) { in xive_set_source()
2477 xive_finish_unmask(xive, sb, state, guest_prio); in xive_set_source()
2483 xive->src_count++; in xive_set_source()
2492 struct kvmppc_xive *xive = kvm->arch.xive; in kvmppc_xive_set_irq() local
2497 if (!xive) in kvmppc_xive_set_irq()
2500 sb = kvmppc_xive_find_source(xive, irq, &idx); in kvmppc_xive_set_irq()
2526 int kvmppc_xive_set_nr_servers(struct kvmppc_xive *xive, u64 addr) in kvmppc_xive_set_nr_servers() argument
2540 mutex_lock(&xive->lock); in kvmppc_xive_set_nr_servers()
2541 if (xive->vp_base != XIVE_INVALID_VP) in kvmppc_xive_set_nr_servers()
2554 xive->nr_servers = KVM_MAX_VCPUS; in kvmppc_xive_set_nr_servers()
2556 xive->nr_servers = nr_servers; in kvmppc_xive_set_nr_servers()
2558 mutex_unlock(&xive->lock); in kvmppc_xive_set_nr_servers()
2565 struct kvmppc_xive *xive = dev->private; in xive_set_attr() local
2570 return xive_set_source(xive, attr->attr, attr->addr); in xive_set_attr()
2574 return kvmppc_xive_set_nr_servers(xive, attr->addr); in xive_set_attr()
2582 struct kvmppc_xive *xive = dev->private; in xive_get_attr() local
2587 return xive_get_source(xive, attr->attr, attr->addr); in xive_get_attr()
2643 struct kvmppc_xive *xive = dev->private; in kvmppc_xive_release() local
2644 struct kvm *kvm = xive->kvm; in kvmppc_xive_release()
2659 debugfs_remove(xive->dentry); in kvmppc_xive_release()
2684 kvm->arch.xive = NULL; in kvmppc_xive_release()
2687 for (i = 0; i <= xive->max_sbid; i++) { in kvmppc_xive_release()
2688 if (xive->src_blocks[i]) in kvmppc_xive_release()
2689 kvmppc_xive_free_sources(xive->src_blocks[i]); in kvmppc_xive_release()
2690 kfree(xive->src_blocks[i]); in kvmppc_xive_release()
2691 xive->src_blocks[i] = NULL; in kvmppc_xive_release()
2694 if (xive->vp_base != XIVE_INVALID_VP) in kvmppc_xive_release()
2695 xive_native_free_vp_block(xive->vp_base); in kvmppc_xive_release()
2721 struct kvmppc_xive *xive = *kvm_xive_device; in kvmppc_xive_get_device() local
2723 if (!xive) { in kvmppc_xive_get_device()
2724 xive = kzalloc(sizeof(*xive), GFP_KERNEL); in kvmppc_xive_get_device()
2725 *kvm_xive_device = xive; in kvmppc_xive_get_device()
2727 memset(xive, 0, sizeof(*xive)); in kvmppc_xive_get_device()
2730 return xive; in kvmppc_xive_get_device()
2738 struct kvmppc_xive *xive; in kvmppc_xive_create() local
2744 if (kvm->arch.xive) in kvmppc_xive_create()
2747 xive = kvmppc_xive_get_device(kvm, type); in kvmppc_xive_create()
2748 if (!xive) in kvmppc_xive_create()
2751 dev->private = xive; in kvmppc_xive_create()
2752 xive->dev = dev; in kvmppc_xive_create()
2753 xive->kvm = kvm; in kvmppc_xive_create()
2754 mutex_init(&xive->lock); in kvmppc_xive_create()
2757 xive->q_order = xive_native_default_eq_shift(); in kvmppc_xive_create()
2758 if (xive->q_order < PAGE_SHIFT) in kvmppc_xive_create()
2759 xive->q_page_order = 0; in kvmppc_xive_create()
2761 xive->q_page_order = xive->q_order - PAGE_SHIFT; in kvmppc_xive_create()
2764 xive->vp_base = XIVE_INVALID_VP; in kvmppc_xive_create()
2768 xive->nr_servers = KVM_MAX_VCPUS; in kvmppc_xive_create()
2771 xive->flags |= KVMPPC_XIVE_FLAG_SINGLE_ESCALATION; in kvmppc_xive_create()
2774 xive->flags |= KVMPPC_XIVE_FLAG_SAVE_RESTORE; in kvmppc_xive_create()
2776 kvm->arch.xive = xive; in kvmppc_xive_create()
2885 struct kvmppc_xive *xive = m->private; in xive_debug_show() local
2886 struct kvm *kvm = xive->kvm; in xive_debug_show()
2941 for (i = 0; i <= xive->max_sbid; i++) { in xive_debug_show()
2942 struct kvmppc_xive_src_block *sb = xive->src_blocks[i]; in xive_debug_show()
2956 static void xive_debugfs_init(struct kvmppc_xive *xive) in xive_debugfs_init() argument
2958 xive->dentry = debugfs_create_file("xive", S_IRUGO, xive->kvm->debugfs_dentry, in xive_debugfs_init()
2959 xive, &xive_debug_fops); in xive_debugfs_init()
2966 struct kvmppc_xive *xive = dev->private; in kvmppc_xive_init() local
2969 xive_debugfs_init(xive); in kvmppc_xive_init()