]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/i915/mchbar: Provide intel_mchbar_read*() abstraction
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 31 Mar 2026 15:42:49 +0000 (18:42 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 1 Apr 2026 14:02:36 +0000 (17:02 +0300)
MCHBAR registers are a bit special in that:
- we access them through the mirror
- the mirror is read only on HSW+
- the mirror requires the actual MCHBAR to be enabled in device 0:0.0
- the mirror is gone on MTL+

So I'd prefer to treat MCHBAR registers as a bit special in
the code as well, and do all accesses to them via dedicated
functions. Prodive such functions in the form of
intel_mchbar_read*().

v2: Put the function arguments on one line
    No intel_uncore_read64() on xe, use intel_uncore_read64_2x32()
    Name the new function intel_mchbar_read64_2x32() as well

Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patch.msgid.link/20260331154259.24600-3-ville.syrjala@linux.intel.com
drivers/gpu/drm/i915/Makefile
drivers/gpu/drm/i915/display/intel_mchbar.c [new file with mode: 0644]
drivers/gpu/drm/i915/display/intel_mchbar.h [new file with mode: 0644]
drivers/gpu/drm/xe/Makefile

index b677720a1c2dba721fcc910a83643996d2ad3299..0e48305df8b242380fba3db262379c99e13a66c1 100644 (file)
@@ -295,6 +295,7 @@ i915-y += \
        display/intel_link_bw.o \
        display/intel_load_detect.o \
        display/intel_lpe_audio.o \
+       display/intel_mchbar.o \
        display/intel_modeset_lock.o \
        display/intel_modeset_setup.o \
        display/intel_modeset_verify.o \
diff --git a/drivers/gpu/drm/i915/display/intel_mchbar.c b/drivers/gpu/drm/i915/display/intel_mchbar.c
new file mode 100644 (file)
index 0000000..2636fe6
--- /dev/null
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#include "intel_display_core.h"
+#include "intel_mchbar.h"
+#include "intel_uncore.h"
+
+u16 intel_mchbar_read16(struct intel_display *display, i915_reg_t reg)
+{
+       struct intel_uncore *uncore = to_intel_uncore(display->drm);
+
+       return intel_uncore_read16(uncore, reg);
+}
+
+u32 intel_mchbar_read(struct intel_display *display, i915_reg_t reg)
+{
+       struct intel_uncore *uncore = to_intel_uncore(display->drm);
+
+       return intel_uncore_read(uncore, reg);
+}
+
+u64 intel_mchbar_read64_2x32(struct intel_display *display, i915_reg_t reg)
+{
+       struct intel_uncore *uncore = to_intel_uncore(display->drm);
+       i915_reg_t upper_reg = _MMIO(i915_mmio_reg_offset(reg) + 4);
+
+       return intel_uncore_read64_2x32(uncore, reg, upper_reg);
+}
diff --git a/drivers/gpu/drm/i915/display/intel_mchbar.h b/drivers/gpu/drm/i915/display/intel_mchbar.h
new file mode 100644 (file)
index 0000000..002a445
--- /dev/null
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef __INTEL_MCHBAR_H__
+#define __INTEL_MCHBAR_H__
+
+#include <linux/types.h>
+
+#include "i915_reg_defs.h"
+
+struct intel_display;
+
+u16 intel_mchbar_read16(struct intel_display *display, i915_reg_t reg);
+u32 intel_mchbar_read(struct intel_display *display, i915_reg_t reg);
+u64 intel_mchbar_read64_2x32(struct intel_display *display, i915_reg_t reg);
+
+#endif /* __INTEL_MCHBAR_H__ */
index 3bbd45ea327a6d227e644d8c74e56b007a66ec9e..015ca5412f86b26c7ee478329be74e8b1894f7e2 100644 (file)
@@ -304,6 +304,7 @@ xe-$(CONFIG_DRM_XE_DISPLAY) += \
        i915-display/intel_link_bw.o \
        i915-display/intel_lspcon.o \
        i915-display/intel_lt_phy.o \
+       i915-display/intel_mchbar.o \
        i915-display/intel_modeset_lock.o \
        i915-display/intel_modeset_setup.o \
        i915-display/intel_modeset_verify.o \