|
| 1 | +/* |
| 2 | + * Copyright(c) 2011-2017 Intel Corporation. All rights reserved. |
| 3 | + * |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | + * copy of this software and associated documentation files (the "Software"), |
| 6 | + * to deal in the Software without restriction, including without limitation |
| 7 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | + * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | + * Software is furnished to do so, subject to the following conditions: |
| 10 | + * |
| 11 | + * The above copyright notice and this permission notice (including the next |
| 12 | + * paragraph) shall be included in all copies or substantial portions of the |
| 13 | + * Software. |
| 14 | + * |
| 15 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 | + * SOFTWARE. |
| 22 | + */ |
| 23 | +#include <linux/debugfs.h> |
| 24 | +#include "i915_drv.h" |
| 25 | +#include "gvt.h" |
| 26 | + |
| 27 | + |
| 28 | +/** |
| 29 | + * intel_gvt_debugfs_add_vgpu - register debugfs entries for a vGPU |
| 30 | + * @vgpu: a vGPU |
| 31 | + * |
| 32 | + * Returns: |
| 33 | + * Zero on success, negative error code if failed. |
| 34 | + */ |
| 35 | +int intel_gvt_debugfs_add_vgpu(struct intel_vgpu *vgpu) |
| 36 | +{ |
| 37 | + struct dentry *ent; |
| 38 | + char name[10] = ""; |
| 39 | + |
| 40 | + sprintf(name, "vgpu%d", vgpu->id); |
| 41 | + vgpu->debugfs = debugfs_create_dir(name, vgpu->gvt->debugfs_root); |
| 42 | + if (!vgpu->debugfs) |
| 43 | + return -ENOMEM; |
| 44 | + |
| 45 | + ent = debugfs_create_bool("active", 0444, vgpu->debugfs, |
| 46 | + &vgpu->active); |
| 47 | + if (!ent) |
| 48 | + return -ENOMEM; |
| 49 | + |
| 50 | + return 0; |
| 51 | +} |
| 52 | + |
| 53 | +/** |
| 54 | + * intel_gvt_debugfs_remove_vgpu - remove debugfs entries of a vGPU |
| 55 | + * @vgpu: a vGPU |
| 56 | + */ |
| 57 | +void intel_gvt_debugfs_remove_vgpu(struct intel_vgpu *vgpu) |
| 58 | +{ |
| 59 | + debugfs_remove_recursive(vgpu->debugfs); |
| 60 | + vgpu->debugfs = NULL; |
| 61 | +} |
| 62 | + |
| 63 | +/** |
| 64 | + * intel_gvt_debugfs_init - register gvt debugfs root entry |
| 65 | + * @gvt: GVT device |
| 66 | + * |
| 67 | + * Returns: |
| 68 | + * zero on success, negative if failed. |
| 69 | + */ |
| 70 | +int intel_gvt_debugfs_init(struct intel_gvt *gvt) |
| 71 | +{ |
| 72 | + struct drm_minor *minor = gvt->dev_priv->drm.primary; |
| 73 | + struct dentry *ent; |
| 74 | + |
| 75 | + gvt->debugfs_root = debugfs_create_dir("gvt", minor->debugfs_root); |
| 76 | + if (!gvt->debugfs_root) { |
| 77 | + gvt_err("Cannot create debugfs dir\n"); |
| 78 | + return -ENOMEM; |
| 79 | + } |
| 80 | + |
| 81 | + ent = debugfs_create_ulong("num_tracked_mmio", 0444, gvt->debugfs_root, |
| 82 | + &gvt->mmio.num_tracked_mmio); |
| 83 | + if (!ent) |
| 84 | + return -ENOMEM; |
| 85 | + |
| 86 | + return 0; |
| 87 | +} |
| 88 | + |
| 89 | +/** |
| 90 | + * intel_gvt_debugfs_clean - remove debugfs entries |
| 91 | + * @gvt: GVT device |
| 92 | + */ |
| 93 | +void intel_gvt_debugfs_clean(struct intel_gvt *gvt) |
| 94 | +{ |
| 95 | + debugfs_remove_recursive(gvt->debugfs_root); |
| 96 | + gvt->debugfs_root = NULL; |
| 97 | +} |
0 commit comments