Lines Matching +full:irq +full:- +full:device

1 // SPDX-License-Identifier: GPL-2.0-only
37 struct vgic_dist *dist = &kvm->arch.vgic; in iter_next()
39 if (iter->dist_id == 0) { in iter_next()
40 iter->dist_id++; in iter_next()
46 * has exhausted the sequentially-allocated INTID space. in iter_next()
48 if (iter->intid >= (iter->nr_spis + VGIC_NR_PRIVATE_IRQS - 1) && in iter_next()
49 iter->nr_lpis) { in iter_next()
50 if (iter->lpi_idx < iter->nr_lpis) in iter_next()
51 xa_find_after(&dist->lpi_xa, &iter->intid, in iter_next()
54 iter->lpi_idx++; in iter_next()
58 iter->intid++; in iter_next()
59 if (iter->intid == VGIC_NR_PRIVATE_IRQS && in iter_next()
60 ++iter->vcpu_id < iter->nr_cpus) in iter_next()
61 iter->intid = 0; in iter_next()
66 struct vgic_dist *dist = &kvm->arch.vgic; in iter_mark_lpis()
67 struct vgic_irq *irq; in iter_mark_lpis() local
71 xa_for_each(&dist->lpi_xa, intid, irq) { in iter_mark_lpis()
72 if (!vgic_try_get_irq_ref(irq)) in iter_mark_lpis()
75 xa_set_mark(&dist->lpi_xa, intid, LPI_XA_MARK_DEBUG_ITER); in iter_mark_lpis()
84 struct vgic_dist *dist = &kvm->arch.vgic; in iter_unmark_lpis()
85 struct vgic_irq *irq; in iter_unmark_lpis() local
88 xa_for_each_marked(&dist->lpi_xa, intid, irq, LPI_XA_MARK_DEBUG_ITER) { in iter_unmark_lpis()
89 xa_clear_mark(&dist->lpi_xa, intid, LPI_XA_MARK_DEBUG_ITER); in iter_unmark_lpis()
90 vgic_put_irq(kvm, irq); in iter_unmark_lpis()
97 int nr_cpus = atomic_read(&kvm->online_vcpus); in iter_init()
101 iter->nr_cpus = nr_cpus; in iter_init()
102 iter->nr_spis = kvm->arch.vgic.nr_spis; in iter_init()
103 if (kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3) in iter_init()
104 iter->nr_lpis = iter_mark_lpis(kvm); in iter_init()
107 while (pos--) in iter_init()
113 return iter->dist_id > 0 && in end_of_vgic()
114 iter->vcpu_id == iter->nr_cpus && in end_of_vgic()
115 iter->intid >= (iter->nr_spis + VGIC_NR_PRIVATE_IRQS) && in end_of_vgic()
116 (!iter->nr_lpis || iter->lpi_idx > iter->nr_lpis); in end_of_vgic()
121 struct kvm *kvm = s->private; in vgic_debug_start()
124 mutex_lock(&kvm->arch.config_lock); in vgic_debug_start()
125 iter = kvm->arch.vgic.iter; in vgic_debug_start()
127 iter = ERR_PTR(-EBUSY); in vgic_debug_start()
133 iter = ERR_PTR(-ENOMEM); in vgic_debug_start()
138 kvm->arch.vgic.iter = iter; in vgic_debug_start()
143 mutex_unlock(&kvm->arch.config_lock); in vgic_debug_start()
149 struct kvm *kvm = s->private; in vgic_debug_next()
150 struct vgic_state_iter *iter = kvm->arch.vgic.iter; in vgic_debug_next()
161 struct kvm *kvm = s->private; in vgic_debug_stop()
171 mutex_lock(&kvm->arch.config_lock); in vgic_debug_stop()
172 iter = kvm->arch.vgic.iter; in vgic_debug_stop()
175 kvm->arch.vgic.iter = NULL; in vgic_debug_stop()
176 mutex_unlock(&kvm->arch.config_lock); in vgic_debug_stop()
182 bool v3 = dist->vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3; in print_dist_state()
187 seq_printf(s, "nr_spis:\t%d\n", dist->nr_spis); in print_dist_state()
189 seq_printf(s, "nr_lpis:\t%d\n", iter->nr_lpis); in print_dist_state()
190 seq_printf(s, "enabled:\t%d\n", dist->enabled); in print_dist_state()
198 static void print_header(struct seq_file *s, struct vgic_irq *irq, in print_header() argument
206 id = vcpu->vcpu_idx; in print_header()
211 seq_printf(s, "----------------------------------------------------------------\n"); in print_header()
214 static void print_irq_state(struct seq_file *s, struct vgic_irq *irq, in print_irq_state() argument
220 if (irq->intid < VGIC_NR_SGIS) in print_irq_state()
222 else if (irq->intid < VGIC_NR_PRIVATE_IRQS) in print_irq_state()
224 else if (irq->intid < VGIC_MAX_SPI) in print_irq_state()
229 if (irq->intid ==0 || irq->intid == VGIC_NR_PRIVATE_IRQS) in print_irq_state()
230 print_header(s, irq, vcpu); in print_irq_state()
232 pending = irq->pending_latch; in print_irq_state()
233 if (irq->hw && vgic_irq_is_sgi(irq->intid)) { in print_irq_state()
236 err = irq_get_irqchip_state(irq->host_irq, in print_irq_state()
251 type, irq->intid, in print_irq_state()
252 (irq->target_vcpu) ? irq->target_vcpu->vcpu_idx : -1, in print_irq_state()
254 irq->line_level, in print_irq_state()
255 irq->active, in print_irq_state()
256 irq->enabled, in print_irq_state()
257 irq->hw, in print_irq_state()
258 irq->config == VGIC_CONFIG_LEVEL, in print_irq_state()
259 irq->group, in print_irq_state()
260 irq->hwintid, in print_irq_state()
261 irq->mpidr, in print_irq_state()
262 irq->source, in print_irq_state()
263 irq->priority, in print_irq_state()
264 (irq->vcpu) ? irq->vcpu->vcpu_idx : -1); in print_irq_state()
269 struct kvm *kvm = s->private; in vgic_debug_show()
271 struct vgic_irq *irq; in vgic_debug_show() local
275 if (iter->dist_id == 0) { in vgic_debug_show()
276 print_dist_state(s, &kvm->arch.vgic, iter); in vgic_debug_show()
280 if (!kvm->arch.vgic.initialized) in vgic_debug_show()
283 if (iter->vcpu_id < iter->nr_cpus) in vgic_debug_show()
284 vcpu = kvm_get_vcpu(kvm, iter->vcpu_id); in vgic_debug_show()
290 if (iter->intid < VGIC_NR_PRIVATE_IRQS) in vgic_debug_show()
291 irq = vgic_get_vcpu_irq(vcpu, iter->intid); in vgic_debug_show()
293 irq = vgic_get_irq(kvm, iter->intid); in vgic_debug_show()
294 if (WARN_ON_ONCE(!irq)) in vgic_debug_show()
295 return -EINVAL; in vgic_debug_show()
297 raw_spin_lock_irqsave(&irq->irq_lock, flags); in vgic_debug_show()
298 print_irq_state(s, irq, vcpu); in vgic_debug_show()
299 raw_spin_unlock_irqrestore(&irq->irq_lock, flags); in vgic_debug_show()
301 vgic_put_irq(kvm, irq); in vgic_debug_show()
316 debugfs_create_file("vgic-state", 0444, kvm->debugfs_dentry, kvm, in vgic_debug_init()
325 * struct vgic_its_iter - Iterator for traversing VGIC ITS device tables.
327 * @ite: Pointer to the current its_ite within the device being processed.
330 * over the ITS device tables. It holds pointers to both the current device
331 * and the current ITE within that device.
339 * end_of_iter - Checks if the iterator has reached the end.
342 * When the iterator completed processing the final ITE in the last device
344 * device and ITE pointers to NULL.
351 return !iter->dev && !iter->ite; in end_of_iter()
355 * vgic_its_iter_next - Advances the iterator to the next entry in the ITS tables.
359 * This function moves the iterator to the next ITE within the current device,
360 * or to the first ITE of the next device if the current ITE is the last in
361 * the device. If the current device is the last device, the iterator is set
366 struct its_device *dev = iter->dev; in vgic_its_iter_next()
367 struct its_ite *ite = iter->ite; in vgic_its_iter_next()
369 if (!ite || list_is_last(&ite->ite_list, &dev->itt_head)) { in vgic_its_iter_next()
370 if (list_is_last(&dev->dev_list, &its->device_list)) { in vgic_its_iter_next()
375 ite = list_first_entry_or_null(&dev->itt_head, in vgic_its_iter_next()
383 iter->dev = dev; in vgic_its_iter_next()
384 iter->ite = ite; in vgic_its_iter_next()
388 * vgic_its_debug_start - Start function for the seq_file interface.
397 * the end of the list is reached, or ERR_PTR(-ENOMEM) on memory
402 struct vgic_its *its = s->private; in vgic_its_debug_start()
407 mutex_lock(&its->its_lock); in vgic_its_debug_start()
409 dev = list_first_entry_or_null(&its->device_list, in vgic_its_debug_start()
416 return ERR_PTR(-ENOMEM); in vgic_its_debug_start()
418 iter->dev = dev; in vgic_its_debug_start()
419 iter->ite = list_first_entry_or_null(&dev->itt_head, in vgic_its_debug_start()
422 while (!end_of_iter(iter) && offset--) in vgic_its_debug_start()
434 * vgic_its_debug_next - Next function for the seq_file interface.
447 struct vgic_its *its = s->private; in vgic_its_debug_next()
461 * vgic_its_debug_stop - Stop function for the seq_file interface.
469 struct vgic_its *its = s->private; in vgic_its_debug_stop()
474 mutex_unlock(&its->its_lock); in vgic_its_debug_stop()
478 * vgic_its_debug_show - Show function for the seq_file interface.
490 struct its_device *dev = iter->dev; in vgic_its_debug_show()
491 struct its_ite *ite = iter->ite; in vgic_its_debug_show()
496 if (list_is_first(&ite->ite_list, &dev->itt_head)) { in vgic_its_debug_show()
498 seq_printf(s, "Device ID: 0x%x, Event ID Range: [0 - %llu]\n", in vgic_its_debug_show()
499 dev->device_id, BIT_ULL(dev->num_eventid_bits) - 1); in vgic_its_debug_show()
501 seq_printf(s, "-----------------------------------------------\n"); in vgic_its_debug_show()
504 if (ite->irq && ite->collection) { in vgic_its_debug_show()
506 ite->event_id, ite->irq->intid, ite->irq->hwintid, in vgic_its_debug_show()
507 ite->collection->target_addr, in vgic_its_debug_show()
508 ite->collection->collection_id, ite->irq->hw); in vgic_its_debug_show()
524 * vgic_its_debug_init - Initializes the debugfs interface for VGIC ITS.
525 * @dev: The KVM device structure.
527 * This function creates a debugfs file named "vgic-its-state@%its_base"
534 struct vgic_its *its = dev->private; in vgic_its_debug_init()
537 name = kasprintf(GFP_KERNEL, "vgic-its-state@%llx", (u64)its->vgic_its_base); in vgic_its_debug_init()
539 return -ENOMEM; in vgic_its_debug_init()
541 debugfs_create_file(name, 0444, dev->kvm->debugfs_dentry, its, &vgic_its_debug_fops); in vgic_its_debug_init()