diff mbox series

[07/22] drm/i915/audio: Protect singleton register with a lock

Message ID 20221011170011.17198-8-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915: ELD precompute and readout | expand

Commit Message

Ville Syrjälä Oct. 11, 2022, 4:59 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

On the "ilk" platforms AUD_CNTL_ST2 is a singleton. Protect
it with the audio mutex in case we ever want to do parallel
RMW access to it.

Currently that should not happen since we only do audio
enable/disable from full modesets, and those are fully
serialized. But we probably want to think about toggling
audio on/off from fastsets too.

The hsw codepaths alreayd already have the same locking.
g4x should not need it since it can only do audio to a
single port at a time, which means it's actually broken
in more ways than this atm.

Cc: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
Cc: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_audio.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Jani Nikula Oct. 12, 2022, 2:38 p.m. UTC | #1
On Tue, 11 Oct 2022, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> On the "ilk" platforms AUD_CNTL_ST2 is a singleton. Protect
> it with the audio mutex in case we ever want to do parallel
> RMW access to it.
>
> Currently that should not happen since we only do audio
> enable/disable from full modesets, and those are fully
> serialized. But we probably want to think about toggling
> audio on/off from fastsets too.
>
> The hsw codepaths alreayd already have the same locking.
> g4x should not need it since it can only do audio to a
> single port at a time, which means it's actually broken
> in more ways than this atm.

"alreayd already"

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

>
> Cc: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
> Cc: Kai Vehmanen <kai.vehmanen@linux.intel.com>
> Cc: Takashi Iwai <tiwai@suse.de>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_audio.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_audio.c b/drivers/gpu/drm/i915/display/intel_audio.c
> index c6f0c8be82b2..9a286d70e281 100644
> --- a/drivers/gpu/drm/i915/display/intel_audio.c
> +++ b/drivers/gpu/drm/i915/display/intel_audio.c
> @@ -707,6 +707,8 @@ static void ilk_audio_codec_disable(struct intel_encoder *encoder,
>  
>  	ilk_audio_regs_init(i915, pipe, &regs);
>  
> +	mutex_lock(&i915->display.audio.mutex);
> +
>  	/* Disable timestamps */
>  	tmp = intel_de_read(i915, regs.aud_config);
>  	tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
> @@ -721,6 +723,8 @@ static void ilk_audio_codec_disable(struct intel_encoder *encoder,
>  	tmp = intel_de_read(i915, regs.aud_cntrl_st2);
>  	tmp &= ~IBX_ELD_VALID(port);
>  	intel_de_write(i915, regs.aud_cntrl_st2, tmp);
> +
> +	mutex_unlock(&i915->display.audio.mutex);
>  }
>  
>  static void ilk_audio_codec_enable(struct intel_encoder *encoder,
> @@ -749,6 +753,7 @@ static void ilk_audio_codec_enable(struct intel_encoder *encoder,
>  
>  	ilk_audio_regs_init(i915, pipe, &regs);
>  
> +	mutex_lock(&i915->display.audio.mutex);
>  
>  	/* Invalidate ELD */
>  	tmp = intel_de_read(i915, regs.aud_cntrl_st2);
> @@ -781,6 +786,8 @@ static void ilk_audio_codec_enable(struct intel_encoder *encoder,
>  	else
>  		tmp |= audio_config_hdmi_pixel_clock(crtc_state);
>  	intel_de_write(i915, regs.aud_config, tmp);
> +
> +	mutex_unlock(&i915->display.audio.mutex);
>  }
>  
>  /**
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_audio.c b/drivers/gpu/drm/i915/display/intel_audio.c
index c6f0c8be82b2..9a286d70e281 100644
--- a/drivers/gpu/drm/i915/display/intel_audio.c
+++ b/drivers/gpu/drm/i915/display/intel_audio.c
@@ -707,6 +707,8 @@  static void ilk_audio_codec_disable(struct intel_encoder *encoder,
 
 	ilk_audio_regs_init(i915, pipe, &regs);
 
+	mutex_lock(&i915->display.audio.mutex);
+
 	/* Disable timestamps */
 	tmp = intel_de_read(i915, regs.aud_config);
 	tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
@@ -721,6 +723,8 @@  static void ilk_audio_codec_disable(struct intel_encoder *encoder,
 	tmp = intel_de_read(i915, regs.aud_cntrl_st2);
 	tmp &= ~IBX_ELD_VALID(port);
 	intel_de_write(i915, regs.aud_cntrl_st2, tmp);
+
+	mutex_unlock(&i915->display.audio.mutex);
 }
 
 static void ilk_audio_codec_enable(struct intel_encoder *encoder,
@@ -749,6 +753,7 @@  static void ilk_audio_codec_enable(struct intel_encoder *encoder,
 
 	ilk_audio_regs_init(i915, pipe, &regs);
 
+	mutex_lock(&i915->display.audio.mutex);
 
 	/* Invalidate ELD */
 	tmp = intel_de_read(i915, regs.aud_cntrl_st2);
@@ -781,6 +786,8 @@  static void ilk_audio_codec_enable(struct intel_encoder *encoder,
 	else
 		tmp |= audio_config_hdmi_pixel_clock(crtc_state);
 	intel_de_write(i915, regs.aud_config, tmp);
+
+	mutex_unlock(&i915->display.audio.mutex);
 }
 
 /**