brintos

brintos / linux-shallow public Read only

0
0
Text · 2.0 KiB · e07c5b3 Raw
92 lines · c
1// SPDX-License-Identifier: MIT2/*3 * Copyright © 2021 Intel Corporation4 */5 6#include <linux/debugfs.h>7#include <linux/string_helpers.h>8 9#include <drm/drm_print.h>10 11#include "gt/intel_gt_debugfs.h"12 13#include "i915_drv.h"14 15#include "intel_pxp.h"16#include "intel_pxp_debugfs.h"17#include "intel_pxp_gsccs.h"18#include "intel_pxp_irq.h"19#include "intel_pxp_types.h"20 21static int pxp_info_show(struct seq_file *m, void *data)22{23	struct intel_pxp *pxp = m->private;24	struct drm_printer p = drm_seq_file_printer(m);25 26	if (!intel_pxp_is_enabled(pxp)) {27		drm_printf(&p, "pxp disabled\n");28		return 0;29	}30 31	drm_printf(&p, "active: %s\n", str_yes_no(intel_pxp_is_active(pxp)));32	drm_printf(&p, "instance counter: %u\n", pxp->key_instance);33 34	return 0;35}36 37DEFINE_SHOW_ATTRIBUTE(pxp_info);38 39static int pxp_terminate_get(void *data, u64 *val)40{41	/* nothing to read */42	return -EPERM;43}44 45static int pxp_terminate_set(void *data, u64 val)46{47	struct intel_pxp *pxp = data;48	struct intel_gt *gt = pxp->ctrl_gt;49	int timeout_ms;50 51	if (!intel_pxp_is_active(pxp))52		return -ENODEV;53 54	/* simulate a termination interrupt */55	spin_lock_irq(gt->irq_lock);56	intel_pxp_irq_handler(pxp, GEN12_DISPLAY_PXP_STATE_TERMINATED_INTERRUPT);57	spin_unlock_irq(gt->irq_lock);58 59	timeout_ms = intel_pxp_get_backend_timeout_ms(pxp);60 61	if (!wait_for_completion_timeout(&pxp->termination,62					 msecs_to_jiffies(timeout_ms)))63		return -ETIMEDOUT;64 65	return 0;66}67 68DEFINE_SIMPLE_ATTRIBUTE(pxp_terminate_fops, pxp_terminate_get, pxp_terminate_set, "%llx\n");69 70void intel_pxp_debugfs_register(struct intel_pxp *pxp)71{72	struct drm_minor *minor;73	struct dentry *pxproot;74 75	if (!intel_pxp_is_supported(pxp))76		return;77 78	minor = pxp->ctrl_gt->i915->drm.primary;79	if (!minor->debugfs_root)80		return;81 82	pxproot = debugfs_create_dir("pxp", minor->debugfs_root);83	if (IS_ERR(pxproot))84		return;85 86	debugfs_create_file("info", 0444, pxproot,87			    pxp, &pxp_info_fops);88 89	debugfs_create_file("terminate_state", 0644, pxproot,90			    pxp, &pxp_terminate_fops);91}92