From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Yin Fengwei Date: Mon, 2 Sep 2019 08:59:03 +0800 Subject: [PATCH] vhm ioreq: add debugfs entry to dump the vhm client io range For debugging purpose, we may need to check all vhm client io range to make sure it's on good shape. We add a interface in debugfs to dump these info for developer to check the client io range info. Tracked-On: projectacrn/acrn-hypervisor#3634 Signed-off-by: Yin Fengwei Reviewed-by: Zhao Yakui --- drivers/vhm/vhm_ioreq.c | 53 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/drivers/vhm/vhm_ioreq.c b/drivers/vhm/vhm_ioreq.c index c8cc09766610..ef89bf827270 100644 --- a/drivers/vhm/vhm_ioreq.c +++ b/drivers/vhm/vhm_ioreq.c @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include @@ -1103,7 +1104,59 @@ void acrn_ioreq_free(struct vhm_vm *vm) } +static struct dentry *vhm_debugfs_dir; + +static void vhm_ioclient_range_show_one(struct seq_file *s, + struct ioreq_client *client) +{ + struct list_head *pos; + + seq_printf(s, " client: %s, id: %d\n", + client->name, client->id); + + spin_lock_bh(&client->range_lock); + list_for_each(pos, &client->range_list) { + struct ioreq_range *range = + container_of(pos, struct ioreq_range, list); + seq_printf(s, " io range: type %d, start 0x%lx, end 0x%lx\n", + range->type, range->start, range->end); + } + spin_unlock_bh(&client->range_lock); +} + +static int vhm_ioclient_range_show(struct seq_file *s, void *data) +{ + struct vhm_vm *vm; + + read_lock_bh(&vhm_vm_list_lock); + list_for_each_entry(vm, &vhm_vm_list, list) { + struct list_head *pos, *tmp; + + get_vm(vm); + seq_printf(s, "vm%ld:\n", vm->vmid); + list_for_each_safe(pos, tmp, &vm->ioreq_client_list) { + struct ioreq_client *client = + container_of(pos, struct ioreq_client, list); + + vhm_ioclient_range_show_one(s, client); + } + put_vm(vm); + } + read_unlock_bh(&vhm_vm_list_lock); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(vhm_ioclient_range); + void acrn_ioreq_driver_init() { idr_init(&idr_client); + vhm_debugfs_dir = debugfs_create_dir("vhm", NULL); + debugfs_create_file("ioclient_range", 0444, vhm_debugfs_dir, NULL, + &vhm_ioclient_range_fops); +} + +void acrn_ioreq_driver_deinit(void) +{ + debugfs_remove_recursive(vhm_debugfs_dir); } -- https://clearlinux.org