| 1 | // SPDX-License-Identifier: MIT |
| 2 | /* |
| 3 | * Copyright © 2020 Intel Corporation |
| 4 | */ |
| 5 | |
| 6 | #include <drm/drm_print.h> |
| 7 | |
| 8 | #include "gt/intel_gt_debugfs.h" |
| 9 | #include "gt/uc/intel_guc_ads.h" |
| 10 | #include "gt/uc/intel_guc_ct.h" |
| 11 | #include "gt/uc/intel_guc_slpc.h" |
| 12 | #include "gt/uc/intel_guc_submission.h" |
| 13 | #include "intel_guc.h" |
| 14 | #include "intel_guc_debugfs.h" |
| 15 | #include "intel_guc_log_debugfs.h" |
| 16 | |
| 17 | static int guc_info_show(struct seq_file *m, void *data) |
| 18 | { |
| 19 | struct intel_guc *guc = m->private; |
| 20 | struct drm_printer p = drm_seq_file_printer(f: m); |
| 21 | |
| 22 | if (!intel_guc_is_supported(guc)) |
| 23 | return -ENODEV; |
| 24 | |
| 25 | intel_guc_load_status(guc, p: &p); |
| 26 | drm_puts(p: &p, str: "\n" ); |
| 27 | intel_guc_log_info(log: &guc->log, p: &p); |
| 28 | |
| 29 | if (!intel_guc_submission_is_used(guc)) |
| 30 | return 0; |
| 31 | |
| 32 | intel_guc_ct_print_info(ct: &guc->ct, p: &p); |
| 33 | intel_guc_submission_print_info(guc, p: &p); |
| 34 | intel_guc_ads_print_policy_info(guc, p: &p); |
| 35 | |
| 36 | return 0; |
| 37 | } |
| 38 | DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(guc_info); |
| 39 | |
| 40 | static int guc_registered_contexts_show(struct seq_file *m, void *data) |
| 41 | { |
| 42 | struct intel_guc *guc = m->private; |
| 43 | struct drm_printer p = drm_seq_file_printer(f: m); |
| 44 | |
| 45 | if (!intel_guc_submission_is_used(guc)) |
| 46 | return -ENODEV; |
| 47 | |
| 48 | intel_guc_submission_print_context_info(guc, p: &p); |
| 49 | |
| 50 | return 0; |
| 51 | } |
| 52 | DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(guc_registered_contexts); |
| 53 | |
| 54 | static int guc_slpc_info_show(struct seq_file *m, void *unused) |
| 55 | { |
| 56 | struct intel_guc *guc = m->private; |
| 57 | struct intel_guc_slpc *slpc = &guc->slpc; |
| 58 | struct drm_printer p = drm_seq_file_printer(f: m); |
| 59 | |
| 60 | if (!intel_guc_slpc_is_used(guc)) |
| 61 | return -ENODEV; |
| 62 | |
| 63 | return intel_guc_slpc_print_info(slpc, p: &p); |
| 64 | } |
| 65 | DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(guc_slpc_info); |
| 66 | |
| 67 | static bool intel_eval_slpc_support(void *data) |
| 68 | { |
| 69 | struct intel_guc *guc = (struct intel_guc *)data; |
| 70 | |
| 71 | return intel_guc_slpc_is_used(guc); |
| 72 | } |
| 73 | |
| 74 | static int guc_sched_disable_delay_ms_get(void *data, u64 *val) |
| 75 | { |
| 76 | struct intel_guc *guc = data; |
| 77 | |
| 78 | if (!intel_guc_submission_is_used(guc)) |
| 79 | return -ENODEV; |
| 80 | |
| 81 | *val = (u64)guc->submission_state.sched_disable_delay_ms; |
| 82 | |
| 83 | return 0; |
| 84 | } |
| 85 | |
| 86 | static int guc_sched_disable_delay_ms_set(void *data, u64 val) |
| 87 | { |
| 88 | struct intel_guc *guc = data; |
| 89 | |
| 90 | if (!intel_guc_submission_is_used(guc)) |
| 91 | return -ENODEV; |
| 92 | |
| 93 | /* clamp to a practical limit, 1 minute is reasonable for a longest delay */ |
| 94 | guc->submission_state.sched_disable_delay_ms = min_t(u64, val, 60000); |
| 95 | |
| 96 | return 0; |
| 97 | } |
| 98 | DEFINE_SIMPLE_ATTRIBUTE(guc_sched_disable_delay_ms_fops, |
| 99 | guc_sched_disable_delay_ms_get, |
| 100 | guc_sched_disable_delay_ms_set, "%lld\n" ); |
| 101 | |
| 102 | static int guc_sched_disable_gucid_threshold_get(void *data, u64 *val) |
| 103 | { |
| 104 | struct intel_guc *guc = data; |
| 105 | |
| 106 | if (!intel_guc_submission_is_used(guc)) |
| 107 | return -ENODEV; |
| 108 | |
| 109 | *val = guc->submission_state.sched_disable_gucid_threshold; |
| 110 | return 0; |
| 111 | } |
| 112 | |
| 113 | static int guc_sched_disable_gucid_threshold_set(void *data, u64 val) |
| 114 | { |
| 115 | struct intel_guc *guc = data; |
| 116 | |
| 117 | if (!intel_guc_submission_is_used(guc)) |
| 118 | return -ENODEV; |
| 119 | |
| 120 | if (val > intel_guc_sched_disable_gucid_threshold_max(guc)) |
| 121 | guc->submission_state.sched_disable_gucid_threshold = |
| 122 | intel_guc_sched_disable_gucid_threshold_max(guc); |
| 123 | else |
| 124 | guc->submission_state.sched_disable_gucid_threshold = val; |
| 125 | |
| 126 | return 0; |
| 127 | } |
| 128 | DEFINE_SIMPLE_ATTRIBUTE(guc_sched_disable_gucid_threshold_fops, |
| 129 | guc_sched_disable_gucid_threshold_get, |
| 130 | guc_sched_disable_gucid_threshold_set, "%lld\n" ); |
| 131 | |
| 132 | void intel_guc_debugfs_register(struct intel_guc *guc, struct dentry *root) |
| 133 | { |
| 134 | static const struct intel_gt_debugfs_file files[] = { |
| 135 | { "guc_info" , &guc_info_fops, NULL }, |
| 136 | { "guc_registered_contexts" , &guc_registered_contexts_fops, NULL }, |
| 137 | { "guc_slpc_info" , &guc_slpc_info_fops, &intel_eval_slpc_support}, |
| 138 | { "guc_sched_disable_delay_ms" , &guc_sched_disable_delay_ms_fops, NULL }, |
| 139 | { "guc_sched_disable_gucid_threshold" , &guc_sched_disable_gucid_threshold_fops, |
| 140 | NULL }, |
| 141 | }; |
| 142 | |
| 143 | if (!intel_guc_is_supported(guc)) |
| 144 | return; |
| 145 | |
| 146 | intel_gt_debugfs_register_files(root, files, ARRAY_SIZE(files), data: guc); |
| 147 | intel_guc_log_debugfs_register(log: &guc->log, root); |
| 148 | } |
| 149 | |