1 // SPDX-License-Identifier: MIT
3 * Copyright © 2021 Intel Corporation
6 #include <linux/debugfs.h>
7 #include <linux/string_helpers.h>
9 #include <drm/drm_print.h>
11 #include "gt/intel_gt_debugfs.h"
13 #include "intel_pxp.h"
14 #include "intel_pxp_debugfs.h"
15 #include "intel_pxp_irq.h"
17 static int pxp_info_show(struct seq_file *m, void *data)
19 struct intel_pxp *pxp = m->private;
20 struct drm_printer p = drm_seq_file_printer(m);
21 bool enabled = intel_pxp_is_enabled(pxp);
24 drm_printf(&p, "pxp disabled\n");
28 drm_printf(&p, "active: %s\n", str_yes_no(intel_pxp_is_active(pxp)));
29 drm_printf(&p, "instance counter: %u\n", pxp->key_instance);
33 DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(pxp_info);
35 static int pxp_terminate_get(void *data, u64 *val)
41 static int pxp_terminate_set(void *data, u64 val)
43 struct intel_pxp *pxp = data;
44 struct intel_gt *gt = pxp_to_gt(pxp);
46 if (!intel_pxp_is_active(pxp))
49 /* simulate a termination interrupt */
50 spin_lock_irq(gt->irq_lock);
51 intel_pxp_irq_handler(pxp, GEN12_DISPLAY_PXP_STATE_TERMINATED_INTERRUPT);
52 spin_unlock_irq(gt->irq_lock);
54 if (!wait_for_completion_timeout(&pxp->termination,
55 msecs_to_jiffies(100)))
61 DEFINE_SIMPLE_ATTRIBUTE(pxp_terminate_fops, pxp_terminate_get, pxp_terminate_set, "%llx\n");
62 void intel_pxp_debugfs_register(struct intel_pxp *pxp, struct dentry *gt_root)
64 static const struct intel_gt_debugfs_file files[] = {
65 { "info", &pxp_info_fops, NULL },
66 { "terminate_state", &pxp_terminate_fops, NULL },
73 if (!HAS_PXP((pxp_to_gt(pxp)->i915)))
76 root = debugfs_create_dir("pxp", gt_root);
80 intel_gt_debugfs_register_files(root, files, ARRAY_SIZE(files), pxp);