drm/i915: make intel_uncore_rmw() write unconditionally
authorAndrzej Hajda <andrzej.hajda@intel.com>
Thu, 6 Oct 2022 16:31:59 +0000 (18:31 +0200)
committerAndi Shyti <andi.shyti@linux.intel.com>
Tue, 11 Oct 2022 11:36:45 +0000 (13:36 +0200)
Two small changes in intel_uncore_rmw will allow to use it more broadly:
- write register unconditionally, for use with latch registers,
- return old value of the register, IRQ cleanup and similar.

If we really want to keep write-only-if-changed feature maybe other
helper will be more suitable for it, intel_uncore_rmw name suggests
unconditional write.

Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221006163200.2803722-4-andrzej.hajda@intel.com
drivers/gpu/drm/i915/intel_uncore.h

index b1fa912..ca74120 100644 (file)
@@ -413,15 +413,15 @@ intel_uncore_read64_2x32(struct intel_uncore *uncore,
 #define intel_uncore_write64_fw(...) __raw_uncore_write64(__VA_ARGS__)
 #define intel_uncore_posting_read_fw(...) ((void)intel_uncore_read_fw(__VA_ARGS__))
 
-static inline void intel_uncore_rmw(struct intel_uncore *uncore,
-                                   i915_reg_t reg, u32 clear, u32 set)
+static inline u32 intel_uncore_rmw(struct intel_uncore *uncore,
+                                  i915_reg_t reg, u32 clear, u32 set)
 {
        u32 old, val;
 
        old = intel_uncore_read(uncore, reg);
        val = (old & ~clear) | set;
-       if (val != old)
-               intel_uncore_write(uncore, reg, val);
+       intel_uncore_write(uncore, reg, val);
+       return old;
 }
 
 static inline void intel_uncore_rmw_fw(struct intel_uncore *uncore,