From: Ville Syrjälä <[email protected]>

Different platforms will need to do different things in
their mmio accessors. The plan is to trade the overhead
of runtime platform checks into no runtime checks and
the cost of a vfunc call. This seems to provide slightly
better overall performance.

Signed-off-by: Ville Syrjälä <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_de.c         | 17 +++++++++++++++++
 drivers/gpu/drm/i915/display/intel_de.h         |  9 +++++++--
 .../gpu/drm/i915/display/intel_display_core.h   |  2 ++
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_de.c 
b/drivers/gpu/drm/i915/display/intel_de.c
index 6b3d06147e58..4f423a684ec2 100644
--- a/drivers/gpu/drm/i915/display/intel_de.c
+++ b/drivers/gpu/drm/i915/display/intel_de.c
@@ -163,7 +163,24 @@ u16 intel_de_read16(struct intel_display *display, 
intel_reg_t reg)
        return intel_uncore_read16(__to_uncore(display), reg);
 }
 
+static u32 i9xx_mmio_read(struct intel_display *display, intel_reg_t reg)
+{
+       return intel_uncore_read(__to_uncore(display), reg);
+}
+
+static void i9xx_mmio_write(struct intel_display *display, intel_reg_t reg, 
u32 val)
+{
+       intel_uncore_write(__to_uncore(display), reg, val);
+}
+
+static const struct intel_mmio_funcs i9xx_mmio_funcs = {
+       .read = i9xx_mmio_read,
+       .write = i9xx_mmio_write,
+};
+
 void intel_de_init(struct intel_display *display)
 {
        display->mmio.uncore = to_intel_uncore(display->drm);
+
+       display->mmio.funcs = &i9xx_mmio_funcs;
 }
diff --git a/drivers/gpu/drm/i915/display/intel_de.h 
b/drivers/gpu/drm/i915/display/intel_de.h
index f1135ee5071b..63aef17e6ed3 100644
--- a/drivers/gpu/drm/i915/display/intel_de.h
+++ b/drivers/gpu/drm/i915/display/intel_de.h
@@ -12,6 +12,11 @@
 #include "intel_uncore.h"
 #include "intel_uncore_trace.h"
 
+struct intel_mmio_funcs {
+       u32 (*read)(struct intel_display *display, intel_reg_t reg);
+       void (*write)(struct intel_display *display, intel_reg_t reg, u32 val);
+};
+
 static inline struct intel_uncore *__to_uncore(struct intel_display *display)
 {
        return display->mmio.uncore;
@@ -30,7 +35,7 @@ intel_de_read(struct intel_display *display, intel_reg_t reg)
 
        intel_dmc_wl_get(display, reg);
 
-       val = intel_uncore_read(__to_uncore(display), reg);
+       val = display->mmio.funcs->read(display, reg);
 
        intel_dmc_wl_put(display, reg);
 
@@ -60,7 +65,7 @@ intel_de_write(struct intel_display *display, intel_reg_t 
reg, u32 val)
 {
        intel_dmc_wl_get(display, reg);
 
-       intel_uncore_write(__to_uncore(display), reg, val);
+       display->mmio.funcs->write(display, reg, val);
 
        intel_dmc_wl_put(display, reg);
 }
diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h 
b/drivers/gpu/drm/i915/display/intel_display_core.h
index 35409f9abb2f..3a48119f7890 100644
--- a/drivers/gpu/drm/i915/display/intel_display_core.h
+++ b/drivers/gpu/drm/i915/display/intel_display_core.h
@@ -49,6 +49,7 @@ struct intel_fbdev;
 struct intel_fdi_funcs;
 struct intel_hotplug_irq_funcs;
 struct intel_initial_plane_config;
+struct intel_mmio_funcs;
 struct intel_opregion;
 struct intel_overlay;
 struct intel_uncore;
@@ -533,6 +534,7 @@ struct intel_display {
 
        struct {
                struct intel_uncore *uncore;
+               const struct intel_mmio_funcs *funcs;
        } mmio;
 
        struct {
-- 
2.56.0

Reply via email to