diff mbox series

[3/4] drm/i915: refactor intel_uncore_rmw

Message ID 20221003223258.2650934-4-andrzej.hajda@intel.com (mailing list archive)
State New, archived
Headers show
Series Simplify uncore register updates | expand

Commit Message

Andrzej Hajda Oct. 3, 2022, 10:32 p.m. UTC
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>
---
 drivers/gpu/drm/i915/intel_uncore.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Andi Shyti Oct. 3, 2022, 11:46 p.m. UTC | #1
Hi Andrzej,

On Tue, Oct 04, 2022 at 12:32:57AM +0200, Andrzej Hajda wrote:
> 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>

Andi
Jani Nikula Oct. 4, 2022, 7:27 a.m. UTC | #2
On Tue, 04 Oct 2022, Andrzej Hajda <andrzej.hajda@intel.com> wrote:
> 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>

Please fix the subject line to state "make intel_uncore_rmw() write
unconditionally" because that's what this change is, not
refactoring. IMO refactoring implies non-functional changes.

On the change,

Acked-by: Jani Nikula <jani.nikula@intel.com>

> ---
>  drivers/gpu/drm/i915/intel_uncore.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_uncore.h b/drivers/gpu/drm/i915/intel_uncore.h
> index 7e1b3b89f68959..5449146a06247c 100644
> --- a/drivers/gpu/drm/i915/intel_uncore.h
> +++ b/drivers/gpu/drm/i915/intel_uncore.h
> @@ -433,15 +433,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,
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/intel_uncore.h b/drivers/gpu/drm/i915/intel_uncore.h
index 7e1b3b89f68959..5449146a06247c 100644
--- a/drivers/gpu/drm/i915/intel_uncore.h
+++ b/drivers/gpu/drm/i915/intel_uncore.h
@@ -433,15 +433,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,