summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/i915/i915_ioctl.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2022-02-11 14:13:36 +1000
committerDave Airlie <airlied@redhat.com>2022-02-11 14:14:07 +1000
commite7a09cea6483b44ea0c82f07145fcbd8a918bf96 (patch)
tree825489ab7bf8347cfac7b2e3eccf9138ed75d624 /drivers/gpu/drm/i915/i915_ioctl.c
parent53dbee4926d3706ca9e03f3928fa85b5ec3bc0cc (diff)
parent7938f4218168ae9fc4bdddb15976f9ebbae41999 (diff)
downloadlinux-e7a09cea6483b44ea0c82f07145fcbd8a918bf96.tar.gz
Merge tag 'drm-intel-next-2022-02-08' of git://anongit.freedesktop.org/drm/drm-intel into drm-next
Cross-subsystem Changes: ------------------------ dma-buf: - dma-buf-map: Rename to iosys-map (Lucas) Core Changes: ------------- drm: - Always include the debugfs_entry in drm_crtc (Ville) - Add orientation quirk for GPD Win Max (Anisse) Driver Changes: --------------- gvt: - Constify some pointers. (Rikard Falkeborn) - Use list_entry to access list members. (Guenter Roeck) - Fix cmd parser error for Passmark9. (Zhenyu Wang) i915: - Various clean-ups including headers and removing unused and unnecessary stuff\ (Jani, Hans, Andy, Ville) - Cleaning up on our registers definitions i915_reg.h (Matt) - More multi-FBC refactoring (Ville) - Baytrail backlight fix (Hans) - DG1 OPROM read through SPI controller (Clint) - ADL-N platform enabling (Tejas) - Fix slab-out-of-bounds access (Jani) - Add opregion mailbox #5 support for possible EDID override (Anisse) - Fix possible NULL dereferences (Harish) - Updates and fixes around display voltage swing values (Clint, Jose) - Fix RPM wekeref on PXP code (Juston) - Many register definitions clean-up, including planes registers (Ville) - More conversion towards display version over the old gen (Madhumitha, Ville) - DP MST ESI handling improvements (Jani) - drm device based logging conversions (Jani) - Prevent divide by zero (Dan) - Introduce ilk_pch_pre_enable for complete modeset abstraction (Ville) - Async flip optimization for DG2 (Stanislav) - Multiple DSC and bigjoiner fixes and improvements (Ville) - Fix ADL-P TypeC Phy ready status readout (Imre) - Fix up DP DFP 4:2:0 handling more display related fixes (Ville) - Display M/N cleanup (Ville) - Switch to use VGA definitions from video/vga.h (Jani) - Fixes and improvements to abstract CPU architecture (Lucas) - Disable unsused power wells left enabled by BIOS (Imre) - Allow !join_mbus cases for adlp+ dbuf configuration (Ville) - Populate pipe dbuf slices more accurately during readout (Ville) - Workaround broken BIOS DBUF configuration on TGL/RKL (Ville) - Fix trailing semicolon (Lucas) Signed-off-by: Dave Airlie <airlied@redhat.com> From: Rodrigo Vivi <rodrigo.vivi@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/YgKFLmCgpv4vQEa1@intel.com
Diffstat (limited to 'drivers/gpu/drm/i915/i915_ioctl.c')
-rw-r--r--drivers/gpu/drm/i915/i915_ioctl.c94
1 files changed, 94 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_ioctl.c b/drivers/gpu/drm/i915/i915_ioctl.c
new file mode 100644
index 000000000000..06a10ccea80b
--- /dev/null
+++ b/drivers/gpu/drm/i915/i915_ioctl.c
@@ -0,0 +1,94 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2022 Intel Corporation
+ */
+
+#include "gt/intel_engine_regs.h"
+
+#include "i915_drv.h"
+#include "i915_gem.h"
+#include "i915_ioctl.h"
+#include "i915_reg.h"
+#include "intel_runtime_pm.h"
+#include "intel_uncore.h"
+
+/*
+ * This file is for small ioctl functions that are out of place everywhere else,
+ * and not big enough to warrant a file of their own.
+ *
+ * This is not the dumping ground for random ioctls.
+ */
+
+struct reg_whitelist {
+ i915_reg_t offset_ldw;
+ i915_reg_t offset_udw;
+ u8 min_graphics_ver;
+ u8 max_graphics_ver;
+ u8 size;
+};
+
+static const struct reg_whitelist reg_read_whitelist[] = {
+ {
+ .offset_ldw = RING_TIMESTAMP(RENDER_RING_BASE),
+ .offset_udw = RING_TIMESTAMP_UDW(RENDER_RING_BASE),
+ .min_graphics_ver = 4,
+ .max_graphics_ver = 12,
+ .size = 8
+ }
+};
+
+int i915_reg_read_ioctl(struct drm_device *dev,
+ void *data, struct drm_file *unused)
+{
+ struct drm_i915_private *i915 = to_i915(dev);
+ struct intel_uncore *uncore = &i915->uncore;
+ struct drm_i915_reg_read *reg = data;
+ struct reg_whitelist const *entry;
+ intel_wakeref_t wakeref;
+ unsigned int flags;
+ int remain;
+ int ret = 0;
+
+ entry = reg_read_whitelist;
+ remain = ARRAY_SIZE(reg_read_whitelist);
+ while (remain) {
+ u32 entry_offset = i915_mmio_reg_offset(entry->offset_ldw);
+
+ GEM_BUG_ON(!is_power_of_2(entry->size));
+ GEM_BUG_ON(entry->size > 8);
+ GEM_BUG_ON(entry_offset & (entry->size - 1));
+
+ if (IS_GRAPHICS_VER(i915, entry->min_graphics_ver, entry->max_graphics_ver) &&
+ entry_offset == (reg->offset & -entry->size))
+ break;
+ entry++;
+ remain--;
+ }
+
+ if (!remain)
+ return -EINVAL;
+
+ flags = reg->offset & (entry->size - 1);
+
+ with_intel_runtime_pm(&i915->runtime_pm, wakeref) {
+ if (entry->size == 8 && flags == I915_REG_READ_8B_WA)
+ reg->val = intel_uncore_read64_2x32(uncore,
+ entry->offset_ldw,
+ entry->offset_udw);
+ else if (entry->size == 8 && flags == 0)
+ reg->val = intel_uncore_read64(uncore,
+ entry->offset_ldw);
+ else if (entry->size == 4 && flags == 0)
+ reg->val = intel_uncore_read(uncore, entry->offset_ldw);
+ else if (entry->size == 2 && flags == 0)
+ reg->val = intel_uncore_read16(uncore,
+ entry->offset_ldw);
+ else if (entry->size == 1 && flags == 0)
+ reg->val = intel_uncore_read8(uncore,
+ entry->offset_ldw);
+ else
+ ret = -EINVAL;
+ }
+
+ return ret;
+}