Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Takashi Iwai <tiwai@suse.de>
Subject: Re: [Intel-gfx] [PATCH v2 22/22] drm/i915/audio: Resume HSW/BDW HDA controller around ELD access
Date: Wed, 12 Oct 2022 17:24:56 +0300	[thread overview]
Message-ID: <Y0bOONxS7ngwntbx@intel.com> (raw)
In-Reply-To: <20221012104936.30911-1-ville.syrjala@linux.intel.com>

On Wed, Oct 12, 2022 at 01:49:36PM +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> On HSW/BDW the hardware ELD buffer does not work if the controller
> is suspended. I'm not 100% which thing in there is needed to make it
> work (at least just forcing the controller into D0 with setpci is
> not enough). But a full runtime resume seems to do the trick here
> at least, and so far it looks like this doesn't even deadlock or
> anything.

So this apparently works for evrything else except module reload,
where the ELD buffer isn't ready by the time we do the first modeset.
Strangely the same thing works fine at boot time when we first load
the drivers. Not sure what the difference is here.

I also tried to disable runtime pm for all the hda stuff via sysfs
(echo on > power/control) before unloading the modules, but that
doesn't help either. And I didn't immediately spot any explicit
stuff to power things off when unloading the hda driver. But maybe
I missed something?

> 
> 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 | 38 ++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_audio.c b/drivers/gpu/drm/i915/display/intel_audio.c
> index 328c47719fd8..467f3f260969 100644
> --- a/drivers/gpu/drm/i915/display/intel_audio.c
> +++ b/drivers/gpu/drm/i915/display/intel_audio.c
> @@ -23,6 +23,7 @@
>  
>  #include <linux/component.h>
>  #include <linux/kernel.h>
> +#include <linux/pm_runtime.h>
>  
>  #include <drm/drm_edid.h>
>  #include <drm/i915_component.h>
> @@ -480,6 +481,16 @@ hsw_audio_config_update(struct intel_encoder *encoder,
>  		hsw_hdmi_audio_config_update(encoder, crtc_state);
>  }
>  
> +static struct pci_dev *hsw_hda_controller(struct drm_i915_private *i915)
> +{
> +	int domain = pci_domain_nr(to_pci_dev(i915->drm.dev)->bus);
> +
> +	if (!IS_HASWELL(i915) && !IS_BROADWELL(i915))
> +		return NULL;
> +
> +	return pci_get_domain_bus_and_slot(domain, 0, PCI_DEVFN(3, 0));
> +}
> +
>  static int hsw_eld_buffer_size(struct drm_i915_private *i915,
>  			       enum transcoder cpu_transcoder)
>  {
> @@ -497,8 +508,14 @@ static void hsw_audio_codec_get_config(struct intel_encoder *encoder,
>  	enum transcoder cpu_transcoder = crtc_state->cpu_transcoder;
>  	u32 *eld = (u32 *)crtc_state->eld;
>  	int eld_buffer_size, len, i;
> +	struct pci_dev *hsw_hdac;
>  	u32 tmp;
>  
> +	/* on HSW/BDW ELD access doesn't work if the HDA controller is supended */
> +	hsw_hdac = hsw_hda_controller(i915);
> +	if (hsw_hdac)
> +		pm_runtime_get_sync(&hsw_hdac->dev);
> +
>  	tmp = intel_de_read(i915, HSW_AUD_PIN_ELD_CP_VLD);
>  	if ((tmp & AUDIO_ELD_VALID(cpu_transcoder)) == 0)
>  		return;
> @@ -511,6 +528,9 @@ static void hsw_audio_codec_get_config(struct intel_encoder *encoder,
>  
>  	for (i = 0; i < len; i++)
>  		eld[i] = intel_de_read(i915, HSW_AUD_EDID_DATA(cpu_transcoder));
> +
> +	if (hsw_hdac)
> +		pm_runtime_put(&hsw_hdac->dev);
>  }
>  
>  static void hsw_audio_codec_disable(struct intel_encoder *encoder,
> @@ -520,6 +540,12 @@ static void hsw_audio_codec_disable(struct intel_encoder *encoder,
>  	struct drm_i915_private *i915 = to_i915(encoder->base.dev);
>  	struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->uapi.crtc);
>  	enum transcoder cpu_transcoder = old_crtc_state->cpu_transcoder;
> +	struct pci_dev *hsw_hdac;
> +
> +	/* on HSW/BDW ELD access doesn't work if the HDA controller is supended */
> +	hsw_hdac = hsw_hda_controller(i915);
> +	if (hsw_hdac)
> +		pm_runtime_get_sync(&hsw_hdac->dev);
>  
>  	mutex_lock(&i915->display.audio.mutex);
>  
> @@ -544,6 +570,9 @@ static void hsw_audio_codec_disable(struct intel_encoder *encoder,
>  		     AUDIO_OUTPUT_ENABLE(cpu_transcoder), 0);
>  
>  	mutex_unlock(&i915->display.audio.mutex);
> +
> +	if (hsw_hdac)
> +		pm_runtime_put(&hsw_hdac->dev);
>  }
>  
>  static unsigned int calc_hblank_early_prog(struct intel_encoder *encoder,
> @@ -664,6 +693,12 @@ static void hsw_audio_codec_enable(struct intel_encoder *encoder,
>  	enum transcoder cpu_transcoder = crtc_state->cpu_transcoder;
>  	const u32 *eld = (const u32 *)crtc_state->eld;
>  	int eld_buffer_size, len, i;
> +	struct pci_dev *hsw_hdac;
> +
> +	/* on HSW/BDW ELD access doesn't work if the HDA controller is supended */
> +	hsw_hdac = hsw_hda_controller(i915);
> +	if (hsw_hdac)
> +		pm_runtime_get_sync(&hsw_hdac->dev);
>  
>  	mutex_lock(&i915->display.audio.mutex);
>  
> @@ -705,6 +740,9 @@ static void hsw_audio_codec_enable(struct intel_encoder *encoder,
>  	hsw_audio_config_update(encoder, crtc_state);
>  
>  	mutex_unlock(&i915->display.audio.mutex);
> +
> +	if (hsw_hdac)
> +		pm_runtime_put(&hsw_hdac->dev);
>  }
>  
>  struct ilk_audio_regs {
> -- 
> 2.35.1

-- 
Ville Syrjälä
Intel

  parent reply	other threads:[~2022-10-12 14:25 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11 16:59 [Intel-gfx] [PATCH 00/22] drm/i915: ELD precompute and readout Ville Syrjala
2022-10-11 16:59 ` [Intel-gfx] [PATCH 01/22] drm/i915/audio: s/dev_priv/i915/ Ville Syrjala
2022-10-12 14:35   ` Jani Nikula
2022-10-11 16:59 ` [Intel-gfx] [PATCH 02/22] drm/i915/audio: Nuke leftover ROUNDING_FACTOR Ville Syrjala
2022-10-12 14:36   ` Jani Nikula
2022-10-11 16:59 ` [Intel-gfx] [PATCH 03/22] drm/i915/audio: Remove CL/BLC audio stuff Ville Syrjala
2022-10-12 14:36   ` Jani Nikula
2022-10-11 16:59 ` [Intel-gfx] [PATCH 04/22] drm/i915/audio: Exract struct ilk_audio_regs Ville Syrjala
2022-10-12 14:36   ` Jani Nikula
2022-10-11 16:59 ` [Intel-gfx] [PATCH 05/22] drm/i915/audio: Use REG_BIT() & co Ville Syrjala
2022-10-12 14:37   ` Jani Nikula
2022-10-11 16:59 ` [Intel-gfx] [PATCH 06/22] drm/i915/audio: Unify register bit naming Ville Syrjala
2022-10-12 14:37   ` Jani Nikula
2022-10-11 16:59 ` [Intel-gfx] [PATCH 07/22] drm/i915/audio: Protect singleton register with a lock Ville Syrjala
2022-10-12 14:38   ` Jani Nikula
2022-10-11 16:59 ` [Intel-gfx] [PATCH 08/22] drm/i915/audio: Nuke intel_eld_uptodate() Ville Syrjala
2022-10-12 14:40   ` Jani Nikula
2022-10-11 16:59 ` [Intel-gfx] [PATCH 09/22] drm/i915/audio: Read ELD buffer size from hardware Ville Syrjala
2022-10-12 14:41   ` Jani Nikula
2022-10-12 14:46     ` Jani Nikula
2022-10-11 16:59 ` [Intel-gfx] [PATCH 10/22] drm/i915/audio: Make sure we write the whole ELD buffer Ville Syrjala
2022-10-12 14:28   ` Jani Nikula
2022-10-12 15:03     ` Ville Syrjälä
2022-10-12 16:06       ` Jani Nikula
2022-10-11 17:00 ` [Intel-gfx] [PATCH 11/22] drm/i915/audio: Use u32* for ELD Ville Syrjala
2022-10-12 14:42   ` Jani Nikula
2022-10-11 17:00 ` [Intel-gfx] [PATCH 12/22] drm/i915/audio: Use intel_de_rmw() for most audio registers Ville Syrjala
2022-10-12 14:33   ` Jani Nikula
2022-10-12 15:05     ` Ville Syrjälä
2022-10-11 17:00 ` [Intel-gfx] [PATCH 13/22] drm/i915/audio: Split "ELD valid" vs. audio PD on hsw+ Ville Syrjala
2022-10-12 15:01   ` Jani Nikula
2022-10-11 17:00 ` [Intel-gfx] [PATCH 14/22] drm/i915/audio: Do the vblank waits Ville Syrjala
2022-10-12 15:01   ` Jani Nikula
2022-10-11 17:00 ` [Intel-gfx] [PATCH 15/22] drm/i915/audio: Precompute the ELD Ville Syrjala
2022-10-12 15:11   ` Jani Nikula
2022-10-11 17:00 ` [Intel-gfx] [PATCH 16/22] drm/i915/audio: Hardware ELD readout Ville Syrjala
2022-10-12 15:19   ` Jani Nikula
2022-10-11 17:00 ` [Intel-gfx] [PATCH 17/22] drm/i915/sdvo: Extract intel_sdvo_has_audio() Ville Syrjala
2022-10-12 15:15   ` Jani Nikula
2022-10-11 17:00 ` [Intel-gfx] [PATCH 18/22] drm/i915/sdvo: Precompute the ELD Ville Syrjala
2022-10-12 15:16   ` Jani Nikula
2022-10-11 17:00 ` [Intel-gfx] [PATCH 19/22] drm/i915/sdvo: Do ELD hardware readout Ville Syrjala
2022-10-12 15:22   ` Jani Nikula
2022-10-11 17:00 ` [Intel-gfx] [PATCH 20/22] drm/i915/audio: Hook up ELD into the state checker Ville Syrjala
2022-10-12 15:25   ` Jani Nikula
2022-10-11 17:00 ` [Intel-gfx] [PATCH 21/22] drm/i915/audio: Include ELD in the state dump Ville Syrjala
2022-10-12 15:26   ` Jani Nikula
2022-10-11 17:00 ` [Intel-gfx] [PATCH 22/22] hax: drm/i915/audio: Make HSW hardware ELD buffer sort of work Ville Syrjala
2022-10-12 10:49   ` [Intel-gfx] [PATCH v2 22/22] drm/i915/audio: Resume HSW/BDW HDA controller around ELD access Ville Syrjala
2022-10-12 11:08     ` Ville Syrjälä
2022-10-12 11:42     ` Kai Vehmanen
2022-10-12 13:53       ` Kai Vehmanen
2022-10-12 14:24     ` Ville Syrjälä [this message]
2022-10-19 18:06       ` Ville Syrjälä
2022-10-14 10:51     ` Kai Vehmanen
2022-10-19 18:43       ` Ville Syrjälä
2022-10-11 17:39 ` [Intel-gfx] [PATCH 00/22] drm/i915: ELD precompute and readout Jani Nikula
2022-10-11 20:38 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
2022-10-11 20:38 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-10-11 21:00 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2022-10-12 12:33 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915: ELD precompute and readout (rev2) Patchwork
2022-10-12 12:33 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-10-12 12:58 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2022-10-14  9:03 ` [Intel-gfx] [PATCH 00/22] drm/i915: ELD precompute and readout Borah, Chaitanya Kumar
2022-10-14  9:13   ` Jani Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y0bOONxS7ngwntbx@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox